Repository navigation
fix(remote): preserve terminal recovery across control refresh - #11513
Conversation
…oad-issue # Conflicts: # config/reliability-gates.jsonc # src/main/runtime/rpc/methods/terminal.ts # src/main/runtime/rpc/terminal-multiplex.test.ts # src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
…oad-issue # Conflicts: # config/reliability-gates.jsonc # tests/e2e/helpers/paired-terminal-parking-oracle.ts # tests/e2e/paired-remote-terminal-retention-memory.spec.ts
Greptile SummaryThis PR fixes a regression where a successful one-shot reachability probe calling
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the pre-ready socket-refresh path and all ordinary close/error/disconnect paths are unaffected. The transport fix is logically sound: ready waiters and pending requests are arrays/maps on the connection object that survive the socket swap, the original deadline timers are untouched, and the socket-generation fence ensures the discarded socket's close event is a no-op. The new unit oracle exercises the exact failure scenario with a real WebSocket server and verifies zero retained bytes after completion. E2E corrections tighten previously vacuous assertions without weakening product behavior. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/shared/remote-runtime-shared-control-connection.ts | Core fix: adds preserveReadyWaitersAndPendingRequests flag to closeSocket so reconnectNow() keeps in-flight RPCs alive across a pre-ready socket refresh; inlines the single-use scheduleReconnectAttemptReset helper with no behavior change. |
| src/shared/remote-runtime-shared-control-state.ts | Adds preserveReadyWaitersAndPendingRequests guard in closeSharedControlSocketState; when true, skips rejecting ready waiters and pending requests so they can migrate to the replacement socket. |
| src/shared/remote-runtime-shared-control-socket-close.ts | Threads the new preserveReadyWaitersAndPendingRequests flag through closeSharedControlSocket to closeSharedControlSocketState; minimal pass-through change. |
| src/shared/remote-runtime-shared-control-connection.test.ts | Adds a real encrypted-WebSocket test that withholds the first ready frame, triggers a reconnectNow(), and verifies the RPC completes on the second connection with zero retained bytes; adds suppressReadyFrameCount to the server factory. |
| tests/e2e/helpers/paired-terminal-parking-oracle.ts | Adds options.hostPage parameter and expectHostTerminalsUnmounted helper that asserts zero host pane managers for the remote tabs using raw host tab IDs (via toHostSessionTabId), correcting the earlier vacuous assertion issue with client-prefixed IDs. |
| tests/e2e/paired-remote-terminal-retention-memory.spec.ts | Uses the active worktree's own ID (instead of worktreeIds[0]) as fallbackWorktreeId for the parking oracle, and passes orcaPage as hostPage to enable the new unmounted-terminals assertion. |
| tests/e2e/new-workspace-linked-item-project-switch.spec.ts | Adds getJiraSourceContext to read the actual active project host setup and Jira identity from the store, supplying a valid taskSourceContext that satisfies the current source-identity contract. |
| tests/e2e/terminal-long-table-fixtures.ts | Consolidates the emoji table completion marker and width marker into a single output line; the old marker string remains a prefix of the new combined line, so existing toContain(marker) checks in specs continue to work. |
| config/reliability-gates.jsonc | Updates invariant/oracle descriptions and coverage notes to reflect the new socket-refresh preservation guarantee and the host-renderer unmount assertion; adds the new unit-test command and its passing run result. |
Sequence Diagram
sequenceDiagram
participant C as Client (request caller)
participant Conn as SharedControlConnection
participant S1 as Socket 1 (pre-ready)
participant S2 as Socket 2 (replacement)
participant H as Host
C->>Conn: request('worktree.ps', 1000ms)
Note over Conn: pendingRequests.set(id, ...)<br/>readyWaiters.push(waiter)
Conn->>S1: open() - awaiting_ready
Note over S1: ready frame suppressed
Note over Conn: status probe succeeds, reconnectNow()
Conn->>Conn: "closeSocket(error, preserveWaiters=true)"
Note over Conn: readyWaiters and pendingRequests PRESERVED<br/>subscriptions marked unsent
S1--xConn: ws.close() stale generation ignored
Conn->>S2: open() new generation
S2-->>Conn: e2ee_ready frame
Note over Conn: resolveSharedControlReadyWaiters()<br/>waiter resolved, send(requestId)
Conn->>H: encrypted RPC (worktree.ps)
H-->>Conn: response
Conn-->>C: resolve ok true result
Note over Conn: pendingRequests.delete(id)<br/>retainedBytes = 0
Reviews (5): Last reviewed commit: "test(terminal): keep restore sentinel on..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughShared-control reconnects now preserve pending requests and ready waiters during transport replacement while resetting readiness state. New tests cover pre-ready socket replacement and request resolution. E2E retention checks verify host terminals remain unmounted during recovery, and reliability gates include the updated contracts. The workspace project-switching test now derives and passes Jira task source context to the composer. Terminal table fixtures now use a derived width marker and omit the standalone restore marker. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5b59b52c-0b25-410d-a540-d70eb20fba03
📒 Files selected for processing (9)
config/reliability-gates.jsoncsrc/main/daemon/daemon-pty-router-events.tssrc/main/daemon/daemon-pty-router.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-socket-close.tssrc/shared/remote-runtime-shared-control-state.tstests/e2e/helpers/paired-terminal-parking-oracle.tstests/e2e/paired-remote-terminal-retention-memory.spec.ts
|
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|
Svelte específicamente en este proyecto |
…yai#11513) * fix(remote): recover stalled terminal streams * fix(i18n): localize manual disconnect error * fix(remote): park paired terminals with host snapshots * test(remote): mock authoritative resync snapshots * fix(terminal): defer startup mounts until hydration * fix(remote): raise paired terminal stream capacity * fix(remote): harden terminal recovery lifecycle * fix(remote): preserve calls across control refresh * test(remote): harden paired recovery oracle * test(workspace): seed Jira source context * test(remote): assert raw host terminal identities * test(terminal): keep restore sentinels atomic * test(terminal): keep restore sentinel on one row --------- Co-authored-by: OrcaWin <[email protected]>
Summary
mainline budgets.Deterministic reproduction
The encrypted-WebSocket oracle reproduces the screenshot error exactly:
It withholds the first ready frame, starts one RPC, then lets a successful one-shot
status.getcallreconnectNow(). Before the fix, replacing the pre-ready socket rejects that RPC. After the fix, the original call survives the refresh and completes through the replacement socket under its original deadline.The oracle requires exactly two connections, one authoritative host RPC, one successful response, zero pending calls, and zero retained request bytes. Ordinary close, error, and manual disconnect paths still reject rather than migrate calls.
Field evidence and lifecycle coverage
On
v1.4.162-rc.1, opening the affected parked terminal on the Windows host over RDP caused the existing client terminal to recover. This shows the PTY could remain alive while client recovery depended on mounting the host renderer.The headed oracle now converts mirrored web tab IDs back to raw host tab IDs and pins the host's actual pre-pairing active workspace. It requires zero matching host pane managers before and after client recovery while the client restores row 4,000, parked-time output, the same PTY, and live input/output. The same parking contract runs against isolated headed desktop-server and headless
orca servetopologies.Release ancestry
v1.4.162-rc.1commit62c51e77b2predates merged PR #11416 and does not containterminal.paired-parking.v1. It contains neither #11416's paired-terminal parking design nor this control-refresh follow-up.Validation
pnpm run typecheckpnpm run lint, reliability manifest, and max-lines ratchetgit diff --checkScreenshots
No visual change.
AI Review Report
Security Audit
Notes
The Jira E2E failure was a stale fixture: current Orca correctly rejects Jira linked items without matching source identity. The fixture now supplies the active project/host and matching Jira site/project identity; product behavior was not weakened.