Repository navigation
Description
Operating system
Other
Orca version
Mobile app: v0.0.18 (3). Desktop: recent build (code references below are against current main, a074ed6)
Details
Short summary:
Closing a terminal from the Orca mobile app never sticks — the terminal disappears for a moment, then reappears as a brand-new terminal (fresh shell). Closing the same terminal from the desktop app works fine. Markdown/file/browser tabs close fine from mobile; only terminal tabs resurrect.
How can we reproduce it?
- Pair the mobile app with a running desktop session.
- Create a terminal from mobile (or use one only ever driven from mobile).
- Long-press the terminal tab on mobile → Close.
- The terminal briefly disappears, then comes back as a brand-new terminal.
Root cause (traced in code):
Terminal tabs are the only tab type on mobile whose Close goes through the handle-only terminal.close RPC instead of the session-tab close path, and the two halves of that path re-create the terminal:
- Mobile Close calls
handleCloseTerminal→terminal.close(mobile/app/h/[hostId]/session/[worktreeId].tsx:4110). Host-sidecloseTerminal(src/main/runtime/orca-runtime.ts:16363) only kills the PTY — it does not remove the session tab or drop its persisted binding. - On PTY exit the runtime keeps the tab in the mobile session snapshot and republishes it as
status: 'pending-handle', terminal: null(orca-runtime.ts:18548-18550, republished viatouchMobileSessionSnapshotsForPtyat:6959). The closed tab is still present — and still marked active. handleCloseTerminalremoves the terminal only from the legacyterminalslist; it never removes the tab fromsessionTabs, never clearsactiveSessionTabId, and sets no tombstone. When the pending snapshot arrives, the auto-activation effect ([worktreeId].tsx:4187) sees an active pending terminal tab and callssession.tabs.activatewithnotifyClients: false→ host hitsshouldMaterializePendingTerminal(orca-runtime.ts:3841-3862) →createHeadlessMobileSessionTerminalspawns a new PTY into the same tab. That is the resurrection.
This exact resurrection class was already fixed for the other tab types: handleCloseSessionTab tombstones closed tabs ([worktreeId].tsx:4154), and host closeMobileSessionTab documents the authoritative-teardown requirement (orca-runtime.ts:4082-4087). The terminal Close button just doesn't use either fix.
Suggested fix:
- Mobile: route the terminal action sheet's Close through the session-tab close path (
session.tabs.close+ tombstone + clearactiveSessionTabId) instead of handle-onlyterminal.close. - Host (defense in depth): in
runtime.closeTerminal, when the handle maps to a runtime-owned mobile session tab, perform the same authoritative teardown ascloseMobileSessionTab(kill PTY + drop persisted binding + prune and emit snapshot) so stale clients cannot resurrect the tab.
Likely shares a root cause with #6927 (headless-server pairing: tab never closes from mobile) — same close path, different manifestation.
Activity
nwparker commentedon Jul 27, 2026
Repro status: cannot_repro on current host close path (please re-test mobile)
Original report: mobile Close →
terminal.closeonly killed PTY → pending tab rematerialized.On
c3a9a5e8a6, hostRuntime.closeTerminalalso tears down the mobile session tab when a surface is present:Mobile UI still routes the action-sheet Close through
handleCloseTerminal→terminal.close(notsession.tabs.close+ local tombstone), which is inconsistent with markdown/file/browser tabs — but the host durable close should prevent resurrection.If still reproducible on latest mobile + host pair, reopen with versions and a network capture of
terminal.closevssession.tabs.*RPCs.fix(mobile): stop re-creating a terminal when the session tab list em…
fix(mobile): keep closed sessions empty (#11251)
fix(mobile): keep closed sessions empty (stablyai#11251)