Skip to content

fix(layout-owner): bring panes back after a live terminal service restart - #51734

Merged
Jinwoo-H merged 12 commits into
layout-owner-v2from
layout-owner-b4-daemon-restart-rebind
Nov 28, 2026
Merged

Jinwoo-H merged 12 commits into
layout-owner-v2from
layout-owner-b4-daemon-restart-rebind

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor

ELI5

When you restart the terminal service (Settings, or the daemon restart action) with the layout-owner build, the panes that were open stayed blank: typing did nothing and the old output never came back with a new prompt. This makes them come back, the way they already do with the switch off.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​142 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​139
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58

Before / after

  • Before (switch on): restart the terminal service with a split open. Both panes stay bound to their dead terminals. orca terminal send into either pane fails with terminal_not_writable, or the text goes nowhere.
  • After: both panes start a fresh terminal in place, keep their old output above the new prompt, and accept input.

Mechanism

Two gaps in main's own pane starts, which the window's restart replacement now goes through:

  1. Main's starts did not wait for the restart. Window starts (pty:spawn) wait for an in-flight terminal service restart so they reach the new service. Main's runtime starts lost that wait in the start unification. During a restart, main's start probed the old service, which still listed the terminal, and reattached to it just before it stopped. The runtime controller's spawn and adoptStablePane now wait on the same local startup/restart promise as pty:spawn.
  2. Main's starts cleared the dead binding before the new one existed. With main owning layout, window starts keep a proven-dead binding until the fresh terminal's bind replaces it in one write. Main's starts did not: they retired the binding first. The pane was briefly published with no terminal, which ended its "starting" status, so the window attached to nothing. Main's starts now keep the dead binding for the swap too. adoptStablePane carries the kept binding on the fresh start's operation, so the spawn that takes the start swaps it, whichever entry point began it. Until a spawn takes it off that operation, adoption owns the kept binding and retires it if the start is aborted or fails first, so a dead binding is never left behind.

Unchanged: only a binding the host proved absent is kept for a swap, and only on local hosts. Remote and SSH bindings still retire on their host. No terminal that a pane binds is stopped, and moved panes are untouched.

Census

Fixes B4 (L314). Removes its expected-fail mark in workspace-layout-oracle.spec.ts, so live-daemon-restart must pass on the switch-on lane.

How it was tested

  • Switch-on build (ORCA_LAYOUT_OWNER=main, marker checked): live-daemon-restart, cold-daemon-restart and restart-restore oracle scenarios, 3 repeats each. 9/9 passed. Before the fix, live-daemon-restart failed on every run: either terminal_not_writable on both panes, or one pane never showed its marker.
  • Switch-off build: the same three scenarios, 3/3 passed.
  • New unit test adopt-stable-absent-swap.test.ts: when the host no longer has a pane's terminal, the fresh start receives the dead binding to swap; an abort or a launch failure before any spawn takes it retires it; a spawn that took it owns its cleanup. The retirement cases fail if the release is reverted.
  • pnpm tc:node, oxlint and oxfmt on the touched files.

Performance

None, because main's terminal starts only add one await on a promise that is already settled unless startup or a terminal service restart is in flight; then they wait for it, as window starts already do. Keeping the dead binding for a swap saves one store write.

Visible changes

None beyond the bug fix: after a terminal service restart, panes come back as they do with the switch off.

Jinwoo-H and others added 12 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.
…tart

With main owning layout, a terminal service restart left both panes of a
split bound to their dead terminals: typing was refused and nothing showed.

Main's own terminal starts no longer waited for an in-flight restart, so a
pane's start reattached to the old service just before it stopped. Main's
starts now wait as window starts do. The start then found the old terminal
gone and cleared the pane's binding before the fresh terminal bound, so the
pane's "starting" status ended with no terminal for the window to attach.
Main's starts now keep the dead binding until the fresh one replaces it in
one write, as window starts already did.
…er-b4-daemon-restart-rebind

# 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/workspace-layout-oracle.spec.ts
A binding kept for the restart swap stayed persisted if the start was
aborted or failed between the attach probe and the spawn. Adoption now owns
the kept binding until the spawn takes it off the fresh operation, and
retires it on any failure before then. Only a start with a fresh launch keeps
one, and a retried attach drops the first attempt's.
@Jinwoo-H
Jinwoo-H merged commit d13e69c into layout-owner-v2 Nov 28, 2026
65 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