Repository navigation
terminal: window says where each new terminal goes (no behavior change) - #26078
Conversation
…eport-only The window now says where each fresh terminal goes: the first pane of a tab sends new-tab with the tab's creation fields, a split sends the parent leaf, direction, ratio and the tree after the split, background launches send the same, and a Codex restart that rebuilds a rootless layout sends root. A reattach sends nothing. Main still only records whether placement names the tab its binding write picks; its 'absent' value now counts only new leaves without placement, so it reads the fallback mint and graft directly. Extends the shared placement type with optional row, ratio and proposedRoot, each dropped alone if malformed, so older and newer peers keep working.
…he tab lacks The adopted tab is created without launchAgent, so a row naming one would diverge from the renderer's tab once main applies placement.
…order wrapInSplit now places the new pane first itself, so the pane-created handler's proposedRoot sees the real post-split tree instead of the order before the subtree split moved it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds tab-row and split-layout details to terminal placement metadata. Pane creation and background terminal spawns attach placement information, and fresh PTY spawns forward it while reattachments omit it. Background pane exit handling moves to a shared helper. Detached Codex restart and terminal topology logic update how they handle rootless or already-present leaves. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This test-only change adds checks for worktree terminal placement metadata without revealing a production regression; it appears safe to merge after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
ELI5
When a new terminal starts, main has to decide which tab and pane it belongs to, and today it partly guesses. The previous PR (#25677) let a terminal start carry a note saying where it goes, and made main compare that note with its guess. This PR makes the window write that note for every terminal it starts. Main still only records whether the note agrees with its guess; it never acts on it. One small fix rides along (below); otherwise nothing changes for users.
What Changed
Before/after for users: one fix. In a remote tab, when a pane was inserted before another pane, the window briefly sent the host the panes in the wrong order and then corrected it. Now it sends the right order once. Everything else is identical to main: same tabs, same panes, same saved state.
The fix: the pane manager now puts a pane that goes before another pane in its final spot while building the split, instead of moving it there afterwards. So everything that reads the layout as the pane appears, including the layout this PR sends, already sees the real order.
What the window now sends on
pty:spawn:Shared type (
src/shared/terminal-pane-placement.ts): new optionalrowon new tab, andratioandproposedRooton split. They reuse the saved-session schemas for tabs and layouts. A malformed optional field is dropped on its own, so the rest of the placement still counts.Main: the recorded
binding.placementvalueabsentnow means "a new pane arrived with no placement" (a pane main already knows reportsleaf_presentfirst). That makes it a direct count of starts that still rely on the guess, which should be zero before the guess is deleted. Still recorded in a guarded block; it cannot fail the start.Moves only, to stay under the file-size limit: the background pane's exit-output saver moves to
lib/background-pane-exit-output.tsunchanged; Codex restart uses the existingcollectLeafIdsinstead of its own tree walk.Why
The next step lets main build the tab or split from this note and stop guessing, which removes one way the same terminal can show up in two tabs (STA-9417). That step needs every window-started terminal to carry the note, including the tab's creation fields (otherwise main would blank them) and the post-split layout (the parent pane and a direction can't describe a split placed before a group of panes). Sending everything now, while main only compares, keeps this PR without behavior changes and lets real traces show how often the guess disagrees before anything depends on it. Putting the data on the existing spawn request avoids a second message or new state.
Linked Issue
Maintainer PR. Part of the terminal layout refactor (Linear STA-9417). Follows #25677.
Visual Proof
N/A: no visible UI change. The one fix is a brief wrong-order layout message to a remote host, which has no on-screen trace to capture.
Testing
Layout parity check (
ORCA_BACKGROUND_LAUNCH=1 pnpm run test:e2e:terminal-layout-parity -- --base origin/main --head HEAD): all 9 scenarios, 0 differences (none declared, none undeclared).pnpm tc, oxlint, oxfmt,check:code-quality:changed: pass.New/updated tests: pane manager sends new tab for the first pane, split with parent and direction, and for a split placed before a group of panes; the placement completion adds the tab row and the real post-split layout (ratio read back from the panes); the transport sends placement on a fresh start and not on a reattach; the pane connection carries it to the transport; background launches and Codex restart send the expected placement; schema keeps the new fields and drops only a bad one; the main inertness test now expects
leaf_presentfor a known pane.Vitest over the touched renderer,
src/main/{persistence,ipc}and shared tests: everything passes except files that fail the same way on origin/main in this environment (unrelated).I manually tested these changes locally
Automated tests added/updated, or explained why not below
Manual app testing not needed: the only behavior change is the remote-tab ordering fix above, which a unit test covers, and the parity run drives the real app for each scenario.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
pty:spawnonly goes from this app's window to its own main process. Placement is never forwarded to the SSH relay, remote runtimes or the web client, which build their own requests field by field. All new fields are optional; an older main ignores them (its schema strips unknown keys).Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)