Repository navigation
feat(agent-status): step 1 — stamp observation provenance and ordering at every status ingress (STA-4293) - #14706
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (25)
🚧 Files skipped from review as they are similar to previous changes (25)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review. 📝 WalkthroughWalkthroughAdds agent-status observation provenance with origin, authority, incarnation, revision, timestamp, boundary, and kind metadata. Main-process ingress points stamp observations and forward them through IPC, while persistence excludes runtime metadata. Renderer status producers stamp launch, process, OSC, and title-derived observations. Pane lifecycle operations retire and rebind observation state. Tests cover sequencing, provenance, boundaries, persistence, renderer ingress, and observation-neutral store behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/store/slices/agent-status.ts (1)
1483-1625: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd test coverage for
forget/rebindon pane authority changes.
retireAgentPaneAuthoritycallsrendererAgentStatusObservations.forgetfor each retired alias.transferAgentPaneAuthoritycallsforgeton the old key andrebindon the new key. No test in the reviewed files exercises this wiring.Add a test that retires or transfers a pane, then observes the pane again through the sequencer, and checks that the resulting incarnation reflects the forget/rebind call.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 880a9ff5-8bb1-4ef6-a110-053f990c186e
📒 Files selected for processing (23)
src/main/agent-hooks/server-observation-provenance.test.tssrc/main/agent-hooks/server.tssrc/main/index.tssrc/renderer/src/components/sidebar/worktree-title-derived-agent-rows.tssrc/renderer/src/components/terminal-pane/parked-terminal-command-status.test.tssrc/renderer/src/components/terminal-pane/parked-terminal-command-status.tssrc/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/lib/automation-session-observer.tssrc/renderer/src/lib/background-agent-status-consumer.tssrc/renderer/src/lib/command-code-prompt-status-seed.tssrc/renderer/src/lib/launch-agent-background-session.test.tssrc/renderer/src/lib/launch-agent-background-session.tssrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/renderer-agent-status-observation-ingress.test.tssrc/renderer/src/lib/renderer-agent-status-observations.tssrc/renderer/src/store/slices/agent-status-observation-neutrality.test.tssrc/renderer/src/store/slices/agent-status.tssrc/shared/agent-hook-listener.tssrc/shared/agent-status-observation.test.tssrc/shared/agent-status-observation.tssrc/shared/agent-status-types.ts
a5d9b2d to
f4cee78
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
b47792f to
1ee9033
Compare
1ee9033 to
a418c07
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Review statusState: What this is, and what it deliberately is not. Step 1 of the STA-4293 agent-status architecture work. It adds an optional Nothing reads it. There is no UI change, no behaviour change, and no consumer. Two independent architecture reviews converged on the same root cause — Validation — what was and was not done. The load-bearing test is a negative: Mutation-tested, so none of it is vacuous: replacing Suites run locally on macOS: Not done: no Linux, Windows, or SSH hardware. There is no platform-dependent code — no paths, shortcuts, or shell invocation — and the relay path is covered by Rebase state — verified independently for this comment. The branch sits directly on top of #15082 ( Known limits a reviewer should read before merging
Wire / persistence. Optional field on existing JSON, no new stream opcode. Supersedes: nothing. |
…ess (STA-4293) Add an optional `observation` facet to agent status rows recording the origin (hook | osc | title | process | launch | orchestration), the authority that sequenced it, a per-pane incarnation, a monotonic revision, and the authority's own clock. Stamp it at every ingress; no consumer reads it. Boundary is stamped from the hook listener's existing per-provider `isNewTurnEvent`, not a second list of event-name literals. Identity-only (`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future consumers do not each rediscover that they are not turn transitions. The staleness-decay contract is documented at the type: staleness must be computed against the same authority clock that stamped `observedAt`, or replicas must decay on local receipt time. Not fixed here. Behavior-neutral: optional field on existing JSON, never persisted, never published to paired clients, and never inherited across writes.
a418c07 to
3d04cf4
Compare
…as spawned into (STA-2069) (#14615)" This reverts commit 15efc87. The premise does not reproduce, the fix does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before. 1. PREMISE FALSE. #14615 asserts Claude Code >= 2.1.206 hosts TUI sessions as workers under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" while 69 interactive sessions are live, and all 68 running clients are direct children of their own pane's shell. Measured across the fleet: 68 distinct pane keys, ZERO collisions. The 19 keys with no live pane also have a dead ORCA_TERMINAL_HANDLE (pane closed, process outlived it). Terminals live under a *different* pane key: 0. Foreground attribution was never broken, so the correction has nothing to correct. 2. DOES NOT FIX THE REAL BUG. The failure #9236 describes is real but scoped to BACKGROUNDED sessions: a `--bg` / `/background` worker inherits the dispatching pane's whole ORCA_* set, and the hook script self-heals its endpoint while taking paneKey straight from ambient env, so the POST lands under the wrong pane. #14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. That needs a `kind: "bg"` guard at ingest instead; #9236 is reopened for it. 3. INTRODUCES A MISATTRIBUTION. Bindings are created at two spawn sites and removed only on PTY death. A pane whose user exits Claude keeps its PTY, so the binding survives; resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. That is the reported symptom, on a path that previously worked. Kept #14706's observations.rebind() in the conflicting hunk — it postdates #14615 and is not part of this revert; only #14615's comments were dropped and the surviving rationale reworded to alias resolution, which is what actually makes paneKey differ from envelope.paneKey now.
…as spawned into (STA-2069) (#14615)" (#15295) Reverts #14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before. 1. PREMISE FALSE. #14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken. 2. DOES NOT FIX THE REAL BUG. The failure in #9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. #14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in #15304. 3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride. Kept #14706's observations.rebind() in the conflicting hunk — it postdates #14615 and is not part of this revert.
…rn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — #14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever.
…ess (STA-4293) (stablyai#14706) Add an optional `observation` facet to agent status rows recording the origin (hook | osc | title | process | launch | orchestration), the authority that sequenced it, a per-pane incarnation, a monotonic revision, and the authority's own clock. Stamp it at every ingress; no consumer reads it. Boundary is stamped from the hook listener's existing per-provider `isNewTurnEvent`, not a second list of event-name literals. Identity-only (`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future consumers do not each rediscover that they are not turn transitions. The staleness-decay contract is documented at the type: staleness must be computed against the same authority clock that stamped `observedAt`, or replicas must decay on local receipt time. Not fixed here. Behavior-neutral: optional field on existing JSON, never persisted, never published to paired clients, and never inherited across writes.
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295) Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before. 1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken. 2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304. 3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride. Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
…rn event (#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — #14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn. (cherry picked from commit d1127b9)
…ess (STA-4293) (stablyai#14706) Add an optional `observation` facet to agent status rows recording the origin (hook | osc | title | process | launch | orchestration), the authority that sequenced it, a per-pane incarnation, a monotonic revision, and the authority's own clock. Stamp it at every ingress; no consumer reads it. Boundary is stamped from the hook listener's existing per-provider `isNewTurnEvent`, not a second list of event-name literals. Identity-only (`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future consumers do not each rediscover that they are not turn transitions. The staleness-decay contract is documented at the type: staleness must be computed against the same authority clock that stamped `observedAt`, or replicas must decay on local receipt time. Not fixed here. Behavior-neutral: optional field on existing JSON, never persisted, never published to paired clients, and never inherited across writes.
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295) Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before. 1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken. 2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304. 3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride. Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
…ess (STA-4293) (stablyai#14706) Add an optional `observation` facet to agent status rows recording the origin (hook | osc | title | process | launch | orchestration), the authority that sequenced it, a per-pane incarnation, a monotonic revision, and the authority's own clock. Stamp it at every ingress; no consumer reads it. Boundary is stamped from the hook listener's existing per-provider `isNewTurnEvent`, not a second list of event-name literals. Identity-only (`providerSessionOnly`) rows are tagged `kind: 'identity-only'` so future consumers do not each rediscover that they are not turn transitions. The staleness-decay contract is documented at the type: staleness must be computed against the same authority clock that stamped `observedAt`, or replicas must decay on local receipt time. Not fixed here. Behavior-neutral: optional field on existing JSON, never persisted, never published to paired clients, and never inherited across writes.
…as spawned into (STA-2069) (stablyai#14615)" (stablyai#15295) Reverts stablyai#14615. Its premise does not reproduce, it does not reach the failure that does, and the correction it installs can misattribute status on a path that worked before. 1. PREMISE FALSE. stablyai#14615 asserts Claude Code >= 2.1.206 hosts TUI sessions under a shared daemon. On 2.1.233 `claude daemon status` reports "not running" with 69 live interactive sessions, and every client is a direct child of its own pane's shell. Measured across the fleet: 68 distinct pane keys, zero collisions. Foreground attribution was never broken. 2. DOES NOT FIX THE REAL BUG. The failure in stablyai#9236 is real but scoped to BACKGROUNDED sessions, whose workers inherit the dispatching pane's whole ORCA_* set. stablyai#14615 mints a binding only for launches Orca constructs, so a typed `claude --bg` produces none. Fixed properly in stablyai#15304. 3. INTRODUCES A MISATTRIBUTION. Bindings are removed only on PTY death, and a user who exits Claude keeps the pane's PTY. Resuming that session in another pane does not rebind (`--resume` is a session selector, so the pin declines), and resolveBoundPaneOverride then rewrites paneKey and tabId onto the ORIGINAL pane despite a correct posted key. Demonstrated with a failing test against main; causation isolated to resolveBoundPaneOverride. Kept stablyai#14706's observations.rebind() in the conflicting hunk — it postdates stablyai#14615 and is not part of this revert.
…rn event (stablyai#15344) * fix(agent-hooks): revive a retired pane on each provider's own new-turn event The un-retirement gate matched two raw event-name literals, UserPromptSubmit and SessionStart. Only 5 of 18 hook sources name their turn boundary that way, so for the rest a reused pane stayed rowless forever: the user starts a new turn and no row ever appears in the sidebar or dashboard. Measured, not estimated — 10 providers fail the new test on main: gemini (BeforeAgent), antigravity (PreInvocation), amp (agent.start), cursor (beforeSubmitPrompt), pi/omp/prime-agent (before_agent_start), grok (user_prompt_submit), copilot (sessionStart, seen raw), hermes (pre_llm_call). The gate was also wrong in the other direction: opencode has no turn boundary at all, yet a literal SessionStart revived its pane. Both directions are covered. The correct per-provider classifier, isNewTurnEvent, was already imported into this file and already used 160 lines below — stablyai#14706 added that call specifically so consumers would stop re-deriving boundaries from literals, and left this one. Keeps the literal check when the remote envelope omits source: that field is optional, an older relay does not send it, and requiring it would have left every source-less remote pane retired forever. * fix(agent-hooks): tell an absent source apart from an unrecognized one Review of the first commit found that `isAgentHookSource(envelope.source) ? envelope.source : undefined` collapses two different wire conditions into one: an older relay that omits `source`, and a NEWER host relaying a provider this build does not know. They need opposite answers. Case two is the normal upgrade order — hosts and clients update independently — and its boundary event will not be UserPromptSubmit/SessionStart, because 13 of the 18 providers we already ship are named something else. So the legacy-literal fallback stranded that provider's panes permanently: the exact defect this branch fixes, silently reintroduced for traffic our own wire doctrine calls normal. Pass the raw wire value so the gate can distinguish them, and fail OPEN on an unrecognized provider. The costs are asymmetric: a stranded pane is invisible, permanent, and has no user-facing recovery, while a spurious revive produces a row that decays after AGENT_STATUS_STALE_AFTER_MS. Also from review: - Cover the source-less branches, which had no coverage at all — including a test pinning what the legacy shim CANNOT do, so nobody later widens the literal list to "fix" it. - Use the source as agentType rather than always 'claude'; 15 of 16 rows were describing a state that cannot occur. - Reword the opencode comment: no plugin in that family emits these literals, so this closes a hole rather than removing behavior. Checked and not changed: the local HTTP path 404s an unresolvable source, so the fallback is unreachable there and masks nothing. * test(agent-hooks): stop pinning opencode's fence behavior on a synthetic event The negative case asserted that an opencode pane stays retired after a literal SessionStart. That rests on a false premise: origin/main's opencode plugin never emits SessionStart at all — zero occurrences in opencode/hook-service.ts, and the shared family source is what mimo-code uses too. So the assertion pinned an event no plugin sends, and it would have become actively wrong the moment a pending change gives opencode a real SessionStart, silently re-breaking the rowless reused-pane case that change exists to fix. Assert against mimo-code and command-code instead. Both genuinely have no boundary event in any planned state, so the case tests what it claims to. * fix(agent-hooks): reject malformed relay sources at retired fence Only a non-empty unknown string can identify a future provider. Keep null, blank, numeric, and object source values behind the retired-pane fence instead of treating malformed wire data as a new turn.
ELI5
Every agent status row in Orca is a claim like "this pane is working". Today the row cannot say who made that claim — a real provider hook, an OSC 9999 payload, or a guess from the terminal title — nor whose clock stamped it, nor what order it came in. This PR adds that label. Nothing reads the label yet. It exists so the next PR can move one consumer at a time onto it and actually be able to tell those cases apart.
What Changed
Adds an optional
observationfacet to agent status rows and stamps it at every ingress.New:
src/shared/agent-status-observation.ts(the type, the ordering + decay contracts, and a small per-authority sequencer) andsrc/renderer/src/lib/renderer-agent-status-observations.ts(the renderer's sequencer instance).Stamped at:
ingestRemote)hookmain/agent-hooks/server.ts—applyNormalizedStatusis the single choke point every main-side ingress funnels throughingestTerminalStatus)oscoscpty-connection.ts,background-agent-status-consumer.ts,automation-session-observer.tslaunchpty-connection.ts,launch-agent-background-session.tsprocesspty-connection.ts,parked-terminal-command-status.ts,command-code-prompt-status-seed.tstitleworktree-title-derived-agent-rows.tsTwo facets both reviewers insisted on:
boundaryis stamped from the hook listener's own per-providerisNewTurnEvent(now exported), not from a new list of event-name literals. Today the retired-pane gate atserver.tsmatches two raw literals (UserPromptSubmit/SessionStart), which is why providers whose boundary event is namedbefore_agent_start,BeforeAgent,agent.start, orbeforeSubmitPromptnever un-retire a pane — the defect fix(agent-hooks): reopen a retired pane on any provider's turn boundary (#12686) #14626 fixed one instance of. Reusing the existing classifier means the target architecture cannot re-create that bug at consumers. A test mutation that swapsisNewTurnEventfor the two literals fails exactly those four providers.kind: 'identity-only'forproviderSessionOnlyevents. Those carry astatefield but are resume-identity refreshes, not turn transitions — fix(stats): count agent sessions from hook transitions, not OSC titles (STA-2445) #14657 had to special-case them by hand.The decay rule is written down at the type (
agent-status-observation.ts). Both reviewers flagged it and neither original review caught it: staleness must be computed against the same authority clock that stampedobservedAt, or replicas must decay on local receipt time.isExplicitAgentStatusFreshcomputesrendererNow − entry.updatedAt, and for a mirrored remote entryupdatedAtis the host's clock. DeclaringobservedAtdisplay-only does not fix that — the skew is in the subtraction, not the tiebreak. This PR does not fix it. It records the contract so the PR that moves the first consumer has something to be correct against.Why
Two independent architecture reviews of this subsystem converged on the same root cause and the same first step.
AgentStatusEntryhas no provenance field, so it cannot say whether a row came from a hook, from OSC 9999, or from a terminal-title guess. Hook rows carry main's watermark-forced monotonic clock; byte-derived rows get the renderer'sDate.now(). Both are arbitrated by a single strict<onupdatedAt. Two clocks, one comparison, no tag — and every recurring bug class in this area traces back to it.The joint recommendation was to introduce observation metadata first, as optional fields beside the existing scalar
state, consumed by nobody, so the later work (one resolver, one consumer at a time, then deletions) has a foundation and each step can be checked in isolation.This changes no behavior, is consumed by nothing, and exists so the NEXT PR can move one consumer at a time.
Deliberate non-scope, all later PRs: no consumer changes, no merge-point consolidation, no deletions, no change to what the host publishes to paired clients, no fix for the title-derived row whose fabricated
entry.statecontradicts its own row state (theorigin: 'title'tag is precisely what makes that detectable).Wire and compatibility
Per
docs/reference/remote-wire-compatibility.md:observationis not onAgentStatusPayloadand is not copied bynormalizeAgentStatusObject— a hook or OSC writer cannot declare its own provenance; only the ingress that accepted the event can stamp it.pickParsedAgentStatusPayloadand the session-tab mirror both pick fields explicitly, soobservationnever reaches a paired client. Changing that is a later, capability-negotiated PR.PersistedAgentHookEventPayload, solast-status.jsonis byte-identical to today and a rehydrated row carries no ordering claim from a dead authority. (The persist path dedupes on exact JSON, so persisting it would also have meant a disk write per event.)authorityIdis regenerated per process instance. Revision counters live in memory, so a restarted authority must not be comparable with what it emitted before; a differingauthorityIdmeans incomparable, not "older", and consumers fall back to today's timestamp rule.ingestRemote) is stamped by the local main that receives it, which is the same authority that already sequences those rows. Folder workspaces and git worktrees are identical here — the facet is pane-scoped, not worktree-scoped.Linked Issue
STA-4293 — "Centralize and improve our agent status reporting code - right now it is pretty scattered, and flimsy". This is step 1 of N.
Fixes #
Visual Proof
N/A— there is no UI or behavior change. That is the claim this PR has to defend, and it is defended by tests rather than screenshots:agent-status-observation-neutrality.test.tsasserts that a stamped row and an unstamped row produce byte-identical output from sidebar rows, the card dot, smart-attention and the freshness gate, and that the store'sagentStatusEpoch/sortEpochtick identically (an extra epoch tick would be an extra render across every aggregate consumer — a behavior change with no visible diff).Testing
Automated (all new suites green; the central one is a negative):
src/renderer/src/store/slices/agent-status-observation-neutrality.test.ts— the safety argument. For each ofworking | blocked | waiting | done: identical entries apart from theobservationkey, identical epochs, and identical output fromisExplicitAgentStatusFresh,buildWorktreeAgentRows,getAgentDotStateandresolveAttention, evaluated both fresh and past the staleness horizon. Plus: an entry with no observation resolves exactly as today (old hosts, persisted rehydration, title-derived and subagent rows all lack it), and an unstamped write never inherits the previous row's observation.src/shared/agent-status-observation.test.ts— revision strictly increases per pane and across interleaved panes; incarnation bumps on rebind and never decreases afterforgetor cap eviction; revision survives eviction of 2,000 panes.src/main/agent-hooks/server-observation-provenance.test.ts— origin per ingress (hookfor HTTP/relay,oscforingestTerminalStatus),snapshotfor relay replay,identity-onlyforproviderSessionOnly, boundary across five providers, revision monotonic, incarnation bumped when a retired pane restarts, and nothing written tolast-status.json.src/renderer/src/lib/renderer-agent-status-observation-ingress.test.ts— title rows taggedtitleunder a fixed projection authority and deterministic innow(a counter there would churn a new revision per render and break memoization); renderer-parsed OSC taggedoscunder arenderer:authority.setAgentStatuspayloads — those assertions now also pin the expectedorigin, which is extra ingress coverage rather than a loosened check.Mutation-tested (each of these makes a specific test fail, so none of them is vacuous):
isNewTurnEventwith the two gate literals → the four non-literal providers fail;observation→ thelast-status.jsontest fails;existing.observation, or makingobservationsort-relevant in the store → the neutrality suite fails.Suites run locally on macOS:
src/main/agent-hooks/(628),src/renderer/src/store/slices/+src/renderer/src/components/sidebar/(4,757),pty-connection.test.ts(579), plus the runtime/session-sync and launch suites — all green.tsc --noEmitclean for both the node and web projects.oxlint, the native and type-aware code-quality configs,lint-react-doctor-changed, andcheck:max-lines-ratchetall clean on the changed files.Not tested on Linux/Windows/SSH hardware. There is no platform-dependent code in this change — no paths, no shortcuts, no shell invocation — and the SSH relay path is covered by the
ingestRemoteunit tests.Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
normalizeAgentStatusObjectbuilds a fresh object from an explicit field list, which drops anyobservationa caller tries to send.observation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author