fix(desktop): keep inactive terminals sized so switching doesn't garble

Hide inactive terminal tabs with `visibility` (absolute-stacked at full size)
instead of `display:none`. A display:none host is 0×0, so its ResizeObserver
fit bails and the terminal stops tracking pane resizes — re-showing it at a
changed size reflowed the buffer into a garbled prompt. Visibility-hidden
hosts keep their layout size, stay in sync, and switch instantly.
This commit is contained in:
Brooklyn Nicholson 2026-06-28 19:08:25 -05:00
parent 6875d6cd3e
commit c1bb34d5e8

View file

@ -32,10 +32,13 @@ export function TerminalInstance({ id, active, cwd, onAddSelectionToChat }: Term
return (
<div
className={cn(
// No top padding — the prompt hugs the titlebar-clearance line instead of
// floating a row below it (the rest of the gap is the required clearance).
'relative min-h-0 min-w-0 flex-1 flex-col bg-(--ui-editor-surface-background) px-2 pb-2 pt-0',
active ? 'flex' : 'hidden'
// Stack every terminal absolutely and toggle visibility (NOT display) so
// inactive tabs keep their layout size and track pane resizes — a
// display:none host goes 0×0, skips fit, and renders garbled when shown
// again at a changed size. No top padding so the prompt hugs the
// titlebar-clearance line (the rest of the gap is required clearance).
'absolute inset-0 flex flex-col bg-(--ui-editor-surface-background) px-2 pb-2 pt-0',
active ? 'visible' : 'invisible pointer-events-none'
)}
>
{status === 'starting' && (