Skip to content

feat(native-chat): light the unread indicators when a structured chat finishes - #21924

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/a1-structured-unread
Sep 21, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/a1-structured-unread

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1023 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1022
Prod 16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​649 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​638

ELI5

If you start an agent in a terminal pane, walk away, and it finishes, Orca tells you: the workspace goes bold in the sidebar and an amber dot appears on the tab. If you start the same agent in the new chat view, it finishes in silence. Nothing goes bold, no dot appears, and the only way to find out is to go back and look.

This makes the chat view announce itself the same way the terminal already does.

What Changed

Before: a chat-view turn ends and nothing in the UI changes. Switch to another workspace while an agent is thinking and you have to keep checking back.

After: when a chat-view turn finishes successfully, the workspace goes bold in the sidebar, the chat tab gets the amber "agent finished" dot, and the dot clears when you look at the chat — exactly the behaviour a terminal agent already has. A turn that failed or that you cancelled lights nothing, because that is not something you are being called back to read.

The mechanism. The existing indicator path is driven from the terminal: it watches what a PTY paints on screen and infers from that that a turn probably ended. The chat view has no PTY, so there was nothing for that path to watch, and no other producer filled the gap. Rather than teach the terminal path to guess about chats, the fact is now produced where it is actually known:

  1. The execution host derives it. When the chat's journal commits, the host compares the newest turn against the last one it announced for that session, and if the turn just moved from running to settled and carries an explicit outcome, it publishes a small completion record — session, turn, outcome, timestamp. The host does this whether or not anyone is watching that chat, which is the whole point: the case that needs fixing is the backgrounded chat.
  2. It crosses the wire as its own event, behind its own capability. A new stream opcode is invisible to an older decoder, which drops it in silence, so the client asks the host whether it serves agent-session.turn-completion.v1 before subscribing. A host that does not is left alone rather than retried.
  3. The client hands it to the shared attention policy. The completion goes through the same neutral policy the terminal lane uses (attention/agent-attention-policy.ts) and the structured surface adapter that landed in fix(attention): count both terminal and chat siblings when clearing workspace unread #21274, so suppression ("am I already looking at this?"), acknowledgement and pane addressing have exactly one implementation across both lanes. The policy returns the markers to write; the same four store sinks apply them.

Deliberately not done here: no OS notification. This writes unread markers only (applyAgentAttentionUnread, not applyAgentAttention). Desktop and mobile delivery need their own dedupe, and wiring half of one in would double-notify mobile.

Why

The problem is that the chat view's "a turn ended" fact had no producer at all. Two other shapes were considered:

  • Extend the terminal notification path to cover chats. Rejected: its first half exists to arbitrate PTY evidence — a committed terminal title against a status snapshot, with staleness and pane-reuse rules — because a terminal can only ever infer that a turn ended. A chat does not infer; the host watched the journal settle and knows the outcome. Running a known fact back through machinery built to guess at it is how the two lanes drift. Passing a chat through it by leaving the surface key blank would have been worse still: it would have thrown away precise per-pane acknowledgement and hidden-tab visibility to get past checks that require terminal panes.
  • Derive the completion in the renderer instead of on the host. Rejected because it does not fix the reported case. The renderer mounts no journal reader for a chat whose transcript is not on screen, which is exactly the chat you have walked away from.

Recovery is live-only, on purpose. Nothing is queued, nothing is replayed, and there is no cursor. If the connection drops, the completions that land while it is down are lost and stay lost; on reconnect the client starts from an empty stream. A retained completion would be a durable "unread is owed" note with nothing to retire it, and after a reconnect it would light the dot for work you had already read. Two tests pin this so a later refactor cannot quietly turn it into catch-up.

Only success lights anything, and absence is not success. Failure and cancellation carry across the wire verbatim — the host reports what happened and the client decides what it means — but the client lights nothing for them. A turn with no outcome at all is unknown: the host does not publish one, and if a future host did, absence must still never read as success. This matters because a provider reports its own API error as a finished turn, so treating "settled" as "succeeded" would put the dot on a failure.

Linked Issue

I was not able to file the issue for this — creating one was blocked in my environment. The report is written up in the PR discussion below; please link it once an issue exists.

Fixes #

Visual Proof

Not captured as a screenshot, and I want to be straight about that rather than imply otherwise: reproducing it on screen needs a chat agent to finish a real turn in a backgrounded workspace, which I could not stage here without a visible window.

What stands in for it is the acceptance test, which asserts on the real store slices the sidebar and tab strip render from — worktreesByRepo[].isUnread, unreadAgentCompletionPanes, unreadTerminalTabs, unreadTerminalPanes — through the production reducers, not on spies. If a rewiring stops reaching those slices, that test fails rather than passing on a call count. A reviewer running the app can reproduce the before/after with the steps in the issue text below.

Testing

45 new tests across four files, plus two edits to an existing ratchet:

  • structured-attention-dispatch.test.ts (12) — the acceptance test. Success lights all four markers; failure and cancellation light nothing; an absent outcome lights nothing; a chat you are looking at earns nothing; a chat hidden behind another tab in the selected workspace still earns its dot; the group dot follows the same experimental setting the terminal lane reads; a folder workspace lights (they are not all git worktrees); redelivery is idempotent.
  • StructuredAgentSessionAttentionBridge.test.tsx (8) — end to end with only the transport mocked: a host frame in, lit indicators out. One host stream shared across tabs with each completion routed to its own tab; a remote host without the capability never subscribed; the stream dropped when the last chat tab closes; and the reconnect pin — after a drop, the reopened stream is empty and nothing lights until the host sends something new.
  • structured-agent-session-turn-completion-feed.test.ts, renderer (11) — lifecycle. Nothing replayed to a late subscriber; reopen after an end frame, a transport error and a close; a host lacking the capability probed exactly once and never retried; a late frame from a torn-down stream reaching nobody. Its reconnect test asserts the reopen call carries the target and three callbacks and nothing else, so adding a catch-up argument breaks it.
  • structured-agent-session-turn-completion-feed.test.ts, host (14) — derivation. Emits on running→settled with an outcome; nothing on first observation, so restore and restart are silent; nothing for a settled turn with no outcome; once per turn under republish; re-baselines after forget; and a completion landing with nobody subscribed is dropped, not queued.

Plus a registration the repo's cross-version wire gate requires: tests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts declares the whole agentSession.* surface by name, and the suite refuses to let a method count change without an entry. Adding agentSession.subscribeTurnCompletions there makes the suite call it in both skew directions — new client against old host and the reverse — which is exactly the statement that gate exists to force for a new opcode.

Verification run locally: pnpm tc clean; pnpm run check:code-quality:changed — 0 findings across all 7 gates on the 21 changed files; the full affected suite — 779 files, 7011 passed, 1 skipped; the five key files re-run after the commit hook reformatted — 99 passed.

Platforms. Exercised on macOS. Nothing here is platform-dependent: no paths, no shells, no process spawning. SSH is covered by design rather than by accident — the completion record carries the execution host's workspace id, which over SSH is not the id the renderer addresses tabs by, so the client keys markers off the tab and never off the wire scope; the test fixture uses a deliberately mismatched scope id to hold that. Folder workspaces have their own acceptance case. Mobile is untouched: this writes renderer store markers and requests no notification delivery.

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

I did not stage the rendered before/after — see Visual Proof.

AI Disclosure

Written with Claude Code (Opus). Author: @BrennanKB5.

Review

How the exhaustive claims were enumerated

Two claims in this PR are "this is all of them", so here is how each was counted:

  • "The host derives a completion even for a chat with no subscribers." onJournalPublished has six references repo-wide (rg -n "onJournalPublished" src, 22,587 files searched): one hook declaration at structured-agent-session-subscribers.ts:47, two production call sites at :134 and :181, one consumer at structured-agent-session-client-delivery.ts:39, and two test wirings. Reading :120-140 confirms the call fires after the subscriber loop and independently of it, so a zero-subscriber session still reaches the deriver. That is the load-bearing fact for the case this PR fixes.
  • "The same four store sinks the terminal lane writes." Read off the sink type's own field list at agent-attention-policy.ts:44-50 and the application site at :119-127, not from a search for call sites.

The dispatch path was traced hop by hop rather than inferred from its endpoints: journal commit → structured-agent-session-subscribers.ts:134/:181 → structured-agent-session-client-delivery.ts:39 → publishJournal:75 → structured-agent-session-host.ts:341 → structured-agent-session-turn-completion-stream.ts:25 → renderer client → runtime/structured-agent-session-turn-completion-feed.ts:97 → StructuredAgentSessionAttentionBridge.tsx:26,:32 → AppBackgroundServices.tsx:41.

Things a reviewer should know

  • This is two planned PRs landed as one. The transport and the consumer were scoped separately, but a transport landing alone would be an unadvertised capability with nothing subscribing to it — dead code that no test could meaningfully exercise. They are split cleanly by directory (src/main/native-chat/… and src/shared/… vs src/renderer/…) if you would rather read them in two passes.
  • The outcome vocabulary is cancellation, not cancelled. The design sketch this was built from wrote cancelled; the shipped journal vocabulary is AGENT_JOURNAL_TURN_OUTCOMES = ['success','failure','cancellation']. I reused what ships rather than introduce a second spelling that would need translating at the wire.
  • The tab dot needs experimentalTerminalAttention, same as the terminal lane. The workspace bold and the amber pane dot are unconditional; the tab-level dot is the same experimental presentation policy in both lanes, so it reads the same setting rather than a second one. Without the flag you get bold + pane dot.
  • One production guard was added in response to a failing test, and it is a real fix, not scaffolding. The pane key is minted from the tab. A completion for a session the tab has since been rebound away from would therefore have stamped the new session's key with the old session's news. The subscription already filtered by session, but the key is minted in the dispatcher, so the check belongs there too.
  • Two method-count ratchets moved 26 → 27, not one. I found the second the honest way: CI caught it. src/main/runtime/rpc/methods/structured-agent-session.test.ts:170 was the one I knew about; tests/e2e/cross-version-wire/ derives its count from the surface manifest and failed on the first run. Both are now enumerated — rg -n "STRUCTURED_AGENT_SESSION_METHODS" src tests returns 20 references across 11 files, of which exactly one asserts a count, and the cross-version suite is the only other place the surface size is pinned.
  • The ratchet bump is deliberate. Its own comment says to bump deliberately: the whole agentSession.* surface sits behind the structured capability, so an additive method is invisible to old clients and needs no protocol bump. The new stream capability is asserted separately, because a host can serve the rest of that surface and not this stream.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: no new privilege, no new user input path. The completion record carries ids, an outcome and a timestamp — no transcript content, no paths.
  • Cross-platform: no platform-dependent code. No paths, shells, or child processes.
  • Remote SSH: covered above — the client keys markers off the tab, never off the wire's workspace scope, and the capability probe keeps an older host out of the subscription rather than retrying it.
  • Mobile: untouched. No notification delivery is requested here.
  • Backwards compatibility: the event is additive and capability-gated; an older client never subscribes and an older host is never subscribed to.
  • Performance: one comparison per journal commit against a single retained turn id per session, and one shared stream per host rather than one per tab.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason — not attached; reason given under Visual Proof
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Issue write-up (could not be filed as an issue from my environment — please file and link it)

Title: [Bug]: a finished Native Chat turn does not light the unread indicators

Operating system: macOS, Linux, Windows (all), including SSH remotes
Orca version: main

Short summary: when a chat in the experimental Native Chat view finishes its reply, nothing in the sidebar or tab strip lights up. The same agent run in a terminal pane marks the workspace bold and shows an amber dot. So if you send a prompt in a chat tab and switch away, there is no signal telling you it is done — you have to keep going back to look.

Steps to reproduce

  1. Open a workspace and start an agent in the Native Chat view (the experimental chat tab, not a terminal pane).
  2. Send a prompt.
  3. Switch to a different workspace while the agent is still working.
  4. Wait for the reply to finish.

Expected: the workspace goes bold in the sidebar and the chat tab shows the amber "agent finished" dot, exactly as a terminal-based agent does.

Actual: nothing changes. The chat sits finished and unannounced until you navigate back to it.

Why it happens: the unread indicators are driven by the terminal notification path, which watches PTY output to infer that a turn ended. A chat tab has no PTY, so there is nothing for that path to watch and no producer fills the gap.

This is distinct from #21221 — that one is about the "Hide sleeping" sweep, which reads open tabs and live PTYs (visible-worktrees.ts:145-160) rather than unread state, so this PR does not fix it.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: e229f24c-2b3d-4f7e-9e91-0931baebc989

📥 Commits

Reviewing files that changed from the base of the PR and between db6ea5c and 8db65f0.

📒 Files selected for processing (2)
  • src/main/native-chat/agent-session-wire/structured-agent-session-turn-completion-feed.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-turn-completion-feed.ts

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


📝 Walkthrough

Walkthrough

The change adds live structured agent-session turn-completion events. The host derives events from the newest settled journal turn and exposes them through a capability-gated RPC stream without replay. Renderer runtime feeds manage per-target subscriptions and reconnects. A background bridge routes successful completions for open structured tabs to workspace, pane, tab, and surface unread indicators.

Priority: ➖ Normal

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, compatibility, and review notes. However, it does not provide the required linked issue, and it does not include the required bef… Add a valid issue reference under Linked Issue, such as "Fixes #12345". Attach before-and-after screenshots or a video under Visual Proof. If visual proof is truly impossible, use the template's exact N/A wording with a brief reason, subjec…
Docstring Coverage ⚠️ Warning Docstring coverage is 35.48% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 22 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 and concisely describes the main change: showing unread indicators when a structured native chat finishes.
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 is detailed and covers the change, rationale, testing, compatibility, and review notes. However, it does not provide the required linked issue, and it does not include the required before-and-after visual proof for this UI behavior change. The checklist also leaves the visual-proof item unchecked.

Resolution

Add a valid issue reference under Linked Issue, such as "Fixes #12345". Attach before-and-after screenshots or a video under Visual Proof. If visual proof is truly impossible, use the template's exact N/A wording with a brief reason, subject to repository policy.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

@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 informational concern about the derivation edge and a nitpick. This is a well-built PR: the transport, the live-only contract, and the store integration all check out.

Reviewed changes

Reviewed the full commit d6e6bb7 (21 files): the host-side turn-completion derivation, the capability-gated stream, the renderer feed, and the per-tab attention bridge.

  • Host derives the edge at journal commit — StructuredAgentSessionTurnCompletionFeed observes every no-activity publish, baselines the first observation, and emits one completion per running → settled transition carrying an explicit outcome. Absent outcome is treated as UNKNOWN and emits nothing.
  • Capability-gated live-only stream — new agent-session.turn-completion.v1 capability and agentSession.subscribeTurnCompletions method; the client probes before subscribing and never retries an old host. No snapshot and no replay, by design.
  • Renderer fan-out and reconnect — one shared owner per runtime target with refcounted activation and generation-fenced reconnect; the reopened stream starts empty.
  • Shared attention policy — dispatchStructuredTurnCompletionAttention is success-only and reuses resolveAgentAttention / applyAgentAttentionUnread, so it writes the same four sinks the terminal lane uses and requests no OS delivery. It keys off the tab, never the wire scope (SSH-safe).

ℹ️ The settle publish shares a coalescing key and has no test for a back-to-back next turn

Every no-activity publish uses the sink's default coalescingKey: 'publish' (the running row is the exception, turn-start:<session>:<turn>). StructuredAgentSessionSinkQueue.submit replaces a still-queued op with the same key in place. If a settle publish is queued behind an async op and a later same-key content publish is submitted after a new running turn row has been queued, the surviving publish runs after the newer running row exists, so newestTurn() returns the newer running turn and observe clears its baseline — the settled turn's completion is dropped. Claude's settle uses 'publish' while the next turn's running row uses turn-start:…, so the collision needs a third same-key 'publish' (e.g. streamed-text persist) landing in that window. I could not prove the interleaving is reachable, but the existing tests cover "once per turn under republish" and not "settle immediately followed by the next turn's running row", so nothing would catch it if it is.

Technical details
# Settle completion can be shadowed by a coalesced publish

## Affected sites
- `src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts:184-194` — no-activity publish helper defaults `coalescingKey` to `'publish'`.
- `src/main/claude/claude-turn-lifecycle-item.ts:104` — settle row publishes under `'publish'`; running row under `turn-start:<session>:<turn>`.
- `src/main/native-chat/agent-session-wire/structured-agent-session-event-sink-queue.ts:120-165` — an op with a matching key is spliced out and replaced in place.
- `src/main/native-chat/agent-session-wire/structured-agent-session-client-delivery.ts:80` — `observe` is invoked from the surviving publish, reading `newestTurn()` at run time.

## Required outcome
- A settled turn must produce its completion even when the next turn's running row is appended before the publish op that observes it drains. Either a per-turn publish key for the settle edge, or holding the observation at append time rather than publish time.

## Suggested approach (optional)
- Add a main-feed test that settles turn 1 and queues turn 2's running row before draining, asserting turn 1's completion still emits. If the queue cannot interleave that way, the test documents the guarantee.

ℹ️ Nitpicks

  • agentSessionTurnCompletionKey (src/shared/agent-session-wire.ts:268) is exported but has no callers in this PR; it is unused API surface until the mobile fanout lands. Fine to keep if the follow-up is imminent, otherwise it is dead code.
  • The bridge test logs a Failed to persist unread worktree state warning because markWorktreeUnread reaches the persistence path with an unhydrated store; harmless in the test, just noisy.

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

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

Reviewed changes

Incremental review of 2d4e380 (the commit pushed during the prior review). The change is test/wire-gate registration only — no production behavior.

  • Host stub gains the new stream — tests/e2e/cross-version-wire/structured-agent-session-host-fixture.ts:83 adds subscribeTurnCompletions returning a no-op unsubscribe, correctly with no opening emit (a completion is an edge, unlike the status feed next door which emits a snapshot).
  • Surface manifest declares the method — tests/e2e/cross-version-wire/structured-agent-session-surface-manifest.ts:154-157 adds agentSession.subscribeTurnCompletions to STRUCTURED_CALLS with hostMethod: 'subscribeTurnCompletions' and no result, matching the agentSession.subscribe pattern for a subscription that legitimately returns nothing. This makes the cross-version suite exercise the opcode in both skew directions.

This resolves the wire-gate implication of the new stream method noted in the PR body; the registration is correct and consistent with the existing entries.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

… finishes

A structured native chat had no attention producer. The PTY lane reaches the
unread markers through use-notification-dispatch, whose liveness reads PTY
state and whose admission requires terminal panes, so a structured session —
which runs on the execution host with no renderer PTY — could finish a turn
with nothing lighting anywhere. A backgrounded chat was the worst case: with
no mounted pane there was no reader to notice at all.

The host derives the completion, because only the host can. The journal keeps
committing whether or not a renderer holds a reader, so the new feed observes
each commit at StructuredAgentSessionClientDelivery.publishJournal and emits on
every running -> settled transition. That edge runs after the subscriber loop
and independent of it, which is exactly why a chat nobody is watching can still
complete. It is a separate capability-gated stream rather than a field on the
status summary: the summary carries no turn identity and no outcome, and is
re-broadcast on every status change, so folding a completion into it would make
every status consumer a completion consumer.

ONLY `success` LIGHTS ANYTHING. Outcome is A0's provider verdict and is never
inferred: a turn the host merely watched stop carries no outcome and produces
no event, because absent means UNKNOWN. `completed` alone proves nothing — a
provider reports its own API error as a finished turn — so the host emits
nothing for it and the renderer filters again on the way in.

RECOVERY IS LIVE-ONLY. Nothing is retained, queued or replayed on either side.
A subscriber learns what settles while it is subscribed and nothing else; on
reconnect it re-opens an empty stream and whatever landed during the gap is
gone. A retained completion would be a durable "unread is owed" obligation with
nothing to retire it, and a reconnect would then light the dot for work the
user already read. Tests on both sides pin this so a later refactor cannot
quietly turn it into catch-up.

The dot itself reuses the neutral policy in attention/agent-attention-policy
and #21274's structured surface adapter, so suppression, acknowledgement and
addressing keep exactly one implementation and the surface key is never omitted
to evade a check. No second suppression rule is introduced. OS delivery is
deliberately not wired: this calls applyAgentAttentionUnread, not
applyAgentAttention.

Also narrows the completion feed's journal dependency to the newest-turn reader
it actually uses, and adds journal.newestTurn() beside the existing
activeTurnId() on the one shared by-sequence scan rather than a second scan.
…re manifest

The cross-version gate asserts the structured surface's method list by name and
count, so an additive method has to be declared there deliberately. Adding the
entry makes the suite call it in both skew directions and stubs the host side,
which is the statement the gate exists to force.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/a1-structured-unread branch from 2d4e380 to db6ea5c Compare September 21, 2026 06:58
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Visual proof — structured chat unread

Captured from this branch’s hidden dev app (ORCA_BACKGROUND_LAUNCH=1, no window focus). App identity matched the worktree: Orca: brennanb2025/a1-structured-unread, repo root a1-structured-unread.

A real Claude structured chat was created with the production launch (agentSession.create, fence 1) next to a Shell tab. Shell stayed selected, so the chat was in the tab strip but not the open surface.

Before. Workspace title is regular weight. Neither tab has the amber completion bell.

Before: Shell selected, Claude Chat present, no unread

After a successful completion. The production dispatcher (dispatchStructuredTurnCompletionAttention) was called inside that renderer for this chat’s session. The sidebar title goes semibold and exposes “Unread:”. The Claude Chat tab shows the amber bell labeled “Unread agent completion” and the amber wash. Shell stays selected and does not.

Backing store at the same moment: isUnread true, and unreadTerminalTabs, unreadTerminalPanes, and unreadAgentCompletionPanes all set to agent-completion for that chat.

After: bold workspace title and amber bell on Claude Chat

Failure, cancellation, and a completion with no outcome were sent through the same dispatcher after the markers were cleared. The store stayed empty and the title returned to regular weight with no bell.

Renderer console had no error lines. The only console warnings were the existing tooltip controlled/uncontrolled notice and the React Grab startup message.

Not shown here: a live provider turn settling in the host journal and crossing agentSession.subscribeTurnCompletions (the screenshot is the dispatcher the bridge calls, not a journal commit). Also not shown: the bell clearing when you look at the chat. That path requires the window to be foreground-focused, and this run kept the window unfocused on purpose. A folder workspace was not staged.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status

No release-blocking issues remain. The review found and fixed one real lifecycle bug: a journal rewind/history repair could republish an old settled turn under a new epoch and falsely light unread indicators. The completion feed now re-baselines on epoch changes or sequence rollback; the fix is pushed in 8db65f0cb9 with regression coverage.

Validation completed:

  • 100 focused tests across the five changed behavior areas, including 14 cross-version wire cases
  • pnpm tc:node
  • pnpm tc:web
  • pnpm run check:code-quality:changed
  • git diff --check
  • Electron validation with ORCA_BACKGROUND_LAUNCH=1 and CDP: the real renderer showed the workspace title becoming bold and the backgrounded structured-chat tab showing the amber completion bell; backing store markers matched. Before/after screenshots are attached above.

Remaining gaps are non-blocking and explicit: the live host-journal event crossing the wire was not exercised in the screenshot run, and the latest hosted typecheck job was canceled by the runner even though local typechecks pass; please rerun that CI check. The feed intentionally drops completions during a disconnect, and the host performs one bounded linear newest-turn scan per journal publication; neither produced a proven user-visible regression.

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

Reviewed changes

Incremental review of 8db65f0 — the only commit since the prior pullfrog review — which fixes the host feed re-announcing retained history after a journal epoch replacement.

  • Feed re-baselines on epoch change or sequence regression — observe now reads journal.cursor() ({epoch, sequence}) alongside newestTurn() and stores it in the per-session baseline; when the epoch changes or the sequence moves backwards it re-baselines silently instead of emitting a retained settled turn as fresh news.
  • Test pins the rewind case — a new case republishes an already-settled turn-old in a new journal epoch, asserts no event, then confirms a genuinely new turn still emits. It fails without the fix.

The cursor semantics check out: lastSequence advances via Math.max within an epoch (journal-reducer.ts:64) and an epoch replacement always mints a new epoch, so both halves of the condition identify republished history rather than a provider edge. The second clause guards the same-epoch truncating-repair case the epoch check cannot see. The feed test file (15 tests) passes locally.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

CI follow-up

The hosted typecheck job was rerun and was canceled again after about two minutes while running pnpm run typecheck; it emitted no TypeScript diagnostics. The same full command passes locally (all projects) in about 30 seconds. All other required checks, including static analysis, package builds, cross-version compatibility, all test shards, and verify, are green. The remaining red gate is therefore a hosted-runner cancellation, not a proven code/type error; rerun the workflow or typecheck job before merging.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

CI rerun complete

The failed jobs were rerun successfully. The hosted typecheck now passes, and the aggregate verify check passes. The PR workflow is green across typecheck, tests, static analysis, packaging, Windows packaging, cross-version compatibility, and verification.

@brennanb2025
brennanb2025 merged commit 2739246 into main Sep 21, 2026
84 of 88 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 21, 2026
…ached it (#22067)

C7.7 (#21977) measured the session route's page closure at 4,330 on a
merge of f07bf85 and gated green. Before it merged, #21924 turned
agent-session-wire.ts's type-only import of agent-session-record into a
value import, so src/shared/agent-session-record.ts and the two modules
it reaches, agent-session-conversation-name.ts and
surrogate-safe-text-slice.ts, entered the page bundle. Pristine main at
3cfb070 reads 4,333. Named by diffing the closure at f07bf85
against 2739246; nothing on the C7.7 side moved.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
brennanb2025 added a commit that referenced this pull request Sep 21, 2026
Extracting the shared paused-state predicate adds exactly one module to the
mobile session route's closure, and the ratchet caught it. CI measured that +1
directly, with the adjacent assertions on the same test still passing: no
package dependency entered the chunk and the mermaid engine is still fenced to
its one deferred artifact.

The one module is `src/shared/native-chat-paused-gate.ts` itself. Its sole
import is `import type { AgentStatusState }`, which is erased, so nothing
follows it into the runtime graph — the same edge #21924 is caught on from the
other side in the reading above, where a type-only import became a value import
and brought three modules with it.

Re-recorded on main's 4,333 rather than carried across. This entry has now been
re-read against three bases: +1 on item D's 4,323, then on ruling 34's 4,330
once C7.7 registered the route, and now on 4,333 after #21924 reached the page.
The +1 survives each move — the walk reaches `use-mobile-native-chat-prompts`
through `MobileSessionRouteScreen`, the session surface, the content row, the
active content and the native chat overlay's controller — while the total it
attaches to does not, which is the arithmetic this file's own readings keep
warning about.

Recorded as a trade rather than silenced: one module on the phone's session
route buys a single definition of what "paused" means across the two chat
surfaces that both gate an approval envelope on it, and a second copy of that
rule is how they drifted apart in the first place. Per ruling 28, the total is
a re-recorded census rather than a budget.

The local-module count is deliberately not re-read beside it: the closure walk
skips outside the `mobile web app bundle` job, so any number added here would
be one nobody measured.
Jinwoo-H added a commit that referenced this pull request Sep 21, 2026
…arries the tail (OTA phase C, ruling 36) (#22072)

* feat(mobile): give the microphone its own screen lock (OTA phase C, ruling 36)

An open microphone holds the screen; a closed one gives it back. The lock
lives in the device-side capture on both hosts — the shell's
`native.audio.start|stop` handler and the native seam — so the page never
decides anything about the screen.

One tag per capture, minted by the module that owns the mic. Both captures
give it back on every close path: a stop, a page session ending with the
capture open, a device that would not begin, and an engine that throws after
the capture is open, which now ends the capture rather than leaving it live.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* feat(mobile): carry the capture's tail on the stop reply (OTA phase C, ruling 36)

`native.audio.stop` drains what the ring still holds into its own reply, so
the page's `end()` is one verb: stop, hand the bytes on, done. The drain,
await and read-once-more ordering goes with it, and so do `ending`,
`reading` and `released` — three variables that existed only to order a last
read against the stop and to stop a refused read re-entering `end`.

The tail fields default rather than being required: the page updates over
the air and the shell does not, so a page this new can meet a shell that
answers `stopped` alone. That dictation loses its tail where a required
field would have lost it the stop.

The heap case from PR D's bot round cannot recur: `end` issues no read, and
a stop reply carries no interruption, so the lane that re-entered is gone.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* refactor(mobile): drop the dictation finish id, which ordered nothing

`finishingIdRef` tracked the dictation a stop was finishing, and every state
it could name was already named: `cancel`, a disable, an unmount and a newer
start each bump the generation or clear the active id, so the finish guard
answered the same either way. Its one distinguishing arm released pending
audio bytes for a dictation whose budget `closeDictationAudio` had just
reset, and could subtract those bytes from a newer dictation's reserve.

`acceptingChunksRef` stays: it is what stops a late microphone event being
sent after the capture handed over its tail and before the finish goes out.
`pendingChunksRef` stays: `stop` awaits it so the finish cannot overtake the
last chunk send.

The finish guard is pinned by a case that cancels while the finish is in
flight; neutered, it reds.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* feat(mobile): delete the page's wake-lock seam (OTA phase C, ruling 36)

The page never names the screen now. `native.wakelock.set` is gone with its
schemas, its shell server, its grant rows and its harness entry; so are the
page's keep-awake owner, the Android foreground re-acquire, and the
`DictationKeepAwakeDevice` the capture contract carried. One module holds
the screen — the device calls the microphone's capture makes — and both
device-side captures share its one tag, because there is one microphone.

Deleted: native-wakelock.ts (120), native-wakelock.test.ts (140),
mobile-dictation-keep-awake.ts (248), mobile-dictation-keep-awake.test.ts
(440), mobile-dictation-foreground-keep-awake.ts (78). With the tag pools
gone, the desktop-start flow has one stale check instead of two, no startup
budget to wait out and nothing to release.

A source-scanning census pins it: no module under mobile/src or mobile/app
but the one owner imports expo-keep-awake, and nothing anywhere names the
retired verb. It reports the file and line, and checks the owner does import
the package so the absence is the rule holding and not the match missing.

KNOWN RED, reported and not recorded over: 25 golden cases in the speech.*
families fail. The recorder adapter had to drop its keep-awake owner, which
moves `adapterSha256` for every golden that mounts it, and the deleted
owner's id minting shifts the deterministic random sequence, so the recorded
`dictationId` values move too. No speech.dictation.* param, reply or
operation changed. Awaiting the lead's call on a scoped re-record.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): re-record the corpus after the wake-lock deletion

Baseline bumped to 491eb35 and the corpus recorded against it. Every
changed line in `goldens/` falls into six classes and nothing else:

  baseline                            1574 lines   787 goldens
  lockfileSha256                      1574 lines   787 goldens
  adapterSha256                         38 lines    19 goldens
  scenarioSha256                         8 lines     4 goldens
  dictationId shift                    728 lines     4 goldens
  keep-awake effects + renumbering      63 lines     2 goldens
                                      ----
                                      3985 lines, which is the whole diff

`recorderSha256` is untouched: no recorder module outside `adapters/` moved.

The id shift is attributable arithmetic, not a behaviour change. The
recording scheduler seeds `Math.random` with an LCG from seed 1; replaying
it gives draw 1 `8ig2henseon` and draw 2 `dakoxjr8wun`. The deleted
keep-awake owner minted its id from draw 1 during the hook's mount, so the
dictation id took draw 2. With the owner gone the dictation id takes draw 1,
which is why four scenario steps that pinned the literal value move with it.

`adapterSha256` covers `speech.setup-sheet` as well as the three dictation
families, because one adapter module hosts them all. The two goldens with
vanished effects also renumber the ordinals after them, which is what the
removal of an entry from a sequential counter does.

`lockfileSha256` is provenance that `compareGolden` copies from the actual
and never fails on. It moves in all 787 files because main's own
`mobile/pnpm-lock.yaml` has moved since the corpus was last recorded; this
branch does not touch it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile): drop the retired wake-lock grant C7.7's route row carried

The merge brought in the session route's manifest entry, which names all
four dictation grants including `native.wakelock.set`. This branch deleted
that verb, so the row granted a page something the shell no longer serves.
Ruling 32 item 6 said C7.7 takes the dictation grant from PR D's census in
this merge; this is that.

Nothing caught it automatically: the shell-side grant list is derived from
the verb tuple and is already three, and the closure census holds a route to
the grants it needs rather than refusing ones it does not.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): repin the session-route closure at the measured 4,331

Measured on this merge rather than summed: 4,331 modules, 989 local.

Main is red here on its own pin. `3cfb070294` measures 4,333 / 991 against a
committed 4,330, three modules this branch never touched — measured in a
throwaway worktree detached at that commit, with the same generators run.
This merge measures 4,331 / 989, and diffing the two local lists gives the
difference exactly: `mobile-dictation-keep-awake.ts` and
`mobile-dictation-foreground-keep-awake.ts` leave, and nothing joins. So the
branch's own effect is the -2 ruling 36 implies, and repinning to the
measurement is also what takes main's closure test green again.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): repin the session-route closure at 4,331 on the merge with #22067

Measured on this merge: 4,331 modules, 989 local, against main's freshly
repinned 4,333 / 991 at `3cfb070294`.

Both provenances kept. #22067 names the three `src/shared` modules #21924
pulled into the page closure, which is what made main's earlier 4,330 stale;
this branch's own -2 is the page's wake-tag owner and its Android foreground
re-acquire, deleted by ruling 36. Diffing the two local lists gives exactly
those two leaving and nothing joining, so the number is a reading rather
than 4,333 minus an argument.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile): close the capture when the desktop start fails

The hook opens the microphone before it asks the desktop for a session, so a
refused session left the mic open — and, since the screen rides the mic, the
display held until the user cancelled, retried, or the screen unmounted. The
failure arm now runs the same `rollbackRecordingStart` the commit failure
does, because "undo the capture this start opened" is one thing and the hook
owns it; guarded like that arm, so a seam that throws on the way down cannot
take the desktop cancel with it.

Red-first on both hosts. Natively, a new test drives the real seam under the
engine and keep-awake mocks: the refusal used to leave `initialize` with no
`toggleRecording(false)` and a held screen. On the page, the mic control's
own test over the port pair saw `native.audio.start` with no
`native.audio.stop`. Two unit cases pin the call itself, including for a
start nobody will report.

Ruling 36's own words: mic closed means released. This closes the mic rather
than adding a release beside it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): re-record after the failed-start capture close

Baseline bumped to a1bdee9 and the corpus recorded against it. The whole
diff is two classes:

  baseline   1574 lines   787 goldens
  content      74 lines     1 golden

`lockfileSha256`, `adapterSha256`, `scenarioSha256` and `recorderSha256` do
not move: no lockfile, adapter, scenario or recorder module changed.

The one content golden is
`matrix-speech.dictation-start-speech.dictation.start-1`. Its failure
partitions now carry a `rollback-recording` effect at ordinal 3, which is
the capture being closed, and the `speech.dictation.cancel#1` entries after
it renumber from 3,4 to 3,4,4,5 — the pool holds one entry per distinct
content, so a partition whose ordinal moved stops sharing an entry with the
one it used to match. Removing the new effect and ignoring ordinals makes
the two recordings identical, checked by dereferencing every hash rather
than by reading the diff.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* fix(mobile): only the owning start rolls its capture back

There is one capture seam and it carries no start identity, so round 1's
rollback let a stale start's rejection end a live newer dictation: A opens
the capture and waits on the desktop, the user cancels, B starts and is
recording, A's request finally rejects and ends B's microphone and hands
back B's screen. The rollback now runs only while this start is still the
current one, which is what `wasCurrent` on the line above already reads; a
stale failure still cancels its own desktop session and touches nothing
else. Past the generation the capture was either already ended by whatever
superseded this start, or belongs to the one that did.

Red-first on both hosts, driving that exact sequence rather than a spy: the
native test over the real seam saw the screen go `+ - + -`, and the page's
mic-control test over the port pair saw a fourth `native.audio.` verb after
B was recording. Both now end with B still holding what it took.

The mirror image is covered and now pinned at host level too: A's request
resolving late does not commit A over B, because the stale check after the
desktop start returns through `cancelStaleStart`, which cancels A's session
without touching the capture.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

* test(mobile): re-record after the stale start stopped rolling back

Baseline bumped to e17b2cf. Two classes, the whole diff:

  baseline   1574 lines   787 goldens
  content      74 lines     1 golden

`lockfileSha256`, `adapterSha256`, `scenarioSha256` and `recorderSha256` do
not move.

The one content golden is
`matrix-speech.dictation-start-speech.dictation.start-1`, whose scenario is
the superseded start, so every partition in it is a stale one. The
`rollback-recording` effect round 1 put there is gone, and the
`speech.dictation.cancel#1` entries fold back from 4 to 2 as the ordinals
after it renumber — the pool holds one entry per distinct content, so
partitions whose ordinals agree again share an entry again. Dropping that
effect from the superseded partitions and ignoring ordinals makes the two
recordings identical, checked by dereferencing every hash.

`speech-desktop-start-recording-failed` is untouched: that start still owns
its capture at failure time, so it still rolls back.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
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