Skip to content

Fix stale agent icons in terminal tabs - #11484

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-tab-icon-wrong
Jul 30, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-tab-icon-wrong

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

  • Keep terminal tab icons aligned with sidebar agent rows after a completed agent leaves live hook status.
  • Resolve retained completion identity by the focused stable pane ID before falling back to stale launch metadata.
  • Preserve live hook, process, title-reuse, sleeping-session, split-pane, remote, and Pi/OMP ownership precedence.

The bug was reproduced in Electron by creating a Claude-default worktree, interrupting Claude, starting Codex, and completing a turn. The deterministic failing state had no live/process/sleeping identity, stale launchAgent: "claude", and the sidebar-retained pane completion identified as Codex. This is the retained-row gap left between the unified pipeline in #7059 and completed identity in #7860; the fix extends that pipeline instead of adding another detector.

Screenshots

Before — the tab falls back to Claude while the retained sidebar row identifies Codex:

Before: Claude tab icon and Codex sidebar row

After — the same backing state renders Codex in both places:

After: Codex tab icon and Codex sidebar row

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused validation:

  • 8 tab-agent test files / 106 tests passed, covering retained identity, live hook priority, process signals, title reuse, sleeping sessions, Pi/OMP, native OpenCode titles, split panes, missing layout, and tab isolation.
  • Type-aware Oxlint, formatting, reliability gates, max-lines ratchet, and diff checks passed.
  • Electron DOM verified data-agent-icon="codex" with stale Claude launch metadata, null live/process/sleeping identity, and retained Codex completion.
  • check:code-quality:changed could not parse pnpm's Node-24 engine warning under local Node 26; its direct strict and type-aware Oxlint scans passed.

AI Review Report

Reviewed the change against the prior tab-identity contracts from #5860, #6543, #7059, #7755, #7860, #9077, and #11382. The main risks were stale retained state overriding a fresh live run, sibling completion hijacking a focused pane, title-based pane reuse regressing, and Pi/OMP or native OpenCode ownership changing. Regression tests and the existing focused suites cover each boundary.

Cross-platform review found no platform-specific behavior: this is renderer store resolution keyed by stable pane IDs. It adds no shortcuts, labels, paths, shell commands, native modules, Git behavior, or Electron platform branches, and applies equally to macOS, Linux, Windows, SSH, and folder workspaces.

Security Audit

No new external input, command execution, path handling, authentication, secrets, dependencies, persistence, network access, or IPC surface. The change reads an existing renderer-owned retained-status map and converts its existing agent type to an icon identity.

Notes

Retained identity is treated as completed pane evidence. It beats stale launch fallback for the focused pane, but remains below live hooks, process identity, and valid title-based pane reuse; sibling retained identity remains below focused launch metadata.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bc427516-979b-48a8-9a5e-ab6916ab5e8b

📥 Commits

Reviewing files that changed from the base of the PR and between 819f46a and 4904ef0.

📒 Files selected for processing (1)
  • src/renderer/src/components/tab-bar/SortableTab.rename-shortcut.test.tsx
📝 Walkthrough

Walkthrough

Adds retained-agent resolvers for focused and sibling panes, filtering retained entries by tab and mapping retained agent types to TuiAgent values. Updates useTabAgent to use retained identities when completed identities are unavailable. Adds direct resolver tests and hook tests covering retained identity selection, live status precedence, cross-agent metadata, and sibling fallback behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main user-facing change: fixing stale agent icons in terminal tabs.
Description check ✅ Passed The description follows the template with Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a visual inconsistency where terminal tab icons could show a stale agent (e.g., Claude) while the sidebar correctly showed the retained completion agent (e.g., Codex). The fix extends the existing tab-identity pipeline so that retainedAgentsByPaneKey is consulted as a fallback after the live completed-hook check for both focused and sibling panes.

  • Two new pure functions (resolveFocusedRetainedTabAgent, resolveSiblingRetainedTabAgent) in tab-agent.ts mirror the structure of their Completed counterparts, iterating retained entries filtered by tab ID and excluded leaf.
  • In use-tab-agent.ts, both focusedCompletedHookAgent and siblingCompletedHookAgent selectors are extended with ?? resolve...RetainedTabAgent(...), so retained identity feeds into the same priority-ordered pipeline (priority 4/7) that already governs idle identity, launch-agent clearing, and suppression logic.

Confidence Score: 5/5

Safe to merge — the change is a focused, additive extension of an existing resolution pipeline with no side effects on unrelated state.

The two new resolver functions are structurally identical to their existing counterparts, touching only the renderer store's read-only retained-status map. The ?? fallback chaining preserves all prior precedence rules intact: live hooks, process signals, title-reuse, sleeping sessions, and launch metadata all remain above retained identity. The fix also correctly arms hasObservedAgentSignal via completedHookEvidence, enabling stale launch-agent clearing when exit evidence is present — a side effect that is intentional and covered by the integration tests. Cross-tab isolation, layout-unavailable fallback, and sibling-vs-focused scoping are all exercised by the new test suite.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/renderer/src/lib/tab-agent.ts Adds resolveFocusedRetainedTabAgent and resolveSiblingRetainedTabAgent plus two private helpers; structure mirrors the existing completed-hook resolvers exactly, with correct tab/leaf scoping and null-safe pane-key parsing.
src/renderer/src/lib/use-tab-agent.ts Extends focusedCompletedHookAgent and siblingCompletedHookAgent selectors to fall back to retained identity via ??; correctly preserves all existing precedence rules (live hook > process > title > idle/retained > sleeping > launchAgent > sibling).
src/renderer/src/lib/use-tab-agent-retained-identity.test.ts New integration test file with four behaviorally distinct cases: retained beats stale launch, live hook beats retained, title reclaim beats retained, and focused launch beats sibling retained — full coverage of the new priority boundaries.
src/renderer/src/lib/tab-agent.test.ts Adds three pure-function unit tests for the new retained resolvers: focused/sibling scoping, layout-unavailable fallback, and cross-tab isolation — clean and non-overlapping with the integration tests.
src/renderer/src/components/tab-bar/SortableTab.rename-shortcut.test.tsx Adds retainedAgentsByPaneKey: {} to the hoisted mock store state so the existing rename-shortcut tests remain type-correct after the new slice field is consumed by useTabAgent.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[useTabAgent] --> B[focusedHookAgent\nlive agentStatusByPaneKey]
    A --> C[siblingHookAgent\nlive agentStatusByPaneKey]
    A --> D{focusedCompletedHookAgent}
    D --> D1[resolveFocusedCompletedTabAgent\nagentStatusByPaneKey state=done]
    D1 -- null --> D2[resolveFocusedRetainedTabAgent\nretainedAgentsByPaneKey NEW]
    D --> E{siblingCompletedHookAgent}
    E --> E1[resolveSiblingCompletedTabAgent\nagentStatusByPaneKey state=done]
    E1 -- null --> E2[resolveSiblingRetainedTabAgent\nretainedAgentsByPaneKey NEW]
    A --> F[resolveTabAgentFromSignals]
    B --> F
    C --> F
    D --> F
    E --> F
    F --> G{Priority cascade}
    G --> G1["1. liveFocusedIdentity (live hook)"]
    G1 --> G2["2. processAgent (foreground process)"]
    G2 --> G3["3. titleAgent (reuse/legacy)"]
    G3 --> G4["4. idleFocusedIdentity (completed hook OR retained)"]
    G4 --> G5["5. sleepingSessionAgent"]
    G5 --> G6["6. activeLaunchAgent (cleared if exit evidence)"]
    G6 --> G7["7. liveSiblingIdentity / idleSiblingIdentity (incl. retained)"]
Loading

Reviews (2): Last reviewed commit: "test(tab-bar): include retained agent st..." | Re-trigger Greptile

@brennanb2025
brennanb2025 merged commit f908ba3 into main Jul 30, 2026
41 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(tabs): prefer retained agent identity for icons

* test(tab-bar): include retained agent store state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant