Repository navigation
fix(native-chat): publish structured session status from the host so the sidebar never goes stale - #18776
Conversation
The sidebar learned whether a structured chat was mid-turn by replaying the session journal in the renderer, through a reader whose lifetime was tied to the chat pane. Hiding the pane stopped the reader before the turn's settlement arrived, so the row stayed on "working" until the chat was reopened. The same coupling meant a tab never opened this session showed no status at all, and a reloaded renderer lost every settled row. The host owns the journal, so it now projects each session's status once per journal publication and fans the changes out on one stream per client (`agentSession.subscribeStatus`). The projection survives eviction of an idle session's provider child and is republished when readable sessions are restored. The renderer bridge subscribes to that feed per runtime target and never opens a transcript reader; the observation hook is gone. Additive wire surface behind the existing structured capability; old hosts reject the method and the renderer retries, showing no status.
|
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: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds shared session-status wire types and projection helpers. The host publishes retained status summaries from journal updates and exposes them through Merge Risk: ⚪ Minimal · up to Session status is now published by the host and restored across hidden chats, eviction, and renderer reloads, with capability-aware behavior for older runtime targets. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives a detailed explanation of the change, motivation, visual proof, and testing. However, it does not provide the required linked issue in the ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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: 6f26d0ff-3bd0-499c-9ae8-0d39fe203e1b
📒 Files selected for processing (20)
src/main/native-chat/agent-session-wire/structured-agent-session-history-result.tssrc/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.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-subscribers.tssrc/main/runtime/rpc/methods/structured-agent-session-status-stream.tssrc/main/runtime/rpc/methods/structured-agent-session.test.tssrc/main/runtime/rpc/methods/structured-agent-session.tssrc/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsxsrc/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session-read.test.tsxsrc/renderer/src/components/native-chat/use-structured-agent-session-read.tssrc/renderer/src/runtime/structured-agent-session-client.tssrc/renderer/src/runtime/structured-agent-session-status-feed.tssrc/shared/agent-session-wire.tssrc/shared/structured-agent-session-projection.test.tssrc/shared/structured-agent-session-projection.tstests/e2e/cross-version-wire/cross-version-agent-session-wire.unit.test.ts
💤 Files with no reviewable changes (1)
- src/renderer/src/components/native-chat/use-structured-agent-session-read.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| if (stream.isClosed()) { | ||
| return | ||
| } | ||
| dispose = host.subscribeStatus({ id: subscriptionId, emit }) |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ast-grep outline src/main/runtime/rpc/methods/structured-agent-session-gate.ts --items all
rg -n -C 6 'requireStructuredHost|requireStructuredCapability|requireHost' \
src/main/runtime/rpc/methods/structured-agent-session-gate.ts \
src/main/runtime/rpc/methods/structured-agent-session-status-stream.ts
ast-grep outline src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts --items all
rg -n -C 8 'subscribeStatus|AgentSessionStatusSummary|latestPrompt|workspaceId|caller' \
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tsRepository: stablyai/orca
Length of output: 10823
🏁 Script executed:
#!/bin/bash
set -euo pipefail
cat -n src/main/runtime/rpc/methods/structured-agent-session-gate.ts | sed -n '1,90p'
cat -n src/main/runtime/rpc/methods/structured-agent-session-policy.ts | sed -n '1,160p'
rg -n -C 10 'subscribeStatus\s*\(|StructuredAgentSessionStatusFeed|statusFeed' \
src/main/native-chat/agent-session-wire/structured-agent-session-host.ts \
src/main/native-chat/agent-session-wire/structured-agent-session-host-types.ts \
src/main/native-chat/agent-session-wireRepository: stablyai/orca
Length of output: 35846
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions
Length of output: 31156
Sensitive Data Exposure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor
Reachability: External
Restrict agentSession.subscribeStatus to authorized session scope.
requireHost(ctx) checks capability negotiation, but host.subscribeStatus subscribes directly to every host session and emits latestPrompt. Pass the authenticated caller or workspace scope to the feed, or allow this method only for full-runtime-trusted clients.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor observation inline.
Reviewed changes
- Host status projection — a new
StructuredAgentSessionStatusFeedprojectsworking/attention/idle(plus latest prompt and provider session) from the journal and broadcasts only changes; the host wires it to the existing transcript-publication edge via anonJournalPublishedhook and republishes on startup and readable-restore. - New streaming RPC method —
agentSession.subscribeStatus(one stream per client, covering all sessions) sits behind the existingagent-session.structured.v1capability;bindStructuredAgentSessionStreamis extracted from thesubscribehandler and reused by both. - Renderer feed + bridge — the transcript-replayer observation hook is deleted; a per-runtime-target status feed (
useSyncExternalStore, exponential-backoff reconnect, cached summaries across disconnects) maps summaries onto the existing pane-key status map. - Shared projection —
projectStructuredAgentSessionStatusSummary/latestStructuredAgentSessionPromptare extracted so host and client compute the same verdict. - Tests — host feed (snapshot, working→idle on tombstone, attention, eviction retention, subscriber teardown), subscriber hook, RPC gate and stream, rewritten bridge, cross-version manifest.
The design is sound: the feed hooks the same publication edges the transcript subscriber already uses (publish/reset/snapshot, plus the unexpected-exit publishFence), so every journal change — including the tombstone that settles a turn — reaches the status feed. Wire compatibility is additive and capability-gated as described, and the reconnect/eviction-retention paths check out.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
| journal: AgentSessionJournal | ||
| ): AgentSessionStatusSummary { | ||
| // An unreadable journal projects as "no turn": the chat itself shows the reset. | ||
| const items = journal.isReadOnly ? [] : journal.snapshot().items |
There was a problem hiding this comment.
summaryFor materializes journal.snapshot().items and projectStructuredAgentSessionStatusSummary runs three full passes over it on every publication, which fires per coalesced delta window during a streaming turn. That is O(items) host-side work now always-on (the old renderer path only ran for the visible pane), so very long conversations pay it on every delta. Consider tracking a running-turn / pending-approval signal incrementally if this shows up for long sessions.
…on subscribe The status stream is additive to a surface that already shipped, so a host advertising agent-session.structured.v1 can still answer subscribeStatus with method_not_found. Every renderer error path reconnected, so a remote host one release behind got a relay round-trip every 5s and no sidebar status at all. Give the method its own capability and probe it before subscribing; a failed probe still retries, an absent capability does not. Re-projecting on subscribe also wrote straight into the shared cache, so a second client could pin the first to a stale summary. Route those diffs through publish() before the arriving subscriber is registered.
… the unread path One status frame carries every retained session and a send admits 256 KB per prompt, so ~16 large-prompt sessions could push the snapshot past the 4 MB outbound guard and into the retry loop. Bound latestPrompt to the same 200-char single-line preview every other agent-status row already carries. A snapshot also replaced the cached map wholesale, so the empty first frame from a restarting host retracted every row before restore republished them. Merge instead; the tab map, not this feed, decides which sessions are listed. Tests: the hidden-pane claim now sits at the host, where a journal with no transcript subscriber is driven from running to idle; the RPC test reads a real projection instead of its own stub.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the single prior observation remains open.
Reviewed changes
- Capability-negotiated the status feed — added
agent-session.status-feed.v1and probe it before subscribing to a remote environment (local skips the probe), so an older host answeringmethod_not_founddegrades once instead of relay-retrying forever; the cross-version suite asserts the capability and method stay in lockstep. - Fixed the subscribe race —
StructuredAgentSessionStatusFeed.subscribenow re-projects each session before registering the subscriber, so a journal change that landed between the append and thepublishqueue submission reaches sitting subscribers and the arriving one's snapshot. - Extracted subscription ids — moved the
agentSession.*id helpers into a shared module and stopped collapsing a missing frame id to'default', which is the collision the id rule exists to prevent. - Bounded the wire prompt —
latestStructuredAgentSessionPromptnow runs throughnormalizePromptField, so the sidebar preview and the wire payload stay within the shared agent-status cap.
The delta is well-scoped and well-tested: the subscribe re-projection fix has a targeted regression test, the capability probe has explicit terminal/retry/local cases, and the cross-version manifest covers the new capability. The terminal-probe tradeoff (a re-paired host under the same environmentId won't re-probe mid-session) is dormant today since structured chat is local-only, and is a documented degrade-once choice rather than a bug.
The one prior observation — summaryFor re-projecting a full pass over journal.snapshot().items on every publication (always-on host cost for long conversations) — is unchanged by this delta, so I'm leaving that thread open rather than resolving it prematurely.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Electron QA — structured chat sidebar status while hiddenValidated SHA Provenance (this PR's source, not a stale build)Fetched the running dev-server module:
and grepped the response: App identity from CDP: Codex prompt used (long-running, Effort High): a 2500-word essay so there was time to switch away before the reply finished. After send, switched to Other Workspace so the Codex Chat pane was unmounted. The chat was never reopened for scenarios 2 and 3. 1. Mid-reply, chat hidden — sidebar shows Working spinnerOther Workspace is selected (green Active). Chat Workspace is not on screen; the center pane is a dummy-folder Terminal 1. Chat Workspace still shows the working spinner, and the nested agent row is Working · Codex Chat - Codex · now. Backing store (chat pane not mounted): 2. Money shot — reply finished, chat still never reopened, row flips to Done on its ownSame view ~2 minutes later. Did not click Chat Workspace. The spinner is gone: Chat Workspace and the Codex Chat row both show Done (green). Center pane is still the dummy terminal. Store poll while staying on Other Workspace: 3. Reload with chat still never opened — Done immediately, not blank
First post-reload store read: ResultThe host-streamed status path works for this structured Codex session: the sidebar row settled to Done while the chat pane was unmounted, and survived a renderer reload without going blank. Caveats (honest, not blockers for this claim):
|
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the single prior observation remains open.
Reviewed changes
- Moved prompt bounding into the summary projection —
latestStructuredAgentSessionPromptnow returns the raw newest user prompt andprojectStructuredAgentSessionStatusSummaryappliesnormalizePromptField, keeping each status frame under the per-send / outbound guard. It is the only caller, so this is a behavioral no-op. - Merged snapshots instead of replacing them — the renderer status feed now merges a snapshot over cached rows, so a restarting host's empty first frame no longer retracts every settled row before restore republishes them.
- Proved the hidden-pane path at the host — a new subscriber test drives a journal with no transcript subscriber from running to idle, and the RPC test now asserts against a real projection rather than a restated stub.
The delta is correct and well-scoped. The bounding move is behavior-preserving (verified latestStructuredAgentSessionPrompt has no other callers), the snapshot merge matches the documented never-retract contract (Tabs, not this feed, decide what is listed), and the new tests fail if either defect returns. The single prior observation — summaryFor re-projecting a full pass over journal.snapshot().items on every publication — is unchanged by this delta, so that thread stays open.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Review status — multi-agent review loop completeReviewed at Fixed
Rejected, with reasons
One correction to an earlier findingTwo reviewers independently called the missing capability gate a net regression against older remote hosts. On tracing it, that is not reachable today: structured sessions are hard-gated to the local execution host at four independent layers (both providers' location-support checks, the create path, the client-supplied-location attach path, and the renderer pinning So fix #1 is forward-looking correctness, not a regression repair. It satisfies the negotiation invariant this PR's own cross-version test asserts, and it matters the moment remote structured sessions ship — at which point a client paired to a host predating Two forward-looking notes for whoever ships remote structured sessions: an "unsupported" verdict is only re-probed on an activation 0→1 edge, so after an in-place host upgrade status stays blank until the last structured tab closes and reopens or the renderer reloads. VerificationCI Ablation-verified rather than assumed — each of these was reverted and watched go red: the capability probe, the failed-probe path, the cross-version capability invariant, the Electron QA is in the preceding comment — sidebar row settles Working → Done with the chat pane unmounted, and survives a renderer reload without going blank, with VerdictClosing readiness pass: SHIP, zero P0, zero P1. The architecture was right as authored — host owns the projection, client is a consumer of a list-level feed — and the review was about hardening the edges rather than redirecting the design. |
…supported host Startup restore indexes a readable session and publishes its status, which is what puts a never-reopened tab back in the sidebar. Only an Electron screenshot covered that wiring; a sitting status subscriber now pins it directly. The terminal "host too old" branch was silent, so a mixed-version report showed an empty sidebar with nothing in the log to explain it.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the single prior observation remains open.
Reviewed changes
- Pinned the restart status publication —
structured-agent-session-restart-status-publication.test.tspersists a turn through one host, reopens the store over a fresh host, and asserts both the subscribe-time re-projection of the restored journal (idle+ persisted prompt) and the restore wiring publishing astatusevent to a subscriber already sitting on the stream. The second test fails ifonReadableever stops publishing, so it genuinely pins the wiring rather than restating it. - Logged the terminal unsupported-host branch — the renderer status feed now warns once when a host predates the status feed, and a
returnkeeps that warning off the supported path (previously nothing explained an empty sidebar on a mixed-version host).
The single prior observation — summaryFor re-projecting a full pass over journal.snapshot().items on every publication, an always-on host cost for very long conversations — is unchanged by this delta and stays open.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
…-sidebar-status-feed # Conflicts: # src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the single prior observation remains open.
Reviewed changes
- Merged
origin/main— the branch now sits on currentmain, bringing the Claude background-task channel (#18757) and pre-commit refusal (#18697) work in alongside the status feed, plus the perf and sidebar commits in between. - Adapted the feed to the history-result rename —
providerSessionMetadatais now the exportedstructuredAgentSessionProviderSessionMetadata; the feed imports it and no stale references remain. - Re-routed
subscribethrough the background-task channel —history/subscribe/publishBackgroundTaskStatenow go throughStructuredAgentSessionBackgroundTaskChannel, while the status feed'sonJournalPublishedhook stays on the sharedAgentSessionSubscribersedge so every publication still reaches it. - Replaced the private
resumeForHoldwith the extractedresumeStructuredAgentSessionForHold, and deduped abench:terminal-partial-escape-tailscript entry the merge had doubled.
The merge resolution is clean: the status feed, subscribeStatus, and the restart/readable-restore republication wiring all survive; the unexpected-exit publishFence path still reaches the feed through subscribers.snapshot; and tc:node plus the targeted feed/host/subscriber/RPC suites (42 tests) pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Merged
|
…the sidebar never goes stale (stablyai#18776) * fix(native-chat): publish structured session status from the host The sidebar learned whether a structured chat was mid-turn by replaying the session journal in the renderer, through a reader whose lifetime was tied to the chat pane. Hiding the pane stopped the reader before the turn's settlement arrived, so the row stayed on "working" until the chat was reopened. The same coupling meant a tab never opened this session showed no status at all, and a reloaded renderer lost every settled row. The host owns the journal, so it now projects each session's status once per journal publication and fans the changes out on one stream per client (`agentSession.subscribeStatus`). The projection survives eviction of an idle session's provider child and is republished when readable sessions are restored. The renderer bridge subscribes to that feed per runtime target and never opens a transcript reader; the observation hook is gone. Additive wire surface behind the existing structured capability; old hosts reject the method and the renderer retries, showing no status. * fix(native-chat): negotiate the status feed and stop losing a change on subscribe The status stream is additive to a surface that already shipped, so a host advertising agent-session.structured.v1 can still answer subscribeStatus with method_not_found. Every renderer error path reconnected, so a remote host one release behind got a relay round-trip every 5s and no sidebar status at all. Give the method its own capability and probe it before subscribing; a failed probe still retries, an absent capability does not. Re-projecting on subscribe also wrote straight into the shared cache, so a second client could pin the first to a stale summary. Route those diffs through publish() before the arriving subscriber is registered. * fix(native-chat): bound the status prompt, merge snapshots, and prove the unread path One status frame carries every retained session and a send admits 256 KB per prompt, so ~16 large-prompt sessions could push the snapshot past the 4 MB outbound guard and into the retry loop. Bound latestPrompt to the same 200-char single-line preview every other agent-status row already carries. A snapshot also replaced the cached map wholesale, so the empty first frame from a restarting host retracted every row before restore republished them. Merge instead; the tab map, not this feed, decides which sessions are listed. Tests: the hidden-pane claim now sits at the host, where a journal with no transcript subscriber is driven from running to idle; the RPC test reads a real projection instead of its own stub. * fix(native-chat): merge the duplicated status-event type import * test(native-chat): pin the restart status publication, and log the unsupported host Startup restore indexes a readable session and publishes its status, which is what puts a never-reopened tab back in the sidebar. Only an Electron screenshot covered that wiring; a sitting status subscriber now pins it directly. The terminal "host too old" branch was silent, so a mixed-version report showed an empty sidebar with nothing in the log to explain it. --------- Co-authored-by: Merge Sim <sim@local>




ELI5
The sidebar used to find out whether a chat was still working by reading that chat's own transcript, and it could only read while the chat was on screen. Switch workspaces and it stopped reading, so the row kept saying "working" until you came back. Now the host, which always has the transcript, keeps a tiny "what is each chat doing" note and sends every change to the sidebar directly. The sidebar never reads transcripts any more, so it cannot go stale when a chat is hidden, was never opened, or the window reloads.
Supersedes #18713, which retained the renderer's transcript reader while a turn was in flight. That patched the reported symptom but left the coupling that causes it.
What Changed
agentSession.subscribeStatus: one stream per client, covering every session. The projection is kept after an idle session's provider child is evicted and republished when readable sessions are restored at startup.Before
After
Why
The status bridge derived turn state by replaying the session journal in the renderer through a reader whose lifetime was tied to the chat pane. Hiding the pane stopped the reader before the settlement tombstone arrived, so the projection froze on "working". The same coupling meant an unopened tab had no reader at all, and a reload lost every cached projection. The host owns the journal and already knows when a turn is active, so it is the right place to publish status; the sidebar becomes a consumer of a list-level feed rather than a transcript replayer.
Wire compatibility: additive method behind the existing
agent-session.structured.v1capability. An older host answersmethod_not_found; the renderer retries with backoff and shows no status, which is what it shows today for a remote host. No existing frame or field changes. The cross-version structured wire suite carries the new method in its manifest.Linked Issue
Reported by Jinjing in the Chat UI UI/UX feedback thread (item 5, "Sometimes the sidebar agent status won't stop 'working' status until I click into the Chat UI view, even it's done working."): https://stablygroup.slack.com/archives/C0BV03ZK1KN/p1788474468997739
No GitHub issue was filed for this report. Supersedes #18713.
Visual Proof
Electron over CDP on a fresh dev profile, Codex structured chat, macOS.
Chat hidden, turn running (other workspace active):
Same view after the turn settled, chat never reopened:
After the provider child was evicted and the window reloaded, chat still never opened:
Testing
pnpm tc:node,pnpm tc:web,oxlinton changed paths.src/main/native-chat/agent-session-wire, structured RPC methods, mobile allowlist and socket wiring, structured integration suites,src/renderer/src/components/native-chat,src/renderer/src/runtime, shared projection, and the cross-version structured wire suite.Platforms tested: macOS. Local runtime only; structured chat is local-only today.
New tests: host status feed (snapshot, working → idle on tombstone, attention, eviction retention, subscriber teardown), subscriber publication hook, shared summary projection, RPC gate and stream, rewritten bridge test against the feed, cross-version manifest entry.
Not in this PR: mobile consuming the same feed (follow-up).
Review
Agent skill upstream boundary
N/A