Skip to content

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.

fix(dino): add icon scaffold, guard detached-node listeners, fix key isolation

enese7d32f73a21d
diff --git a/src/renderer/nodes/DinoNode.tsx b/src/renderer/nodes/DinoNode.tsx
index 1231c7cdc..0a67141cb 100644
--- a/src/renderer/nodes/DinoNode.tsx
+++ b/src/renderer/nodes/DinoNode.tsx
@@ -30,9 +30,12 @@ export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
- // Keep game keys from reaching React Flow (pan/scroll) while hovering the body.
+ // The engine listens for game keys at the document level, so we must NOT
+ // stopPropagation (React's root listener sits below document — that would
+ // starve the engine). preventDefault only stops the page from scrolling on
+ // Space/arrows; the event still bubbles to document and the engine handles it.
const onKeyDown = (e: React.KeyboardEvent) => {
- if (GAME_KEYS.has(e.key)) e.stopPropagation()
+ if (GAME_KEYS.has(e.key)) e.preventDefault()
}
return (
@@ -40,7 +43,7 @@ export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {
<NodeResizer minWidth={400} minHeight={160} isVisible={selected} color={data.color} />
<div className="dino-node__header" style={{ background: `${data.color}33` }}>
- <button className="term-node__color" style={{ background: data.color }} title="Color" disabled />
+ <span className="term-node__color" style={{ background: data.color }} />
<input
className="term-node__title nodrag"
value={data.title}
diff --git a/src/renderer/nodes/dino/dino-game.ts b/src/renderer/nodes/dino/dino-game.ts
index e7dcbc335..6d33a4ae5 100644
--- a/src/renderer/nodes/dino/dino-game.ts
+++ b/src/renderer/nodes/dino/dino-game.ts
@@ -52,6 +52,15 @@ export function createDinoGame(
template.content.appendChild(makeAudio('offline-sound-reached', DINO_SOUNDS.reached))
host.appendChild(template)
+ // The engine's init() does `document.querySelector('.icon-offline').style…`
+ // (and setupDisabledRunner uses `.icon`); with no such element the query
+ // returns null and `.style` throws from the Runner constructor → blank node.
+ // A single hidden element satisfying BOTH selectors keeps init() happy.
+ const icon = document.createElement('div')
+ icon.className = 'icon icon-offline'
+ icon.style.display = 'none'
+ host.appendChild(icon)
+
// The engine does `document.querySelector(selector)` for its outer container.
const wrapper = document.createElement('div')
wrapper.className = wrapperClass
@@ -79,8 +88,14 @@ export function createDinoGame(
return {
destroy() {
window.clearInterval(poll)
+ // Separate try blocks so a throw in stop() can't skip stopListening()
+ // (which removes the gameplay key listeners — input must not leak).
try {
runner.stop()
+ } catch {
+ /* engine already torn down */
+ }
+ try {
// Removes the gameplay keydown/keyup/mouse listeners (engine uses a
// `handleEvent` method, so removeEventListener(…, this) works).
;(runner as unknown as { stopListening: () => void }).stopListening()
@@ -92,6 +107,7 @@ export function createDinoGame(
wrapper.remove()
sprites.forEach((el) => el.remove())
template.remove()
+ icon.remove()
// NOTE: the engine also binds window resize/visibility/blur/focus and one
// anonymous document keydown that it has no API to remove — an accepted
// minor leak. stopListening() drops the gameplay keys, which is what
diff --git a/src/renderer/nodes/dino/trex-runner.js b/src/renderer/nodes/dino/trex-runner.js
index d1b10f56b..67452ac0c 100644
--- a/src/renderer/nodes/dino/trex-runner.js
+++ b/src/renderer/nodes/dino/trex-runner.js
@@ -425,6 +425,8 @@ const Runner = (function () {
* Adjust game space dimensions on resize.
*/
adjustDimensions: function () {
+ // nodeterm: bail if node was unmounted (engine has no teardown API)
+ if (!this.outerContainerEl || !this.outerContainerEl.isConnected) return;
clearInterval(this.resizeTimerId_);
this.resizeTimerId_ = null;
@@ -884,6 +886,8 @@ const Runner = (function () {
* Pause the game if the tab is not in focus.
*/
onVisibilityChange: function (e) {
+ // nodeterm: bail if node was unmounted (engine has no teardown API)
+ if (!this.outerContainerEl || !this.outerContainerEl.isConnected) return;
if (document.hidden || document.webkitHidden || e.type == 'blur' ||
document.visibilityState != 'visible') {
this.stop();