Repository navigation
fix(orchestration): unify structured-session status across worktree ps and sidebar - #19217
Conversation
…ion as idle A worktree running a structured Claude or Codex chat read as idle to `orca worktree ps`, while the desktop sidebar showed the same session working. The sidebar was right: the host already projects a status summary for every structured session and publishes it, and the renderer maps it into an agent row. `worktree ps` simply never consumed it, so the agent-facing surface was the blind one. Structured sessions have no PTY, so they reach neither the hook snapshots nor the retained ones that every other row is built from. This reads the summaries the host has already published and applies the same projection the sidebar does — working, attention as blocked, otherwise done — so the CLI and the GUI cannot disagree about one session. Two things worth knowing: The connected-PTY evidence gate had to be skipped for these rows. It exists to drop a row whose PTY is gone, which is the wrong question for a session that never had one; a structured row's liveness evidence is the status feed that produced it. The exemption is keyed on the row being structured, so every PTY-backed row keeps today's behaviour. `RuntimeWorktreeAgentRow` needed no change. It was already a non-PTY shape — paneKey, state, agentType, and no ptyId, connected or writable — so a structured row fits without inventing a fake terminal coordinate. The pane key is the DERIVED one the renderer already publishes, never the orchestration bearer handle or the minted worker pane key: both are credentials, since `orchestration check` is identity-gated and accepts a caller-supplied pane key. `orca terminal list` is deliberately untouched, and a test pins that. Adding rows there breaks real consumers: mobile mounts a terminal WebView per row that can never receive a frame, a `connected`-keyed refresh check goes permanently true and pins shipped clients to a fast cadence with no exit, and the plugin projection has no field that can carry `writable: false`. Every safe consumer of a terminal summary checks `ptyId`; the breaking ones key off `connected` or mere row presence, which no added field can qualify. An honest partial-listing count there is a separate change.
|
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:
📝 WalkthroughWalkthroughThe status feed now exposes summaries only for sessions still held in its live session map. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Idle structured sessions may be reported as requiring permission rather than inactive, producing incorrect worktree status until done rows are excluded from activity aggregation. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the problem, implementation, issue follow-up, and validation, but it omits required template sections and checklist details. It does not provide visual proof or an explicit Resolution Complete the required template sections. Add visual proof for the behavior change, or write
✨ Finishing Touches 💡 1📝 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 36f38468-3d9e-4839-923f-2d4457186a82
📒 Files selected for processing (5)
src/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/runtime/orca-runtime-get-worktree-ps.tssrc/main/runtime/runtime-worktree-agent-rows-structured.test.tssrc/main/runtime/runtime-worktree-agent-rows.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
Important
The enumerator reads every summary the host has ever projected, including sessions whose tabs have since been closed, so worktree ps will report closed structured chats as phantom rows.
Reviewed changes
- Host exposes its projected summaries —
StructuredAgentSessionHost.publishedStatusSummaries()andStructuredAgentSessionStatusFeed.publishedSummaries()expose the last projected status per session for polling readers. worktree psenumerates structured sessions —attachRuntimeWorktreeAgentRowsaccepts astructuredSummariessource and projects each into a row using the sameworking/blocked/donemapping the sidebar applies, skipping null-status sessions and exempting them from the connected-PTY gate.- Tests — five new cases in
runtime-worktree-agent-rows-structured.test.tsplus a source ratchet pinning thatterminal liststays untouched.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
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. |
The status feed's `published` map is a broadcast cache, not a roster. It deliberately never retracts — an evicted idle session is still idle, and a reloading renderer must not lose every settled row — so enumerating it lists every session the host has ever opened, and eviction's `forget-session` step deletes the session from the live map while touching nothing else. Reading it as a roster made `worktree ps` report a closed chat forever. The sharp edge is a chat closed while an approval was pending: a deliberate close does not settle a pending prompt, so the retained summary stays `attention`, maps to a `blocked` row, and merges the worktree to `permission` for the whole 30-minute freshness window — on the CLI and on the mobile sidebar it backs. The poller now answers from the sessions the host still holds, intersecting the live map with the retained projections. `subscribe()` and its snapshot are untouched: retention there is the point. Gating on the live session set rather than the visible tabs keeps a headless orchestration worker listed, which is what the agent-facing surface is for. Also folds out two things the enumerator left behind: the working/attention/idle to working/blocked/done mapping now lives once in the shared projection module instead of once per process, which is what actually enforces "the CLI and the GUI cannot disagree"; and the structured row source no longer builds a write-only `payload` behind an `as` cast that compensated for nothing. The structured source construction moves to its own module to keep runtime-worktree-agent-rows.ts clear of the 300-line cap.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
What changed since the prior review (a2f4bd9):
- Phantom rows fixed via a live-session intersection —
publishedSummaries()becameliveSessionSummaries(), which third-party the retained broadcast cache againstthis.deps.sessions(the map eviction'sforget-sessionstep deletes), soworktree psno longer lists closed structured chats as phantom rows. - Source projection extracted — the inline structured-summary loop moved into
structuredRuntimeWorktreeAgentSources()in its own module, emitting astructured: truesource with the derived pane key and no fake hook payload. payloadmade optional with a guard —RuntimeWorktreeAgentSource.payloadis now optional; retained/hook sources populate flattened top-level fields, and the monitoring hook-match branch gained anexisting.payload !== undefinedguard.- Status-state mapping shared across the wire —
structuredAgentSessionStatusState()instructured-agent-session-projection.tsreplaces the inline ternary in both the CLI rows and theStructuredAgentSessionStatusBridge, so the two surfaces cannot disagree. - Tests — a feed unit test for the liveness intersection plus an end-to-end
runtime-worktree-structured-agent-rows-liveness.test.tscovering the closed-chat-parked-on-approval sharp edge (blocked while held, gone once evicted).
The prior findings are addressed and no new issues surfaced. Affected suites pass locally (22 tests).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
# Conflicts: # src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
Both structured-row suites called attachRuntimeWorktreeAgentRows directly with summaries they built themselves, so nothing ever ran getWorktreePs's own `getStructuredAgentSessionHost()?.liveSessionStatusSummaries()`. That file carries `@ts-nocheck`, so renaming the accessor was green in typecheck and in the suite, while `orca worktree ps` and mobile's 3s poll would throw a TypeError for every user — the `?.` optional-chains the host, not the method. Swapping the call back to a whole-cache read was equally invisible: the liveness suite injects feed.liveSessionSummaries() itself, and the string-match guard only needs the identifier to appear somewhere in the file. Drives the real runtime with a stub host over a real status feed that has published two sessions and forgotten one, asserting the live session's row reaches ps output, that the live accessor is the one called, and that the `?? []` fallback still returns a page with no host installed. The stub is typed against the real host, so a class-side rename reddens tc here.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Exercised the production
worktree pscall site end to end — a newworktree-ps-structured-host.spec.tsdrivesOrcaRuntimeService(store).getWorktreePs()through the realattachRuntimeWorktreeAgentRowspath, whereas both prior structured-row suites calledattachRuntimeWorktreeAgentRowsdirectly with hand-built summaries. This closes the/@ts-nocheck/gap onorca-runtime-get-worktree-ps.ts: renamingliveSessionStatusSummaries(or reverting the call site to a whole-cache read) now reddens the suite, since the test pins both the accessor name viaexpect(liveSessionStatusSummaries).toHaveBeenCalledTimes(1)and the live-only behavior via thetoHaveLength(1)assertion on a feed that still retains a forgotten session.
The change is test-only; the production wiring and projection are unchanged from the prior reviewed state.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status: ready to merge — with one follow-up I'd file before someone trips over itReviewed across four loops (independent review, precedent review, two fix rounds, plus opening and closing readiness audits). One blocker was found and fixed, three smaller items were folded in, and the branch was brought up to date with 1. Functional correctnessA blocker was found and fixed. The original revision enumerated
The fix replaces Also folded in: the 2. Architectural fitHonest read: the bug class is removed, but one part of the expression is a bolt-on. The mechanism was twofold — structured sessions reached no row source, and the connected-PTY evidence gate would have dropped them anyway. The first half is genuinely removed: they now have a source, and its liveness is established at the source rather than assumed. The second half is expressed as The greenfield shape would make row sources a discriminated union ( I did not do that here: it touches the whole row builder and its existing tests for what is otherwise a contained bug fix. Recommended as an actionable follow-up, not a merge gate. 3. Precedent, and where it deviatesComparing mechanisms rather than surface behaviour:
I am naming the matching part specifically rather than claiming the design "follows precedent" wholesale. 4. Validation performed, and remaining gaps
Known and accepted
Follow-up worth filing now
|
Electron validation — screenshotsCaptured from a dev instance launched off this branch at What these show: the app boots and runs at this commit, and the workspace is live. What they do not show: any visual delta — this change is main-process only, and the desktop sidebar reads the store rather than The load-bearing Electron evidence is not visual: with a non-null structured host installed, |
|
Reviewed and refactored in Functional correctness: A real Codex structured session appeared in Architecture: Replaced the third-input/boolean-bypass shape with one admitted source collection. PTY hook/retained reconciliation, connected-process evidence and mirrored workspace resolution now belong to a PTY source adapter. Structured rows come from the installed host's held-session projections; row assembly no longer assumes PTYs or makes structured exceptions. The broadcast cache remains history rather than lifecycle authority. Hold-resume wiring moved into the existing lifetime module, taking the host below its line cap without a lint suppression. Mechanism boundaries: PTY reports still arrive through independent hook and retained-status channels, so precedence and conservative remote evidence rules remain necessary. A held structured session is not a claim that its provider child is running; successful eviction removes it, while failed cleanup deliberately keeps it available for retry. The existing 30-minute freshness rule and differing CLI/sidebar activity timestamps are preserved; complete timing parity is not claimed. Validation: On the committed candidate, 1,342 tests passed and one was skipped across eight runtime, source-admission, host, handoff, hold and feed suites. Full Remaining gaps: live Claude approval/input journeys, Windows/Linux/WSL/SSH/relay/mobile runs, and release-scale latency/heap measurements. No provider subprocess, journal replay, new subscription or polling interval was added to the status read. Existing runtime row shape and vocabulary are retained for mobile clients. The screenshots show actual CLI JSON reduced to status, provider and pane identity beside the sidebar: Working structured session: After closing that chat: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts (1)
51-51: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winRefresh cached timestamps for active summaries.
workingandattentionsummaries compare equal when onlyupdatedAtchanges.publish()then keeps the old cached timestamp. An active structured row can exceed the preserved 30-minute freshness window during a long unchanged turn.Update
publishedwith the new summary before the equal-projection return. Keep event suppression separate from cache freshness.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: f2714108-752b-4d2b-939c-85b4e0c129ff
⛔ Files ignored due to path filters (2)
docs/review-evidence/pr-19217/closed.pngis excluded by!**/*.pngdocs/review-evidence/pr-19217/working.pngis excluded by!**/*.png
📒 Files selected for processing (15)
docs/review-evidence/pr-19217/README.mdsrc/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/runtime/orca-runtime-get-worktree-ps.tssrc/main/runtime/orca-runtime-tests/worktree-ps-structured-host.spec.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/runtime-worktree-agent-rows-structured.test.tssrc/main/runtime/runtime-worktree-agent-rows.tssrc/main/runtime/runtime-worktree-agent-source.tssrc/main/runtime/runtime-worktree-agent-sources.test.tssrc/main/runtime/runtime-worktree-agent-sources.tssrc/main/runtime/runtime-worktree-pty-agent-sources.tssrc/main/runtime/runtime-worktree-structured-agent-rows-liveness.test.tssrc/main/runtime/runtime-worktree-structured-agent-rows.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review (ce10240), commit 0adaea5 refactors the source admission ahead of row projection without changing behavior:
- Source admission extracted from row shaping —
attachRuntimeWorktreeAgentRowsnow receives a pre-collectedrowSources: ReadonlyMap<string, RuntimeWorktreeAgentSource>instead of the raw snapshots. The retained/hook reconciliation (including the monitoring-enrichment branch) and the connected-PTY gate moved verbatim intocollectRuntimeWorktreePtyAgentSourcesinruntime-worktree-pty-agent-sources.ts. structuredbypass flag eliminated —RuntimeWorktreeAgentSourcemoved to its own module and dropped the optionalpayloadandstructuredfields. Structured (non-PTY) sources are now admitted as a separate collection merged after the PTY sources incollectRuntimeWorktreeAgentSources, so the connected-evidence gate applies to PTY-backed rows by construction rather than via a flag exemption; a PTY-backed row still wins on a pane-key collision.- Hold factory consolidated —
createStructuredAgentSessionHoldsnow takesreconcileLeases/attach/closeand buildsresume/evictinternally, removing theresumeStructuredAgentSessionForHoldimport fromstructured-agent-session-host.ts. Theresumepath is equivalent:lifetimeContext()returns stabledeps/sessions/runtimeState/nowreferences, so capturing it once at construction matches the prior per-resume call. - Tests + evidence — a new
runtime-worktree-agent-sources.test.tspins admission precedence (disconnected-local rejection, remote evidence, mirror ownership, monitoring enrichment); the structured-row suites were migrated to the new API, anddocs/review-evidence/pr-19217records the manualworktree psvalidation.
Verified locally: pnpm tc:node clean, the four changed/adjacent test suites pass (25 tests), the full orca-runtime.test.ts passes (1261/1262, 1 skipped), and the changed-code quality gate reports 0 new findings.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review resumed on September 8, 2026. The earlier Codex launch failure was caused by an incorrect model ID ( The checkout has been safely fast-forwarded to PR head Grok validation was replaced at the author’s request after Grok Build reported its weekly usage limit. No merge-readiness verdict is claimed yet. |
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: 632d8141-501b-483f-af0d-b05c964d6185
📒 Files selected for processing (4)
src/main/runtime/runtime-worktree-agent-rows.tssrc/main/runtime/runtime-worktree-agent-source.tssrc/main/runtime/runtime-worktree-structured-agent-rows-liveness.test.tssrc/main/runtime/runtime-worktree-structured-agent-rows.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/runtime/runtime-worktree-agent-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
Important
The new structured-host authority bypass overreaches: it drops the state !== 'done' exclusion together with the staleness window, so an idle structured session (a completed turn the host still holds) now marks its worktree permission — the CLI/GUI drift this PR aims to eliminate, in the opposite direction.
Reviewed changes
- Made structured-host statuses authoritative past the freshness window —
RuntimeWorktreeAgentSourcegainedauthority?: 'structured-host'(set on structured sources), and the row loop now skipsisFreshNonDoneAgentStatusfor them so an aged host-heldworking/attentionsummary no longer decays to inactive. - Tests — two liveness cases assert an aged host-held working / approval state stays authoritative, matching the sidebar.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior review (e370aeb), commit f7330f9 replaces the static structured-host authority flag with a host-owned execution lifecycle, which also fixes the done→permission regression from the last review:
hostExecutionOwnedlifecycle —AgentSessionStatusSummarygainshostExecutionOwned: true, published only whilesession.hasProviderChildis set, and re-published (clearing the flag) on every child-exit path: handoff, unexpected exit, and Claude rewind.closerevokes it out-of-band viastatusFeed.revokeLive.doneexclusion restored — the structured-host freshness waiver is nowsource?.authority === 'structured-host' && row.state !== 'done', so an idle held session can no longer bump its worktree topermission.- Renderer mirrors the waiver —
structuredHostOwnedonAgentStatusEntrykeeps a host-owned row fresh past the staleness window, and the status feed strips it on disconnect (revokeSnapshotOwnership) so a lost host degrades cleanly instead of leaving a phantom working row. - Tests — a feed ownership-transition test, a renderer feed lifecycle suite, host-held freshness/disconnect cases, and a "completed host-held session stays
inactive" assertion.
Verified locally: the affected suites pass (feed 16, liveness 4, structured rows 6, bridge 16, feed lifecycle 3).
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Review complete for The fixes make structured activity follow provider ownership, preserve journal timestamps and completed history, and revoke live authority on exit, handoff, rewind, closure, or feed loss. Completed sessions no longer turn the worktree into a permission wait. PTY admission and expiry remain unchanged. Validation passed: focused host/renderer/runtime tests, completion and reconnect regressions, installed-host call-site tests, typechecking, and changed-code quality checks. All code CI checks are green, including all eight test shards, wire compatibility, and packaging including Windows. The automated review is still pending. Final macOS Electron validation used a real structured Codex turn: working → done (worktree |
…ver store Structured (native chat) sessions have no PTY and no hook script, so their status never reached the hook server's store; #19217 gave `worktree ps` its own adapter over the structured feed instead. The feed now writes every projection into that store through a status sink the runtime wires, drops the row when the host closes the session, and `worktree ps` reads the one snapshot like every other agent. Rows carry a `structuredHost` marker and the journal clock; they are never persisted to last-status.json, and the main process does not forward them to the renderer yet, whose feed bridge still owns them until it is retired. Design and the two follow-ups: docs/reference/agent-status-store.md.
…ver store (#19683) * refactor(agent-status): publish structured sessions into the hook server store Structured (native chat) sessions have no PTY and no hook script, so their status never reached the hook server's store; #19217 gave `worktree ps` its own adapter over the structured feed instead. The feed now writes every projection into that store through a status sink the runtime wires, drops the row when the host closes the session, and `worktree ps` reads the one snapshot like every other agent. Rows carry a `structuredHost` marker and the journal clock; they are never persisted to last-status.json, and the main process does not forward them to the renderer yet, whose feed bridge still owns them until it is retired. Design and the two follow-ups: docs/reference/agent-status-store.md. * chore: drop stray @pnpm/exe lockfile entry An unrelated local pnpm run added @pnpm/exe as a packageManagerDependency with no package.json change, so CI's --frozen-lockfile install failed before any job ran. * docs(agent-status): describe the step that actually landed The design record claimed PR 1 deletes RuntimeAgentRowStore, drops the retained-versus-hook reconciliation, stamps terminalHandle on OSC rows, and tags rows with a source field of 'structured-host'. None of that is true of the shipped code: the retained store and its reconciliation are still in place, and the row field is structuredHost: 'held' | 'owned'. AGENTS.md points every future contributor here before they touch agent status, so split the roadmap into the 1a that landed and the 1b that has not, and name the fields the code actually writes. * fix(agent-status): pair session removal with the status-row forget A session dropped from the host's map without an explicit forget left its row in the store forever: `structuredHostOwned` bypasses the staleness check, so a failed re-attach (the Claude rewind path reaches one) stranded a permanently working agent in `worktree ps` and on mobile with no UI able to clear it. Deletion and forget are now one operation both callers route through. * fix(agent-status): give orcad the store worktree ps reads from `orcad` constructed its runtime with neither `getAgentStatusSnapshot` nor `structuredAgentStatusSink`, so once `worktree ps` sourced rows only from that snapshot the headless host published nowhere and listed nothing. The hook server's store is a module singleton whose import tree never reaches Electron, and its file paths come from `start()`, which orcad never calls. * fix(agent-status): drop a structured row without a renderer clear `dropStructuredStatus` went through `clearPaneState`, which fans a pane clear out to the renderer for a pane key the renderer's own feed bridge still writes - so 'exactly one writer per pane key' held for writes and not for deletes. `dropStatusEntry` routes through the status-drop tap instead, and skips the resume-identity remnant: a structured session has no pane to resume into, and every null-status publish would otherwise re-mint one. * test(agent-status): pin both half-migration structured-row filters Neither the `agentStatus:getSnapshot` filter nor the main-window listener's had a single assertion, so deleting either — the first step of PR 2 — was green everywhere. Also covers the perf skip and the drop's lack of a renderer clear. * docs(agent-status): correct three statements this PR made false The sink JSDoc claimed only tests construct a host without one; `orcad` did. The doc argued a structured row needs no tab mirror 'because headless serve has no renderer', reasoning about exactly the topology the wiring had not reached. The deleted runtime adapter's warning that the pane key must be the DERIVED one - never a bearer handle or minted worker key - was lost with it. * test(agent-status): declare orcad in the hook-row producer census Wiring the hook store into the orcad runtime added a production site that hands hook rows to a consumer, which the census ratchet pins deliberately. --------- Co-authored-by: Merge Sim <sim@local>








Structured Claude and Codex chats have no PTY or hook snapshots, so
worktree pscould report no agent activity while the sidebar showed a running chat.The runtime now reads the execution host's currently held sessions through source adapters and uses the shared working/blocked/done mapping. PTY admission and expiry stay unchanged, and structured chats are not added to terminal inventory.
Live execution ownership is distinct from retained conversation history. An optional ownership marker keeps genuinely running or approval-waiting sessions active beyond the hook timeout, without changing journal timestamps. Completion does not become a permission wait. Provider exit, handoff, rewind, closure, and status-feed teardown revoke ownership; reconnects cannot restore it from stale callbacks or cached history. Older hosts without the marker retain the freshness fallback.
Validation: focused host, renderer, lifecycle, and runtime regression tests; the installed-host
worktree pscall-site tests; typechecking and changed-code quality checks. Final Electron evidence and review status are recorded in the review comment.Follow-up to #18827.