Skip to content

Reflow terminal panes when a sibling is spawned#189

Open
luckeyfaraday wants to merge 1 commit into
mainfrom
fix/terminal-pane-reflow-on-spawn
Open

Reflow terminal panes when a sibling is spawned#189
luckeyfaraday wants to merge 1 commit into
mainfrom
fix/terminal-pane-reflow-on-spawn

Conversation

@luckeyfaraday

Copy link
Copy Markdown
Owner

Problem

Spawning a terminal pane below an existing one didn't shrink the pane above — the new pane rendered into a stale, half-garbled layout. It only happened after a pane had been manually resized.

Root cause

Each pane exposes a native drag-resize handle (.slotPane { resize: vertical }). When you drag it, the browser writes an inline height: straight onto the DOM node. React never sets that property, so it never clears it on re-render — the resized pane stays pinned at its old height and won't participate in the grid when a sibling is added. Un-resized panes have no inline height, so they reflow fine (hence "only sometimes").

Fix

  • CommandRoom.tsx — clear the inline height on every visible pane whenever the pane set changes (spawn / close / reorder), so the grid re-tiles all of them. Because each pane's box then actually changes size, its existing ResizeObserver fires and refits the xterm, clearing the stale render too.
  • styles.css — switch the non-focused embedded stage to an equal share-space grid (grid-auto-rows: minmax(0, 1fr) + align-content: stretch, .slotPane min-height: 0) so panes shrink to make room instead of the stage just scrolling.

Behavior / trade-off

Manual vertical resize still works within a stable set of panes; it's just no longer sticky across spawn/close — adding or removing a pane snaps everyone back to equal tiling. overflow: auto is kept so a deliberately tall pane scrolls rather than clips.

Testing

  • tsc -p tsconfig.json --noEmit passes.
  • Not yet driven in the running Electron UI.

🤖 Generated with Claude Code

A pane's native `resize: vertical` handle writes an inline height directly
onto the DOM node. React never manages that property, so it is never cleared,
which left a previously resized pane pinned at its old height when a new pane
was spawned below it — the pane above refused to shrink and the new pane
rendered into a stale layout.

Clear the inline height on every visible pane whenever the pane set changes,
so the grid re-tiles all of them (which also fires each pane's ResizeObserver
and refits its xterm). Switch the non-focused embedded stage to an equal
share-space grid (minmax(0, 1fr) + stretch, min-height 0) so panes actually
shrink to make room instead of scrolling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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