fix(desktop): force a repaint when a terminal is re-activated

A WebGL terminal doesn't paint while visibility:hidden, so switching to it
(e.g. after closing the active tab) revealed a stale/garbled frame. On
activation, clear the glyph atlas and force a full term.refresh against the
live buffer (after the refit), then focus.
This commit is contained in:
Brooklyn Nicholson 2026-06-28 19:13:58 -05:00
parent b02f453496
commit 6e12f8ce4a

View file

@ -708,16 +708,21 @@ export function useTerminalSession({ id, cwd, active, onAddSelectionToChat, onSh
return term ? registerTerminalReader(id, makeTerminalReader(term)) : undefined
}, [id, status])
// On (re)activation the host went display:none→visible: focus it and refit so
// a stale 0×0 fit from while it was hidden doesn't strand the prompt.
// On (re)activation: a WebGL terminal doesn't paint while visibility:hidden, so
// it reveals a stale/garbled frame. Refit, rebuild the glyph atlas, and force a
// full redraw against the live buffer, then focus.
useEffect(() => {
if (!active || status !== 'open') {
return
}
const frame = requestAnimationFrame(() => {
const term = termRef.current
fitRef.current?.()
termRef.current?.focus()
webglRef.current?.clearTextureAtlas()
term?.refresh(0, term.rows - 1)
term?.focus()
})
return () => cancelAnimationFrame(frame)