Skip to content

fix(layout-owner): main wakes slept panes it owns (B1, B2, B3, B5) - #51731

Merged
Jinwoo-H merged 18 commits into
layout-owner-v2from
layout-owner-b1-b3-sleep-wake
Nov 28, 2026
Merged

Jinwoo-H merged 18 commits into
layout-owner-v2from
layout-owner-b1-b3-sleep-wake

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Into layout-owner-v2. Fixes census rows B1, B2 (L308), B3 (L309) and B5 with the new layout path on.

ELI5

Sleeping agents broke in four ways when main owns the layout:

  1. Messaging a slept agent by its handle crashed in main.
  2. After a sleep, main still told the CLI and phones that each pane ran its old, stopped terminal.
  3. A phone opening the workspace woke the tabs you could see, but not a hidden tab.
  4. A host with no window (orcad, orca serve, a closed window) could not wake a slept agent at all.

Now main wakes the panes it owns itself, whoever asks, and the window only draws.

Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​423 $\color{#cf222e}{\Huge{\mathbf{−}}}$​82 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​341
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​383 $\color{#cf222e}{\Huge{\mathbf{−}}}$​180 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203

Before / after

Before (switch on) After
Wake a slept agent by handle (message, CLI, worker start) Runtime graph publisher belongs to a superseded renderer generation, wake fails Main starts the pane once, under the same handle
orca terminal show / terminal.list on a slept agent Stopped process, connected/writable: false The idle agent, writable: true (same as switch off)
After sleep: terminal.list / session tabs Name the stopped terminal ids Name no terminal, as the window draws it
Phone wake with a hidden tab Hidden tab stays asleep Main resumes it
Wake with no window agent_wake_failed Main resumes it

Mechanism

  • One wake path (slept-pane-resume.ts): handle wakes, mail wakes (and their prepare step), and phone workspace wakes now go through resumeSleptPaneTerminal. If main's layout owns the tab and still holds the pane, main starts it with ensureRestoredPaneStarted, the starter behind startPane/wake. That starter already shares one start per pane, so a handle wake and a phone wake that race start one process. Otherwise the window relay is used as before. That covers switch off, paired-server tabs, and a record whose tab is gone, which the window reopens in a fresh tab.
  • Mail-wake id (restored-pane-start.ts, restored-pane-materialize.ts, mobile-terminal-owned-create.ts): the mail wake's attempt id rides the start trigger into the created terminal's launchToken, so the wake confirms it as before.
  • Phone wake (slept-workspace-wake.ts, runtime-workspace-sleep-operations.ts): main also resumes the hibernated and quit agents the window used to resume. It still skips tab-open-only panes ([Bug]: Interrupted agent sessions are never auto-hibernated, and manual workspace sleep silently discards them on wake #11598). It sends the window relay only for panes main does not hold.
  • No window-side wake code: the renderer parked-pane wake from the previous round is removed; the renderer is unchanged from the base.
  • B1 (session-window-graph.ts): main's own pane reinstall no longer counts as a newer window graph, so the window's pending reply does not throw.
  • Slept panes list as writable (write-orchestration-pointer-pty.ts, resolve-terminal-pane.ts): main marks an Agent-slept pane sleeping, but list and show now report the idle agent.
  • Handle kept (terminal-create.ts, preallocated-terminal-handles.ts): a terminal main starts into an Agent-slept pane takes the handle the pane already answers to, as a window-started resume does, so mail, waits and worker lists keep naming the agent.
  • No window, really (slept-leaf-handles.ts, unmounted-slept-agents.ts): after the window closes or the host restarts, a wake by handle finds the pane again. The pane's saved sleep record names the handle, and when no sleep row is left, main's binding names the stopped terminal.
  • Closed split pane (stored-pane-binding.ts): a pane closed out of a split no longer counts as held because its sibling keeps the tab.
  • Phone report (workspace-sleep.ts): a phone opening a workspace with no window hears requested for the agents main now resumes.
  • Legacy records (agent-session-resume-ownership.ts): an originless sleep record (Paired-client pane resume treats originless legacy done records as pane-owned #29303) in a pane main holds resumes its agent instead of a plain shell.
  • B3 (terminal-surface-index.ts, pty-exit-lifecycle.ts): a pane whose terminal certainly exited is published with no terminal. The exit now re-composes main's panes right away, so this holds with no window graph too.

The #44113 policy layer (held mail, one wake per handle, wait for idle) is unchanged.

How it was tested

  • New slept-pane-main-wake.test.ts (switch on). Three of its tests run main's real start, faking only the PTY spawn and the Git worktree listing. They check that the resumed terminal keeps the slept handle and carries the mail wake's id, and that an originless record resumes its agent. The others cover:

    • a wake after a real window close, and after a restart with only saved records and no window;
    • a phone's wake report with the window closed;
    • a pane closed out of a split starts nothing;
    • a handle wake racing a workspace wake starts one process;
    • a mail wake's start carries its attempt id;
    • a tab-open-only pane stays asleep on a workspace wake;
    • a pane closed before its wake starts nothing;
    • a slept agent lists and shows as the writable idle agent with no stopped terminal.

    With fix 1 or fix 5 reverted, those tests fail.

  • slept-agent-wake-no-window.test.ts now passes with the switch on (B5). With the switch off it stays an expected failure, because the window owns the pane.

  • The tests fake only the process main spawns (a harness override of startRestoredPaneTerminal). The real one-start-per-pane starter runs.

  • Both modes, --maxWorkers=1: orchestration/mailbox, session-graph, session-lifecycle, workspaces/sleep, terminal/{surface,recovery,lifecycle}, terminal-authority pass. The only switch-on failures are the D1 rows already listed.

  • E2E, local darwin build with ORCA_LAYOUT_OWNER=main (plain build, setting given at run time): relaunch-sleeping-agents-resume-on-view 3/3. Its phone step now pairs a real phone client and calls worktree.activate, instead of sending the window a fake message. Oracle sleep-quit-resume passes.

  • tc:node, oxlint, oxfmt clean.

Not covered

  • The user opening a sleeping tab still sends main a startPane intent from the window. That is a view intent, not a wake.

Performance

None, because each wake does what it did before (one start per pane), and main now does that start itself. The other changes add one counter compare per graph reply, one exit-verdict lookup per main-owned pane on compose, and one re-compose per certified terminal exit.

Visible changes

None with the switch off. With the switch on, these are bug fixes only: hidden tabs resume on a phone wake, a windowless host can wake a slept agent, and the CLI/phone no longer list a stopped terminal id for a sleeping pane.

Jinwoo-H and others added 10 commits November 28, 2026 03:47
Runs ORCA_LAYOUT_OWNER=main on PRs that touch layout, tabs, session,
persistence, PTY or terminal code: the units whose imports reach a
switch-reading file plus restored layout invariants, checked against a
list of known switch-on failures, and 34 restored layout e2e specs in
three shards. Known switch-on failures are marked expected-fail with
their census row.
Seed the worktree-cards notice as seen, skip orcad oracle cases when
out/orcad is not built, mark the layout-compat baseline drift (L311),
keep A3 marked on darwin only, retry once in CI, and rebalance shards.
Main reinstalling its own panes no longer counts as a newer window graph, so
the window's pending graph reply stops throwing. A slept agent in a main-owned
pane shows as the idle agent, not its stopped process. Close and move steps in
the wake tests go through main's layout when the switch is on.
…aches parked panes

With the new layout path, main published a pane bound to a terminal that had
exited, so after a sleep the CLI and phones still named the stopped terminal
while the window drew none. Main now publishes such a pane with no terminal,
as the window draws it; the layout keeps the binding.

A hidden pane that main starts waited for its first view even when a phone
wake asked for it. A workspace wake now has main start a parked pane right
away, and a tab mounted by that wake starts on mount.
…er-b1-b3-sleep-wake

# Conflicts:
#	.github/workflows/layout-owner-switch-on.yml
#	config/scripts/ci/layout-owner/check-switch-on-unit-results.mjs
#	config/scripts/ci/layout-owner/switch-on-known-unit-failures.json
#	src/main/runtime/orchestration/mailbox/routing/slept-agent-wake-no-window.test.ts
#	src/shared/workspace-layout/commands/workspace-layout-command.test-fixture.ts
#	src/shared/workspace-layout/workspace-layout-command-model.test.ts
#	tests/layout-owner-e2e/relaunch-sleeping-agents-resume-on-view.spec.ts
#	tests/layout-owner-e2e/workspace-layout-oracle.spec.ts
…t a window

With the new layout path on, every slept-pane wake (a message, a CLI act, a
worker start, a phone opening the workspace) now has main start the pane
itself through its restored-pane starter, which already shares one start
per pane. A mail wake's attempt id is carried into the started process, so
the wake can confirm it. The window no longer drives these wakes; the
window-side wake code from the last commit is removed. A record whose tab
is gone stays with the window, which reopens it in a fresh tab.

This also lets a host with no window wake a slept agent.

Also: a slept agent's pane lists and shows as the writable idle agent even
though main marks it sleeping, and a terminal's certified exit now updates
what main publishes right away instead of at the next window graph.
@Jinwoo-H Jinwoo-H changed the title fix(layout-owner): slept-agent wake, sleep-quit-resume and phone wake under the new layout path fix(layout-owner): main wakes slept panes it owns (B1, B2, B3, B5) Nov 28, 2026
…er-b1-b3-sleep-wake

# Conflicts:
#	config/scripts/ci/layout-owner/switch-on-known-unit-failures.json
…fter a window close or restart too

- A terminal main starts into an Agent-slept pane takes the handle the pane
  answers to, as a window-started resume already did, so mail, waits and
  worker lists keep naming the agent.
- A wake by handle finds the pane again after the window closes or the host
  restarts: the pane's saved sleep record names the handle, and main's
  binding names the stopped terminal when no sleep row is left.
- A pane closed out of a split no longer counts as held because its sibling
  keeps the tab.
- A phone told about a wake now hears that main resumes what it holds.
- Main resumes an originless legacy sleep record in a pane it holds instead
  of starting a plain shell.
…er-b1-b3-sleep-wake

# Conflicts:
#	tests/layout-owner-e2e/workspace-layout-oracle.spec.ts
@Jinwoo-H
Jinwoo-H merged commit 7f681c8 into layout-owner-v2 Nov 28, 2026
67 checks passed
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