fix(terminal): keep the terminal resize observer alive across SSE init

initTerminal() creates the ResizeObserver on #terminalContainer once per page,
and _resetAllAppState() (run by handleInit on EVERY SSE init, page load
included) disconnected and dropped it. From the first init on, only a window
resize refit the terminal, so anything that resized just the terminal box left
xterm at its old row count with the bottom rows clipped behind the toolbar.

Pre-existing since the March app.js module split, but this release makes it
constant: #538's state rows grow and shrink the header whenever a session
starts or stops working, and #544 reserves lineage room when the first child
appears. Measured on the beta: header 115 -> 170 px, container 743 -> 688 px,
xterm stayed at 35 rows (32 fit) until a tab switch. initTerminal() already
disconnects any previous observer before creating one, so the reset has
nothing to clean up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer
2026-10-08 20:06:53 +02:00
parent aa8e06c162
commit 3904428a4f
2 changed files with 55 additions and 5 deletions
+9 -5
View File
@@ -4570,11 +4570,15 @@ class CodemanApp {
}
this.notificationManager.groupingMap.clear();
}
// Disconnect terminal resize observer (prevents memory leak on reconnect)
if (this.terminalResizeObserver) {
this.terminalResizeObserver.disconnect();
this.terminalResizeObserver = null;
}
// ⚠️ The terminal resize observer is NOT reset here. initTerminal() owns its
// lifecycle (it runs once per page and disconnects any previous observer
// before creating one), and this reset runs on EVERY SSE init, page load
// included. It used to disconnect the observer "to prevent a leak", which
// left the terminal with no observer from the first init on: only a WINDOW
// resize ever refit it, so anything that resized just the terminal box
// (state rows and lineage room appearing in the header, the tab strip
// wrapping) clipped xterm's bottom rows behind the toolbar until a tab
// switch or a window resize.
// Clear any other orphaned timers
if (this.planLoadingTimer) {
clearInterval(this.planLoadingTimer);