Repository navigation
fix(runtime): a server with no window answers its first terminal create, not 'handle stale' (switch-on builds only) - #31391
Conversation
…andle after main's pane adopts it (switch-on builds only)
…th no leaf fallback read the adopted own handle (switch-on builds only)
… after main's pane adopts it, as before main listed panes (switch-on builds only)
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 Walkthrough
Priority: ⚪ Pending latest changes Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
🧹 Nitpick comments: 1
src/main/runtime/headless-create-terminal-handle-main.test.ts: 1
1-67: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise a follow-up operation with the created handle.
The test validates the handle lookup that occurs during creation, but it does not validate a later terminal operation. Add a read using
created.tab.terminalso a stale-handle regression after creation fails both headless cases.Suggested fix
expect(created.tab).toMatchObject({ status: 'ready' }) + const handle = created.tab.terminal! + await expect(runtime.readTerminal(handle)).resolves.toMatchObject({ handle })
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
40139bf9-1669-432d-9b12-78dfdce37dc6
📒 Files selected for processing: 3
src/main/runtime/headless-create-terminal-handle-main.test.tssrc/main/runtime/terminal/query/pty-terminal-summary.tssrc/main/runtime/terminal/surface/terminal-surface-replies.test-fixture.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
ELI5
In the new layout build (switched off in every shipped build), a server with no window open (
orca serve) failed the first terminal a phone or paired desktop created on it: the terminal started, but the create answered "terminal handle stale". This PR makes the create answer with the running terminal.What Changed
Behind the
ORCA_LAYOUT_OWNERbuild switch, off in shipped builds; switch-off behaviour is unchanged.session.tabs.createTerminal(and the other runtime-owned creates) threwterminal_handle_stalethough its terminal was running. Paired-desktop and phone flows on such a server broke at their first create.getLivePtyForHandleonly took runtime terminal records, so the create found nothing, and a split on the handle took the pane path, which waits for a window to start the pane and timed out. Now, with the switch on and no window (the graph authority is the headless runtime, also after a window closed),getLivePtyForHandlealso accepts the terminal's own handle when the pane main's layout binds that terminal adopted it: the same answer that handle gave before Layout-owner build: main answers terminal questions from its own layout (A1, dark) #31187, when no window meant no panes.Why
Fixed where the miss happens, in the one lookup every caller uses, and limited to what changed in #31187 (no window, main's own panes), so it restores the old answer instead of inventing a new one. Alternatives tried: accepting any pane handle main binds changed windowed replies (A1's cross-version goldens); a separate lookup only for callers with no pane path fixed the create but left a split on the same handle waiting for a window that does not exist; keeping the adopted record a runtime terminal record inside the adoption would move every windowed pane handle off the pane path.
Linked Issue
Regression from A1 (#31187), found by the switch-on server e2e specs. Bisect: the unit repro below fails at #31187 (c335070) with
terminal_handle_staleand passes the no-window case at its parent, #31171 and #31130.Visual Proof
N/A: no change in shipped builds (the switch is off).
Testing
headless-create-terminal-handle-main.test.ts(switch on): on a host that never had a window, and one whose window closed, a phone's terminal create answers ready. Fails at base withterminal_handle_stale(both cases), passes at head. The fixture's binding write now tells its write listeners, as the Store does, and offersbindPaneso a mock spawn binds its pane like the PTY host's spawn commit.src/main/runtime+src/main/persistence, base b99552c vs head b91ceba in clean worktrees: 11 vs 11 failing, none fails only at head. Switch-off: 2 vs 2, none only at head.windowlessOwnHandlecheck, which folds toreturn false, and its call ingetLivePtyForHandle's guard; switch-off behaviour is identical. Renderer: manifest entry order only.Server specs: switch-on, fresh
build:electron-vite:parallel --mode e2e+build:cliat each commit, through run-slot.sh app.base b99552c: 1 passed, 2 failed (paired-mobile-desktop-tab-composition:
session.tabs.createTerminalterminal_handle_stale; paired-desktop-server-layout-frames: runtime timeout onterminal.split); headless-serve-focused-terminal-create passed.head b91ceba: 3 passed (paired-mobile-desktop-tab-composition, paired-desktop-server-layout-frames, headless-serve-focused-terminal-create).
head 50473fb (with origin/main merged, including D1b-1 Layout groundwork (switched off): main starts every split and new pane, the window only attaches #31258): 3 passed. The layout-frames runtime timeout on a windowless split, also seen at base, is gone at head: it was a downstream symptom of the same handle adoption.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Reviews:
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
layout-owner-e2e.yml) runs only on manual dispatch; no PR trigger runs these specs with the switch on.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)