Repository navigation
refactor(terminal): add in-place pane layout geometry apply (unused) - #25671
Conversation
PaneManager.applyLayoutGeometry applies a layout's split orientation and ratios to the mounted pane tree without remounting panes, and never fires onLayoutChanged. Nothing calls it yet; the live-layout reconciler adopts it in a later change.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughAdds shared split-ratio reading for layout serialization and a PaneManager method that applies orientation and ratio changes to a mounted pane tree. The geometry update validates the full tree before making DOM changes. Tests cover ratio and orientation updates, nested splits, unchanged layouts, mismatched trees, zoomed trees, and missing dividers. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The new geometry method has no production callers, and the identified ratio concern does not affect supported pane operations. The change is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The new operation is not connected to live callers, validates existing pane identities and tree shape before changing geometry, and preserves saved-layout behavior. No material security exposure was identified in this change. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- In-place geometry apply (new, unused):
pane-layout-geometry-apply.tsvalidates that the mounted pane tree exactly matches the suppliedTerminalPaneLayoutNode— same leaves, same shape, same child order — before touching the DOM. On a mismatch it returns without any writes, so it never half-applies. On a match it updates split directions and flex ratios in place, disposes the old divider and creates a new one on an orientation flip (a divider binds its drag axis at creation), refits the affected panes, and never firesonLayoutChanged. - Public API:
PaneManager.applyLayoutGeometry(layout)exposes the managed wrapper; the two collapsed constructor arrows inpane-manager.tsare behavior-preserving. - Tests: five happy-dom tests on a real
PaneManager(ratio-only change preserves pane/container/terminal identity with no create/close/layout-changed callbacks; orientation flip swaps the divider to the new axis; identical layout produces zero DOM mutations viaMutationObserver; a nested split changes in isolation; a mismatched tree writes nothing).
I traced the write path against wrapInSplit, refitPanesUnder, createDivider/disposeDivider, findPaneChildren and serializePaneTree, and independently confirmed happy-dom's MutationObserver actually records mutations (so the zero-writes test is real coverage). The tolerance and readSplitRatio formula match serialization, and the recursive plan discards accumulated writes when a deeper subtree mismatches. No reachable input applies a change against a tree that does not match.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…toast Main (#25668) introduced a duplicate import that fails the focused code-quality lint.
…ess trees in geometry apply
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review (80a5045): the ratio-read extraction, the new tree-match guards, the apply-path merge, and two new tests.
- Shared split-ratio read:
readSplitRatioandSPLIT_RATIO_TOLERANCEmoved intopane-split-ratio.ts;serializePaneTreeand the geometry apply now share them with identical near-0.5 behavior (both yieldundefined/no-write when total grow is not positive). - Refuse zoomed trees:
applyPaneLayoutGeometrynow returnsfalsewith zero DOM contact when either child of a split isdisplay: none— the expand/zoom state, where the expanded pane hides its siblings and owns their flex, so an apply would be overwritten by collapse's saved-style restore. - Require exactly one divider:
findDividersmakes a dividerless or multi-divider split a tree mismatch, so a ratio-only apply never runs against a split whose drag handle is missing or duplicated. - Simplified apply path:
applyManagedPaneLayoutGeometryfolded intoapplyPaneLayoutGeometry(host, layout)returningboolean; the orientation flip disposes and replaces the divider captured during planning instead of re-querying the DOM. - Tests: Added coverage that a zoomed pane tree and a split missing its divider each yield
falsewith no DOM mutations.
I verified the zoom guard against applyExpandedLayoutTo (it sets display: none on every sibling along the path to the root, so the guard trips at the topmost split regardless of which subtree holds the expanded pane), confirmed findDividers/findPaneChildren count direct children only, and ran the suite locally (7 passed).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
Later in this refactor the app window will follow main's copy of the terminal layout. When main says "this split is now 60/40" or "this split is now vertical", the window needs to change the panes already on screen without tearing them down (which would lose scrollback and focus). This PR adds that ability. Nothing calls it yet, so nothing changes for users.
What Changed
src/renderer/src/lib/pane-manager/pane-layout-geometry-apply.ts: given a layout, it compares it to the panes on screen split by split. If the panes are not exactly the same set in the same shape (including a split missing its divider), or a pane is currently zoomed to fill the tab, it does nothing (never half-applies). Zoom is skipped because un-zooming restores the pane sizes saved at zoom time and would overwrite anything applied meanwhile. Otherwise it updates split ratios and directions in place, refits the affected panes and restyles dividers. A direction change swaps the divider element, because a divider's drag axis is fixed when it is created. Ratio differences of 0.005 or less are ignored, so a saved layout re-applied moves nothing. The ratio read and that 0.005 limit now live inpane-split-ratio.ts, shared withserializePaneTree(same results as before). It never callsonLayoutChanged, so applying a layout cannot trigger a save.PaneManager.applyLayoutGeometry(layout)exposes it. Two constructor arrow functions were collapsed to single lines to stay under the file's line limit (no behavior change).Before/after for users: none. There are no production callers; the layout reconciler starts using it in a later PR of this series, together with the protection that stops a host update from undoing an in-progress local drag.
Why
Without in-place apply, the window would have to rebuild panes to follow a layout change from main. Wiring it in now would add cross-client divider syncing (a new feature, not a fix) and could make a divider jump back during a local drag, so it lands inert and is wired up later.
Linked Issue
Maintainer PR. Part of the terminal layout refactor (context: Linear STA-9417, STA-9259).
Visual Proof
N/A: no caller, so no visible change.
Testing
pnpm tc, oxlint, oxfmt andcheck:code-quality:changedpass.7 new tests on a real
PaneManager(happy-dom; xterm's open mocked): a ratio change keeps pane ids, containers and terminal objects with no create/close/layout-changed callbacks; a direction flip keeps the split and swaps the divider; an identical layout makes zero DOM changes (MutationObserver); only a changed nested split updates; a mismatched layout, a zoomed pane, or a split without a divider makes zero changes. Each test was checked by breaking the code; each break fails at least one test.lib/pane-managerandcomponents/terminal-panesuites: all pass except two tests in an untouched file (remote-snapshot-alt-screen-host-chain.test.ts) that time out the same way with this PR's files reverted to main.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Not manually tested in the app: nothing calls the new code.
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
No change to saved state, wire protocols, SSH, mobile or platform behavior.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)