Repository navigation
Conversation
Unmounting a pane cedes renderer ownership of its agent status back to the host. The next mirrored snapshot that carries no status for the surface then reached buildMirroredAgentStatusPatch's delete loop, which was gated only on ownership, so a genuine waiting/blocked row was deleted rather than retired: a pending question disappeared from the sidebar because the user switched tabs. Gate the delete on state as well. A still-fresh waiting/blocked row survives the handover and retires the way an owned row does, by decaying past the freshness boundary; every other state keeps the previous behavior. Fixes stablyai#22445
There was a problem hiding this comment.
Important
The retention guard keys on the absence of host status alone, so it also outlives panes and rows the host genuinely removed — a closed split leaf, and a host-side dismissal/clear — until the 30-minute decay. Details inline on the guard.
Reviewed changes
- Keep a fresh pending blocker across an ownership handover —
buildMirroredAgentStatusPatchnowcontinues past the delete loop for ablocked/waitingrow that is stillisAgentStatusFresh, so an unmounted pane's unanswered question is not deleted when the next mirrored snapshot carries no status for the surface. - Regression coverage for the unmount-then-snapshot sequence — the new suite replays the real snapshot mirror, renderer-ownership registry, and store with a driven clock:
waiting/blockedsurvive,doneis still deleted, and a stalewaitingstill decays. - Named test-store type —
store-test-helpers.tsexportsTestAppStoreand givescreateTestStorean explicit return type, so suites stop reaching throughReturnType.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| // Why: unmount cedes renderer ownership (session-reconcile-dispose), so the | ||
| // ownership gate below stops covering a pane the moment the user switches | ||
| // tabs. A host snapshot carrying no status is not a resolution, and deleting | ||
| // an unanswered question drops it from the sidebar (#22445). Retire a pending | ||
| // blocker the way an owned row retires: by decaying past the freshness | ||
| // boundary, never by the absence of a host value. | ||
| const pendingBlocker = state.agentStatusByPaneKey[paneKey] | ||
| if ( | ||
| (pendingBlocker.state === 'blocked' || pendingBlocker.state === 'waiting') && | ||
| isAgentStatusFresh(pendingBlocker, now) | ||
| ) { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Retention here is keyed only on the entry's state and freshness — not on whether the pane still exists, nor on whether the host deliberately removed the row. A host-side drop/dismissal (dropAgentStatus → agentStatus.drop, which republishes the worktree with the surface present but no agentStatus) and a closed split leaf (tab still published through a sibling leaf) both now keep a blocked/waiting row alive for up to 30 minutes. For a host-authoritative row the host is the owner per docs/reference/agent-status-store.md, so this is the reader overriding a host removal rather than a presentation-policy decision.
Technical details
# Blanket absence-retention also outlives host removals
## Affected sites
- `src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts:182-188` — the guard; runs after the ownership, retraction, and `nextByPaneKey` gates, so it is the last word for any absent-status row.
- `src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts:70-78` and `agent-status-primitives.ts:59-65` — `mirroredTabIds`/`isMirroredAgentPaneKeyForTabs` are tab-level only, so a closed leaf's pane key still reaches the guard while a sibling leaf keeps the tab published.
- `src/renderer/src/store/slices/agent-status-drop-actions.ts:112-117` — dismissal drops the authoritative row and fans out `agentStatus.drop`; the worktree republish then carries the surface with `agentStatus` omitted (`hook-status-session-tabs-republish.ts`).
- `src/shared/runtime-mobile-session-tab-contracts.ts:19` — the wire schema has no per-surface clear marker, so "host removed the row" and "hook-only host never published one" are the same signal.
## Required outcome
- A `blocked`/`waiting` row the host has actually removed (dismissal/clear) must still leave a paired client promptly; retention should not override host authority for rows the client never wrote.
- A closed pane/leaf must not leave a sidebar ghost for 30 minutes.
## Suggested approach (optional)
- Scope retention to the ownership-handover case the issue describes: retain only when the row was client-authored before the release (or while an ownership handover is in flight), rather than for every fresh blocker whose host snapshot omits status. The current form cannot distinguish those, which is why it is worth deciding explicitly.
## Open questions for the human (optional)
- Is host-side dismissal of a `waiting`/`blocked` row a supported flow? If so, its 30-minute client-side lag is a regression, not a tradeoff.
- Is a 30-minute ghost after closing a split leaf acceptable, given STA-4593 removed exactly this class of ghost for retracted tabs?
- No test pins either case (the new suite publishes a single surface; the ghost-row suite covers tab retraction only). Worth a control in a follow-up if the behavior is intended.|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe registry retains time-limited evidence of panes that wrote agent status before release. The retirement logic uses this evidence to preserve fresh renderer-written Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to A remounted pane can incorrectly regain client status authority, and a withdrawn host blocker can remain visible while fresh. Resolve both status-retirement paths before merging. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
Review catch: gating retention on state and freshness alone also outlived rows the host deliberately removed — a sidebar dismissal (dropAgentStatus) and a closed split leaf both republish the surface without status, and both were held for the full staleness window. Distinguish the two silences. The ownership registry now keeps a released claim instead of deleting it, so the mirror can tell a pane whose status only ever came from this renderer's bytes (the host publishes nothing for it, so its silence carries no information) from a pane the host minted status for (where absence is the host withdrawing it). Only the former retains a pending blocker; a host-minted row is deleted on the first snapshot without status, exactly as before. The retained claim is bounded: it is swept once it can no longer describe a live row, and a pane that never proved a byte-derived write leaves nothing behind.
|
Valid on both counts, and fixed in 0ba9b46. The guard keyed on state and freshness alone, which cannot tell two different silences apart:
Retention was covering both. Your reading of What changed. The ownership registry now keeps a released claim rather than deleting it, and exposes Two details worth naming:
Coverage. New case in the suite: a host-minted Checks on the new head: |
A blanket oxfmt run swept three files this change does not touch into the previous commit. Restore them to main so the PR diff is only the agent-status retention change.
There was a problem hiding this comment.
Important
The retention guard is now scoped to the pane's write history rather than to the row's author, so a host-authored blocked/interactivePrompt row on a pane that ever emitted OSC status is still retained after the host withdraws it. This is the prior review's host-removal case, only narrowed — details and a verified repro inline.
Reviewed changes
- Scope blocker retention to panes this renderer wrote — the ownership registry now records a
releasedAton the claim and exposesisReleasedClientWrittenAgentStatusPane(paneKey, now); the delete-loop guard requires it, so a host-minted blocker on a never-written pane is deleted immediately again. - Tighten
isClientAuthoritativeAgentStatusPane— it now also requiresreleasedAt === null, preserving the previous external result (release used to delete the entry outright). - Registry lifecycle coverage — tests for release/remount/sweep, the reworked "leaks nothing" case, and a host-minted control; plus a
TestAppStoreexport instore-test-helpers.ts. Thepty-connection-*andmirrored-status-tab-retractionsedits are formatting-only.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| const pendingBlocker = state.agentStatusByPaneKey[paneKey] | ||
| if ( | ||
| (pendingBlocker.state === 'blocked' || pendingBlocker.state === 'waiting') && | ||
| isReleasedClientWrittenAgentStatusPane(paneKey, now) && | ||
| isAgentStatusFresh(pendingBlocker, now) | ||
| ) { | ||
| continue | ||
| } |
There was a problem hiding this comment.
This scopes retention to the pane's write history, not to which writer authored the row. A host permission block pierces the client fence (hostAgentStatusPiercesClientAuthority) and overwrites a client-written pane's store row with a host-authored blocked/interactivePrompt entry, while hasClientWrite stays true. So on unmount plus host withdrawal such a row is still retained for up to 30 minutes — exactly the host-removal case the prior review asked to fix, just narrowed. The new control test (web-session-tabs-sync-unmount-pending-blocker.test.ts:210) does not catch it because it never registers the pane, so hasClientWrite is false there.
Technical details
# Pane-level write history still retains host-authored rows on host withdrawal
## Affected sites
- `src/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts:184-191` — the guard checks `isReleasedClientWrittenAgentStatusPane(paneKey, now)` (pane-level) and the row's `state`, never the row's author.
- `src/renderer/src/components/terminal-pane/renderer-owned-agent-status-registry.ts:87-94` — predicate keys on the pane entry's `hasClientWrite`/`releasedAt`; it is not consulted per row.
- `src/renderer/src/runtime/web-session-tabs-sync/agent-status-primitives.ts:70-72` — `blocked` or any `interactivePrompt` row is host-only and pierces the fence.
- `src/renderer/src/runtime/web-session-tabs-sync-remote-status-title-flap.test.ts:493-516` — pins the supported mixed flow: client OSC `working` then a host `blocked` + `interactivePrompt` overwrite on the same pane, leaving `hasClientWrite === true`.
- `src/renderer/src/runtime/web-session-tabs-sync-unmount-pending-blocker.test.ts:210-221` — the host-minted control uses a pane with no registration, so it only covers the never-client-written subcase.
## Verified repro (temporary test against this head, since removed)
client OSC `working` on a registered pane -> host snapshot with `state: 'blocked'` + `interactivePrompt` -> `release()` -> host snapshot without status. Result: `agentStatusByPaneKey[PANE_KEY]?.state === 'blocked'` (retained) instead of deleted.
## Required outcome
- A `blocked`/`interactivePrompt` row the host has withdrawn must retire promptly on the client, regardless of whether the pane earlier produced byte-derived status; retention should not outlive host authority for a row the host itself authored.
- The control test should exercise a pane that has emitted OSC status and then received a host-pierced row, so the intended scoping is actually pinned.
## Suggested approach (optional)
- Skip retention when the row's present state is one the client's bytes cannot author: `hostAgentStatusPiercesClientAuthority(pendingBlocker)` is already available in this module. That keeps retention for client-authored `waiting` rows while letting host-authored blocks retire on withdrawal.
## Open questions for the human
- Is host-side dismissal/withdrawal of a `blocked`/`interactivePrompt` row a supported flow? If so this 30-minute lag is a regression, not a tradeoff (this is the prior review's first open question, still unanswered).There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 05f78f85-2f24-4ed5-97a6-7db92538bcfc
📒 Files selected for processing (4)
src/renderer/src/components/terminal-pane/renderer-owned-agent-status-registry.test.tssrc/renderer/src/components/terminal-pane/renderer-owned-agent-status-registry.tssrc/renderer/src/runtime/web-session-tabs-sync-unmount-pending-blocker.test.tssrc/renderer/src/runtime/web-session-tabs-sync/agent-status-patch.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| const entry: RendererOwnedAgentStatusPane = { | ||
| environmentId, | ||
| hasClientWrite: existing?.environmentId === environmentId && existing.hasClientWrite | ||
| hasClientWrite: existing?.environmentId === environmentId && existing.hasClientWrite, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Expire a released claim before copying its write history.
If a pane releases, remains unregistered for more than AGENT_STATUS_STALE_AFTER_MS, and then re-registers with the same paneKey, this line copies hasClientWrite before forgetExpiredReleases runs. The new entry sets releasedAt to null, so the sweep cannot delete it. The expired claim becomes active client authority again and can retain or fence a stale row without a new renderer write.
Run the expiry sweep before reading existing, and add a same-paneKey re-registration test after the stale boundary.

ELI5
An agent asks you a question. You glance at another Orca tab and come back — the question is gone from the sidebar. It is kept now.
Problem
Switching tabs unmounts a pane.
dispose()callsreleaseRendererOwnedAgentStatusPane()(session-reconcile-dispose.ts), handing agent-status authority for that pane back to the host. The next mirrored host snapshot that carries no status for the surface reachesbuildMirroredAgentStatusPatch's delete loop, and that loop was gated on ownership alone (isClientOwnedAgentStatus). Nothing looked at the row'sstate, so an unansweredwaiting/blockedrow took exactly the same path as a stale one: deleted, not retired.The row was the only record of a question waiting on the user.
Solution
Absence of host status is not a resolution — but only for the panes where the host never had status to begin with. The fix turns on telling those two silences apart:
waiting/blockedrow; it retires by decaying pastAGENT_STATUS_STALE_AFTER_MSdropAgentStatus) or a closed split leaf: surface still published, status goneWhat Changed
renderer-owned-agent-status-registry.ts— the release closure marksreleasedAtinstead of deleting the entry, andisReleasedClientWrittenAgentStatusPanereads it.isClientAuthoritativeAgentStatusPanestill returnsfalseafter release, so the live-ownership fence is untouched; the new predicate is a separate, weaker signal. A pane that never proved a byte-derived write leaves nothing behind, and a retained claim is swept at the next registration once it can no longer describe a live row.agent-status-patch.ts— one guard ahead of the ownership gate: ablocked/waitingrow that is still fresh and whose pane this renderer wrote and has since unmounted skips the delete.workinganddoneare unchanged, and a host-minted row of any state is unchanged.Why
Per
docs/reference/agent-status-store.mdthe execution host owns status and readers keep only presentation policy. Unmount is a presentation event, so deciding retirement from it is the wrong layer — and so is overriding a host that deliberately withdrew a row, which is why the guard requires the released client-write claim rather than state alone.Freshness bounds the retention. An unanswered blocker is not kept forever; it decays on the same boundary every other mirrored row uses. Retaining unconditionally would re-introduce the ghost rows STA-4593 removed.
Linked Issue
Fixes #22445.
Visual Proof
N/A — renderer store state, not pixels. The observable effect is whether an
agentStatusByPaneKeyrow survives an unmount-then-snapshot sequence, which the regression suite asserts at that exact seam.Testing
web-session-tabs-sync-unmount-pending-blocker.test.tsreplays the real path — real snapshot mirror, real ownership registry, real store, driven clock:waiting/blocked, client-written, releasedAGENT_STATUS_STALE_AFTER_MSdone, same handoverwaiting, host stops publishing statusVerified RED on the base commit: the blocker cases fail with
expected undefined to be 'waiting'/'blocked'— the row is gone — and pass with the guard.renderer-owned-agent-status-registry.test.tsgained the bounded-evidence contract: a released claim is readable while fresh, gone after the window, swept at the next registration, and never retained for a pane that never wrote.Checks on
8d6fec597b:vitest run src/renderer/src/components/terminal-pane src/renderer/src/runtime: 679 files, 6264 tests pass — including the suites that pin this delete loop (paired-reconnect-sidebar-agent-count,web-session-tabs-sync-host-tab-retraction-ghost-rows,mirrored-status-tab-retractions,web-session-tabs-sync-remote-status-title-flap).vitest run src/renderer/src/store: 369 files, 3390 tests pass — covers thestore-test-helperssignature change.pnpm tc:web,oxlint,oxfmt --check,check-changed-code-quality.mjs: pass.Not run: native Windows/Linux, live SSH, e2e. Mobile is unaffected — it does not go through
buildMirroredAgentStatusPatch.Review
Independently reviewed by @pullfrog, which caught that gating on state and freshness alone also outlived host-withdrawn rows. That is fixed in
0ba9b46298and covered by the withdrawal case above; the retention now requires the released client-write claim.store-test-helpers.tsgained a namedTestAppStoreexport andcreateTestStorean explicit return type, because the repo rule against publishing contracts throughReturnType<typeof fn>applies to the new suite. Existing suites keep their local aliases; migrating them is not this PR's job.Two existing registry assertions pinned "release deletes immediately, zero entries left". That contract is intentionally different now, so they were retargeted at the bounded-evidence invariant and renamed to say so, not re-pinned to new numbers.
The SSH / Remote Orca Server case the issue asks about runs the same mirrored-snapshot path with the same environment-scoped ownership check, so the guard covers it; there is no separate branch for it.
Agent skill upstream boundary
Notes
retractedTabIdsskip above this guard.Checklist
N/Awith reasonpnpm lint,pnpm typecheck, focusedpnpm test, and the changed-code quality gate pass; packaging left to CI