From 38185b9659641500dc272b899eaf5b029eb5f4da Mon Sep 17 00:00:00 2001 From: Fusion Date: Sun, 24 May 2026 15:19:31 +0200 Subject: [PATCH] fix: remove container ResizeObserver causing infinite growth loop - Container-level ResizeObserver created feedback loop with fitAddon.fit() - Removed it, kept initialization-time dimension check only - Rely on window resize listener for viewport changes --- apps/web/src/components/terminal.tsx | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/apps/web/src/components/terminal.tsx b/apps/web/src/components/terminal.tsx index c7442e7..f69bac2 100644 --- a/apps/web/src/components/terminal.tsx +++ b/apps/web/src/components/terminal.tsx @@ -56,7 +56,6 @@ export const TerminalComponent: React.FC = ({ }); const lastPingRef = useRef(0); const heartbeatCheckRef = useRef(null); - const containerResizeObserverRef = useRef(null); const calculateFontSize = useCallback(() => { if (!isMobile) return fontSize; @@ -319,28 +318,6 @@ export const TerminalComponent: React.FC = ({ window.addEventListener("resize", handleResize); - // Watch container size changes (e.g. mobile header auto-hide, keyboard) - const containerResizeObserver = new ResizeObserver((entries) => { - for (const entry of entries) { - const { width, height } = entry.contentRect; - if (width > 0 && height > 0) { - fitAddon.fit(); - const { cols, rows } = term; - if (ws.readyState === WebSocket.OPEN) { - ws.send( - JSON.stringify({ - type: "resize", - cols, - rows, - }) - ); - } - } - } - }); - containerResizeObserver.observe(container); - containerResizeObserverRef.current = containerResizeObserver; - // Notify parent about terminal readiness if (onTerminalReadyRef.current) { const sendData = (data: string) => { @@ -370,10 +347,6 @@ export const TerminalComponent: React.FC = ({ clearTimeout(resizeTimeout); window.removeEventListener("resize", handleResize); document.removeEventListener("visibilitychange", handleVisibilityChange); - if (containerResizeObserverRef.current) { - containerResizeObserverRef.current.disconnect(); - containerResizeObserverRef.current = null; - } if (ws) { ws.close(); }