Repository navigation
fix(mobile): replay terminal creates killed by transport cutover - #9796
brennanb2025 wants to merge 4 commits into
Conversation
A quick command tapped right after opening a session over relay could fail with a bare "Couldn't run <label>" toast: the relay→direct cutover (migrateTo in stable-logical-rpc-client) rejects in-flight requests with LogicalClientCutoverError while connState stays 'connected', so the session.tabs.createTerminal RPC died client-side and the desktop never saw it. Same mechanism proven for the capability probe in #9794. Fix: replay the create with the SAME clientMutationId on cutover (bounded, immediate — the replacement session is already authenticated), mirroring tasks/worktree-create-retry.ts. The host has deduped createTerminal by mutation id (e253d46) since before it advertised terminal.quick-commands.v1 (5fcf777), so gating the replay on that capability provably cannot double-create on older hosts. Also stop masking the underlying failure: the toast now appends the real RPC/transport reason, and tapping a quick command while disconnected says so instead of doing nothing.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a runtime capability for idempotent session terminal creation and preserves mutation-based terminal work across interrupted connections. Mobile terminal creation now uses capability-gated, bounded retries with the same mutation ID after cutover errors. The session screen tracks runtime support, formats terminal creation failures, extends error toast duration, and reports disconnected quick-command launches explicitly. Tests cover runtime replay, retry behavior, capability gating, error formatting, and retry bounds. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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.
🧹 Nitpick comments (1)
mobile/src/session/session-terminal-create-retry.ts (1)
14-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the shared cutover-retry loop.
sendSessionTerminalCreateResilientuses the same bounded, capability-gated cutover retry pattern assendWorktreeCreateResilient; a shared helper would keep the retry budget and error classification from drifting.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 12f2d807-a18d-4f5a-adb5-60940157472f
📒 Files selected for processing (9)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/session/session-terminal-create-retry.test.tsmobile/src/session/session-terminal-create-retry.tsmobile/src/terminal/quick-commands.test.tsmobile/src/terminal/quick-commands.tsmobile/src/transport/stable-logical-rpc-client.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/shared/protocol-version.ts
…le-quick-command # Conflicts: # mobile/app/h/[hostId]/session/[worktreeId].tsx # mobile/src/transport/stable-logical-rpc-client.ts
Manual QA evidenceValidated the mobile Quick Command flow against this branch using an iPhone 17 Pro simulator paired to the branch-specific Electron dev app. One tap created exactly one new terminal (1 → 2 tabs), selected Terminal 2, and ran Mobile Electron Post-conflict validation: mobile tests 2,186 passed (2 skipped), mobile typecheck/lint passed, and runtime/protocol tests 810 passed. |
…gration (#9798) Opening the Quick Commands sheet right after connecting over relay races the relay->direct cutover, which rejects the in-flight one-shot settings.getTerminalQuickCommands with LogicalClientCutoverError while connState stays 'connected'. The sheet then strands on "RPC interrupted by connection migration" with an empty list until closed and reopened. The read is side-effect-free, so replay it on cutover (capped at 5, cancelled if the sheet closes or the client is replaced). Same failure class and pattern as #9794 (capability probe) and #9796 (terminal create).
|
Close this older implementation after creating a GitHub issue for terminal creation interrupted by a phone connection change. Keep safe retries and useful failure feedback in the current host launch path. The remaining problem is tracked in #27646. |
…gration (stablyai#9798) Opening the Quick Commands sheet right after connecting over relay races the relay->direct cutover, which rejects the in-flight one-shot settings.getTerminalQuickCommands with LogicalClientCutoverError while connState stays 'connected'. The sheet then strands on "RPC interrupted by connection migration" with an empty list until closed and reopened. The read is side-effect-free, so replay it on cutover (capped at 5, cancelled if the sheet closes or the client is replaced). Same failure class and pattern as stablyai#9794 (capability probe) and stablyai#9796 (terminal create).


Problem
Tapping a quick command on mobile shortly after opening a session over relay could fail with a bare "Couldn't run codex review" toast. Desktop-side there was zero trace — no PTY, no tab, nothing in the daemon log: the request never arrived.
Root cause: the relay→direct cutover (
migrateToinstable-logical-rpc-client.ts) rejects all in-flight requests withLogicalClientCutoverErrorwhileconnStatestays'connected'. The cutover fires seconds after connecting over relay — exactly when a quick command gets tapped after opening a session. Same mechanism as the capability-probe loss addressed in #9794.Fix
session.tabs.createTerminalwith the sameclientMutationIdwhen a cutover kills it, bounded to five authenticated cutovers.session.tabs.create-terminal-idempotency.v1only with that disconnect-safe behavior, and require this exact capability before mobile replays. Hosts that only advertise Quick Commands fail closed rather than risking a duplicate terminal.Timeout-shaped losses that are not identified as cutovers are intentionally not replayed.
Reliability contract
terminal-session.create-cutover-idempotency— one mutation creates at most one terminal across relay/direct connection migration.terminal:requestTabCreate; client tests require the same key, explicit capability, non-cutover propagation, and a six-attempt hard ceiling.config/reliability-gates.jsoncentry exists yet. Deterministic mobile and host unit contracts cover this PR.Verification
orca-runtime.test.ts.