Skip to content

fix(native-chat): deliver queued messages while the chat pane is hidden - #20659

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-outbox-admission
Sep 16, 2026
Merged

brennanb2025 merged 3 commits into
mainfrom
brennanb2025/native-chat-outbox-admission

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem

With multiple native-chat messages queued, later messages could remain in the renderer until the user returned to that chat/worktree. The outbox only inspected its head, while retirement of a host-admitted pending entry depended on a journal subscription activated by visibility. Hiding the pane also relinquished its desktop hold, allowing the host to evict an idle session after its 15-second grace period.

Change

  • Share one admission rule between draining and Retry. Skip host-admitted entries, while an unconfirmed or refused entry blocks later sends.
  • Track the actual in-flight entry, including a tail entry. When a journal admission arrives before its RPC reply, publish the reconciled queue so releasing single-flight also wakes the drain.
  • Hold the queue while launch-prompt dispatch is in flight outside the hook's single-flight. Resume after either accepted or pending settlement.
  • Keep the retaining journal subscription active while an enabled session owes delivery, regardless of pane/worktree visibility. Unpublished provisional sessions remain inactive.
  • Scope the outbox projection's cached snapshot and listeners to subscribed sessions. Notify only the changed session, and remove its cache after the last unsubscribe.

The host continues to own ordered admission through its existing per-session serialization and journal-before-dispatch path. The renderer still owns pre-admission delivery and unsettled retry state; this change keeps that work progressing in hidden mounted panes rather than moving it into a process-independent dispatcher. Closing the renderer still relies on persisted outbox recovery on the next mount.

Pending entries are deliberately retained: they may later settle rejected or unknown, and the entry carries retry state. They are not the only copy of the text: applySubmission creates a render item from the submission body, and projection filters the matching outbox item once that journal item exists.

Validation

  • Independent review and opening/closing readiness checks: no remaining actionable findings at 85d3ed9c107689515e40fc14500350d63505fa1b.
  • CI passes at that head: all eight unit-test shards, typecheck, static analysis, and macOS/Windows packaging.
  • Local renderer/shared suite: 9,889 passed, one expected failure, 123 skipped on production-identical a2b4a3b2e7; host admission/settlement/retention tests: 52 passed. The only subsequent change renamed a test-local type for the static-analysis gate.
  • Admission tests cover journal acknowledgement before RPC reply, later pending entries, blocking unknown/refused entries, and launch settlement in both accepted and pending cases.
  • Final rendered QA and exact-head ablation details are recorded in the closing review comment.

The local full typecheck encountered an existing unused test import already removed on current main; the PR's CI typecheck passes. Rendered validation covers macOS with a real local provider. Live SSH/network-failure, Windows/WSL, Linux, and mobile UI scenarios were not exercised; this change adds no wire or platform-specific behavior.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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: ef8b662a-c6c6-4a33-92b6-9d86008e96de

📥 Commits

Reviewing files that changed from the base of the PR and between a2b4a3b and 85d3ed9.

📒 Files selected for processing (1)
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox-admission.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox-admission.test.tsx

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


📝 Walkthrough

Walkthrough

The outbox now admits entries by state instead of assuming the head is always actionable. Dispatch tracks the in-flight entry by client message ID and reconciles journal ownership before releasing single-flight state. Refusals and retries identify the affected entry directly. Storage publishes per-session undelivered-state changes. Hidden enabled sessions continue reading while delivery remains pending. Tests cover admission, retry targeting, storage subscriptions, and hidden-session reads.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 85d3e

The dispatch path now preserves reconciled outbox state rather than restoring accepted or already-owned messages, so this previously identified duplicate-send risk does not block merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.82% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 16 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the problem, implementation, validation, limitations, and testing results, but it does not follow the required template. It omits the required ELI5, Linked Issue, Visual Proof… Rewrite the description using the repository template. Add an ELI5 section, a What Changed section, a Why section, a valid Linked Issue entry instead of Fixes #, and a Visual Proof section with before/after attachments or N/A with a rea…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: delivering queued native-chat messages while the chat pane is hidden.
Full details: Description check

Explanation

The description explains the problem, implementation, validation, limitations, and testing results, but it does not follow the required template. It omits the required ELI5, Linked Issue, Visual Proof, checklist sections, and other required headings.

Resolution

Rewrite the description using the repository template. Add an ELI5 section, a What Changed section, a Why section, a valid Linked Issue entry instead of Fixes #, and a Visual Proof section with before/after attachments or N/A with a reason. Complete Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: Advanced

Run ID: 059b4542-3fa4-4bc7-83ac-ae46cf8db9d7

📥 Commits

Reviewing files that changed from the base of the PR and between c6a7216 and 3234f84.

📒 Files selected for processing (10)
  • src/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
  • src/renderer/src/components/native-chat/NativeChatStructuredSessionDelivery.test.tsx
  • src/renderer/src/components/native-chat/structured-agent-session-outbox-storage.test.ts
  • src/renderer/src/components/native-chat/structured-agent-session-outbox-storage.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts
  • 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/shared/structured-agent-session-outbox.ts
  • src/shared/structured-agent-session-send-disposition.ts

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

dispatchingRef.current ||
blockedIdRef.current === next.clientMessageId
) {
const admission = admitStructuredAgentSessionOutboxEntry(outbox, blockedIdRef.current)

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Use the reconciled outbox snapshot in the drain.

The preceding effect can update outboxRef.current after it removes an accepted entry or marks a host-owned entry as dispatching. This effect still admits and stages entries from the stale render-time outbox.

For example, if reconciliation removes an accepted head while a queued tail exists, staging the tail from outbox restores the accepted head in state and storage. A session change or crash before the next reconciliation can then resend that message.

Read one current snapshot from outboxRef.current. Use that snapshot for both admission and staging. Add a regression test for journal-driven single-flight release.

Proposed fix
   useEffect(() => {
-    const admission = admitStructuredAgentSessionOutboxEntry(outbox, blockedIdRef.current)
+    const current = outboxRef.current
+    const admission = admitStructuredAgentSessionOutboxEntry(current, blockedIdRef.current)
     const next = admission.state === 'dispatch' ? admission.entry : null
     if (!next || next.sessionId !== sessionId || fence === null || dispatchingRef.current) {
       return
     }
     dispatchingRef.current = true
     dispatchingIdRef.current = next.clientMessageId
     const dispatchGeneration = dispatchGenerationRef.current
     const staged = updateStructuredAgentSessionOutboxEntry(
-      outbox,
+      current,
       next.clientMessageId,
       (entry) => ({ ...entry, state: 'dispatching' as const, lastAttemptAt: Date.now() })
     )

Also applies to: 160-160

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

Caution

This PR leaves a dispatching head stranded on a fence change when a queued tail exists. After a reconnect (fence change) with an in-flight head and a queued message behind it, the drain dispatches the tail and never re-sends the head, which sits in dispatching with no request in flight. The old head-only drain was safe here; the new dispatching-is-not-a-barrier rule makes the drain's stale read of outbox destructive. Reproduced with a focused test — see the inline comment.

Reviewed changes

  • Shared admission rule — admitStructuredAgentSessionOutboxEntry returns dispatch/blocked/idle, with dispatching explicitly non-blocking; drain and Retry both read it.
  • Undelivered projection — writeOutbox publishes per-session "has outbox" state; the read hook activates on isVisible || hasUndelivered.
  • Defect fixes — single-flight release moved into applyDisposition; reconcile release keyed on dispatchingIdRef; refusal blocks the refused index; probe scans for the first unconfirmed entry.
  • Tests — outbox, storage-projection, read-hook, and delivery tests added/updated.

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

dispatchingRef.current ||
blockedIdRef.current === next.clientMessageId
) {
const admission = admitStructuredAgentSessionOutboxEntry(outbox, blockedIdRef.current)

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.

The drain reads the render-time outbox here (and again in updateStructuredAgentSessionOutboxEntry below), but the fence/session effect at line 82 already rewrote the dispatching → queued reset into outboxRef.current. In the same commit the drain runs on the stale closure, so on a fence change with a dispatching head + queued tail it skips the head as non-blocking, dispatches the tail, then writes the stale dispatching head back — stranding it with no in-flight send.

Technical details
# Stale `outbox` read strands a dispatching head on fence change

## Affected sites
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:152` — `admitStructuredAgentSessionOutboxEntry(outbox, …)` reads the closure, not `outboxRef.current`.
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:160` — `updateStructuredAgentSessionOutboxEntry(outbox, …)` likewise re-stages from the closure.
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:82-98` — the fence/target/session effect maps `dispatching → queued` into the ref; its `setOutbox` does not re-render before the later passive effects run.

## Why the old code was safe
Old drain: `const next = outbox[0]; if (… next.state !== 'queued' …) return`. A stale `dispatching` head returned early, so the re-render installed the queued reset before dispatch. Admission now skips `dispatching`, so the stale closure dispatches the tail and the staged write reverts the head.

## Reproduction (verified)
`send('first')` with a never-settling transport + `send('second')`, then `rerender({ fence: 2 })`. Observed: `mocks.call` texts `['first','second']` (first only at fence 1; never re-sent), and `outbox` states `['dispatching','dispatching']`. Expected: first is re-queued and re-sent against fence 2.

## Impact
If the head's frame never reached the host before the fence changed (connection drop mid-send), it is silently dropped while the tail is delivered — a reorder plus message loss. Delivery-unknown is exactly the case a fence change is supposed to recover from.

## Required outcome
The drain must observe the `dispatching → queued` reset before choosing the next entry, so a not-in-flight dispatching head is re-sent rather than skipped. Reading `outboxRef.current` for both the admission and the staged write is sufficient; making the fence reset synchronous (e.g. layout effect) is an alternative.

## Open questions for the human
Should a `dispatching` entry that is neither `dispatchingIdRef.current` nor host-owned always be treated as a barrier rather than skipped? That would also close this without relying on the ref ordering.

With two or more messages queued, everything behind the head waited on the
user's attention. The drain only inspected the head and returned unless it was
`queued`, and a `pending` send deliberately leaves the head `dispatching`. An
entry only leaves that state through the journal subscription, which is torn
down when the pane goes hidden -- and a worktree switch hides it.

Two changes, both needed:

- One shared admission rule now says what the queue does next, and the drain
  takes its `dispatch`: the first `queued` entry, skipping entries the host has
  already acknowledged. It still stops at an `unconfirmed` entry or a refusal
  the user must act on. Order is not the outbox's to keep -- the host appends
  the submission inside the per-session serialize chain before dispatching, so
  journal order is arrival order. Holding the tail bought no ordering guarantee
  and cost delivery. Single-flight still keeps sends strictly sequential, and a
  launch prompt's in-flight send, which runs outside it, still stops the queue.
- The journal subscription now stays open while a session has undelivered outbox
  entries, published from the `writeOutbox` choke point. The subscription's
  retaining hold is what also keeps the host from evicting the session 15s after
  the last turn, which would otherwise turn the stall into a blocked head
  refusing `agent_session_ownership_unknown`.

An acknowledged entry stays in the outbox rather than retiring on `pending`: the
text is safe either way, since the journal upserts a render item from the
submission's own body, but a `pending` can still settle `rejected` or `unknown`
and only the entry carries the retry state that answer needs.

Follow-on corrections the head-only assumption had hidden:

- Single-flight is released where the disposition is applied, not in a later
  `.finally`. That state write is what re-runs the drain, so the release has to
  land first or the queue has no trigger left.
- One ref now holds the in-flight entry's id instead of a bare boolean, and the
  reconcile effect keys its release on that, not on the head, so a journal update
  about the head can no longer discard a still-unsettled send of the tail.
- A refusal blocks the entry it refused, read back by index so a rotated id is
  preserved.
- The automatic unknown probe and the Retry affordance both read the blocker at
  whatever index it sits, the Retry through the same shared rule as the drain.

`raises no delivery notice for a stuck message behind a healthy head` asserted
that a message behind an admitted head raises nothing, because a Retry could not
act on it. It now can, so that guard is rewritten to assert the notice names
that entry and its Retry sends that entry.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-outbox-admission branch from 3234f84 to 546061b Compare September 16, 2026 08:58

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

Important

Two delivery-ordering defects remain in the reworked drain: a fence change can dispatch a queued tail ahead of the head it just requeued, and a journal-first pending release leaves the queue with no trigger to advance. Both reproduced with focused tests against 546061b; details inline.

Reviewed changes

  • Reworked single-flight from a boolean dispatchingRef to inFlightIdRef keyed on the in-flight entry, released in applyDisposition and when the journal owns that entry.
  • Added the shared admitStructuredAgentSessionOutboxEntry rule (dispatching non-blocking, unconfirmed/refused a barrier) and pointed the drain and NativeChatDeliveryRetry at it.
  • Staged dispatches by entry id via updateStructuredAgentSessionOutboxEntry, and made a launch-prompt send hold the whole queue while it is in flight.
  • Published an undelivered-outbox projection from writeOutbox and activated the read while hidden through providerVisible || (enabled && hasUndelivered).
  • Corrected refusal blocking to read the refused index, and the unknown probe to target the first unconfirmed entry at any index.
  • Added admission/storage/transport tests and rewrote the stuck-message delivery guard.

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

dispatchingRef.current ||
blockedIdRef.current === next.clientMessageId
) {
const admission = admitStructuredAgentSessionOutboxEntry(outbox, blockedIdRef.current)

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.

The drain admits from the render-time outbox snapshot, but the fence/session effect above (:72-92) has already requeued dispatching → queued into outboxRef.current and storage for the same commit. On a fence bump with a dispatching head and a queued tail, admission skips the just-requeued head and dispatches the tail first.

Reproduced at 546061b: send('first') (transport never settles) + send('second') + rerender({ fence: 2 }) → calls ['first','second'], with the head left queued behind the dispatching tail. Reading outboxRef.current (or the persisted array) for the admission closes it. The existing fence test uses a single entry, so it never exercises this.

Technical details
# Drain admits from a stale `outbox` snapshot on fence change

## Affected sites
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:176` — `admitStructuredAgentSessionOutboxEntry(outbox, …)` reads the closure, not the post-requeue array.
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:72-92` — the fence effect rewrites `dispatching → queued` in `outboxRef.current` and storage; its `setOutbox` cannot update the drain effect's closure within the same passive flush.
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:145,156` — the launch probe reads the same stale snapshot.

## Required outcome
- The drain must choose its entry from the post-requeue array (`outboxRef.current` or the `persisted` read) so a head the fence effect just requeued is dispatched before any tail.

## Reproduction (verified)
`send('first')` with a never-settling transport, then `send('second')`, then `rerender({ fence: 2 })`: call texts are `['first','second']`, outbox reads `[queued, dispatching]`. Expected: `first` is re-sent at fence 2 before `second`.

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

Important

The new commit closes the journal-first release gap raised in the previous review, but its sibling — the fence-change ordering defect — is still present at this head. A fence bump with a dispatching head and a queued tail still dispatches the tail first and leaves the head queued; the prior inline thread on that remains open and unaddressed.

Reviewed changes

  • Journal-first release now advances the queue — the reconcile effect forces the state write when the journal owns the in-flight entry (admittedInFlight), so the drain re-runs and the queued tail dispatches before the send RPC settles.
  • Per-session undelivered subscriptions — replaced the global listener set and permanently-cached map with per-session subscription records seeded from storage and released when the last subscriber leaves; the providerVisible || (enabled && hasUndelivered) composition is unchanged.
  • Blocked/error clearing generalized — a blocked id the host now owns is cleared directly, and any host-owned unconfirmed entry clears the error banner.
  • Tests — added the journal-first ordering case, scoped-subscription and cache-release cases, and parameterized the launch-hold test over accepted/pending.

⚠️ Fence-change ordering still dispatches the tail ahead of a requeued head

The previous review flagged this inline on the drain's admission read; this commit does not touch that path, so it reproduces unchanged at a2b4a3b (send('first') never settling + send('second') + rerender({ fence: 2 }) → calls ['first','second'], head left queued, tail dispatching). Recording it here only so the non-approval has a stated reason — the detailed brief lives in the open thread.

Technical details
# Drain admits from a stale `outbox` snapshot on fence change

## Affected sites
- `src/renderer/src/components/native-chat/use-structured-agent-session-outbox.ts:181` — `admitStructuredAgentSessionOutboxEntry(outbox, …)` reads the render-time snapshot; the fence effect at `:72-92` has already requeued `dispatching → queued` into `outboxRef.current` within the same commit.

## Required outcome
- The drain must choose its entry from the post-requeue array (`outboxRef.current` or the `persisted` read) so a head the fence effect just requeued is dispatched before any tail.

## Suggested approach (optional)
- See the open thread from the previous review for the verified reproduction and the alternatives already proposed.

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

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA (isolated background launch)

Exercised head a2b4a3b2e7 in worktree native-chat-outbox-admission. App identity was Orca: brennanb2025/native-chat-outbox-admission; the renderer served the final-head admittedInFlight marker. Launch used ORCA_BACKGROUND_LAUNCH=1 + an isolated profile (CDP screenshots of a hidden renderer; no OS focus).

Scenario

Structured Codex Chat on a fixture git worktree. Enabled structured native-chat settings on the isolated profile (defaults launch TUI). Two worktrees: main (chat) and qa-hidden-switch.

  1. Launch prompt + follow-up (visible): QA20659-LAUNCH then QA20659-FOLLOWUP.
  2. Queued pair then switch: QA20659-A (40-line story) then QA20659-B (B_ACK), immediately switched to qa-hidden-switch, stayed hidden past the 15s hold clock, then returned.

Observable result

While still on qa-hidden-switch (chat not visible), the hidden main sidebar showed Done Codex Chat - B_ACK. Host journal (session codex_14daef5e_3e14_41fa_923c_9a5c1b0198cb) order:

event seq ts vs hideAt 1789581092541
A user submission 37 −407ms
B user submission 39 −284ms
A assistant (story / A_ACK) 63 +14.2s hidden
B assistant B_ACK 66 +17.0s hidden

At hide, renderer outbox held only B in dispatching. At ~27s still hidden, outbox was []. At ~62s still hidden, the session was not evicted (no ownership-unknown / retry). Returning to the chat showed A_ACK then B_ACK in the transcript.

Launch+follow-up (visible): journal seq 2 LAUNCH, seq 31 FOLLOWUP, seq 34 FOLLOWUP_ACK.

Screenshots (uncropped real app)

Switched away (chat hidden; qa-hidden-switch active):

07-switched-away-hidden.png

Still hidden after >15s — sidebar on the other worktree already shows B_ACK:

08-still-hidden-after-15s.png

Returned to the chat — A_ACK then B_ACK:

09-returned-to-chat-after-hidden-delivery.png

Message rail (LAUNCH, FOLLOWUP, A, B):

10-returned-user-messages.png

Launch prompt typed before first send:

05-launch-prompt-typed.png

Gaps (not merge-safe from this alone)

  • B’s host submission is 284ms before hideAt, so the send RPC started while the pane was still up. Hidden-period proof is A’s turn finishing, B_ACK landing, outbox draining, and surviving >15s without coming back — not that B’s first RPC waited until after the switch.
  • No SSH / WSL / Windows / mobile. Folder workspaces not exercised.
  • Isolated profile required flipping structured-native-chat settings; that is not default.

Durable notes/journals/screenshots live outside the tracked diff under the worktree git-path qa-pr20659-electron/.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA supplement (pending outbox head + second queued entry)

Follow-up to the earlier A+B screenshots. Head 85d3ed9c10 (production same as a2b4a3b2e7). Isolated background app identity Orca: brennanb2025/native-chat-outbox-admission. Session codex_14daef5e_3e14_41fa_923c_9a5c1b0198cb. This is not a restatement of the first run (that one had only B in the outbox at hide).

Scenario

A (QA20659-SLEEP2 / sleep 45) was already running. Through the real composer: B Reply exactly FOLLOWUP_B, wait until B was dispatching in the outbox, then C Reply exactly FOLLOWUP_C, then immediately switch to qa-hidden-switch. Chat stayed hidden >120s.

Outbox at hide (hideAt=1789581869667)

Two unsettled entries, both dispatching:

  • B 1789581869194-c332d1ae6b3945ce97cb5a04c0acb575
  • C 1789581869271-bc8ee069ff16453a82f4f3d917196cb5

Immediately before C, the outbox held only B. After C and after the switch, both were still present. Outbox was empty by ~17s hidden without returning to the chat.

Host journal vs hideAt

seq event Δ hide
82 A SLEEP2 submission −25307ms
84 A dispatch accepted −25199ms
90 B FOLLOWUP_B submission −427ms
91 C FOLLOWUP_C submission −331ms
92 B dispatch accepted +12700ms hidden
93 C dispatch accepted +12728ms hidden
94 sleep 45 tool completed (44.9s, exit 0) +23174ms
96 assistant FOLLOWUP_C +25222ms

C was admitted (seq 91) while B had a journal submission but no accepted dispatch yet (B accepted only at seq 92, +12.7s hidden). That is admission past a pending head. Both B and C host submissions precede hideAt; their dispatch accepted rows are after hide, while A’s sleep was still running. Boundary: C did not wait until after hide to reach the host.

Provider reply (do not over-read)

Codex did not emit assistant ACTIVE_DONE or a second assistant FOLLOWUP_B for this B. After sleep finished it answered FOLLOWUP_C only. The earlier assistant FOLLOWUP_B (seq 79/80) belongs to a previous interrupted sleep-30 send, not this B.

Screenshots

Hidden, A still running (sleep in the sidebar):

12-hidden-BC-pending.png

Still hidden after drain (FOLLOWUP_C in the sidebar, qa-hidden-switch selected):

13-still-hidden-after-drain.png

Returned transcript: SLEEP2 + B + C user bubbles, assistant FOLLOWUP_C:

14-returned-ABC.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review complete at 85d3ed9c107689515e40fc14500350d63505fa1b. No remaining actionable findings from the independent same-model review or opening/closing readiness checks. Fixes are pushed; this PR has not been merged.

Functional correctness: both required mechanisms remain: drain past host-admitted entries and retain the journal read while delivery is owed. Unknown/refused entries still block at any index. Review found and fixed a further race: journal admission could clear single-flight before the RPC replied without triggering another drain. The reconciled queue now publishes that transition. Pending entries retain retry state; journal render items also hold their message text.

Architecture and performance: existing host serialization and journal admission remain the ordering authority. The launch path holds the entire queue while its external dispatch is in flight. The outbox projection now owns its cache/listeners per subscribed session and releases them after the last subscriber, eliminating unbounded session-cache growth and unrelated-session notifications. This remains renderer-owned pre-admission delivery for mounted panes; it is not a process-independent dispatcher. Closing the renderer relies on persisted recovery when mounted again. Blocked owed work intentionally retains the read while its pane remains mounted.

Validation: all CI gates pass, including eight test shards, typecheck, static analysis, and macOS/Windows packaging. Local renderer/shared tests passed 9,889 with one expected failure and 123 skipped on production-identical a2b4a3b2e7; 52 host admission/settlement/retention tests passed. The final delta only renamed a test type, with all six admission tests rerun successfully.

Immediately before this comment, reran ablations at 85d3ed9c107689515e40fc14500350d63505fa1b with the same three Vitest files (21 tests), verifying each temporary edit landed and restoring exact final-head bytes:

Temporary removal Result
Admission changes 4 fail / 17 pass
Owed-work read retention 2 fail / 19 pass
Both mechanisms 6 fail / 15 pass
Review fix for journal-before-RPC wakeup 1 fail / 20 pass
Only the whole-queue launch-dispatch hold 2 fail / 19 pass
Restored final head 21 pass

The launch-only ablation fails both accepted/pending cases at the assertion that the later message must not be sent before launch settlement. These are behavioral assertion failures, not missing imports or unmatched test filters. Working tree is clean; no generated lockfile drift was committed.

Rendered Electron QA: Grok exercised an isolated background macOS app with a real local Codex provider and attached screenshots plus journal timing. While A ran, B remained pending and C reached the host behind it. Both were still in the outbox at the worktree switch, settled about 12.7 seconds afterward, and drained by about 17 seconds hidden; the other worktree remained active over 120 seconds. Both initial submissions preceded the switch. The provider answered the combined followups with FOLLOWUP_C, not separate B/C responses. QA processes were stopped and evidence preserved.

Remaining validation limits: no live SSH/network-failure, Linux, Windows/WSL or mobile UI run, and no full real-app heap/frame benchmark. No wire or platform-specific behavior changed. Local full typecheck encountered an existing unused test import already fixed on current main; CI typecheck passes. An existing late journal rejection without a Retry action remains outside this focused change.

@brennanb2025
brennanb2025 merged commit f02d09c into main Sep 16, 2026
28 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 17, 2026
…7) (#21089)

* test(mobile): record main's session reply behaviour at every unrecorded read site

Step 7 for the session domain changes how 51 RPC readers read a *malformed*
reply. Eleven of the session read sites had no recording family, so main's
answer to a malformed reply at those sites was undocumented and the reader
change would have had nothing to move. This commit is the before picture, taken
from main's own tree with no product edit in it.

Ten new families, twelve scenarios, twenty-five goldens:

- `session.review-file-diff` / `session.review-branch-diff` — `git.diff` and
  `git.branchDiff` read through the review projection, which the Changes
  screen's verbatim readers do not cover.
- `session.review-git-mutations` — the single-file `git.stage` / `git.discard`
  and the bulk stage sweep's second `git.stage`.
- `session.review-send-sheet` — `session.tabs.list` read for the agent
  terminals the send sheet lists, the third reader on that method. Needs an
  `open-send-sheet` action on the review-action adapter, which re-digests that
  family's eight goldens on `adapterSha256` and nothing else.
- `session.browser-tab-create` — `browser.tabCreate`.
- `agentSession.structured-create` — `agentSession.create`, whose family base
  only ever covered the support probe.
- `session.tab-rename` / `session.tab-close-session` — `terminal.rename` and
  `session.tabs.close`.
- `settings.new-tab-local-agents` — `preflight.detectAgents`, the arm the
  new-tab loader takes for a workspace with no connection.

`baseline` is repinned to main's tip because two commits (#20659, #21004)
touched a fenced path after the pilot's pin, so `--record` refuses on main's own
tree until it moves. The repin is what rewrites `baseline` on all 705 existing
goldens; nothing else about them moves.

Decoded against origin/main through the value pool: 705 header-only (`baseline`
on every one, `adapterSha256` on the eight review-action goldens), 0 body-moved,
25 added, 0 deleted.

Not covered, with the reason: the chunked clipboard upload's
`appendImageUploadChunk`, `commitImageUpload` and `abortImageUpload` cannot be
matrixed, because `replyMatrixSites` takes every completion in the base scenario
and the chain's later params carry the `uploadId` the start reply named. Driving
`clipboard.startImageUpload#1` therefore makes main send an append whose params
no scripted step matches, and the recorder raises `Request params mismatch:
clipboard.appendImageUploadChunk#1` instead of recording. The two families were
written, probed and removed.

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

* refactor(mobile): checked reply readers for the session domain (step 7)

Fifty-one unchecked reply readers across nine files become checked zod readers,
so a malformed host reply surfaces as one readable error at the operation
boundary instead of a downstream `TypeError`, a rendered `undefined`, or a
screen left ready over garbage. Deliberately a behaviour change on malformed
replies only.

Eight schema modules, one per reply family, each recording the consumer line
behind every requirement and the host handler that publishes it:

- `clipboard-image-reply-schema.ts` — the upload slot's `uploadId`, the commit
  and single-frame path strings, and the two legs whose body nothing reads.
- `github-pr-mutation-reply-schema.ts` — the `{ ok, error }` status envelope as
  two variants, and the bare-boolean confirmation.
- `github-pr-entity-reply-schema.ts` / `github-pr-read-reply-schema.ts` — the
  seven PR sidebar reads. Every identity requirement the hand parsers had is
  kept, so a payload that degraded to null still degrades to null; what changes
  is a payload that is not the declared container at all.
- `diff-review-reply-schema.ts` — the normalized branch compare, the review
  notes on the worktree record, the three file-diff arms, and the file-level git
  mutations.
- `review-terminal-reply-schema.ts`, `session-launch-reply-schema.ts`,
  `session-read-reply-schema.ts`, `session-write-reply-schema.ts` — the review
  send sheet, the launch paths, the session screen's reads and its writes.

Requirements are exactly the members a consumer reads unguarded, everything else
is a salvaged optional with main's own default applied in the transform, and no
schema is `.strict()`: a member a newer host adds passes through untouched.
Enum arm sets that a reader compares against pass through or degrade to the arm
the reader handles most conservatively; the two closed sets — the committed
change status and the diff kind — are closed because main *dropped* an arm it
did not know rather than passing it through, and degrading them would draw a row
or render a diff main never did. No member is coerced on the way back to the
host.

`github-pr-parsers.ts`, `github-pr-comment-parsers.ts` and
`github-pr-value-readers.ts` are gone; their suite is now the parity record for
the schemas that replaced them, with the four cases that refuse rather than
degrade marked as such. Twelve call-site casts are deleted, and three dead
"response was invalid" branches with them: the reader refuses those replies now,
so the error names its method.

The nine session files come off `unchecked-rpc-reader-inventory.ts` entirely
rather than being lowered. `git show --stat` on this commit touches nothing
under `mobile/rpc-foundation`.

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

* test(mobile): unit-pin every session reply schema's decision

Three kinds of case, one per kind of decision the schemas encode: a member a
consumer reads unguarded is required and its absence refuses, an arm set a
reader compares against degrades to the arm that reader handles most
conservatively, and a reply whose arms need different members is declared as
variants and each arm is read.

The last suite is the wire-compatibility claim: a member no reader knows passes
straight through, on the markdown document, the upload slot and the terminal
inventory alike, so a newer host is never refused for a field mobile does not
read.

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

* test(mobile): refresh the corpus for the session domain's checked readers

Repins `baseline` to the last commit touching a fenced path and re-records all
730 goldens, which is the disclosed behaviour change taken as an observation.

Decoded through the value pool against the pre-refactor tree on this branch:
688 header-only with `baseline` the only key that moved, 42 body-moved, 0 added,
0 deleted. The 42 are seven named scenarios and thirty-five matrix goldens, and
every moved checkpoint's own reply is malformed or refused. Three `normal`
partitions appear in the list and none of them reads a well-formed reply
differently: the review file-diff family's base scenario drives three legs and
its third is scripted `{ kind: 'unknown' }`, so that leg's checkpoint moves in
every variant, the varied leg included. The same append-only-history effect puts
`pr-read-upstream-error`'s `no-pr` checkpoint in the list for the malformed PR
recorded before it.

What the corpus now records, in one sentence: a property read on null, a V8
destructuring message shown to the user, and four hand-written "response was
invalid" strings are replaced by one message that names the method, and four
screens that published a malformed payload as ready state now show an error
instead.

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

* refactor(mobile): split the expanded check run out of the PR read schemas

`github-pr-read-reply-schema.ts` was 328 code lines against the 300-line cap.
The expanded check run and the annotations, jobs and steps listed under it are
one reply with no reader in common with the other six, so they move to
`github-pr-check-reply-schema.ts` whole. A move, not an edit: no schema changes
and no golden moves.

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

* test(mobile): repin the corpus to the branch's last fenced-path commit

The schema-module split touched `mobile/src`, so `--record` refuses on the pin
the previous refresh left behind. Repins to that commit and re-records. Decoded
against the previous corpus: 730 header-only with `baseline` the only key that
moved, 0 body-moved, 0 added, 0 deleted — the split is a move, and the corpus
says so.

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

* refactor(mobile): drop the worktree display-name cast's type import

The live-title read is typed by its schema now, so the cast it annotated is gone
and the import it needed with it. oxlint flags the leftover.

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

* test(mobile): repin the corpus to the branch tip

The unused-import removal touched a fenced path, so the pin moves with it.
Decoded against the previous corpus: 730 header-only on `baseline` alone,
0 body-moved, 0 added, 0 deleted.

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

* fix(mobile): contain a refused prChecks reply to the checks section

The checks read was the one phase-1 dependency that could take the whole PR
sidebar down. `loadPrSidebarData` routed `!checksOutcome.ok` through
`failureState`, so a host whose `github.prChecks` shape drifted cost the user
the title, body, comments, reviewers and merge controls — everything they
opened the sidebar for — over a section that renders a row of icons. Main
never noticed because its unchecked reader answered `[]` for the same reply;
this branch's reader refuses it, which is correct, and which is what makes the
containment necessary.

Contained the way phase 2 already is: a failed read keeps `kind: 'ready'`,
empties `checks`, and carries the message in a new `checksError` so the checks
section can say what happened. The sidebar can no longer reach `error` or
`blocked` on the checks read alone.

Also pins the enum departure this PR makes deliberately. The degrading arm
sets go through `salvagedOptional(name, z.enum(...))` rather than `openEnum`
because `openEnum` refuses a non-string where main mapped it to the
conservative arm; nothing held that, and all 2477 tests stayed green against
the swap. Six cases now hold both halves: a non-string degrades on the three
open sets, and an unknown arm drops the row on the closed ones.

Four deletions the reviewer found: a reaction-token alias with no importers,
the `errorType`/`fetchedAt` the branch-lookup reader fabricated to satisfy a
type whose only consumer reads neither, two bare schema aliases, and a
quick-commands pass-through with two callers.

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

* test(mobile): repin the corpus to the containment commit

`--record` refuses unless the product tree equals `baseline`, so the fix above
moves the pin. The corpus re-recorded in place against it: 730 goldens, every
one header-only on `baseline`, no observation moved.

No observation moved because no family reaches the code the fix changed. The
`github.pr-read` family calls the seven wrapper reads directly and records
their `{ ok, error }` outcomes; `loadPrSidebarData` sits a layer above that and
no scenario mounts it. The prChecks outcome is identical before and after —
what changed is what the sidebar does with it — so the unit suite is the only
oracle for the containment.

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

* test(mobile): record the PR sidebar's checks containment

The containment landed with no golden: no scenario mounted `loadPrSidebarData`,
so the row in the delta table rested on unit tests alone. `PrSidebarLoadDeps` is
five client-taking functions, so a new adapter drives phase 1 directly and
records the `PrSidebarState` it resolves to — no React host, and no edit to an
existing adapter, so no recorded golden moves.

Two scenarios: a normal load, and one whose checks leg answers a shape the
reader refuses. The matrix over the base then drives all eleven partitions at
`github.prChecks#1`, and every one of them records `ready` with a `checksError`
where main took the whole sidebar to `error`. `pr-sidebar-checks-failure-state`
is the mutant that routes the refusal back through `failureState`; it moves both
`pr-sidebar-checks-refused` and the prChecks matrix golden.

Also pins two closed-and-required enum decisions that were free to become
defaults — an unknown check-summary state drops the summary block, an unknown
reaction content drops the reaction — deletes four exported type aliases and
five enum constants with no reader outside their own file, makes
`PRChecksSection`'s `checksError` required so a second caller cannot silently
lose the message, and stops the header reading "No checks" when the checks were
unreadable rather than absent.

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

* test(mobile): repin the corpus to the pr-sidebar family commit

Six new goldens — two pilots and the four matrix sites the base scenario
scripts — and `baseline` on the 730 that already existed. No body moved and no
`adapterSha256`: the family is a new adapter module, so nothing recorded through
another one re-digests.

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

* test(mobile): re-record the corpus against the merged main

Repins `baseline` to the merge commit and re-records all 736 goldens in
place. Against `origin/main` the 705 shared goldens move only on
`baseline` (672 of them header-only), leaving the same 33 body moves and
the same partitions the branch carried before the merge, plus its 31
added goldens.

Every body also takes main's recorder shape from #21088: `sent` becomes
`ordinal` over one interleaved write counter, subscriptions record a
cleanup checkpoint, and a salvaging read now reports a `reply-salvage`
effect naming what it dropped.

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

* fix(mobile): keep an explicit null on the two tri-state PR flags

`autoMergeAllowed` and `mergeQueueRequired` carry three answers, not two:
`null` is GitHub saying auto-merge is not allowed, `undefined` is the host
not carrying the member at all. The readers coalesced the null away, so a
well-formed reply read differently from the parsers they replaced, which
preserved it explicitly. Both shared types already declare `boolean | null`.

No consumer separates the two today — `pull-request-auto-merge-availability`
compares with `=== true` and `!== false` — so this is parity, not a visible
fix, which is exactly why it needed a test.

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

* test(mobile): repin the corpus to the tri-state flag commit

All 736 goldens move on `baseline` alone: no scenario scripts an explicit
null on either flag, so preserving it changes no recorded screen.

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

* refactor(mobile): check the two session-write readers #21083 brought

Step 7 empties the session block of the unchecked-reader inventory, and
#21083 landed two readers into it after that: the New Tab create's member
read of `tab`, and the display-mode toggle's payload. Converting them is
what keeps the claim true — a session line reappearing would mean the
domain is not migrated.

`created-terminal-tab` requires `tab.id` and `tab.type === 'terminal'`,
because the strip keys the new tab on the id and spreads the rest into a
union whose arm `type` picks. `terminal`, `title` and `terminalTheme` stay
optional behind main's own guards, and unknown members pass through.
`terminal-display-mode-set` reads nothing, so it takes the same
`z.unknown()` the other five unread writes take.

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

* test(mobile): repin and re-record over #21083's corpus

All 736 goldens this branch already had move on `baseline` alone, and
#21083's 22 arrive beside them. One of the 22 moves against main's own
recording: `matrix-session.create-terminal-session.tabs.createterminal-1`,
where the New Tab create's five malformed partitions read
`Cannot read properties of undefined (reading 'tab')` and now read the
method's own message. Two of them also stop unsubscribing the terminal the
user was watching before the property read threw, so a create that never
happened no longer costs the live pane its subscription.

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

* docs(mobile): say what carries a refused create reply to the catch

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…en (stablyai#20659)

* fix(native-chat): deliver queued messages while the chat pane is hidden

With two or more messages queued, everything behind the head waited on the
user's attention. The drain only inspected the head and returned unless it was
`queued`, and a `pending` send deliberately leaves the head `dispatching`. An
entry only leaves that state through the journal subscription, which is torn
down when the pane goes hidden -- and a worktree switch hides it.

Two changes, both needed:

- One shared admission rule now says what the queue does next, and the drain
  takes its `dispatch`: the first `queued` entry, skipping entries the host has
  already acknowledged. It still stops at an `unconfirmed` entry or a refusal
  the user must act on. Order is not the outbox's to keep -- the host appends
  the submission inside the per-session serialize chain before dispatching, so
  journal order is arrival order. Holding the tail bought no ordering guarantee
  and cost delivery. Single-flight still keeps sends strictly sequential, and a
  launch prompt's in-flight send, which runs outside it, still stops the queue.
- The journal subscription now stays open while a session has undelivered outbox
  entries, published from the `writeOutbox` choke point. The subscription's
  retaining hold is what also keeps the host from evicting the session 15s after
  the last turn, which would otherwise turn the stall into a blocked head
  refusing `agent_session_ownership_unknown`.

An acknowledged entry stays in the outbox rather than retiring on `pending`: the
text is safe either way, since the journal upserts a render item from the
submission's own body, but a `pending` can still settle `rejected` or `unknown`
and only the entry carries the retry state that answer needs.

Follow-on corrections the head-only assumption had hidden:

- Single-flight is released where the disposition is applied, not in a later
  `.finally`. That state write is what re-runs the drain, so the release has to
  land first or the queue has no trigger left.
- One ref now holds the in-flight entry's id instead of a bare boolean, and the
  reconcile effect keys its release on that, not on the head, so a journal update
  about the head can no longer discard a still-unsettled send of the tail.
- A refusal blocks the entry it refused, read back by index so a rotated id is
  preserved.
- The automatic unknown probe and the Retry affordance both read the blocker at
  whatever index it sits, the Retry through the same shared rule as the drain.

`raises no delivery notice for a stuck message behind a healthy head` asserted
that a message behind an admitted head raises nothing, because a Retry could not
act on it. It now can, so that guard is rewritten to assert the notice names
that entry and its Retry sends that entry.

* fix(native-chat): resume outbox after journal admission and scope subscriptions

* test: name outbox send request by domain role
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…7) (stablyai#21089)

* test(mobile): record main's session reply behaviour at every unrecorded read site

Step 7 for the session domain changes how 51 RPC readers read a *malformed*
reply. Eleven of the session read sites had no recording family, so main's
answer to a malformed reply at those sites was undocumented and the reader
change would have had nothing to move. This commit is the before picture, taken
from main's own tree with no product edit in it.

Ten new families, twelve scenarios, twenty-five goldens:

- `session.review-file-diff` / `session.review-branch-diff` — `git.diff` and
  `git.branchDiff` read through the review projection, which the Changes
  screen's verbatim readers do not cover.
- `session.review-git-mutations` — the single-file `git.stage` / `git.discard`
  and the bulk stage sweep's second `git.stage`.
- `session.review-send-sheet` — `session.tabs.list` read for the agent
  terminals the send sheet lists, the third reader on that method. Needs an
  `open-send-sheet` action on the review-action adapter, which re-digests that
  family's eight goldens on `adapterSha256` and nothing else.
- `session.browser-tab-create` — `browser.tabCreate`.
- `agentSession.structured-create` — `agentSession.create`, whose family base
  only ever covered the support probe.
- `session.tab-rename` / `session.tab-close-session` — `terminal.rename` and
  `session.tabs.close`.
- `settings.new-tab-local-agents` — `preflight.detectAgents`, the arm the
  new-tab loader takes for a workspace with no connection.

`baseline` is repinned to main's tip because two commits (stablyai#20659, stablyai#21004)
touched a fenced path after the pilot's pin, so `--record` refuses on main's own
tree until it moves. The repin is what rewrites `baseline` on all 705 existing
goldens; nothing else about them moves.

Decoded against origin/main through the value pool: 705 header-only (`baseline`
on every one, `adapterSha256` on the eight review-action goldens), 0 body-moved,
25 added, 0 deleted.

Not covered, with the reason: the chunked clipboard upload's
`appendImageUploadChunk`, `commitImageUpload` and `abortImageUpload` cannot be
matrixed, because `replyMatrixSites` takes every completion in the base scenario
and the chain's later params carry the `uploadId` the start reply named. Driving
`clipboard.startImageUpload#1` therefore makes main send an append whose params
no scripted step matches, and the recorder raises `Request params mismatch:
clipboard.appendImageUploadChunk#1` instead of recording. The two families were
written, probed and removed.

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

* refactor(mobile): checked reply readers for the session domain (step 7)

Fifty-one unchecked reply readers across nine files become checked zod readers,
so a malformed host reply surfaces as one readable error at the operation
boundary instead of a downstream `TypeError`, a rendered `undefined`, or a
screen left ready over garbage. Deliberately a behaviour change on malformed
replies only.

Eight schema modules, one per reply family, each recording the consumer line
behind every requirement and the host handler that publishes it:

- `clipboard-image-reply-schema.ts` — the upload slot's `uploadId`, the commit
  and single-frame path strings, and the two legs whose body nothing reads.
- `github-pr-mutation-reply-schema.ts` — the `{ ok, error }` status envelope as
  two variants, and the bare-boolean confirmation.
- `github-pr-entity-reply-schema.ts` / `github-pr-read-reply-schema.ts` — the
  seven PR sidebar reads. Every identity requirement the hand parsers had is
  kept, so a payload that degraded to null still degrades to null; what changes
  is a payload that is not the declared container at all.
- `diff-review-reply-schema.ts` — the normalized branch compare, the review
  notes on the worktree record, the three file-diff arms, and the file-level git
  mutations.
- `review-terminal-reply-schema.ts`, `session-launch-reply-schema.ts`,
  `session-read-reply-schema.ts`, `session-write-reply-schema.ts` — the review
  send sheet, the launch paths, the session screen's reads and its writes.

Requirements are exactly the members a consumer reads unguarded, everything else
is a salvaged optional with main's own default applied in the transform, and no
schema is `.strict()`: a member a newer host adds passes through untouched.
Enum arm sets that a reader compares against pass through or degrade to the arm
the reader handles most conservatively; the two closed sets — the committed
change status and the diff kind — are closed because main *dropped* an arm it
did not know rather than passing it through, and degrading them would draw a row
or render a diff main never did. No member is coerced on the way back to the
host.

`github-pr-parsers.ts`, `github-pr-comment-parsers.ts` and
`github-pr-value-readers.ts` are gone; their suite is now the parity record for
the schemas that replaced them, with the four cases that refuse rather than
degrade marked as such. Twelve call-site casts are deleted, and three dead
"response was invalid" branches with them: the reader refuses those replies now,
so the error names its method.

The nine session files come off `unchecked-rpc-reader-inventory.ts` entirely
rather than being lowered. `git show --stat` on this commit touches nothing
under `mobile/rpc-foundation`.

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

* test(mobile): unit-pin every session reply schema's decision

Three kinds of case, one per kind of decision the schemas encode: a member a
consumer reads unguarded is required and its absence refuses, an arm set a
reader compares against degrades to the arm that reader handles most
conservatively, and a reply whose arms need different members is declared as
variants and each arm is read.

The last suite is the wire-compatibility claim: a member no reader knows passes
straight through, on the markdown document, the upload slot and the terminal
inventory alike, so a newer host is never refused for a field mobile does not
read.

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

* test(mobile): refresh the corpus for the session domain's checked readers

Repins `baseline` to the last commit touching a fenced path and re-records all
730 goldens, which is the disclosed behaviour change taken as an observation.

Decoded through the value pool against the pre-refactor tree on this branch:
688 header-only with `baseline` the only key that moved, 42 body-moved, 0 added,
0 deleted. The 42 are seven named scenarios and thirty-five matrix goldens, and
every moved checkpoint's own reply is malformed or refused. Three `normal`
partitions appear in the list and none of them reads a well-formed reply
differently: the review file-diff family's base scenario drives three legs and
its third is scripted `{ kind: 'unknown' }`, so that leg's checkpoint moves in
every variant, the varied leg included. The same append-only-history effect puts
`pr-read-upstream-error`'s `no-pr` checkpoint in the list for the malformed PR
recorded before it.

What the corpus now records, in one sentence: a property read on null, a V8
destructuring message shown to the user, and four hand-written "response was
invalid" strings are replaced by one message that names the method, and four
screens that published a malformed payload as ready state now show an error
instead.

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

* refactor(mobile): split the expanded check run out of the PR read schemas

`github-pr-read-reply-schema.ts` was 328 code lines against the 300-line cap.
The expanded check run and the annotations, jobs and steps listed under it are
one reply with no reader in common with the other six, so they move to
`github-pr-check-reply-schema.ts` whole. A move, not an edit: no schema changes
and no golden moves.

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

* test(mobile): repin the corpus to the branch's last fenced-path commit

The schema-module split touched `mobile/src`, so `--record` refuses on the pin
the previous refresh left behind. Repins to that commit and re-records. Decoded
against the previous corpus: 730 header-only with `baseline` the only key that
moved, 0 body-moved, 0 added, 0 deleted — the split is a move, and the corpus
says so.

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

* refactor(mobile): drop the worktree display-name cast's type import

The live-title read is typed by its schema now, so the cast it annotated is gone
and the import it needed with it. oxlint flags the leftover.

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

* test(mobile): repin the corpus to the branch tip

The unused-import removal touched a fenced path, so the pin moves with it.
Decoded against the previous corpus: 730 header-only on `baseline` alone,
0 body-moved, 0 added, 0 deleted.

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

* fix(mobile): contain a refused prChecks reply to the checks section

The checks read was the one phase-1 dependency that could take the whole PR
sidebar down. `loadPrSidebarData` routed `!checksOutcome.ok` through
`failureState`, so a host whose `github.prChecks` shape drifted cost the user
the title, body, comments, reviewers and merge controls — everything they
opened the sidebar for — over a section that renders a row of icons. Main
never noticed because its unchecked reader answered `[]` for the same reply;
this branch's reader refuses it, which is correct, and which is what makes the
containment necessary.

Contained the way phase 2 already is: a failed read keeps `kind: 'ready'`,
empties `checks`, and carries the message in a new `checksError` so the checks
section can say what happened. The sidebar can no longer reach `error` or
`blocked` on the checks read alone.

Also pins the enum departure this PR makes deliberately. The degrading arm
sets go through `salvagedOptional(name, z.enum(...))` rather than `openEnum`
because `openEnum` refuses a non-string where main mapped it to the
conservative arm; nothing held that, and all 2477 tests stayed green against
the swap. Six cases now hold both halves: a non-string degrades on the three
open sets, and an unknown arm drops the row on the closed ones.

Four deletions the reviewer found: a reaction-token alias with no importers,
the `errorType`/`fetchedAt` the branch-lookup reader fabricated to satisfy a
type whose only consumer reads neither, two bare schema aliases, and a
quick-commands pass-through with two callers.

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

* test(mobile): repin the corpus to the containment commit

`--record` refuses unless the product tree equals `baseline`, so the fix above
moves the pin. The corpus re-recorded in place against it: 730 goldens, every
one header-only on `baseline`, no observation moved.

No observation moved because no family reaches the code the fix changed. The
`github.pr-read` family calls the seven wrapper reads directly and records
their `{ ok, error }` outcomes; `loadPrSidebarData` sits a layer above that and
no scenario mounts it. The prChecks outcome is identical before and after —
what changed is what the sidebar does with it — so the unit suite is the only
oracle for the containment.

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

* test(mobile): record the PR sidebar's checks containment

The containment landed with no golden: no scenario mounted `loadPrSidebarData`,
so the row in the delta table rested on unit tests alone. `PrSidebarLoadDeps` is
five client-taking functions, so a new adapter drives phase 1 directly and
records the `PrSidebarState` it resolves to — no React host, and no edit to an
existing adapter, so no recorded golden moves.

Two scenarios: a normal load, and one whose checks leg answers a shape the
reader refuses. The matrix over the base then drives all eleven partitions at
`github.prChecks#1`, and every one of them records `ready` with a `checksError`
where main took the whole sidebar to `error`. `pr-sidebar-checks-failure-state`
is the mutant that routes the refusal back through `failureState`; it moves both
`pr-sidebar-checks-refused` and the prChecks matrix golden.

Also pins two closed-and-required enum decisions that were free to become
defaults — an unknown check-summary state drops the summary block, an unknown
reaction content drops the reaction — deletes four exported type aliases and
five enum constants with no reader outside their own file, makes
`PRChecksSection`'s `checksError` required so a second caller cannot silently
lose the message, and stops the header reading "No checks" when the checks were
unreadable rather than absent.

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

* test(mobile): repin the corpus to the pr-sidebar family commit

Six new goldens — two pilots and the four matrix sites the base scenario
scripts — and `baseline` on the 730 that already existed. No body moved and no
`adapterSha256`: the family is a new adapter module, so nothing recorded through
another one re-digests.

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

* test(mobile): re-record the corpus against the merged main

Repins `baseline` to the merge commit and re-records all 736 goldens in
place. Against `origin/main` the 705 shared goldens move only on
`baseline` (672 of them header-only), leaving the same 33 body moves and
the same partitions the branch carried before the merge, plus its 31
added goldens.

Every body also takes main's recorder shape from stablyai#21088: `sent` becomes
`ordinal` over one interleaved write counter, subscriptions record a
cleanup checkpoint, and a salvaging read now reports a `reply-salvage`
effect naming what it dropped.

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

* fix(mobile): keep an explicit null on the two tri-state PR flags

`autoMergeAllowed` and `mergeQueueRequired` carry three answers, not two:
`null` is GitHub saying auto-merge is not allowed, `undefined` is the host
not carrying the member at all. The readers coalesced the null away, so a
well-formed reply read differently from the parsers they replaced, which
preserved it explicitly. Both shared types already declare `boolean | null`.

No consumer separates the two today — `pull-request-auto-merge-availability`
compares with `=== true` and `!== false` — so this is parity, not a visible
fix, which is exactly why it needed a test.

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

* test(mobile): repin the corpus to the tri-state flag commit

All 736 goldens move on `baseline` alone: no scenario scripts an explicit
null on either flag, so preserving it changes no recorded screen.

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

* refactor(mobile): check the two session-write readers stablyai#21083 brought

Step 7 empties the session block of the unchecked-reader inventory, and
stablyai#21083 landed two readers into it after that: the New Tab create's member
read of `tab`, and the display-mode toggle's payload. Converting them is
what keeps the claim true — a session line reappearing would mean the
domain is not migrated.

`created-terminal-tab` requires `tab.id` and `tab.type === 'terminal'`,
because the strip keys the new tab on the id and spreads the rest into a
union whose arm `type` picks. `terminal`, `title` and `terminalTheme` stay
optional behind main's own guards, and unknown members pass through.
`terminal-display-mode-set` reads nothing, so it takes the same
`z.unknown()` the other five unread writes take.

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

* test(mobile): repin and re-record over stablyai#21083's corpus

All 736 goldens this branch already had move on `baseline` alone, and
stablyai#21083's 22 arrive beside them. One of the 22 moves against main's own
recording: `matrix-session.create-terminal-session.tabs.createterminal-1`,
where the New Tab create's five malformed partitions read
`Cannot read properties of undefined (reading 'tab')` and now read the
method's own message. Two of them also stop unsubscribing the terminal the
user was watching before the property read threw, so a create that never
happened no longer costs the live pane its subscription.

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

* docs(mobile): say what carries a refused create reply to the catch

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