Repository navigation
fix(agent-status): prevent ghost sidebar row on completed split-pane detach - #10698
Conversation
📝 WalkthroughWalkthroughPane authority transfer now applies conditional source-pane retention suppression when migrating live agent state, while continuing to move pane-keyed state. Tests cover suppression expectations, migrated completed-agent status, consumption by retained-agent collection, and the absence of suppression when the detached pane had no live agent. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/store/slices/agent-status.ts (1)
1306-1314: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense the duplicated retention rationale.
Keep a single concise “why” beside the production mutation and remove or reduce the test preamble; the test name and assertions already convey the scenario.
src/renderer/src/store/slices/agent-status.ts#L1306-L1314: replace the multi-line walkthrough with a one-line explanation of suppressing the old live key during migration.src/renderer/src/store/slices/terminal-pane-detach-agent-retention.test.ts#L8-L14: remove the duplicated mechanism description or reduce it to one line.As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 14d45ec1-f952-4de9-af17-3c89e7c52c90
📥 Commits
Reviewing files that changed from the base of the PR and between c67aadb and c6f19827d46df3c5bb3329a15e480e68437842af.
📒 Files selected for processing (3)
src/renderer/src/store/slices/agent-status.tssrc/renderer/src/store/slices/terminal-pane-detach-agent-identity.test.tssrc/renderer/src/store/slices/terminal-pane-detach-agent-retention.test.ts
f5d3e53 to
059861d
Compare
…detach Detaching a done-state split pane into its own tab migrated the agent paneKey from oldTab:leaf to newTab:leaf. useRetainedAgentsSync only saw the old key vanish and, finding no suppressor, resurrected it as an unclickable duplicate sidebar row (and inflated the worktree count). Plant a one-shot retention suppressor on the source key during transferAgentPaneAuthority, but only when the source actually held a live agent, so a suppressor is never leaked for a pane that had none. Fixes stablyai#10675 Co-Authored-By: Claude <[email protected]>
…tion comments Type the migrated retentionSuppressedPaneKeys as Record<string, true> so a computed-key `true` isn't widened to boolean, which broke the web typecheck. Also condense the retention rationale comments per review. Co-Authored-By: Claude <[email protected]>
059861d to
fb09feb
Compare
Greptile SummaryThis PR fixes a ghost sidebar row that appeared when detaching a completed split-pane agent into its own tab. The root cause was that
Confidence Score: 5/5Safe to merge — the change is a single atomic store update that closes a narrow retention-hook race without touching any public APIs or rendering paths. The fix is minimal and well-scoped: one new suppressor write in transferAgentPaneAuthority, guarded exactly the same way existing suppressors are guarded elsewhere in the slice. The atomic set() ensures the suppressor and the paneKey migration land in the same snapshot, so the retention hook can never observe a window where the source key is absent but unguarded. Two new tests exercise the store→hook contract directly, and the updated identity test locks in the expected suppressor state. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/store/slices/agent-status.ts | Targeted fix in transferAgentPaneAuthority: plants a guarded one-shot suppressor on the source paneKey to prevent useRetainedAgentsSync from creating a ghost row; logic is atomic, correctly guarded on fromWasLive, and mirrors existing suppressor patterns in the slice. |
| src/renderer/src/store/slices/terminal-pane-detach-agent-identity.test.ts | Single assertion correctly flipped from toBeUndefined() to toBe(true) to reflect the new suppressor planted on the source key during transfer. |
| src/renderer/src/store/slices/terminal-pane-detach-agent-retention.test.ts | New regression test covering both the done-agent detach (suppressor consumed, no ghost row) and the agent-less pane detach (no suppressor leak) scenarios; exercises the full store→hook contract via collectRetainedAgentsOnDisappear. |
Reviews (1): Last reviewed commit: "fix(agent-status): annotate suppressor r..." | Re-trigger Greptile
…detach (stablyai#10698) * fix(agent-status): prevent ghost sidebar row on completed split-pane detach Detaching a done-state split pane into its own tab migrated the agent paneKey from oldTab:leaf to newTab:leaf. useRetainedAgentsSync only saw the old key vanish and, finding no suppressor, resurrected it as an unclickable duplicate sidebar row (and inflated the worktree count). Plant a one-shot retention suppressor on the source key during transferAgentPaneAuthority, but only when the source actually held a live agent, so a suppressor is never leaked for a pane that had none. Fixes stablyai#10675 Co-Authored-By: Claude <[email protected]> * fix(agent-status): annotate suppressor record type and condense retention comments Type the migrated retentionSuppressedPaneKeys as Record<string, true> so a computed-key `true` isn't widened to boolean, which broke the web typecheck. Also condense the retention rationale comments per review. Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Summary
Fixes #10675 — detaching a completed (done-state) split-pane agent into its own tab split the same agent session into two sidebar rows: one working, one a stale unclickable duplicate, plus an inflated worktree agent count.
Root cause: detaching a pane onto the tab strip keeps the
leafIdbut changes thetabId, so the agent'spaneKeymigratesoldTab:leaf → newTab:leaf.transferAgentPaneAuthoritymoves the live status to the new key, but the sidebar'suseRetainedAgentsSynchook tracks live pane keys in its ownprevAgentsRefand only observes the old key disappearing. A live/done agent has no retention suppressor on the source key (suppressors are only planted on explicit teardown), so moving suppressors is a no-op and the source key is left unguarded — the hook misreads the migration as a "done agent that vanished" and resurrects it as a retained snapshot. The retained row's activation callback is a no-op, so the duplicate can't be opened.Fix
Plant a one-shot retention suppressor on the source key during
transferAgentPaneAuthority, so the disappear the hook later observes is consumed instead of retained. Guarded onfrom in s.agentStatusByPaneKey(the source actually held a live agent) — mirroring the existinghasLiveguards elsewhere in the slice — so a suppressor is never leaked for a pane that never had an agent (e.g. detaching a plain terminal pane).Changes
agent-status.ts—transferAgentPaneAuthoritynow plants a guarded one-shot suppressor on the source paneKey.terminal-pane-detach-agent-identity.test.ts— flipped the stale assertion (source key now carries the suppressor).terminal-pane-detach-agent-retention.test.ts(new) — regression coverage for the store→retention-hook contract: a detached done agent produces no ghost row, and an agent-less pane detach plants no (leaking) suppressor.Test plan
viteston affected suites — 56 passed (agent-status, detach-identity, detach-retention, useRetainedAgents, useRetainedAgentsSync)tsc -p config/tsconfig.tc.web.json) — cleancodex exec review— no correctness issues foundretainedAgentsByPaneKeyempty (no ghost row), suppressor consumedNotes
orca-mobileis a separate app that doesn't use this slice and is unaffected.🤖 Generated with Claude Code
ELI5
Detaching a finished split-pane agent into its own tab left a ghost duplicate sidebar row and wrong agent counts. Detach now moves identity cleanly so only one real row remains.