Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(terminal): pin addon-webgl to 0.18.0 and heal a renderer-less release
enesd7a5c7b60e26
diff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex 04276c3ae..f439a17c8 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -22,6 +22,14 @@ updates:update-types: [version-update:semver-major]- dependency-name: node-ptyupdate-types: [version-update:semver-major]+ # The @xterm family must move in LOCKSTEP, by hand: the addons reach into the core's+ # internals, so an addon bump against an older core crashes at runtime with no compile+ # error. addon-webgl 0.19.0 on the 5.5 core read `_core._store` (a 5.6+ field) in its+ # dispose path and aborted the DOM-renderer restore — every context release left a+ # renderer-less, permanently black terminal (the zoom-out blackout). Guarded by+ # src/renderer/terminal/webgl-addon-pair.test.ts; upgrade the whole family together+ # (next vehicle: the xterm 6.x major).+ - dependency-name: "@xterm/*"# Keep the GitHub Actions pinned in the workflows current (security patches to# checkout / setup-node / codeql-action land here).diff --git a/package-lock.json b/package-lock.jsonindex 588bbf706..ee9ffbef7 100644--- a/package-lock.json+++ b/package-lock.json@@ -34,7 +34,7 @@"@vitejs/plugin-react": "^4.3.1","@xterm/addon-fit": "^0.11.0","@xterm/addon-search": "^0.16.0",- "@xterm/addon-webgl": "^0.19.0",+ "@xterm/addon-webgl": "0.18.0","@xterm/xterm": "^5.5.0","@xyflow/react": "^12.11.2","electron": "^42.7.1",@@ -3219,11 +3219,14 @@}},"node_modules/@xterm/addon-webgl": {- "version": "0.19.0",- "resolved": "https://registry.npmjs.org/@xterm/addon-webgl/-/addon-webgl-0.19.0.tgz",- "integrity": "sha512-b3fMOsyLVuCeNJWxolACEUED0vm7qC0cy4wRvf3oURSzDTYVQiGPhTnhWZwIHdvC48Y+oLhvYXnY4XDXPoJo6A==",+ "version": "0.18.0",+ "resolved": "https://registry.npmjs.org/@xterm/addon-webgl/-/addon-webgl-0.18.0.tgz",+ "integrity": "sha512-xCnfMBTI+/HKPdRnSOHaJDRqEpq2Ugy8LEj9GiY4J3zJObo3joylIFaMvzBwbYRg8zLtkO0KQaStCeSfoaI2/w==","dev": true,- "license": "MIT"+ "license": "MIT",+ "peerDependencies": {+ "@xterm/xterm": "^5.0.0"+ }},"node_modules/@xterm/xterm": {"version": "5.5.0",diff --git a/package.json b/package.jsonindex 2a7630f14..6997f96fb 100644--- a/package.json+++ b/package.json@@ -136,7 +136,7 @@"@vitejs/plugin-react": "^4.3.1","@xterm/addon-fit": "^0.11.0","@xterm/addon-search": "^0.16.0",- "@xterm/addon-webgl": "^0.19.0",+ "@xterm/addon-webgl": "0.18.0","@xterm/xterm": "^5.5.0","@xyflow/react": "^12.11.2","electron": "^42.7.1",diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex f3c8176b6..61907b00e 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -1674,14 +1674,36 @@ export function TerminalNode({const canvases = term.element ? Array.from(term.element.querySelectorAll('canvas')) : nulltry {webgl.dispose()- } catch {- // already disposed via context loss+ } catch (err) {+ // A second dispose after onContextLoss already ran is a silent no-op — a THROW here is+ // never that. The addon's dispose is ALSO its put-xterm-back-on-a-DOM-renderer path (a+ // disposable registered at activate), so a throw aborts the restore and would leave the+ // terminal with NO renderer at all: zero canvases, zero `.xterm-rows`, a permanently+ // black node no repaint can reach. Seen in the field as the zoom-out blackout when+ // addon-webgl 0.19.0's dispose guard read xterm-5.6 internals (`_core._store`) on the+ // 5.5 core and crashed on EVERY release. The renderer-less check below is the heal; the+ // warn is its field trace.+ console.warn('[nodeterm] webgl dispose threw mid-release', err)}webgl = nullloseWebglContexts(canvases)// A dispose that died midway leaves its (now context-lost, permanently BLACK) canvas// attached OVER the DOM rows — sweep it before the repaint (see the safety-net note).verifyCleanDomState('release')+ // The other way a dispose dies midway: canvases already gone but the DOM renderer never+ // installed (the throw above). `verifyCleanDomState` cannot see that state — it keys on+ // stray canvases, and here there are none — so probe for the renderer's row container+ // directly and rebuild what the addon's aborted restore owed. Skipped while a glyph+ // attachment owns the screen (no rows there by design, and `setRenderer` would dispose+ // the glyph addon — see the both-renderers invariant).+ if (!disposed && !glyphAttach && term.element && !term.element.querySelector('.xterm-rows')) {+ if (restoreDomRenderer()) {+ console.warn('[nodeterm] healed a renderer-less webgl release: DOM renderer restored')+ } else {+ escalateRespawn('webgl release left no renderer and the DOM restore failed')+ return+ }+ }// The DOM renderer that replaced the addon starts from an EMPTY row container, and this// release almost always runs while the node is HIDDEN — the swap's own refresh defers// behind xterm's pause flag, which is exactly where it can be lost. Re-arm it explicitly.diff --git a/src/renderer/terminal/webgl-addon-pair.test.ts b/src/renderer/terminal/webgl-addon-pair.test.tsnew file mode 100644index 000000000..00333f908--- /dev/null+++ b/src/renderer/terminal/webgl-addon-pair.test.ts@@ -0,0 +1,41 @@+import { describe, it, expect } from 'vitest'+import fs from 'node:fs'+import path from 'node:path'++/**+ * Guard for a runtime-only version coupling that bit for real: `@xterm/addon-webgl` reaches+ * into `@xterm/xterm`'s INTERNALS, so the pair compiles cleanly at any version skew and only+ * fails in the field. 0.19.0's dispose guard reads `_core._store._isDisposed` — a field the+ * 5.6+ core has and the 5.5 core does not — so on xterm 5.5.0 EVERY `WebglAddon.dispose()`+ * threw before its own put-xterm-back-on-a-DOM-renderer disposable ran. Every budget release+ * (zoom gate, LRU reclaim, hidden-release delay, memory pressure) then left that terminal with+ * no renderer at all: zero canvases, zero `.xterm-rows`, a permanently black node. Field+ * signature: zoom-out across the 40% gate blacked out every visible terminal at once.+ *+ * The dependabot config ignores `@xterm/*` for the same reason (a grouped minor bump is what+ * shipped 0.19.0). This test is the in-repo half of that guard: it pins the exact pair, so a+ * bump that slips past dependabot — or a hand edit that moves one half — fails the suite with+ * this story attached. Upgrading is fine, deliberately, and as a FAMILY: verify the release+ * path end-to-end (zoom a busy canvas across the 40%/45% band, terminals must fall back to+ * readable DOM rows, not black), then update both sides of this expectation together.+ */+describe('@xterm/addon-webgl ↔ @xterm/xterm version pair', () => {+ it('stays on the exact pair the release path was verified against', () => {+ const pkg = JSON.parse(+ fs.readFileSync(path.resolve(__dirname, '../../../package.json'), 'utf8')+ ) as { devDependencies: Record<string, string> }+ expect(pkg.devDependencies['@xterm/addon-webgl']).toBe('0.18.0')+ expect(pkg.devDependencies['@xterm/xterm']).toBe('^5.5.0')+ })++ it('the installed addon has no dispose-time core-internals guard the 5.5 core cannot satisfy', () => {+ // The exact expression that crashed: a dispose-path read of `_core._store`. 0.18.0 does not+ // contain it; if a future addon build does, the core must be new enough to carry the field —+ // re-verify the release path before loosening this.+ const src = fs.readFileSync(+ path.resolve(__dirname, '../../../node_modules/@xterm/addon-webgl/lib/addon-webgl.js'),+ 'utf8'+ )+ expect(src.includes('_store._isDisposed')).toBe(false)+ })+})