debug: add console logging for terminal resize debugging

This commit is contained in:
Fusion
2026-05-24 19:44:21 +02:00
parent 738e01bb7c
commit 3092038e40
2 changed files with 28 additions and 12 deletions
+15 -12
View File
@@ -216,26 +216,29 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
// Fit terminal and notify backend
const fitTerminal = () => {
if (!fitAddonRef.current || !termRef.current) return;
if (!fitAddonRef.current || !termRef.current) {
console.log('[Terminal] fitTerminal: refs not ready');
return;
}
const oldCols = termRef.current.cols;
const oldRows = termRef.current.rows;
// Force layout recalculation before fit
if (container) {
void container.offsetWidth;
void container.offsetHeight;
}
console.log('[Terminal] fitTerminal called, container dims:', container?.offsetWidth, container?.offsetHeight);
fitAddonRef.current.fit();
const { cols, rows } = termRef.current;
if (cols !== oldCols || rows !== oldRows) {
// Delay refresh to next frame so renderer can process resize first
requestAnimationFrame(() => {
termRef.current?.refresh(0, rows - 1);
});
}
console.log('[Terminal] fitTerminal result:', cols, rows, '(was:', oldCols, oldRows + ')');
// Always refresh on initial load or when dimensions change
requestAnimationFrame(() => {
termRef.current?.refresh(0, rows - 1);
});
if (ws.readyState === WebSocket.OPEN) {
console.log('[Terminal] Sending resize:', cols, rows);
ws.send(JSON.stringify({ type: "resize", cols, rows }));
} else {
console.log('[Terminal] WebSocket not open, state:', ws.readyState);
}
};