Skip to content

fix(native chat): retain transcript while reconnecting (STA-3333) - #12495

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/sta-3333-reconnect-cache
Aug 6, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/sta-3333-reconnect-cache

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Manual reconnect no longer blanks an already-settled native-chat transcript while the replacement client reloads the same conversation.

  • Shares one identity-bounded transcript-retention policy between desktop and mobile instead of duplicating cache logic.
  • Keys retention to the runtime/source owner, agent, session, and transcript path so host, workspace, owner, session, or path changes cannot leak messages.
  • Retains only one settled message list and exposes it only during the same identity's loading state; settled errors and other non-loading states remain authoritative.
  • Keeps live interactive asks authoritative and suppresses transcript-derived ask cards until the fresh transcript read settles.
  • Preserves current main behavior for mobile replay/pagination fencing, session options, prompt dismissal, and sticky-status gating.
  • Resolves the branch conflicts with current main.

Refs STA-3333.

Performance and safety

The cache is hook-local, one-entry, and identity-bounded. It adds no polling, global state, unbounded growth, broad scans, or message copying. SSH-backed runtimes and folder workspaces use the same opaque identity inputs as local git worktrees.

Testing

  • Root focused Vitest: 35/35 passed.
  • Full mobile Vitest: 3,207 passed, 3 skipped.
  • Root and mobile typechecks passed.
  • Targeted oxfmt and oxlint passed.
  • Max-lines and reliability gates passed with no suppressions.
  • Changed-code quality under Node 24: 0 native, type-aware, or React Doctor findings across all 14 changed files.
  • Fresh same-model review of the final pushed head returned CLEAN without edits.
  • Electron smoke passed on the final pushed head through CDP with an isolated profile; renderer console and page errors were empty.
  • iOS manual reconnect passed on the dedicated iPhone 17 Pro simulator: the four-message transcript remained visible during the disconnected state and at +3s inside a 15-second replacement-client read; post-settle AX showed identical frames with no duplicates or scroll jump.

Screenshots

See the final QA evidence comment on this PR. Attachments are hosted outside the branch diff.

A manual retry closes the client and opens a fresh one, so the chat session
hook saw a new client under an unchanged identity, dropped its settled read,
and handed out an empty list — the transcript collapsed to a full-screen
spinner until the swapped client's snapshot landed.

Hold the last settled list per identity (captured post-commit) and keep
rendering it while the re-read is in flight. `transcriptLoading` still gates
consumers that decide from an empty transcript, so the launch-draft seed is
unaffected. The held list is keyed by a new `sourceIdentity` (host/workspace)
in addition to agent/session/transcript, so it can never serve another
source's messages.

Refs STA-3333.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The native chat controller now creates a shared host/worktree sourceIdentity. The session hook includes this identity in session tracking. During same-identity client reconnects, the hook retains the last settled messages while loading and replaces them after the fresh snapshot arrives. Source identity changes clear the cached messages. Transcript-derived asks are suppressed while loading, while status-derived asks remain available. Tests cover these behaviors.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the summary, screenshots, and testing sections but omits the required AI Review Report, Security Audit, and Notes sections. Add the AI Review Report, Security Audit, and Notes sections, and state the build status explicitly.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 describes retaining the native chat transcript during reconnects and includes the relevant issue reference.
✨ Finishing Touches
📝 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.

…rame

The re-subscribe lands a commit after the first render of the swap, so a
regression that cleared the held list there left frame 0 green and still
blanked the transcript. Verified: clearing the cache in the subscribe
cleanup now fails this test, where before only the view-toggle test caught it.
The cache this PR adds keeps the previous list rendered while a swapped
client re-reads. useMobileNativeChatPrompts was the one consumer reading
`messages` without honouring `transcriptLoading`, so an ask answered on
the terminal resurrected as a live, tappable card during that window.

Gating on `transcriptLoading` is exactly base behaviour: `setRead` only
ever stores 'ready'/'error', so status==='loading' implied an empty list
before this PR. The live `askFromStatus` path is untouched.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Emulator QA — A/B on a real iOS Simulator (STA-3333 / #12495)

Ran /orca-mobile-emulator-qa on a dedicated iPhone 17 Pro simulator (STA-3333 ReconnectCache QA) against a paired mock desktop, then A/B'd the same device against the base hook via Metro fast refresh. No Computer Use / AppleScript / OS-level input injection — all taps went through orca emulator tap.

Rig

  • Mock runtime with MOCK_NATIVE_CHAT=1, E2EE-paired to the sim, serving a 4-message transcript with two marker lines.
  • A throwaway patch to nativeChat.subscribe let me stall the snapshot by a control file. It was reverted before this comment — the branch is clean at dd803c0416 and carries only the 5 reviewed files.
  • Manual reconnect exercised through the real surface: freeze the runtime → header degrades to "Can't connect — tap to retry" → tap it → ctx.forceReconnect closes the old RpcClient and mints a new one. The mock log confirms the swap — the post-reconnect request id restarts at rpc-1-…, i.e. a brand-new client, with the same host/worktree/agent/session identity.
  • Transcript re-read stalled 15s so the in-flight window is observable rather than a single frame.

Result

This PR (dd803c0416) Base (e9cf1067)
t+5s into the re-read held spinner
Cached transcript stays on screen Collapses to a full-screen spinner

Same device, same mock, same tap sequence, same 15s stall — only the hook module differed.

  • Held for the whole 15s window (checked at t+2s, t+5s, t+10s), not just the first frame.
  • Settled state after the read lands is byte-identical to before the reconnect — no duplicated messages, no flash, no scroll jump: settled
  • Base recovers once the read lands, confirming the blank window is exactly the read window and the only delta is what renders during it: base recovered
  • Composer stayed correctly gated ("Waiting for terminal…") for the whole held window — the cache does not re-open the input floor early.

Desktop smoke (/electron)

Launched the branch's dev build on an isolated profile/CDP port, attached over CDP with a pinned named session, verified identity is this worktree (Orca: brennanb2025/sta-3333-reconnect-cache), app renders, 0 renderer console errors: screenshot

Stated plainly: this is a smoke test only. The diff is confined to mobile/src/session/, and grep over src/ finds no desktop importer of the three touched modules, so there is no desktop surface that this change can alter.

Gates

Full mobile suite 3015 passed / 3 skipped / 0 failed; React Doctor 0 issues; max-lines ratchet OK; mobile typecheck, oxfmt and oxlint clean; changed-code-quality reconstructed manually → 0 new findings.

@brennanb2025 brennanb2025 changed the title fix(mobile): keep the cached transcript visible while manually reconnecting (STA-3333) fix(native chat): retain transcript while reconnecting (STA-3333) Aug 5, 2026
@brennanb2025

brennanb2025 commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Final QA evidence for PR head 4db77ffb7c7c7cfe69098743c95f4c64dac9603f.

Electron smoke on final head — passed

CDP-only validation with an isolated profile rendered the app normally. Interactive snapshot succeeded; renderer console and page errors were empty.

Electron smoke on final head

iOS manual reconnect — passed

Dedicated iPhone 17 Pro simulator with an isolated four-message transcript and 15-second delays on both nativeChat.subscribe and nativeChat.readSession.

Disconnected state retained all four messages and gated the composer:

Disconnected transcript retained

After the mock restarted, manual reconnect was tapped at 18:50:24Z. AX at +3s—definitively inside the 15-second replacement-client read—showed ALPHA/BRAVO/CHARLIE/DELTA exactly once at their original frames. The held screenshot was captured at +4s:

Transcript held during replacement-client read

Post-settle AX at +28s showed the same four messages exactly once at identical frames, with no duplicate or scroll jump:

Transcript after replacement-client read settled

The held and post-settle PNGs are bit-for-bit identical (SHA-256 36fc6e0ea6d23e9c97190d9a3ca574bd19007158fe85da25826ae6f6abb7ff53), confirming no visual flash or movement across settle.

Final validation: root focused 35/35, full mobile 3,207 passed/3 skipped, root/mobile typechecks, targeted format/lint, max-lines, reliability, and changed-code quality all passed. A fresh same-model review of the final pushed head returned CLEAN without edits. QA fixtures and lockfile churn were reverted; servers/helpers stopped; worktree and remote head remained clean and unchanged.

@brennanb2025
brennanb2025 merged commit 79896cb into main Aug 6, 2026
43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ablyai#12495)

* fix(mobile): keep the cached transcript visible while reconnecting

A manual retry closes the client and opens a fresh one, so the chat session
hook saw a new client under an unchanged identity, dropped its settled read,
and handed out an empty list — the transcript collapsed to a full-screen
spinner until the swapped client's snapshot landed.

Hold the last settled list per identity (captured post-commit) and keep
rendering it while the re-read is in flight. `transcriptLoading` still gates
consumers that decide from an empty transcript, so the launch-draft seed is
unaffected. The held list is keyed by a new `sourceIdentity` (host/workspace)
in addition to agent/session/transcript, so it can never serve another
source's messages.

Refs STA-3333.

* test(mobile): assert the whole reconnect window, not just its first frame

The re-subscribe lands a commit after the first render of the swap, so a
regression that cleared the held list there left frame 0 green and still
blanked the transcript. Verified: clearing the cache in the subscribe
cleanup now fails this test, where before only the view-toggle test caught it.

* fix(mobile): don't derive a tappable ask card from the held transcript

The cache this PR adds keeps the previous list rendered while a swapped
client re-reads. useMobileNativeChatPrompts was the one consumer reading
`messages` without honouring `transcriptLoading`, so an ask answered on
the terminal resurrected as a live, tappable card during that window.

Gating on `transcriptLoading` is exactly base behaviour: `setRead` only
ever stores 'ready'/'error', so status==='loading' implied an empty list
before this PR. The live `askFromStatus` path is untouched.

* chore: keep merge formatting scoped
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