Skip to content

Drag a pane out to a new tab through main (dark, build switch off by default) - #29351

Merged
Jinwoo-H merged 49 commits into
mainfrom
layout/c2-pane-detach
Oct 16, 2026
Merged

Jinwoo-H merged 49 commits into
mainfrom
layout/c2-pane-detach

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​611 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​611
Prod 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​454 $\color{#cf222e}{\Huge{\mathbf{−}}}$​94 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​360

ELI5

In a test-only build (switch ORCA_LAYOUT_OWNER=main), dragging one pane of a split out into a new tab now goes through the background process's layout command path, like the other tab and pane changes. The background process decides the new tab's id and where it goes, and the window opens the tab under that id. Normal builds are unchanged.

Stacked on #29327 (tab close through the background process).

What Changed

Normal builds: nothing. The one switch point in the drag-out compiles to today's code.

Test builds with the switch on, for a local or SSH workspace:

  • Before: the window picked an id for the new tab and asked the background process to move the pane through its own message (pty:moveLeafToNewTab).
  • After: the window sends movePaneToNewTab through layout.apply, with the terminal the pane shows and the target group and position. The background process:
    • picks the new tab's id, one id for every saved partition that holds the pane;
    • moves the pane, its terminal binding, title, sleeping-agent record and scrollback with it, in every holding partition, in one write;
    • moves the pane-keyed screen marks, SSH terminal leases and remote session ids to the new tab;
    • moves agent status and orchestration records to the pane's new key, as today's move does.
  • The window then opens the new tab under the background process's id. The terminal keeps running, so its output stays.
  • When the background process does not hold the tab or pane, or a paired server owns the workspace, today's move message runs instead.

The shared pane move (movePaneToNewTab) gains an option, windowDetach, that only layout.apply sets. With it, the move follows today's desktop rules:

  • the terminal the window's pane shows wins over an older binding in a saved copy, and that copy's stale incarnation is dropped;
  • the tab's last pane in the background process's copy moves too, because the window holds the other panes that copy has not seen yet;
  • before anything is written, every partition is checked: a pane another tab holds is refused, and so is a terminal that no copy names.

Phones and the headless host do not set the option, so their pane move is unchanged.

Refactors with no behaviour change:

  • The re-keying of agent status and orchestration records moves from the move message's handler into runtime/moved-pane-owner-rekey.ts, so both paths share it.
  • The check for "another tab holds this pane" and the screen-mark and lease writer are shared between today's move and the new one.
  • pane-close-remote-session.ts is renamed pane-remote-session-follow.ts, since it now follows a moved pane too.

Why

  • The legacy rules go into the shared command behind an option. That keeps one move implementation that phones will use later, without changing what phones and the headless host do today.
  • The background process picks the id after all partitions agree. The cross-partition checks run before any write, so the move lands in every holding partition or in none.
  • Falling back to today's message covers the cases where the background process's copy lags the window's, as the other C-phase commands do.

Linked Issue

Part of the layout single-owner plan (phase C2).

Visual Proof

N/A for shipped builds: no behaviour change with the switch off.

Switch on, hidden test app, real pointer drags of a pane's handle onto a tab strip:

  • Into the same group: the window sent movePaneToNewTab with the pane's live terminal. The background process replied ok, tabId f56c472c… with that terminal. The new tab "Terminal 2" opened under that id, still showing the command typed before the drag.
  • Into the other group of a two-group workspace: the reply was ok, tabId e528cf33…. The tab opened at the requested position in that group.
  • After a restart: both groups, all three tab ids and each tab's pane came back as they were.

Testing

  • I manually tested these changes locally (macOS, hidden dev app with the switch on)
  • Automated tests added/updated

Automated tests:

  • Store level: today's move tests repeated through layout.apply, covering:
    • re-keying of records, screen marks and SSH leases;
    • the last pane of the background process's copy;
    • both refusals, and taking the one bound terminal;
    • remote session ids;
    • an SSH pane held by two partitions, including after a respawn;
    • the earlier bug's sequence (move, reattach, stale save, restart).
  • Shared command:
    • the window's terminal wins over a stale binding;
    • an unbound copy keeps its incarnation;
    • the last pane moves.
  • Record patch: every saved-session fixture round-trips the drag-out.
  • Main routing:
    • every non-paired-server holder;
    • re-keying by the terminal's id;
    • a committed move still answers ok if re-keying throws.
  • Request checks: the window cannot name the new tab.
  • Window:
    • main's id is used;
    • the fallback to today's message;
    • a refusal keeps the pane and shows the failure toast.

End-to-end, switch on, built from this branch restacked onto the current pane-gesture branch (which includes main's layout stream):

  • layout oracle 21/21, including drag-out-to-tab;
  • terminal-layout parity and pane-binding specs 12/12, including drag-out-to-tab and restart-restore.

Switch off, built bundles (base #29327's head c7f51d3, with chunk hashes, minified names and the build commit normalized):

  • Renderer: every chunk is identical apart from the build commit. The drag-out compiles to today's message.
  • Main: differs in two ways:
    • the windowDetach branches of the shared move, the cross-partition check and the layout.apply params and routing, which run only from layout.apply, registered only with the switch on;
    • three extractions that change no behaviour: the re-key function, the other-tab check, and the screen-mark and lease writer.

Checks run locally:

  • the static-analysis steps from the PR workflow;
  • pnpm tc;
  • vitest for src/main/persistence, src/main/runtime, src/main/ipc/pty, src/shared and the renderer store, tab-group, terminal-pane and runtime folders: 3782 files passed. One fish-shell test fails because of this machine's fish config, and it touches nothing here.

Review

  • Opus review: MERGE AFTER FIXES. Both must-fixes are fixed in a899093:
    • Must-fix: a saved copy that never bound the pane lost its incarnation. It now keeps it, as today's move does.
    • Must-fix: if re-keying threw after a committed move, the window would also run today's move. A committed move now always answers ok.
    • Nits taken: the callback takes only the move, the remote-session file rename, and a comment on the legacy tab-id fallback.
    • Delta nit taken: the re-key takes only the move (its terminal is the committed one).
    • Nit declined: the source terminal id is still read twice. Both reads use the same tab entry.
  • Opus delta review: MERGE AS IS.

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

SSH workspaces take the same path as local ones, including a pane held by both the local and SSH partitions. Paired-server workspaces keep today's message. Folder workspaces use the same command, and the oracle's folder scenario passes.

If the tab-creation PR (#29311) lands first, its create recorder will also send a create for the tab the window opens here. The background process already holds that tab, so it is a refused no-op, but the drag-out should skip it. I'll handle that in whichever PR lands second.

Temporary code (removed when main becomes the only layout writer, phase F unless noted): the drag-out switch point, the windowDetach option (folds into movePaneToNewTab once every caller uses the desktop rules), and the fallback to today's move message.

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)

… through main behind ORCA_LAYOUT_OWNER

A build made with ORCA_LAYOUT_OWNER=main registers layout.apply: main applies the
window's layout command to the stored partition through the shared applyLayoutCommand,
minting new ids. A user split then waits for main's answer and mounts the pane id main
minted. Every other build substitutes 'window', so neither branch is compiled in.
A load-then-save rewrite also normalizes records the command never touched. The command's
effect is now the diff between the save before and after it, written onto the stored
partition record by record. A split whose main reply says a paired server holds the tab
splits as today.
…CA_LAYOUT_OWNER

In a layout-owner build the window's pane close, title change and equalize go through
layout.apply and the window shows main's answer. A window pane close keeps the legacy
close's rules: the tab's last pane is refused, a pane restarted since main read the close is
left alone, every partition holding the tab closes it, and the tab's remote session id follows
the remaining pane. The rules sit behind a command field only layout.apply sets.
…ORCA_LAYOUT_OWNER

Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…e drops main cannot take

Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…oday

Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…de-up profile state

Claude-Session: 10569c9a-a0a1-4fc9-8469-0edfb7aed125
…row names a paired server

The split switch point asked which host to route to with a helper that falls back to the focused
server, so a focused server could claim a workspace whose row names no owner. Use the same owner
test the tab mirror uses.
…yout/c1b-pane-ops

# Conflicts:
#	src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-split-through-layout-owner.ts
…ed or failed splits and moves, ratios during a move, release guard

- A pane main saved but the window could not mount (source pane or manager gone during the await)
  is closed again in main, so it does not come back on restart.
- A split main refuses because its copy lacks the workspace, tab or pane, or a failed call, splits
  as today; a refused or failed move moves as today.
- Divider ratios committed while a move is in flight wait for the window's move, then go to main.
- The orcad bundle gets the ORCA_LAYOUT_OWNER define when the switch is on.
- Packaging and the orcad template refuse ORCA_LAYOUT_OWNER=main and any output a dark build marked.
- workspace-layout-record-patch.ts: no non-null assertions; plain comment for the map depth.
…throws, not just for splits

- sendPaneCommandToLayoutOwner runs asToday for workspace/tab/pane_not_found and a thrown call, so
  close, rename and equalize fall back like split and move; a handler that throws no longer runs the
  fallback too.
- A close main refuses as its last pane, while this window still has others, closes as today.
- A move whose local step throws still releases held divider ratios.
- Drop the orcad output marker: nothing read it; the template build refuses the switch itself.
# Conflicts:
#	src/main/persistence/loading-store/pty-binding-persistence.ts
#	src/main/persistence/terminal-topology/terminal-layout-apply.test.ts
#	src/main/persistence/terminal-topology/terminal-pane-admission.ts
#	src/main/runtime/orca-runtime.ts
#	src/main/runtime/rpc/methods/workspace-layout-apply.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.test.ts
#	src/renderer/src/components/terminal-pane/terminal-pane-split-with-inherited-cwd.ts
#	src/shared/rpc-contract/workspace-layout-params.ts
#	src/shared/workspace-layout/workspace-layout-record-patch.test.ts
#	src/shared/workspace-layout/workspace-layout-record-patch.ts
…layout-owner build switch

In an ORCA_LAYOUT_OWNER=main build, the tab bar's rename, color and pin ask main's layout.apply
first; the window then runs today's action. When main lacks the tab or the call fails the
window acts as today; a paired server's workspace keeps today's path. Pinning a tab now also
ends its preview in main's copy, as the tab bar's pin does. Other builds compile the switch out.
…in opens files

Changing the shared pin command would change what a paired client's pin does in every build.
…ut.apply command touches its claim

A legacy terminal row the load folds into a tab-bar tab stays stored as is. Closing the tab it
repeats, or giving it a tab-bar entry by moving it, let the next load resolve the claim the other
way: the row came back or took the other tab's terminal. Such a command now writes the row as
the load had it; every other record still stays as stored.
…t.apply

Group sizes have no tab, so they go to the workspace's routed partition.
…rminal pane folder

Tab groups send through it too; it now also acts as today when main lacks the group.
…s, through main behind ORCA_LAYOUT_OWNER

A tab drop and Move Tab to Split wait for main's answer and then show main's placement, with main's
new group id; group divider sizes are drawn while dragging and saved by main when the drag ends.
Closing an empty group needs no command: main never holds an empty group.
- Read a folded row's terminals with the loader's own claim rule, so rows sharing only an SSH
  session are covered too, and drop the row's remote session entry with it.
- The record-patch test allows a folded row only in its loaded form.
- A tab drag ends at once; main's answer shows the move after.
- A lone group main moved whole is placed so only when this window's group is lone too.
A row's remote session entry is carried through load and save unchanged, so adopting it from the
load changed nothing (the earlier commit's message overstated it).
closeTabs can now record each terminal tab it closes, or does not find, as closed for the given
reason (pruned as a partition's records are), so a start that commits later is refused, as today's
close records it. layout.apply takes one tab's close with the window's reason: main forces it in
every holder partition, marks a user close's launches, stops no terminal (the window already did,
sparing any another tab shares), and leaves a workspace it lacks to today's close. A sibling the
load supplied that the close only renumbered is no longer written.
…A_LAYOUT_OWNER

The window still closes the tab and stops its terminals itself; main records the close through
layout.apply instead of the close intent, which stays for paired servers and when main lacks the
workspace.
- The window's close sends through a store-free sender, so the store no longer imports itself.
- Main marks a user close's launches by the terminal's own id.
- A recorded close prunes the whole partition's close records, as today, not one workspace's.
Main moved the layout.apply sender to runtime/layout-owner-command.ts: the tab-bar rename and props commands join its WindowLayoutCommand, and the params reuse main's OnTab.
Main split the layout.apply command type into runtime/layout-apply-send.ts: the tab-bar rename and props commands join it there.
@Jinwoo-H
Jinwoo-H changed the base branch from layout/c2-tab-close to main October 16, 2026 08:22
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7369db51-e15c-4749-871e-8bb79d4465fb
📥 Commits

Reviewing files that changed from the base of the PR and between 941ad1e and ee316ee.

📒 Files selected for processing: 23
  • src/main/ipc/pty/ipc/leaf-move.ts
  • src/main/persistence/terminal-topology/pane-remote-session-follow.ts
  • src/main/persistence/terminal-topology/restorable-write.ts
  • src/main/persistence/terminal-topology/terminal-leaf-move.ts
  • src/main/persistence/terminal-topology/terminal-pane-admission.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts
  • src/main/persistence/terminal-topology/terminal-window-pane-detach.test.ts
  • src/main/persistence/terminal-topology/window-pane-detach.ts
  • src/main/runtime/moved-pane-owner-rekey.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/workspace-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.test.ts
  • src/main/runtime/runtime-layout-apply.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-detach-layout-owner.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
  • src/renderer/src/runtime/layout-apply-send.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • src/shared/terminal-leaf-move.ts
  • src/shared/workspace-layout/workspace-layout-command-types.ts
  • src/shared/workspace-layout/workspace-layout-commands.test.ts
  • src/shared/workspace-layout/workspace-layout-pane-commands.ts
  • src/shared/workspace-layout/workspace-layout-record-patch.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📝 Walkthrough

Window pane detachment now carries pane, PTY, and optional tab identity through layout commands. The renderer can route moves through the layout owner. The main process resolves detach requests across session partitions, commits successful moves, and updates profile records and remote-session mappings. Successful moves report the resulting PTY and tab IDs, and trigger pane-owner rekeying.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to ee316

The inspected drag-out and fallback paths show no issue requiring a fix before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarizes the main change: routing pane drag-out into a new tab through main, with the build switch disabled by default.
Description check Passed The description is comprehensive and follows the required template. It explains the user-visible change, implementation, rationale, testing, visual proof, compatibility considerations, and checklist s…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is comprehensive and follows the required template. It explains the user-visible change, implementation, rationale, testing, visual proof, compatibility considerations, and checklist status. The linked issue section does not include a direct issue link, but it references related issues and the overall description remains sufficiently complete.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit 127704b into main Oct 16, 2026
62 of 63 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