Skip to content

fix(native-chat): publish structured session status from the host so the sidebar never goes stale - #18776

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/chatui-5-sidebar-status-feed
Sep 5, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/chatui-5-sidebar-status-feed

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​903 $\color{#cf222e}{\Huge{\mathbf{−}}}$​126 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​777
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​652 $\color{#cf222e}{\Huge{\mathbf{−}}}$​108 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​544

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

  • Host projects each structured session's status (working / attention / idle, latest prompt, provider session) once per journal publication and fans out only changes on a new streaming method, 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.
  • Renderer status bridge subscribes to that feed once per runtime target and maps summaries onto the existing pane-key status map. The transcript-reader observation hook is deleted.
  • The status projection helper is shared, so host and client compute the same verdict.

Before

  • Start a Codex or Claude chat reply, switch to another workspace, and the row stays on the "working" spinner after the reply finishes. It only flips to Done when you click back into that chat.
  • A structured chat you have not opened since launching Orca shows no sidebar status at all.
  • Reloading the window drops every settled chat row's status until each chat is reopened.

After

  • The row flips from "working" to Done on its own when the reply finishes, wherever you are in the app.
  • Every structured chat with a persisted turn shows its status without being opened.
  • Status survives the host retiring an idle chat's provider process and survives a window reload.

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.v1 capability. An older host answers method_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.

Before (#18713 baseline behaviour) After (this PR)
Turn running, chat hidden Row shows the working spinner Row shows the working spinner
Turn finishes, chat still hidden Row stays on "working" until the chat is clicked Row flips to Done on its own
15 s later, provider child evicted Row keeps whatever the renderer cached Row stays Done
Window reloaded, chat never opened No status on the row Row shows Done immediately

Chat hidden, turn running (other workspace active):

after-1-hidden-working.png

Same view after the turn settled, chat never reopened:

after-2-hidden-settled.png

After the provider child was evicted and the window reloaded, chat still never opened:

after-3-reload-unopened.png

Testing

  • Sent a long Codex prompt, switched to another workspace while it ran: the sidebar row went Working → Done with the chat hidden.
  • Waited past the 15 s release grace (provider child evicted): the row stayed Done.
  • Reloaded the window with the other workspace active: the row showed Done immediately; the chat was never opened.
  • pnpm tc:node, pnpm tc:web, oxlint on changed paths.
  • Test surface run: 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.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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

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.
@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: f92745bd-2c72-46aa-8762-9cf38603505d

📥 Commits

Reviewing files that changed from the base of the PR and between 143a40b and 0ffd097.

📒 Files selected for processing (2)
  • src/main/native-chat/agent-session-wire/structured-agent-session-restart-status-publication.test.ts
  • src/renderer/src/runtime/structured-agent-session-status-feed.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The change adds shared session-status wire types and projection helpers. The host publishes retained status summaries from journal updates and exposes them through agentSession.subscribeStatus. The runtime adds shared stream cleanup, subscription IDs, capability checks, and renderer subscription support. The renderer maintains per-target feeds with reconnection and projects summaries into agent status state. Hold resumption uses a shared lifetime helper. Tests cover projections, feeds, transport, reconnection, capability checks, and cross-version wire behavior.

Merge Risk: ⚪ Minimal · up to 0ffd0

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 Fixes # field and omits the template'… Add a valid linked issue after Fixes #, or document an approved issue reference. Complete the Notes and Checklist sections, including the AI Disclosure section when applicable.
Docstring Coverage ⚠️ Warning Docstring coverage is 38.10% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 42 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: the host publishes structured session status so the sidebar does not become stale.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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 Fixes # field and omits the template's Notes and Checklist sections.

✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch brennanb2025/chatui-5-sidebar-status-feed

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 6f26d0ff-3bd0-499c-9ae8-0d39fe203e1b

📥 Commits

Reviewing files that changed from the base of the PR and between e2b70a5 and 38ec0f2.

📒 Files selected for processing (20)
  • src/main/native-chat/agent-session-wire/structured-agent-session-history-result.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host-lifetime.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-host.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-subscribers.ts
  • src/main/runtime/rpc/methods/structured-agent-session-status-stream.ts
  • src/main/runtime/rpc/methods/structured-agent-session.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session.ts
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.test.tsx
  • src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-read.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-read.ts
  • src/renderer/src/runtime/structured-agent-session-client.ts
  • src/renderer/src/runtime/structured-agent-session-status-feed.ts
  • src/shared/agent-session-wire.ts
  • src/shared/structured-agent-session-projection.test.ts
  • src/shared/structured-agent-session-projection.ts
  • tests/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 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.ts

Repository: 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-wire

Repository: 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor observation inline.

Reviewed changes

  • Host status projection — a new StructuredAgentSessionStatusFeed projects working/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 an onJournalPublished hook and republishes on startup and readable-restore.
  • New streaming RPC method — agentSession.subscribeStatus (one stream per client, covering all sessions) sits behind the existing agent-session.structured.v1 capability; bindStructuredAgentSessionStream is extracted from the subscribe handler 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 / latestStructuredAgentSessionPrompt are 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Merge Sim added 2 commits September 4, 2026 20:36
…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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — the single prior observation remains open.

Reviewed changes

  • Capability-negotiated the status feed — added agent-session.status-feed.v1 and probe it before subscribing to a remote environment (local skips the probe), so an older host answering method_not_found degrades once instead of relay-retrying forever; the cross-version suite asserts the capability and method stay in lockstep.
  • Fixed the subscribe race — StructuredAgentSessionStatusFeed.subscribe now re-projects each session before registering the subscriber, so a journal change that landed between the append and the publish queue 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 — latestStructuredAgentSessionPrompt now runs through normalizePromptField, 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA — structured chat sidebar status while hidden

Validated SHA 3d00f36ebf7 (3d00f36ebf7d9ab0dbd192a5f3821a0c7c75fdb4) on macOS in a fresh isolated pnpm/electron-vite profile (CDP 9335, renderer 5176). Chat flags enabled via updateSettings (experimentalNativeChat, experimentalStructuredNativeChat, openAgentTabsInChatByDefault), then renderer reload, then New tab → Codex. The tab was labelled Codex Chat, had a composer, and had no terminal beneath it (structured lane, not a TUI fallback).

Provenance (this PR's source, not a stale build)

Fetched the running dev-server module:

http://127.0.0.1:5176/@fs/Users/brennanbenson/orca/workspaces/orca/pr18776-electron-qa/src/shared/protocol-version.ts

and grepped the response:

101:// Why: agentSession.subscribeStatus is additive to a surface that already shipped, so a host
104:export const AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY = "agent-session.status-feed.v1";
188:AGENT_SESSION_STATUS_FEED_RUNTIME_CAPABILITY,

App identity from CDP: Orca: brennanb2025/pr18776-electron-qa / worktree pr18776-electron-qa.

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 spinner

Other 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.

01-working-chat-hidden.png

Backing store (chat pane not mounted): agentStatusByPaneKey[…].state === "working".


2. Money shot — reply finished, chat still never reopened, row flips to Done on its own

Same 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.

02-done-chat-still-hidden.png

Store poll while staying on Other Workspace: working (epoch 2) → done (epoch 3, updatedAt advanced) at poll iter 31. Accessibility tree: option "… Done Chat Workspace …" / treeitem "Done Codex Chat - Codex 2m". hasCodexChatTab === false.


3. Reload with chat still never opened — Done immediately, not blank

location.reload() while Other Workspace remained active. After hydration, without opening Chat Workspace, the row is Done immediately (green), not empty/blank.

03-done-after-reload-chat-never-opened.png

First post-reload store read: state: "done", epoch: 1, hasCodexChatTab: false. Accessibility: option "… Done Chat Workspace …" / treeitem "Done Codex Chat - Codex now".


Result

The 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):

  • Driven via Playwright CDP, not a human click path beyond New tab → Codex / composer Send / workspace switch.
  • Folder workspaces were seeded through window.api.projectGroups.create({ parentPath }) + folderWorkspaces.create so the sidebar actually rendered them (a manual group with parentPath: null does not emit folder rows).
  • ELECTRON_CLI_ARGS mock-keychain was set on the electron-vite parent; CDP returned real targets (not the zero-byte keychain-park failure).
  • Playwright's tiny comment overlay is visible at the bottom of screenshots; it is not Orca UI.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — the single prior observation remains open.

Reviewed changes

  • Moved prompt bounding into the summary projection — latestStructuredAgentSessionPrompt now returns the raw newest user prompt and projectStructuredAgentSessionStatusSummary applies normalizePromptField, 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status — multi-agent review loop complete

Reviewed at 38ec0f26af5 through 143a40b93ab. Six independent passes: correctness, performance, open-source precedent, two readiness checklists (open and close), and Electron validation. Seven defects found and fixed; four proposed changes rejected with reasons.

Fixed

# Sev Defect
1 P1 agentSession.subscribeStatus was gated only on the pre-existing agent-session.structured.v1, so a client could not detect its absence during negotiation, and every renderer error path funnelled into a 5 s reconnect with no terminal state. Now behind agent-session.status-feed.v1, probed for environment targets, with "unsupported" terminal and a thrown probe still reconnecting.
2 P1 subscribe() wrote re-projected summaries into the shared published cache without broadcasting, so a second client connecting could permanently pin the first to a stale summary via the dedupe in publish(). Re-projection now routes through the one broadcast path.
3 P2 latestPrompt was unbounded on the wire (a send admits 256 KB) while one snapshot frame carries every retained session — enough to breach the 4 MB outbound guard. Now clamped with normalizePromptField, the same 200-char single-line preview every other agent-status row already uses.
4 P2 resetStructuredAgentSessionStatusFeedsForTests() cleared the owner map without stopping owners, leaking a live subscription and its reconnect timer into the next test.
5 P3 applyEvent replaced the cached map wholesale on snapshot, contradicting the module's own "never retracts a summary" contract — a restarted host restores asynchronously, so an empty first snapshot flickered every row to no-status. Now merges; header corrected.
6 P3 The status stream rebuilt the subscription-id rule inline and collapsed a missing frame id to a literal 'default', reintroducing the collision the existing helper documents. Rule extracted and shared.
7 — Two tests overclaimed. settles a hidden session on the host status alone mocked its transport and proved only summary→store mapping; renamed, and the real proof added at the host layer as settles a session nobody is reading, from running to idle. The RPC test now runs against a real feed instead of asserting a stub's own echo.

Rejected, with reasons

  • A subscribers.size === 0 early-out in publish() — unsafe. published doubles as the post-eviction retention cache and publish() already returns early once a session leaves the host index, so the guard would starve the cache for a session evicted during a zero-subscriber window: exactly the "unopened tab has no status" bug this PR exists to fix. The existing eviction-retention test would go red, and that test is the feature.
  • Making the projection incremental (raised in review) — measured at ~29 µs per publication at 2,000 items, roughly 0.3 % of the synchronous=FULL SQLite commit the same publication already performs on the same thread. Publication is coalesced (60 ms window plus a geometric checkpoint gate), and summariesEqual excludes updatedAt, so the wire stays quiet through a streaming turn. No change; adding state to save that is complexity for nothing.
  • Pruning / LRU-capping the retention map — moot once the prompt is clamped: one entry per session opened in the process lifetime, ~100 B each.
  • Scoping subscribeStatus to an authenticated caller or workspace (raised in review as a data-exposure concern) — false positive on two independent readings. agentSession.subscribe and agentSession.history sit behind the same capability gate, take a client-supplied sessionId with no workspace scoping, and return strictly more; session ids are already enumerable cross-workspace through the session-tab inventory. No new exposure class.

One correction to an earlier finding

Two 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 kind: 'local'), and no remote client capability list advertises agent-session.structured.v1, so the whole agentSession.* surface is invisible to remote clients.

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 agent-session.status-feed.v1 will show no sidebar status for structured chats, including no "blocked" for pending approvals, until the host updates. That is the deliberate degrade-once tradeoff: keeping the old renderer-side fallback would reintroduce the frozen-"working" bug on exactly those hosts.

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.

Verification

CI PR Checks green at 143a40b93ab — 26 jobs, zero failures. Locally: pnpm tc:node and pnpm tc:web clean; changed-code quality, type-aware, and React Doctor all 0 new findings; audit:code-quality:native clean; touched test surface 7 files / 74 tests green. No pnpm-lock.yaml, package.json, or config/patches/ churn against the base.

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 subscribe() broadcast, the reset teardown, the prompt clamp, the snapshot merge, the real-feed RPC projection, and the host-publishes-for-unsubscribed-sessions path. That last one is the user-reported bug: removing the onJournalPublished hook reproduces the pre-PR state and turns the test red.

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 /@fs provenance proving the running renderer served this branch. It was captured at 3d00f36ebf7; the only commit since (143a40b93ab) merges a duplicated type import in one test file, so runtime behaviour is identical.

Verdict

Closing 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts persists 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 a status event to a subscriber already sitting on the stream. The second test fails if onReadable ever 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 return keeps 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…-sidebar-status-feed

# Conflicts:
#	src/main/native-chat/agent-session-wire/structured-agent-session-host.ts

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta — the single prior observation remains open.

Reviewed changes

  • Merged origin/main — the branch now sits on current main, 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 — providerSessionMetadata is now the exported structuredAgentSessionProviderSessionMetadata; the feed imports it and no stale references remain.
  • Re-routed subscribe through the background-task channel — history/subscribe/publishBackgroundTaskState now go through StructuredAgentSessionBackgroundTaskChannel, while the status feed's onJournalPublished hook stays on the shared AgentSessionSubscribers edge so every publication still reaches it.
  • Replaced the private resumeForHold with the extracted resumeStructuredAgentSessionForHold, and deduped a bench:terminal-partial-escape-tail script 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Merged main — conflicts resolved, CI green at 01316a4b155

Merged origin/main (e95d247be1e, 33 commits since the base). One conflict, in structured-agent-session-host.ts: #18757 extracted history()/subscribe() into StructuredAgentSessionBackgroundTaskChannel and deleted an import adjacent to ours. Resolved by keeping the status-feed import and dropping readStructuredAgentSessionHistoryResult, which is now unused in that file (the channel imports it directly and is its only consumer).

Checked the merge did not silently drop enforcement, since that is the usual failure mode here. All four wiring points survive: the statusFeed field, the onJournalPublished hook, onReadable → statusFeed.publish, and subscribeStatus; all three hook call sites in structured-agent-session-subscribers.ts intact. The new channel is constructed with the same AgentSessionSubscribers instance, so status still publishes. Its backgroundTasks(...) path emits items: [] and deliberately does not fire onJournalPublished — correct, and consistent with handoff(...), since neither changes journal content.

Verified on the merged tree, not assumed: tc:node and tc:web clean, 155 test files / 1372 tests green (including the new background-task suites), changed-code quality / type-aware / React Doctor all 0 new findings, and audit:code-quality:native clean. CI PR Checks green — 26 jobs, zero failures.

Unrelated observation while diffing the resolution against the mechanical merge: main currently carries a duplicate bench:terminal-partial-escape-tail key in package.json. JSON takes the last one, so behaviour is unaffected and this branch's value is identical to main's effective value — the pre-commit hook deduped it here. Worth fixing on main, as it will resurface for anyone else merging.

Known gap this merge surfaces (not caused by this PR)

claude-background-task-tracker.ts:226 computes monitoring as the complement of an active foreground turn:

const details = this.foregroundTurnActive ? [] : this.backgroundTaskDetails()

So background-task monitoring is reported only when no turn is running — which is exactly the condition under which this feed projects idle and the sidebar renders Done. The two states are disjoint by construction, so for the whole time #18757's feature is visible in the chat, the sidebar row says Done.

This is not a regression from this PR: the previous renderer-side projection derived from the same turn lifecycle and showed the same thing. What changes is that the row is now durably and confidently Done rather than stale.

The fix belongs in this feed rather than in a second status channel: fold the tracker state into summaryFor (which already reaches outside the journal for providerSession) and give it a publication edge at publishBackgroundTaskState, since a monitoring transition currently reaches no status edge at all. Deliberately not by making backgroundTasks(...) fire the journal hook — that would be the wrong edge.

Leaving it as a follow-up rather than widening this PR into #18757's feature area, since surfacing "busy for a reason other than the current turn" in the session list is a product call on that feature. Flagging it here so it is not lost.

@brennanb2025
brennanb2025 merged commit 2513e21 into main Sep 5, 2026
28 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant