Repository navigation
fix(agent-status): report a stale pane that still holds a PTY as unverifiable, not idle - #18012
Conversation
…e mirror #11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (#16414, #16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from #13621 that blocked this were all written before the `authoritative` label existed (#13621 landed 2026-08-11; the capability landed 2026-08-26 in #16546). #13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs #11495
…lock #15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs #15317
A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged.
…lock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget.
There was a problem hiding this comment.
Important
One substantive concern about the liveness evidence's granularity; the rest is minor.
Reviewed changes
One review of a two-commit fix that splits the decay destination for a stale agent-status row (unverifiable vs idle) and stamps a replica-local receipt clock so mirrored remote rows decay on the reader's clock instead of the host's.
- Decay destination split — new
resolveDecayedAgentRowState(entry, hasLivePty)routes a stale non-doneentry on a live-PTY pane tounverifiable, elseidle; wired intobuildWorktreeAgentRowsand smart-attention (new class 4 between working and idle, idle renumbered to class 5). - Mirrored-remote clock skew — new
mirroredEvidenceReceivedAtfacet stamped bybuildMirroredAgentStatusPatchand carried forward on repaints;agentStatusEvidenceObservedAtprefers it so the decay subtraction uses one machine's clock. - Shared dot-state mapping —
agentRowDotStateconsolidates three duplicateasDotStatecopies;AgentStateDot/DashboardAgentRow/compact sidebar rows render the amber dashedunverifiableindicator. - Clock rules split —
AGENT_STATUS_STALE_AFTER_MSplus the observation/decay accessors move toagent-status-freshness.tsand are re-exported (nomax-linesdisable).
⚠️ Decay evidence is tab-granular, but the claim is pane-granular
The PR's premise is "a pane that still holds a live PTY", but resolveDecayedAgentRowState receives hasLivePty = tabHasLivePty(ptyIdsByTabId, tab.id), which is true when the tab holds any live PTY, not when the pane does. The row this decides for is per-pane (entry.paneKey = tabId:leafId). In a split-pane tab, a stale entry on a pane whose own PTY is closed — but which shares the tab with a still-running sibling — decays to unverifiable ("No update in N") instead of idle, even though Orca can already verify that pane is gone.
This errs in the safe direction (never claims a held pane is empty) and is narrow, but it is the exact distinction the feature exists to draw. Leaf-level liveness is derivable at every call site, so this is a "confirm intent" finding rather than a hard defect.
Technical details
# Decay liveness signal is tab-level, not pane-level
## Affected sites
- `src/renderer/src/lib/agent-row-decay-state.ts:24` — `resolveDecayedAgentRowState(entry, hasLivePty)` documents "a pane whose PTY is still in the live-PTY map", but the map is keyed by tab.
- `src/renderer/src/components/sidebar/worktree-agent-rows.ts:173` — `hasLivePty = tabHasLivePty(ptyIdsByTabId, tab.id)` per tab, applied to every per-pane entry.
- `src/renderer/src/components/sidebar/smart-attention.ts:301` — `collectTabPaneInputs` computes one `hasLivePty` per tab and stamps it on each hook input; `buildAttentionByWorktree` (line 390) hardcodes `hasLivePty: false` for the no-tab fallback.
- `src/renderer/src/lib/tab-has-live-pty.ts:11` — the source of the tab-level signal.
## Scenario
Split-pane tab with two panes. Pane A's agent crashes without a `done` signal (its PTY dies and is dropped from `ptyIdsByTabId`); pane B's agent keeps running. Pane A's stale `working` entry still has `tabHasLivePty(tab.id) === true` because of pane B, so it renders `unverifiable`/amber instead of `idle` — a stale "Orca still holds this pane" claim for a pane Orca can already verify is gone.
## Required outcome
- Either plumb leaf-level PTY evidence (`TerminalLayoutSnapshot.ptyIdsByLeafId`, already available as `terminalLayoutsByTabId` at all three call sites) into `hasLivePty`, or
- Document the tab-level granularity in the code (not just the PR body) so the `unverifiable` contract is "the pane's tab still holds a PTY", not "the pane does".
## Open questions for the human
- Is split-pane-with-multiple-agents frequent enough to justify the extra plumbing, or is tab-level an acceptable simplification today?ℹ️ Nitpicks
unverifiablehas three labels across surfaces:agentStateLabel→ "No recent update",formatSummaryStateLabel→ "not reporting",agentNoUpdateLabel→ "No update in N". Each fits its slot, but a reader can't tell they name the same state.- The idle→class-5 renumber didn't sweep its stale "Class 4 = idle" references:
smart-attention.ts:203("pane stays in Class 4"),use-sort-order.ts:108("collapse all to Class 4"), andsmart-sort.test.tsdescribe names/comments ("stale entries fall to Class 4", "Class 4 ordering"). These sit right beside the fixed "passing for the wrong reason" test in the same file. smart_sort_class_distribution.class_4silently changes meaning (idle → unverifiable) for any existing analytics on that bucket; the schema comment documents it, but a changelog/analytics note would save someone a confused regression report.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (31)
📝 WalkthroughWalkthroughThe change adds ✨ 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 |
…rifiable, not idle (stablyai#18012) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317 * fix(sidebar): stop a stale agent row claiming the pane is empty A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged. * fix(agent-status): decay a mirrored remote row on the replica's own clock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget. Mirror-Of: 266b2ea
…rifiable, not idle (stablyai#18012) * fix(remote): stop one unlabelled inventory tombstoning a live worktree mirror stablyai#11495 Step C. `buildMissingWebSessionTabsRemovals` synthesised a `removed: true` tombstone -- emptying a worktree's entire mirror -- for any tracked worktree absent from a single inventory frame, without ever consulting the host's own authority label. `mirror-settle` already refuses to settle an *empty* inventory that is not `authoritative` (stablyai#16414, stablyai#16546); the strictly more destructive action was ungated. An inventory the host labels `authoritative` carries a complete PTY census, so one omission is host attestation and removal stays immediate. An unlabelled inventory is a degraded or version-skewed census: `unverifiable`, not `exited`. It must now repeat before it can destroy anything, reusing the two-observation shape of `confirmSurfaceInventoryAbsence`. A legacy host that never negotiates the capability still converges after two rounds, so ghost rows cannot outlive the fence. The 14 tests from stablyai#13621 that blocked this were all written before the `authoritative` label existed (stablyai#13621 landed 2026-08-11; the capability landed 2026-08-26 in stablyai#16546). stablyai#13621's own summary says "Reconcile each resumed host from an authoritative inventory, including removals", so their fixtures are retargeted to say so explicitly rather than weakened. Refs stablyai#11495 * fix(agent-status): stop a reconnect replay restamping the staleness clock stablyai#15317 correctness half. `receivedAt` was doing two jobs: delivery order and evidence age. A relay reconnect replays every cached row, and `receivedAt` must restamp to clear the connection watermark that `clearStatusEntriesForConnection` raises -- so a pane stuck at `working` had its 30-minute deadline pushed out by another 30 minutes on every reconnect. The TTL was never reached, which is why this read as a tuning question. Two clocks, not one rewritten clock: - `receivedAt` is untouched. The transient-clear watermark and the four `<` ordering drops (`agent-status-event-applicator`, `agent-status-live-entry-builder`, `agent-status-cleanup-actions`) keep working unchanged. Restamping a replay with its original time would have made it `<= watermark` and dropped it outright, leaving the pane with no row at all. - `evidenceObservedAt` is new, optional, and read only by the staleness comparison (`isFreshNonDoneAgentStatus`, `isExplicitAgentStatusFresh`, the freshness scheduler). Main holds it per pane across the transport clear -- the clear deletes the row on purpose, but the *age* of evidence a later replay restates is not a claim about the pane. Absent means "no separate observation", and every consumer falls back to `receivedAt`/`updatedAt`, so old hosts and old rows behave exactly as today. Behaviour: a genuinely active pane keeps stamping the observation clock from its real events, so it stays `working` across a reconnect. A pane whose relay restarted replays nothing and still falls through to title evidence. A torn-down pane drops its remembered clock in `clearPaneState`, so a reused pane key cannot inherit one. `AGENT_STATUS_STALE_AFTER_MS` is deliberately unchanged -- the window length remains a product decision. Refs stablyai#15317 * fix(sidebar): stop a stale agent row claiming the pane is empty A stale non-`done` entry decayed to `idle` whether or not Orca still held the pane's PTY, so "we lost the reporting stream" and "nothing is running here" were the same display class. Split the destination on evidence already computed: with a live PTY the row is `unverifiable` and reports the observer's own fact — how long the silence has run — so the user can apply context Orca has no way to know. With no PTY it stays `idle`. Smart sort gains class 4 for it, between working (3) and idle (now 5): still plausibly the most important pane, never outranking one that is reporting, and never a claim that the agent finished. `unverifiable` stays renderer-local; the dashboard card projection publishes today's `idle` because that vocabulary is validated against a fixed allowlist in main and read by older pop-outs. AGENT_STATUS_STALE_AFTER_MS is unchanged. * fix(agent-status): decay a mirrored remote row on the replica's own clock A paired client mirrored a remote host's status rows verbatim, host wall clock included, and the staleness gate then computed `rendererNow - hostStamp`. The effective window was 30 minutes plus or minus the two machines' skew: a host running fast held every remote row permanently fresh, a host running slow decayed them on arrival. The constant was never the lever there — the subtraction straddled two clocks. The replica now stamps `mirroredEvidenceReceivedAt` from its own clock when the authority's observation advances, carries it forward across an exact repaint (a restated observation is not a new one), and decays against it. Both sides of the subtraction come from one machine; locally observed rows carry no stamp and are unchanged. The alternative the type comment named — carrying the authority's freshness verdict — was rejected: a verdict is computed at publish time and cannot age between snapshots, so once the host goes quiet the replica would hold `fresh` forever. That is precisely the loss-of-contact case the window exists for. AGENT_STATUS_STALE_AFTER_MS is unchanged; the clock rules move to agent-status-freshness.ts to keep agent-status-types.ts under its line budget.

Stacked on #17981. Two commits: the decay destination, and the mirrored-remote clock skew.
Why this exists
#17981 made the 30-minute agent-status staleness window actually fire (it had been restamped on every reconnect, so it never elapsed). Now that it fires, where it decays to matters — and the destination was wrong.
worktree-agent-rows.tsdecayed to'idle', and smart-sort defines that bucket as "no live entry, stale entry, interrupted done, or an aged-out completion." So a pane that is stale but still holds a live PTY was bucketed identically to a pane with no agent at all. It never claimed finished — but it asserted "nothing is happening here" on zero evidence.Commit 1 — split the decay destination
New
resolveDecayedAgentRowState(entry, hasLivePty):!isFresh && tabHasLivePty→unverifiable; otherwiseidle, exactly as before.Rendered in the observer's voice with elapsed time — an amber
CircleDashed(not thedonecheck, not theworkingspinner) and "No update in 34m", measured fromagentStatusEvidenceObservedAtso a relay replay cannot reset it. The elapsed time is the point: it lets a user apply knowledge Orca doesn't have, like knowing they started a 40-minute build.Smart-attention gains class 4 (unverifiable) between working (3) and idle (now 5), ordered by last observation so the least-silent pane ranks first.
Naming deviation, flagged: I asked for
unverified; the implementation usedunverifiable, becausedocs/reference/ssh-execution-boundary.mdfixes the vocabulary aslive/unverifiable/exitedand says "do not introduce synonyms" — andunverifiableis already the word inUnstoppedPtyVerdict,HostLiveTerminalProbeVerdict,TerminalStreamEndVerdict, andpty-liveness-verdict. That is the right call and I was wrong; a one-token rename if anyone disagrees.Two deliberate narrowings:
restoredUnconfirmedrows stayidle— stale by construction rather than by elapsed silence, and their last evidence predates a process boundary, so there is no honest gap to report. Including them would have flipped a large population of rows on every app start.DashboardCardDotStateis validated against a fixed allowlist and read by pop-outs, so it still publishesidle. Mobile derives its own decay fromRuntimeWorktreeAgentRow, which carries no liveness signal at all, sounverifiableis underivable there without a Rule 1 addition. Rule 3 satisfied by construction.Commit 2 — the mirrored-remote clock skew
agent-status-observation.tsdocumented this and left it unfixed: for a mirrored remote row,updatedAtis the host's clock, and freshness computedrendererNow − hostClock. So on the paired-runtime path the effective window was 30 minutes ± host clock skew — tuning the constant was meaningless there. (The SSH relay path is unaffected: its envelope carries no timestamp andingestRemotestamps on client receipt.)Chose the local receipt stamp. A new replica-local
mirroredEvidenceReceivedAtis stamped when the authority's observation clock advances and carried across an exact repaint, so both sides of the subtraction come from one machine. The accessor is split so the distinction is nameable:agentStatusAuthorityObservedAt(host clock, for cross-row arbitration) vsagentStatusEvidenceObservedAt(reader clock, for decay).Rejected the alternative — carrying the authority's freshness verdict — and there is a test asserting against it: a verdict is computed at publish time and cannot age between snapshots, so the moment the host stops publishing (the loss-of-contact case the window exists for) the replica would hold
freshforever. It would also still need the receipt stamp as the mixed-version fallback: two mechanisms for one rule.A test that was passing for the wrong reason
smart-sort.test.ts's "palette ranks blocked above working" used fixed-epoch 2026-03-27 stamps against a liveDate.now(), so both entries were months stale and the assertion passed on alphabetical fallback — never on the class layer it claims to pin. Switched to a live clock so it tests its stated intent.That is the eighth test in this sweep found green while encoding something other than its stated claim.
User-facing regressions
None expected.
AGENT_STATUS_STALE_AFTER_MSis untouched at 30 minutes. Negative controls, all passing: a live pane with fresh events still readsworking; a pane with no live PTY still readsidle; adonepane is unaffected includinginterrupted; the dot is neverdoneand neverworking.One genuine improvement: the freshness scheduler now arms its timer off the receipt clock for mirrored rows, so on a replica the timer fires at the right wall time for the first time.
Testing
Commit 1 before:
Tests 6 failed | 5 passed (11)—expected 'idle' to be 'unverifiable',expected 4 to be less than 4,Expected: "No update in 34m" / Received: "Claude". After:11 passed.Commit 2 before:
Tests 5 failed (5)—expected true to be falseon the decay boundary in both skew directions. After:5 passed.pnpm tcall projects clean;check:code-quality:changed0 new findings across 54 files; localization verified with no catalog change. Regression sweepsrc/renderer src/main src/shared mobile→ 64,650 passed; the 5 failing files are Electron-harness/temp-dir flakes, andrun-electron-vite-devwas reproduced failing identically on the base branch.agent-status-types.tscrossed the 300-linemax-linesbudget, so the clock rules moved to a newsrc/shared/agent-status-freshness.tsand are re-exported — no lint disable.Finding worth passing on
Mobile has the same clock-skew defect, unfixed.
mobile/src/worktree/agent-row-display.ts:34compares the host'supdatedAtagainst mobile's ownnow. Fixing it needs a host-clock offset on the mobile client or a wire change, so it is out of scope here — but it is the same bug class on a second surface.