diff --git a/apps/web/src/components/terminal.tsx b/apps/web/src/components/terminal.tsx index 68434e4..5a24863 100644 --- a/apps/web/src/components/terminal.tsx +++ b/apps/web/src/components/terminal.tsx @@ -214,6 +214,19 @@ export const TerminalComponent: React.FC = ({ term.open(container); ws = connectWebSocket(); + // Force xterm.js to fully redraw after resize + const forceRedraw = () => { + if (!termRef.current) return; + const term = termRef.current as any; + const rows = term.rows; + // Access internal renderer to force clear and redraw + if (term._core?.renderer) { + term._core.renderer.clear(); + } + // Refresh all visible rows + term.refresh(0, rows - 1); + }; + // Fit terminal and notify backend const fitTerminal = () => { if (!fitAddonRef.current || !termRef.current) return; @@ -221,9 +234,9 @@ export const TerminalComponent: React.FC = ({ const oldRows = termRef.current.rows; fitAddonRef.current.fit(); const { cols, rows } = termRef.current; - // Force refresh if dimensions changed + // Force full redraw if dimensions changed if (cols !== oldCols || rows !== oldRows) { - termRef.current.refresh(0, rows - 1); + forceRedraw(); } if (ws.readyState === WebSocket.OPEN) { ws.send(JSON.stringify({ type: "resize", cols, rows }));