Repository navigation
Conversation
…rted window tabs
[Low impact] The PR reaches test coverage for main-owned terminal starts, not shipped runtime behavior. The tests-only PR has no newly identified blocking defect, but two test checks should be strengthened. FindingsSummaryAdds unit and E2E coverage for main-owned terminal starts.
Reviews (1) · Last reviewed commit: "test(layout-owner): add unit and e2e tes..." · Reviewed by Greptile |
| await phone.request('session.tabs.activate', { | ||
| worktree: `id:${worktreeId}`, | ||
| tabId: exitedSurface!.id, | ||
| notifyClients: false, | ||
| navigation: 'caller', | ||
| intent: 'user' | ||
| }) |
There was a problem hiding this comment.
Refused phone opens go unnoticed
The exited-tab test ignores the reply from phone.request('session.tabs.activate', ...). request returns failed replies without throwing, so the test can pass when the server refuses to open the tab: no second command runs, but the phone never reaches the behavior being tested.
Use phone.call or assert that the reply has ok: true. The planning-tab and create-gap tests also discard activation replies.
| phone = pairMobileClient(mobileOffer) | ||
|
|
||
| const gapPrefix = 'gap-race-' | ||
| await delayWindowTabTerminalCreate(hostApp, gapPrefix, 800) |
There was a problem hiding this comment.
The test delays terminal.create for only 800 ms, then makes several phone requests before activation. Nothing checks that the delay is still running when activation arrives. On a slow run, the create can finish first and the model assertion can pass without testing the race.
Hold the create request behind an explicit gate until the phone activation reaches the server, then release it.
…umed start stays consumed - One-call tab create (design step 6): the window's terminal.create carries its createTerminalTab; main writes the tab as the first step of the pane's start, under the start gate. No window or phone finds the tab recorded but unstarted, so none starts it without its --model or startup. A refusal or failed start answers with the call's frame; host_not_owned still records the tab alone and the window starts it, as before. - PaneStarter.ensureStarted refuses a consumed pane instead of clearing it: a phone opening an exited main-started tab no longer runs its command again. A stop (forget) or a layout command's start (byLayoutCommand: startPane with a resume record, wake, restartPane) still starts it. - A died pane's Restart reaches main's restartPane: the connect is marked as a restart, since the exited transport no longer names its terminal. - Tests from #52167 merged; refusal stubs follow the one call, my spec imports the shared harness.
d71938a
into
layout-owner-launch-drafts-through-main
…start through main (#51934) * fix(layout-owner): window tabs that launch an agent or carry a draft start through main * test(layout-owner): read the recorded window spawns without a cast * test(layout-owner): type the recorded window spawns as a declared global * test(layout-owner): count only terminals the window's own spawn starts * fix(layout-owner): main-started window tabs never start twice, seed status on every attach, typed launch refusals, safe draft paste * test(layout-owner): type the seeded tab options instead of casting * fix(layout-owner): a main-started pane's late connect may only attach to main's terminal * fix(layout-owner): a window tab's failed agent launch shows one typed outcome, none for a closed pane Main's create asks the launch what a failed pane shows before either failure writer publishes, so no raw start failure reaches the window first. Exited-during-start shows the launch refusal, as the pane's own spawn does. Main-started view facts are dropped on a failed create and when the tab closes. The draft cap counts sanitised UTF-8 bytes. * fix(layout-owner): a window tab main starts only attaches; one starter per pane in main The window asks main once who starts a new tab's first terminal (asking, then main or window) before the pane connects. A pane main starts sends pty:attachPane, built from an allow-list, which awaits main's in-flight start and answers a typed state instead of an error, so it never starts a terminal or feeds remount recovery. Main runs the window tab's start under the same per-pane gate as every other start and marks it consumed, so a later startPane never re-runs it from tab facts. Main hands the launch's view facts back with the attach. The window's starting mark, startup hand-off and give-back remount, and the main-started view map are gone. * test(layout-owner): prove a pane main starts is started once, by one owner A lane-wide oracle fails any switch-on spec whose window starts a terminal in a pane main started. The window-tab spec adds a command that exits before its view, remounts during main's start, and a slow decline remounted while the window is still asking. Unit tests pin the per-pane starter, the consumed startPane rule, the one-way owner latch and the attach request's allow-list. * test(layout-owner): withhold main's window-tab starts in the default-tabs crash spec Main now starts default tabs that carry startup fields, through the window's terminal.create, so stalling only pty:spawn no longer keeps every terminal from starting before the crash. The exited-before-view case no longer assumes the tab closes: it stayed open on Linux and closed on macOS. * fix(layout-owner): main owns a window tab's start through restart, daemon restart and reload - Restart (account switch, died-pane Restart) of a main-started pane goes through main's restartPane: main stops the terminal and starts the pane again through the same starter. - A daemon restart forgets the consumed start, so main's startPane runs again. - Main publishes 'starting' when it takes a start, and the launch status per terminal, so a reloaded window waits on main and re-seeds the agent status instead of starting a shell. - A refused create only closes the tab. - Attach replies: closed/owner-changed races map to states, an exited registration is 'exited', 'held' shows the newer-daemon card; an already-present binding is attached at once. - An exited-before-view tab stays open: main notes the spawn commit before the binding save, and the window treats main's first start as its fresh spawn. * test(layout-owner): the layout.apply reply contract covers the window's restartPane * test(layout-owner): add unit and e2e tests against PR #51934 main-started window tabs * fix(layout-owner): one call writes a window tab and starts it; a consumed start stays consumed - One-call tab create (design step 6): the window's terminal.create carries its createTerminalTab; main writes the tab as the first step of the pane's start, under the start gate. No window or phone finds the tab recorded but unstarted, so none starts it without its --model or startup. A refusal or failed start answers with the call's frame; host_not_owned still records the tab alone and the window starts it, as before. - PaneStarter.ensureStarted refuses a consumed pane instead of clearing it: a phone opening an exited main-started tab no longer runs its command again. A stop (forget) or a layout command's start (byLayoutCommand: startPane with a resume record, wake, restartPane) still starts it. - A died pane's Restart reaches main's restartPane: the connect is marked as a restart, since the exited transport no longer names its terminal. - Tests from #52167 merged; refusal stubs follow the one call, my spec imports the shared harness. * fix(layout-owner): a window tab's start is spent only when its terminal ends on its own - Replace the pane-level 'consumed' flag with a fact about the start's terminal: a window-tab start is spent once the terminal it ran ends on its own (main's existing ended-on-its-own exit verdict), no later terminal holds the pane, and the pane keeps no resume record. Sleep, Restart, a daemon replacing the terminal and a held pane are not that, so wake, mailbox/CLI wake, a phone opening a slept tab and held Reopen start again with no forget call; the daemon-restart forget is gone. A failed start stays spent; a refused tab records nothing. - createTab publishes the first terminal's cwd with the tab, and the terminal bridge passes its startup command into createTab, so the one-call create carries both (nothing is queued after). - host_not_owned from the one call answers as layout.apply would (a twin's start goes to the window, a local refusal closes the tab), with no second layout.apply. - A held pane's Reopen asks main to start it, then attaches. - The switch-on window lane runs the two new window-tab specs. * test(layout-owner): window tabs main starts in one call wake from sleep, reopen held, survive restarts and keep their inputs - Slept window agent and draft tabs wake once, through main, from the sidebar and from a phone. - A held window tab's Reopen after a newer terminal service gets a live terminal from main. - A daemon restart after the tab was viewed, opened on a phone and reloaded gives it a live terminal. - A repeated one-call create runs nothing new and leaves the pane startable. - ui:createTerminal's startup command and a subfolder project's first terminal run in the right cwd. - The spawn oracle no longer counts a refused or reattached one-call create as a main start. * fix(layout-owner): a workspace woken or opened while its sleep is still settling wakes its slept tabs Main finishes a sleep before the window commits it. Opening the workspace or one of its tabs in that gap saw terminals that were still listed, so nothing woke the slept tabs: - the window remounts the tabs when the sleep ends on a workspace that was already reopened - attach answers `sleeping` for a pane main keeps a resume record for, so the view asks main to wake it - a phone open waits for a sleep that is still running, then trusts main's resume record over the window's stale `ready` Also adds an e2e for an Agent Sleep woken by a terminal send to its handle. * fix(layout-owner): a tab removed during tab creation drops its queued starting directory * fix(layout-owner): a frame binds a layout whose last terminal binding cleared, as the full build does
ELI5
Tests-only PR targeting PR #51934 (
layout-owner-launch-drafts-through-main, head52b685804e7). No product code is changed. It exercises every tricky lifecycle case for window tabs whose terminals start in main underORCA_LAYOUT_OWNER=main(in-place restart, multi-tab daemon restart, reload during planning and right after start, refused creates, exit-before-view across reload, two desktop windows on one workspace, and a phone client opening the same tab) and pins three remaining bugs before the next review round.Before / After
parsePaneAttachRequest, leaving died-pane Restart, multi-tab daemon restart without reload, reload with delayed draft readiness +agentLaunchplanning, two desktop windows on one workspace, and phone client interactions untested.52b685804e7, 11 pass (proving those paths hold) and 5 fail for 3 distinct real bugs.Mechanism (Pass / Fail Summary on
52b685804e7)Failing tests (3 real bugs exposed)
Died-pane Restart on a main-started tab never sends
restartPane— FAIL (Unit)src/renderer/src/components/terminal-pane/pty-connection/attach/main-pane-attach-lifecycle.test.ts(routes a died-pane Restart (after transport exited and cleared ptyId) through main restartPane)ipc-pty-transport'smarkExited()setsptyId = null. WhenusePaneProcessRestartcallsreleasePaneTransportForRestart(transport),replacesPtyIdisnull, sosession.pendingReplacedPtyIdisnull.runDeferredSessionAttachonly routes torestartMainStartedPanewhensession.pendingReplacedPtyIdis truthy, so died-pane Restart falls intoattachMainStartedPane, receives{ state: 'exited' }, and leaves the tab dead with no terminal.PaneStarter.ensureStartedignoresconsumed, so a phone opening an exited main-started tab re-runs its command — FAIL (Unit + E2E)src/main/runtime/terminal/recovery/pane-starter-consumed-and-restart.test.ts(does not re-start a consumed exited pane on ensureStarted (e.g. phone open), until forget())tests/layout-owner-e2e/window-tab-main-start-multi-client.spec.ts(a phone client opening an exited main-started tab does not re-run its command)perform-mobile-session-pty-records-refresh.ts:203callsthis.ensureRestoredPaneStarted(pane, trigger)directly when a phone activates a non-ready tab. Unlike thestartPanelayout reducer,PaneStarter.ensureStarted(restored-pane-start.ts:93) clearsthis.consumed.delete(key)and launches a second agent process (launches.length === 2instead of1).Two-RPC tab-create gap (
createTerminalTab→terminal.create { windowTab }): a second desktop window or phone steals the unstarted tab and drops its startup — FAIL (2 E2E tests)tests/layout-owner-e2e/window-tab-main-start-multi-client.spec.ts(two desktop windows on one workspace and a phone client opening a live or planning tab share one start with its startup intact)tests/layout-owner-e2e/window-tab-main-start-multi-client.spec.ts(a phone activating a new window tab during the createTerminalTab-to-terminal.create gap does not steal its startup)recordCreatedTerminalTabInLayoutOwnersendslayout.apply createTerminalTabfirst, then sendsterminal.create { windowTab: true }on reply. Main publishes the new unbound, unstarted tab in a layout frame /session.tabs.listduring that gap. A paired desktop window already viewing the workspace (without any artificial delay) or a phone activating the tab triggers a genericensureRestoredPaneStartedbeforeterminal.create { windowTab: true }reachesstartWith, launchingopencodewith emptyargv: []and silently dropping--model test/fake-model(and anyagentLaunch/draftPrompt).Passing tests (11 passing, proving these cases are covered on
52b685804e7)main-pane-attach-lifecycle.test.ts: live account-switch restart routes through mainrestartPane(neverstartFreshSpawn);onPaneAttachMissre-attaches once without looping when the binding frame already landed beforeunstarted/unknown;heldwithNEWER_DAEMON_HOLD_ERRORopens the Reopen card instead of a raw error toast.terminal-tab-create-refusal.test.ts: refusedcreateTerminalTabcloses the tab without settling the owner latch to'window'or invokingterminal.create.pane-starter-consumed-and-restart.test.ts:PaneLaunchStatusesstays visible while bound to the started terminal and expires once rebound after restart.attach-pane-states.test.ts:attachPaneViewawaits an in-flight start in main and unhides a hidden-started PTY on visible attach withattachOnlyView: true(no start fields);heldreturns{ state: 'held', reason }without invokingrunPtyIpcSpawn.window-tab-main-start-lifecycle.spec.ts, 4/4 pass):isPidAlive === false), binds a newptyId !== before.ptyId, accepts interactive input, 0 windowpty:spawns, 0 error toasts.window.api.pty.management.restart()) with active agent tab + hidden draft tab + initial shell tab open (no prior reload): every tab gets a live interactive terminal, draft is pasted only once, 0 error toasts.agentLaunchplanning (slow--versionprobe) and right after start (delayed draft readiness): 1 start each, 1 draft paste,initialAgentStatusre-seeded for both tabs, 0 windowpty:spawns.pty:spawn,terminal.create,terminal.createAgentSessionall 0), and commands exiting before view attach (both background and active untouched) keep their tabs open even across reload with 1 launch each and 0 error toasts.How It Was Tested
All runs executed in the foreground with
ORCA_LAYOUT_OWNER=main(andORCA_SERVER_LAYOUT_OWNER=main,ORCA_BACKGROUND_LAUNCH=1for E2E):pnpm test ... --maxWorkers=2): 7 passed, 2 failed (the 2 real unit bugs above).pnpm exec playwright test tests/layout-owner-e2e/window-tab-main-start-lifecycle.spec.ts tests/layout-owner-e2e/window-tab-main-start-multi-client.spec.ts --config tests/layout-owner-playwright.config.ts --project electron-headless --workers=1 --reporter=list): 4 passed, 3 failed (the 2 real multi-client/phone E2E bugs above).oxfmt,oxlint: 0 warnings, 0 errors across all 7 files.pnpm run typecheck:ci: 0 errors.pnpm run typecheck:e2e: 0 errors intests/.Visible Changes
None (tests only).