Repository navigation
Fix stale agent icons in terminal tabs - #11484
Conversation
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds retained-agent resolvers for focused and sibling panes, filtering retained entries by tab and mapping retained agent types to 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Greptile SummaryThis 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
Confidence Score: 5/5Safe 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.
|
| 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)"]
Reviews (2): Last reviewed commit: "test(tab-bar): include retained agent st..." | Re-trigger Greptile
* fix(tabs): prefer retained agent identity for icons * test(tab-bar): include retained agent store state
Summary
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:
After — the same backing state renders Codex in both places:
Testing
pnpm lintpnpm typecheckpnpm testpnpm buildFocused validation:
data-agent-icon="codex"with stale Claude launch metadata, null live/process/sleeping identity, and retained Codex completion.check:code-quality:changedcould 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.