Repository navigation
fix(mobile): survive connection-migration cutovers during worktree create - #9234
Conversation
|
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 (11)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds optional 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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)
src/main/runtime/orca-runtime.test.ts (1)
1406-1417: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winCover successful-entry expiry, not only reuse.
This proves retention but not eviction after the 60-second TTL. Permanent caching would still pass, retaining promises and returning stale results for reused keys. Add a clock-controlled assertion that a post-TTL call runs the factory again.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 256f8b03-fcda-4aa2-b9c6-d367da979450
📒 Files selected for processing (8)
mobile/src/tasks/blank-workspace-create.test.tsmobile/src/tasks/worktree-create-retry.test.tsmobile/src/tasks/worktree-create-retry.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/worktree-schemas.tssrc/main/runtime/rpc/methods/worktree.test.tssrc/main/runtime/rpc/methods/worktree.ts
…eate A worktree.create in flight when the mobile transport migrates (relay/direct hand-off on shoddy cellular, relay lease rotation, relay recovery) rejects with "RPC interrupted by connection migration" even though the host completed it — leaving the Create Workspace modal stuck while the worktree exists on desktop. A naive retry hits a name collision and spawns a duplicate. Mirror the existing mobile terminal-create idempotency: worktree.create now accepts an optional clientMutationId that the host dedupes (in-flight + brief post-success TTL), and mobile mints one key per candidate name and re-issues the create on a cutover so the retry reconciles instead of duplicating.
3065e9c to
dc6c8b9
Compare
…eate (stablyai#9234) * fix(mobile): survive connection-migration cutovers during worktree create A worktree.create in flight when the mobile transport migrates (relay/direct hand-off on shoddy cellular, relay lease rotation, relay recovery) rejects with "RPC interrupted by connection migration" even though the host completed it — leaving the Create Workspace modal stuck while the worktree exists on desktop. A naive retry hits a name collision and spawns a duplicate. Mirror the existing mobile terminal-create idempotency: worktree.create now accepts an optional clientMutationId that the host dedupes (in-flight + brief post-success TTL), and mobile mints one key per candidate name and re-issues the create on a cutover so the retry reconciles instead of duplicating. * fix(mobile): gate worktree cutover replay by capability * fix(mobile): await worktree replay capability
Problem
On mobile (relay, shoddy cellular), creating a workspace fails with "RPC interrupted by connection migration" and the Create Workspace modal stays open — yet the worktrees actually got created on the desktop.
Root cause: the stable logical RPC client rejects any in-flight request with
LogicalClientCutoverError("RPC interrupted by connection migration") whenever the endpoint supervisor migrates the underlying transport — relay↔direct hand-off, relay lease rotation, or relay recovery after a cellular blip. Aworktree.createin flight during a migration rejects on the client even though the host already ran it, so the modal surfaces the raw error while the worktree exists. A naive client retry is unsafe:worktree.createisn't idempotent, so it hits "branch already exists" → suffix bump → a duplicate worktree (matching the reporter seeing several created).Fix
Mirror the codebase's existing precedent — mobile terminal creation already dedupes reconnect-replays via a
clientMutationId(createMobileSessionTerminal) — and apply the same shape toworktree.create:worktree.createaccepts an optionalclientMutationId.OrcaRuntimeService.dedupeWorktreeCreatewraps the create handler: a retry with the same key returns the in-flight (or just-finished, 60s TTL) worktree instead of spawning a duplicate; failures drop immediately so a genuine retry starts fresh. No key (desktop/CLI) runs unchanged.createWorktreeWithNameRetrymints one key per candidate name and re-issues the create on aLogicalClientCutoverError(bounded, 5×). The shared key makes the retry idempotent; a name-collision bump still gets a fresh key. Both create paths (blank + composer/source) funnel through this one function.Net effect: a migration mid-create transparently re-lands on the fresh session and returns the existing worktree — the user gets past the screen with no duplicate.
Tests
worktree-create-retry.test.ts): cutover retry reuses the same key then succeeds; budget exhaustion rethrows; ordinary transport errors are not treated as cutovers; a name collision mints a fresh key per candidate;clientMutationIdis stamped on the request.orca-runtime.test.ts):dedupeWorktreeCreatecoalesces concurrent same-key creates, reuses a settled success within TTL, drops failures for a fresh retry, and never dedupes across repos or without a key.All green: mobile
pnpm test(143), runtimeworktree/schemas/dedup suites;typecheck:node+ mobiletypecheck; oxlint (incl. max-lines gate) + oxfmt.Cross-cutting notes
clientMutationIdis an opaque optional string.QA note
The normal create flow is covered by the tests above. The actual fix — recovery from a live QUIC/relay connection migration — can't be reproduced deterministically in a simulator (needs live pairing + a real network hand-off), so it's validated at the unit level rather than via screenshot.