Repository navigation
fix(mobile): reattach restored runtime-owned terminals before activation - #19247
brennanb2025 wants to merge 4 commits into
Conversation
A restarted runtime records a surviving serve/SSH PTY from provider inventory as connected, so the mobile projection reports the tab as ready — but nothing attached it this generation and typed input goes nowhere. Gate activation on a runtime-owned live binding, not on inventory presence.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to Restored mobile terminal tabs now reconnect when the runtime no longer owns their binding, while renderer-owned and local terminals retain their existing behavior. The covered reattachment and exclusion cases leave no identified merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description clearly explains the user impact, root cause, fix, scope, regression tests, and validation results. However, it omits required template sections, including Visual Proof or an explicit N/A statement, the Linked Issue format, platform-specific manual testing details, and the checklist sections. Resolution Add the missing template sections. Provide a Visual Proof attachment or write
✨ 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 new issues found.
Reviewed changes
- Activation-time reattach predicate —
activateMobileSessionTabnow also materializes a serve/SSH-owned terminal tab that already reportsreadybut has no live runtime-owned binding, so a restored-but-unattached PTY is reattached before input is routed to it. The parked-pane and host-focus guards still apply to both arms. - Characterization + regression tests — a new suite models a restarted runtime whose SSH pane survived, pinning the mechanism (inventory presence ≠ ownership), the reattach-on-activation behavior, idempotency, and a negative control for local tabs.
The predicate is sound: hasServeOrSshOwnedBinding (id shape ⇒ runtime-owned) is the same invariant isRuntimeOwnedHeadlessMobileTab and hasLiveOrPersistedServeOrSshOwnedPtyBinding already rely on, and hasLiveRuntimeSessionOwnedPtyBinding (connected && runtimeSessionOwned) is false exactly in the restored-unattached state, since runtimeSessionOwned is set true at create/surface and false only on close/exit/teardown. The reattach reuses the existing createRuntimeOwnedMobileSessionTerminal path with identity.sessionId, which SshPtyProvider treats as a relay reattach and which is idempotent (providers skip startup commands when attaching to live sessions), so no double-launch is possible.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior Pullfrog review, this PR narrowed the reattach predicate and added a matching negative control:
- Renderer-graph membership gates reattach —
needsRestoredRuntimeReattachnow also requires!this.tabs.has(tab.parentTabId), so a renderer-published SSH tab is focused instead of reattached, which would steal a live session from the desktop. The discriminator mirrorsisRuntimeOwnedHeadlessMobileTab. - Negative control for renderer-published tabs —
focuses a renderer-published SSH tab instead of reattaching itpublishes the tab into the window graph and assertsspawnis not called andfocusTerminalis. This is a genuine red-then-green: without the new clause the predicate would be true and the tab would be re-spawned.
The predicate is sound: this.tabs is the renderer window graph keyed by tab id (rebuilt on syncWindowGraph), and tab.parentTabId is the same id isRuntimeOwnedHeadlessMobileTab, orca-runtime-close-mobile-session-tab, and orca-runtime-stop-explicitly-closed-tab-ptys already compare against renderer-graph membership. An ssh: id is minted on the runtime-owned create flow but the flag defaults false on the inventory-restore path, so neither id shape nor runtimeSessionOwned separates "never attached" from "desktop owns it" — only renderer-graph membership does.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Independent verification at
The PR body needs an evidence refresh: “nine lines” predates the renderer guard, its test list omits the fifth desktop-owned SSH control, and its previous broad-suite counts/live-case statement are not current independent manual evidence. The new claim should name both separate ablations and retain the manual gap until the actual mobile flow is exercised. |
|
Closing: its issue #27649 is closed. |

Supersedes #11868.
What the user sees
Before. On Orca Mobile, a terminal tab restored after a runtime restart or SSH reconnect renders with its scrollback and reports ready — but typing goes nowhere. The runtime discovered the surviving PTY through inventory and never attached to it, so the tab looks healthy while its writes land nowhere.
After. Activating such a tab reattaches it first, so input reaches the process it appears to be connected to.
Root cause
Inventory presence was treated as ownership.
orca-runtime-refresh-pty-worktree-records-with-controller-inventory.ts:217-218records an inventory-listed session asconnected: truewithout ever settingruntimeSessionOwned. The projection therefore issues a handle and stampsstatus: 'ready'(runtime-mobile-session-projection.ts:87,214-224,271-273), and the activation gate skips materialization because the tab already claims to be ready.Attachment is an operation distinct from process existence: seeing a process in restored state is not the same as having attached to it.
The fix
Nine lines at
orca-runtime-perform-mobile-session-pty-records-refresh.ts:145-150. A restored serve/SSH-owned binding with no live runtime-owned binding now also triggers materialization, folded into the existing condition so the parked-pane and host-focus guards still apply to both arms.Evidence
Red-then-green, with the ablation re-run independently:
reattaches the restored session on activation instead of trusting inventory— red on unmodified main (zero spawn, zero attach), green after.reattaches once, not on every activation— red on main, green after.records an inventory-restored PTY as connected without owning it— passes on main; this is the mechanism, not a regression test.leaves an inventory-restored local tab alone— negative control, green in both states.Reverting just the predicate fails exactly the two regression tests and leaves the mechanism test and negative control passing.
src/main/runtimesuite: 7,269 passed, 15 skipped, 1 failure (structured-agent-session-adoption-replay.test.ts) confirmed pre-existing on unmodified main. Lint, format, max-lines, ts-nocheck ratchet, reliability and changed-code gates all clean.Scope notes
registerRemote→ensureProviderAttach) is local-only by construction and never covers SSH ids.reattachKnownPtysruns on relay session connect, not on the activation path for a PTY discovered this runtime generation vialistProcesses.@ts-nocheck(as do 175 files insrc/main/runtime), so the test suite is the only real safety here.What was deliberately dropped from #11868
Four of its five sub-defects landed independently over the past month: folder-scope host resolution and hydration targets (#11832, extended by #17486), same-path folder PTY identity (#12474), reattach-across-reconnect for the relay-connect path (#14844), and folder-deletion pruning (now the
worktreeInstanceIdfence plus #17779). Its tombstone/overflow-bucket persistence, pane-spawn reservations,stable-pane-idadditions, materialization-freshness key and host-aware reservation path flavor are superseded or unexercised, and its newPersistedStatefields are not worth the cost.A separate latent issue was found and deliberately not fixed here:
getKnownWorktreeIds()(runtime-workspace-session-controller.ts:116-134) cannot admit afolder:key and enumerates only local + repo hosts, while its siblinggetHydrationTargets()(:159-165) also readsgetWorkspaceSessionHostIds(). It has no current user impact — the hydration path masks it — and no red test can be written for it today, so it is filed rather than patched.