Repository navigation
fix(remote-runtime): a paired terminal accepts input again after its host app relaunches - #25736
Conversation
A relaunched desktop host accepts RPC before its renderer publishes a window graph. During that gap session.tabs.list answers with an unpublished empty graph (publicationEpoch "none", snapshotVersion 0, tabs []). The client's reconnect inventory treats that as removal and retires the pane (retireRemoteTerminalId(-1)): the pane goes to "ended", the reconnect overlay disappears, and keystrokes never reach the surviving daemon PTY. Both tests are red on main by design; they are the repro for the fix. - e2e: holds the relaunched host's runtime:syncWindowGraph so the client's reconnect deterministically meets the unpublished host (4/4 red). - unit: transport-level repro of the same retirement (red in ~2s). - restart helper gains a beforeFirstWindow hook; LaunchOptions moves to its own module to stay under the max-lines budget.
After the host app quit and relaunched (daemon still running), a paired client's terminal cleared its reconnect overlay and then ignored all input. The relaunched host answers session.tabs.list before its renderer publishes, with a synthesized empty frame. A paired client sees that frame through its navigation projection as epoch "none:client-navigation", which the shared "does this frame answer for the worktree" check did not recognise, so the pane read it as removal and retired itself. - hostSnapshotAffirmsWorktreeContents treats the client-projected placeholder as no answer at any version (the projection adds its navigation revision). - The reconnect inventory keeps polling on such a frame instead of retiring; a published frame lacking the surface still retires the pane. - Pushed frames that affirm nothing no longer report the surface absent. - When the bounded inventory wait ends without evidence, the first published snapshot carrying the same handle now reattaches the pane, rather than waiting out the ~3 minute auto-recovery deadline. Client-only: the host already labels the frame, old hosts send the same frame, and the wire is unchanged. The e2e helper drops its type assertions.
- One epoch rule: the placeholder epoch, bare or with the shared client-navigation suffix, is no answer. Hosts only ever send it at version 0, so the version check is dropped. - Unpublished frames are dropped where pushed snapshots enter, instead of a nullable per-subscriber update. - A published same-handle snapshot fires the parked retry through retryNow(), which now also fires a retry parked while still 'recovering' (nothing is in flight then). This replaces state-reading wiring in the listener and lets online/resume fire it too. - The Windows e2e runs the fixture through PowerShell's call operator.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughSnapshot authority now treats unpublished host-graph epochs, including client-navigation projections, as non-authoritative. Remote PTY recovery keeps polling when an unpublished graph omits a terminal surface and retries eligible same-handle updates. Empty-worktree responses use authoritative publication epochs after graph publication. New unit and end-to-end tests cover delayed graph publication, terminal reattachment, and input after reconnect. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No concrete issue remains that would prevent merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The reconnection change preserves the distinction between a host still starting and a terminal actually being removed. One limited availability concern remains: pending publication notifications can outlive their requesting connection when startup stalls. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 22.58% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 23 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — one test-integrity suggestion inline.
Reviewed changes
- Placeholder epoch recognized in both forms (
host-session-snapshot-authority.ts, sharedCLIENT_NAVIGATION_PUBLICATION_EPOCH_SUFFIX):hostSnapshotAffirmsWorktreeContentsnow keys only on the epoch, so a paired client'snone:client-navigationprojection — which carries a nonzerosnapshotVersion— is treated as "no answer" again. Confirmed the host placeholder is only ever emitted at version 0, so dropping the version half does not misclassify any genuine host answer. - Transport keeps asking on an unpublished frame (
remote-runtime-pty-transport.ts): inventory absence retires the pane only when the frame affirms; a synthesized placeholder keeps the bounded (15s) loop alive instead of returninghandle: null. - First published update reattaches (
remote-runtime-pty-transport.tsupdate listener +remote-runtime-pty-recovery-state.ts):retryNow()now fires a retry parked duringrecovering, so the host's own republish reconnects the pane rather than waiting out the ~3-minute recovery deadline. Traced thatrecovering + pendingRetryonly ever means a parked retry with nothing in flight, so this cannot double-reconnect. - Placeholder frames dropped at the handle-event boundary (
web-session-terminal-handle-events.ts), plus unit coverage that fails without the fix and an e2e repro that holds the relaunched host's graph publication.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| export async function holdWindowGraphPublication(app: ElectronApplication): Promise<void> { | ||
| await app.evaluate(({ ipcMain }, channel) => { | ||
| Reflect.set(globalThis, '__e2eGraphHeld', true) | ||
| Reflect.set(globalThis, '__e2eGraphPublished', 0) |
There was a problem hiding this comment.
The counter is zeroed here at install and never compared against a pre-install value, so releaseWindowGraphPublication(...).toBe(0) in the spec proves only that no publication completed after install — not that the hold beat the host's first publication. If the relaunched renderer already completed its first runtime:syncWindowGraph before this beforeFirstWindow evaluate runs (there is a CDP round-trip plus assertElectronResolvedIsolatedHome ahead of it in orca-restart.ts:183-190), the wrap silently no-ops and the e2e can pass against unfixed code.
Technical details
# Hold does not prove it won the race against the host's first graph publication
## Affected sites
- tests/e2e/helpers/hold-window-graph-publication.ts:13-14 — `__e2eGraphPublished` initialized to 0 with no record of whether a publication already happened.
- tests/e2e/helpers/hold-window-graph-publication.ts:32-38 — the wrap silently no-ops if `_invokeHandlers` is not a `Map` or the channel handler is absent, with no install self-check and no return value the caller verifies.
- tests/e2e/paired-remote-terminal-host-quit-reconnect-input.spec.ts:330-333 — `expect(releaseWindowGraphPublication(...)).toBe(0)` is the assertion that is meant to guarantee the client met an unpublished host.
## Required outcome
- `toBe(0)` should mean "the hold was installed before the host's first publication", so a lost install race fails the spec instead of silently making it pass against unfixed code.
## Suggested approach (optional)
- At install, verify the handler was actually wrapped (and fail loudly if not), and record whether any publication had already completed before install; assert that pre-install count is 0 (or expose the runtime's already-published graph state) rather than assuming the reset-to-zero is meaningful.…irst publish The spec now asks the held host for its tab list and requires the unpublished placeholder before releasing, so a hold installed too late fails instead of passing against unfixed code. The helper keeps its gate in a typed global instead of Reflect lookups.
A retry parked for a handle that needs a replacement was consumed by an early external trigger and then refused by the epoch's snapshot-wait guard, leaving nothing to revive the pane. An external trigger now takes over that snapshot wait as a fresh attempt, and a republished fenced handle no longer fires the retry. Also refreshes comments that still paired the placeholder epoch with version 0.
…t has published The host sent its unpublished placeholder for any worktree it had no entry for, including one its window had never opened, long after startup. With the placeholder now read as "ask me later", a paired client opening such a worktree never got its first terminal. The host now sends the placeholder only until its graph first publishes. Afterwards a worktree with no tabs gets a real empty answer, and a client that was told "ask me later" during startup is sent that answer once on publication. Against an older host the client withholds the automatic first terminal for such a worktree, which the user can still create. A host push now fires only a parked retry, never cutting a scheduled backoff short.
… later Hosts before #25736 answer an empty workspace with "ask me later" and never follow it with a real answer, so waiting for that answer left a blank workspace with no terminal against them. Wait only on hosts that advertise session-tabs.empty-worktree-answer.v1; older hosts keep main's behaviour. Workspaces this client just created are known empty and open their first terminal without waiting. Co-Authored-By: Claude <[email protected]>
…ing a terminal (#28154) * fix(remote-runtime): wait for the host's terminal list before opening a terminal A paired client opening a workspace whose terminals it had not heard about yet read "no answer from the host" as "zero terminals" and asked the host for one. When the host's list then arrived with terminals, the workspace gained an extra terminal; when it arrived empty, the first-frame bootstrap created a second one. The client now treats an unknown host count as unknown. Activation without explicit startup work waits, and the active subscription's first real answer seeds the workspace if it is empty. An "ask me later" frame from a host that has not published yet no longer records a count of zero, and the host's later answer (sent as an update) is accepted as the first answer for seeding. * fix(remote-runtime): count an unknown host as empty unless it answers later Hosts before #25736 answer an empty workspace with "ask me later" and never follow it with a real answer, so waiting for that answer left a blank workspace with no terminal against them. Wait only on hosts that advertise session-tabs.empty-worktree-answer.v1; older hosts keep main's behaviour. Workspaces this client just created are known empty and open their first terminal without waiting. Co-Authored-By: Claude <[email protected]> * fix(remote-runtime): log a failed delayed terminal open; drop an inert flag Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>

ELI5
When the Orca app on a paired host machine is quit and reopened, the terminals keep running in the background. A client connected to that host showed "Reconnecting…", the message went away, and then typing into the terminal did nothing. Now the client waits for the host to finish starting and reconnects the same terminal, so typing works again.
What Changed
Before: a reopened host starts answering requests before its window has reported its tabs. In that gap it answers "what tabs exist?" with a placeholder: an empty list marked "not published yet". The client already knew how to read that marker, but only the bare form. A paired client receives the placeholder through its per-client view, where the marker is renamed (
nonebecomesnone:client-navigation). So the client took the empty list to mean the terminal was closed and shut the pane down for good. The overlay cleared and input went nowhere.After:
hostSnapshotAffirmsWorktreeContents): the placeholder marker counts as "no answer" in both its bare and per-client forms. The per-client suffix is now a shared constant used by both host and client. Every client reader of this rule benefits, not just terminals.retryNow()can now fire a retry parked while recovery is still running (nothing is in flight at that point), so going back online or waking the machine can fire it too.Why
The host already labels the frame as unpublished; the client was misreading one spelling of the label. Fixing it on the client also covers older hosts, which send exactly this frame. The host change makes the placeholder honest: it now means only "still starting". Older clients read the new empty answer correctly, since it is just an ordinary empty list. Against an older host, a new client doesn't automatically create a first terminal in a worktree that host never opened, because it can't tell that apart from a host still starting. The user can still create one, and holding back an automatic action is the safe direction when versions differ. The alternative was to make the host hold back its tab list until its window publishes. That would slow every caller of that request (mobile, CLI), could hang if the window never publishes, and changes what the host publishes to every client. Firing the existing parked retry reuses the normal reconnect path, rather than adding a separate reattach state. Older clients keep the bug until they update, which is acceptable.
Linked Issue
N/A (internal report).
Visual Proof
N/A. This changes reconnect behavior with no UI change. The e2e checks the rendered pane: the overlay clears, typed text reaches the host terminal, and the echo appears.
Testing
e2e repro,
tests/e2e/paired-remote-terminal-host-quit-reconnect-input.spec.ts: a real host and a paired client run on isolated profiles. The host app quits and reopens while its background terminal process survives. The reopened host is held before it publishes its tabs, then the test types through the pane.recovery: ended); 3/3 green after.recovery: endedsymptom as the field; 3/3 green after. The spec now launches its fixture through PowerShell's&call operator so it can run on Windows.e2e first terminal,
tests/e2e/paired-client-first-terminal-unopened-host-worktree.spec.ts: a paired client adds a repo through the host, so the host's window never opens it, then opens it on the client and expects a first terminal. It passes before this PR, failed partway through it (the regression this commit fixes), and passes now.Host unit tests (
session-tabs-empty-worktree-publication.test.ts): the placeholder is sent only before publication; afterwards the answer is a real empty list; a client that asked during startup is told once on publication; nothing extra is sent when the publication already includes the worktree.Unit tests (
remote-runtime-pty-transport-unpublished-host-graph.test.ts,web-session-tabs-sync-terminal-bootstrap.test.ts):Existing suites: all transport, recovery-state, and session-snapshot suites pass, plus
pnpm tcand the changed-code gate. Two tests that pinned "a placeholder with a nonzero version counts as an answer" were removed: no host has ever sent that.SSH: unaffected, since this path is the paired remote runtime. The change follows the execution-boundary rule that absence is never evidence a process exited.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
An independent review pushed for the simplest design: a single epoch rule, dropping placeholder frames where they enter, and firing the parked retry instead of reading phase, epoch, and policy state in the listener. All of it is applied.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)