revert: remove ResizeObserver and stty-on-every-resize to fix infinite loop

The ResizeObserver detected size changes caused by the stty command
output appearing in the terminal, creating an infinite resize loop:
1. Resize detected -> fit() -> send resize to backend
2. Backend sends stty command through PTY
3. stty text appears in terminal output
4. ResizeObserver detects content height change
5. fit() calculates new rows -> send resize
6. Loop continues forever

Reverted to:
- Window resize event instead of ResizeObserver
- stty command only sent once on first resize

This means the container shell stays at the initial size and won't
dynamically resize when the browser window changes, but prevents
the infinite loop.
This commit is contained in:
Fusion
2026-05-24 16:54:05 +02:00
parent 6e600fdbcd
commit f37813a317
2 changed files with 13 additions and 14 deletions
+7 -6
View File
@@ -254,15 +254,16 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
ws.send(data);
});
// Handle container resize with ResizeObserver (more reliable than window resize)
// Handle window resize with debounce
let resizeTimeout: ReturnType<typeof setTimeout>;
const resizeObserver = new ResizeObserver(() => {
const handleResize = () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
fitTerminal();
}, 100);
});
resizeObserver.observe(container);
}, 250);
};
window.addEventListener("resize", handleResize);
// Refit after mobile header auto-hides (3s delay + 0.3s transition)
const headerHideTimeout = setTimeout(() => {
@@ -297,7 +298,7 @@ export const TerminalComponent: React.FC<TerminalProps> = ({
return () => {
clearTimeout(resizeTimeout);
clearTimeout(headerHideTimeout);
resizeObserver.disconnect();
window.removeEventListener("resize", handleResize);
document.removeEventListener("visibilitychange", handleVisibilityChange);
if (ws) {
ws.close();