Repository navigation
Layout-owner build: a CLI send, wait or read starts a saved pane that has no terminal yet (dark) - #31307
Conversation
…efuses a taken one
… starts them, window or none (dark; twin e)
… starts them, window or none (dark; twin e)
…nt fails to start; no window takes over (dark)
…ne; a terminal close stands after a failed write (dark)
…te; switch off still refuses
…abs start once; a tab's last pane keeps its card (dark)
…l; main starts it whatever failed
…so a closed tab stays closed (dark)
…ives (both builds)
… reads a shared import (dark)
…ts old terminal (dark)
…back a closed pane by design
…build, and main's switch-on proofs
…g live; remote host answers pass through (dark)
…e copy's last pane; the window's terminal claim is not consulted (L127, dark)
…terminals; a starting pane is never exited on the inventory alone; terminal.list lists every saved pane main owns; the pane claim lookup leaves the output path (dark)
…ayout switch on An exited pane closes through the legacy retirement unless the keep rule holds; the default tab's title and color still reach the window and the phone's live tabs.
…vouched -1 Main's taken and closed-id guard now runs where every pane write goes, so a runtime create replayed after its tab closed is refused before it spawns. An exit code nothing vouches for keeps the pane, as the window does; a kept pane sends the phone no retirement. Converts the switch-on tests that asserted the deleted window hand-off and title bridge.
… checks on client commands A paired host starts each pane of a client's tab as a create under the tab's id, so a held tab id is refused only for a client's own layout command.
Only a requested stop or a host-confirmed death closes a pane on a negative exit code. Pins that the closed-tab guard never fires in the shipped build.
…itions hold, the fence reads ownership once, a legacy pane keeps its claim; switch-on tests assert main's answers after a window closes (dark)
…ged to its own module, for the file's line cap
… does, re-reading routing only on a write or a terminal registration; a worktree stop names every terminal main binds; a starting pane is unverifiable (dark)
…fd/a1-main-terminal-surfaces
…ng live; a resuming pane is unverifiable like a starting one (dark)
…rts it once first (switch-on builds only)
…rts; terminal.send starts it before its checks (switch-on builds only)
…he pane; bound the start by the caller's abort and wait deadline (switch-on builds only)
…dline and cleans its bounds on first settle; tighter A1c tests
…al create bound for every CLI entry point (runtime_timeout)
…; every other send, wait and read stays synchronous as before
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
ELI5
After a restart, a saved terminal pane may not have its terminal running yet. Phones already start such a pane when they open it. In the new layout build (switched off in every shipped build), this PR does the same for a command-line or orchestration
send,waitorreadaimed at that pane, instead of failing with "not writable".What Changed
Everything is behind the
ORCA_LAYOUT_OWNERbuild switch, which is off in shipped builds. Switch-off behaviour is unchanged.With the switch on, for a pane in a workspace main owns (local or SSH; paired-server workspaces still mirror their server):
orca terminal send|wait|read(and orchestration message delivery) on a saved pane that has no terminal yet used to fail (terminal_not_writable, or an empty read). Now it starts the pane through main's one starter (ensureRestoredPaneStarted, the one phones use), then delivers, waits or reads on the started terminal.runtime_timeoutafter the pending-terminal create bound (MOBILE_TERMINAL_SURFACE_TIMEOUT_MS, 10 s), for every entry point including a read and atui-idlewait with no timeout. The caller's abort signal and a shorter wait deadline (timeout) also apply, and a wait keeps only the deadline the start left.adoptFirstPtyForLeafHandle), so an open wait is not invalidated.Mechanism: one new class layer,
restored-handle-pane-start.ts(startRestoredHandlePane), called at the top ofsendTerminal,sendTerminalAgentPrompt,readTerminalandwaitForTerminal.Why
The final design's restore starter (C1b) gave main one start for every trigger except the window's own restore; phones were wired, CLI and orchestration were not. Calling the existing starter from the four runtime entry points covers the RPC, the stream input path, plugins and orchestration in one place. Rewriting the caller's handle to point at the new terminal was considered and rejected: it is deleted when the pane's binding lands, which would fail open waits.
Linked Issue
Part of the terminal layout final design (A1 follow-up: CLI wiring for the C1b restore starter). Ledger L237 note.
Visual Proof
N/A: no change in shipped builds (the switch is off).
Testing
restored-pane-start-cli-handles.test.ts(switch on, windowless host, a saved pane with no terminal): a send starts the pane once and delivers, and a second send on the same handle reaches the same terminal; aterminal.sendrequest does the same; a wait and a read do the same; a CLI send and a phone opening the pane together start it once; a failed start fails the send with its error; a wait survives main binding the pane later and answers under the caller's handle; a wait's timeout covers a start that never finishes; a read, and atui-idlewait with no timeout, on a start that never finishes fail withruntime_timeoutat the 10 s bound (fake timers).Gates: ci-static-gate passes. Switch-on
src/main/runtime+src/main/persistencein clean worktrees, main c335070 vs this head: 11 vs 11 failing, none fails only at this head. Only a handle whose saved pane needs a start goes async; every other send, wait and read keeps today's synchronous path, so existing wait-timing tests are unchanged.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Reviews:
terminal.sendhandler change altered some refusal replies (removed, that file is now unchanged).runtime_timeout), and the switch-on comparison then caught all waits going async (5 timing tests); fixed so only a call that needs a start goes async.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
runtime:<env>) workspaces are not owned and keep today's path.OrcaRuntimeWithRestoredHandlePaneStartclass in the runtime class chain (its method folds toreturn handleand nothing calls it with the switch off) and, at the four entry points,const target = handle; if (target !== handle) ..., a branch that can never run, so switch-off behaviour is identical. The renderer manifest differs only in entry order.ensureRestoredPaneStarted), and the handle hand-off uses the existing first-terminal adoption; no new state.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)