Skip to content

PR 6d: Runtime stops asking the window to change layout - #27982

Open
Jinwoo-H wants to merge 8 commits into
layout/pr6-6cfrom
layout/pr6-6d
Open

Jinwoo-H wants to merge 8 commits into
layout/pr6-6cfrom
layout/pr6-6d

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 151 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1855 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13431 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11576
Prod 160 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1388 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6866 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5478

Part of the PR 6 stack; merged as one unit, do not merge alone.

ELI5

Until now, when a phone, the CLI or an agent asked for a new terminal, a split, a close, a rename or a focus change, the main process asked the desktop window to do it, and only did it itself when no window was open. This slice deletes those requests: the main process's own copy of the layout (added in 6a) now makes every such change, with or without a window. The window catches up in later slices (6f draws what the runtime holds, 6g stops saving its own copy).

What Changed

  • Deleted window round trips. The runtime no longer sends the window: terminal create, split, rename, focus, close (tab and pane), reveal, mount, session-tab move/close, agent-launch tab publish, browser tab create/close, legacy worker reveal/resolution, or activateWorktree. Their preload listeners and renderer bridges are gone, with the code that only served them (mount waits, the [Bug]: Creating a Claude tab from mobile spawns it on the desktop, then reaps it ~10s later — mobile tab creation broken #7587 create rescue, close-relay acks, the focus coalescer).
  • One path, the runtime's layout. Each of those requests now always takes the path a host with no window already took:
    • terminal.create always spawns in the runtime; a create naming no workspace opens in the one the desktop view shows. A terminal a phone creates and activates moves the desktop view to it, as main's focusTerminal did.
    • terminal.split splits the PTY the handle names, including a window terminal's leaf handle. A split addressed by a leaf handle does not move the desktop (main's window split did not either) and returns the pane's real paneRuntimeId. A leaf whose terminal is not running yet is split in the layout and the new pane starts; a split that passes a command or env to such a leaf is refused (terminal_handle_stale).
    • Focus, file opens and worktree activation move the desktop view and send it a navigate frame (focusTab, focusPane, revealWorkspace).
    • Closes, pane closes and moves run through the old-client translators from 6c.
    • Agent launch tabs are created in the runtime's layout before the agent spawns, and the launch verdict (proceed, not-started, unconfirmed, withdrawn) is a layout transition (agentLaunchPaneSet).
    • Legacy worker recovery is a layout transition (legacyWorkerRecovered) followed by a durable write.
  • Old-client reorder with chats. A client too old to show chat tabs sends a reorder without them. The window path used to keep those chats in place; the translator now does the same (they keep their places, like other hidden tabs), instead of refusing with invalid_tab_order.
  • Browser tab profile. A browser tab's sessionProfileId is a saved layout field, so browser tab set-profile is now a layout command (layout.setBrowserTabProfile {workspace, tabId, profileId}, with today's checks: the profile must exist, default falls back to the default profile, the page's tab must be held). The window round trip (browser:requestTabSetProfile, its preload listener and renderer bridge) is deleted.
  • Browser pages with a window. An Electron serve that later opens a window gives new browser pages to that window, as main did; only a host with no window uses the offscreen backend (create and close).
  • Default agent chat on --activate (plan O2). A deliberately activated, empty workspace (no startup agent, default tabs or setup) opens the user's default agent as a chat, by the window's own rule (empty-workspace-default-agent-chat.ts): chat tabs on, default not blank, the default or a detected agent, a structured session the host can create, else the shell. The window ran this rule only when the user opened a workspace; the runtime now runs it for worktree create --activate, with or without a window.
  • Launch prompt memory. A window launch's remembered prompt is forgotten once the launch settles, unless the pane shows a notice that offers it (pane-says).
  • Legacy worker sleeping records. Recovery also drops a worker's sleeping record whose pane the layout does not hold, as main's recovery did.
  • Kept on purpose. ui:focusTerminal, ui:focusEditorTab, ui:activateWorktree (notification clicks) and sleep/resume stay.

Why

The plan makes the runtime's layout the only writer. As long as the runtime asked the window first, every flow had two implementations that drifted apart (the window path and the headless path) and every bug had to be fixed twice. Deleting the window side, rather than keeping it behind a flag, leaves one path to review and test. Clients of every version keep talking to the runtime the same way.

Linked Issue

Part of the terminal topology / PR 6 stack.

Visual Proof

N/A: until 6f the window does not draw runtime-created tabs, so this slice is not meant to be used alone (see Review).

Testing

  • pnpm tc, oxlint on changed files, check:code-quality:changed, check-compat-boundary-imports, check-layout-writer-ratchets (baseline pruned) pass.

  • vitest --config config/vitest.config.ts over src/main, src/shared, src/preload, src/renderer and tests/e2e, on this branch and on the 6c head 699b989f92e, compared test by test: no new failures. The tests that fail on both are local-environment ones (fish profile, zsh live shell, packaged CLI assets, browser-manager identity/viewport, relay-region-correction). One test in runtime-environment-preference.test.ts failed once under the full run and passes on 3 reruns; this PR does not touch it.

  • CI e2e: per the plan (§2), unit and static checks gate this slice and e2e gates the stack top. Each failing spec on head 778a7083e24 (the same set as dbc14ffc5cd and 5f8e3d5bf77), with its failing assertion:

    • layout oracle client-reorder-tabs, cli-create-rename-close, client-create-split-close, two-clients-create-close (tests/e2e/workspace-layout-oracle.spec.ts:510): oracle "view" findings, e.g. "runtime order [...] but drawn [...]", "runtime terminal tab ... has no drawn tab", "runtime group ... is not drawn". The oracle compares the runtime's layout with the window's DOM; the window does not draw runtime changes until 6f.
    • layout oracle cli-split (:226) and old-client-pane-tree (:374): "Expected 2 visible terminal panes" in waitForBoundPanes, which counts panes in the window's DOM. The split happened in the runtime.
    • layout oracle host-navigation (:323): the window's tab strip must mark the focused tab active; the runtime sent the focusTab navigate frame, which the window follows from 6f.
    • layout oracle setup-split-first-activation (:510): group_id_changed. The runtime provisions the setup terminals in its group, then the window's first activation saves its own group over it (the window saves until 6g).
    • terminal-parked-cli-split.spec.ts:258: "CLI did not remount its parked target", which reads the window's mounted pane managers. Its "active tab unchanged" assertion holds once 6f draws the split: a leaf-handle split no longer moves the desktop.
    • paired-remote-terminal-serve-restart-binding.spec.ts passes on 778a7083e24 (fixed in 6c 381552ab581).
  • Headless layout oracle (workspace-layout-oracle-headless.spec.ts, orcad and electron serve): 18/18 pass on dbc14ffc5cd and 5f8e3d5bf77. ssh-orcad-terminal-root-owner failed once and passed on the next run.

  • Tests of deleted window round trips were deleted. Tests of the behaviour they guarded were rewritten against the runtime's layout (pane-close no-widening, paired close stays closed, phone-created terminal stays listed, old-client reorder with a hidden chat and a stale browser page, legacy worker durability ordering). New: a CLI create --activate with a default agent configured gets that agent's chat (and a shell with chat tabs off), the default-chat rule, a phone-created terminal moving the desktop, a leaf-handle split leaving the desktop where it is, a split of a leaf whose terminal has not started, a serve's window taking browser pages, launch prompts forgotten once settled, legacyWorkerRecovered and agentLaunchPaneSet transitions, the launch tab show/verdict, setBrowserTabProfile (pure command; with no window it updates the model and survives a save and reload), a CLI split on a window leaf handle, and the unplaced sleeping record drop.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

Incomplete until later slices

  • 6f: the window does not draw runtime-created tabs or splits, or follow navigate frames. A terminal created from a phone or the CLI exists in the runtime and on phones but not in the window.
  • 6f: from 6d until 6f, a worktree created from the window gets its setup/startup terminals (the runtime provisions them), but the window doesn't show them or switch to the worktree.
  • 6f: browser tab set-profile changes the saved profile; the window remounts the tab's webviews when it reacts to the frame.
  • 6g: the window's session save still reloads the runtime's layout, so a save can drop tabs the runtime created. A pane closed from a phone during the window's split-save race closes the held single-pane tab; the window's next save brings the split back.
  • 6g: the sleep-resume fork and notifier.resumeSleepingAgents stay until layout.wake lands.
  • 6e: the Command Code working status. The main-side Command Code detector writes "working" into the hook server's status store before the window graph is deleted.
  • 6h: file open on a runtime: server workspace can be refused with workspace_not_found.
  • 6f/6g: the window's next save also undoes these runtime changes until the window stops saving: a CLI rename of a window pane; a phone's setTabProps and updatePaneLayout (main made them no-ops with a window); an agent-session close; a legacy worker's exited retire and its sleeping-record clear.
  • 6f: with a window, every browser create still waits the full 8 s waitForTabRegistration, because the window mounts no webview until 6f (the wait is old code).
  • 6f: an old phone closing a pinned browser or editor tab while a window is open closes it without the desktop's pin dialog. The dialog needs the window to read a confirm request from the layout stream, which starts in 6f; the deleted close relay was the only way to ask it in 6d. Headless pinned close keeps P4's behaviour.
  • 6g: a window "launch through host" pane stays blank until the launch returns (after prompt delivery), and a spawn failure closes the tab as not-started instead of explaining in the pane. The hold's other releases were in the deleted publish relays; the window path moves in 6g.
  • 6f: a CLI or phone agent launch whose agent did not start no longer offers "Copy prompt" in the window (see below).

Decisions and behaviour changes

  • Creates are "visible" with no warning. Before: a headless terminal.create (no window to reveal in) returned surface: 'background' with "Terminal X is running, but Orca could not make it discoverable. Run orca terminal focus --terminal X…" (6c orca-runtime-create-terminal.ts:246-271), and the CLI printed Created terminal … [background] plus that warning (src/cli/terminal-format.ts:230-235); with a window it returned visible. After: every create returns visible unless it asked for background, with no warning (orca-runtime-create-terminal.ts ~248). The tab is in the runtime's layout, which every client reads, so it is discoverable everywhere; from 6d to 6f the window does not draw it.
  • Copy prompt. Before: a CLI or phone agent launch with a prompt whose agent did not start showed a pane notice with a "Copy prompt" button (AgentLaunchPaneNotice.tsx:19-36); the window remembered the prompt in its publish relay (6c agent-launch-tab-publication.ts:80-82, ~120-122). After: launches started in the window still remember it and now forget it once settled unless the pane offers it (agent-launch-through-host.ts); remote launches have no window relay, and the prompt is session-only and not in the layout (agent-launch-pane-prompt.ts:1-5), so their notice has no prompt to copy. 6f can carry it as an unsaved per-pane fact on the published frame.
  • A CLI-created worktree with --activate now opens the default agent chat in the runtime (O2, above). Main never did this for a CLI activation (it activated without seedUserDefaultSurface), and a headless host used to get a shell; it now gets the chat by the same rule.
  • Split telemetry from the window reveal is gone with the reveal.
  • host-session-tab-target.ts is kept: the kept ui:focusEditorTab listener imports it.
  • With a window, a reorder naming a tab twice now answers invalid_tab_order instead of duplicate_tab_order, the code the headless path always gave.
  • Host navigation sends one extra session-tabs republish to paired clients.
  • Legacy worker durability follows Q4 ("No timed retry, backoff or rollback. The change stays in memory and is logged, and the next ordinary save writes the latest state."): recovery settles once the write ends, even when it fails; a worker whose write failed is re-found by orphan adoption at next launch. The two durability tests were rewritten to that contract.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Wire: no new methods or fields. Old clients keep their session.tabs.* and terminal.* calls; the runtime now answers them from its own layout. SSH: closes and creates on ssh: workspaces go through the same runtime path that served windowless hosts. Mobile: phones read the same projection as in 6c.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Delete the runtime's window layout relays (create, split, focus, rename, close, reveal, mount,
move, session tab create/close) and their preload listeners; the runtime's layout is the one path.
…ch; Q4 legacy recovery tests; drop unplaced sleeping records; clear #7587 leftovers
…ted leaves; phone create navigates; offscreen browser pages only without a window; forget settled launch prompts; dead code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant