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(renderer): refuse a non-positive hibernation idle window
enes4f1a5dc02220
diff --git a/src/renderer/components/settings/sections/AgentsSection.tsx b/src/renderer/components/settings/sections/AgentsSection.tsxindex 26ace91b9..08177fd79 100644--- a/src/renderer/components/settings/sections/AgentsSection.tsx+++ b/src/renderer/components/settings/sections/AgentsSection.tsx@@ -236,14 +236,11 @@ export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.Elmin={5}max={600}step={5}- // A cleared/invalid field falls back to the default rather than 0: zero minutes- // would exit every session the instant a turn ends. Never NaN — it does not- // survive the JSON round-trip to settings.json (it lands as `null`).- onChange={(v) =>- update({- agentHibernationIdleMinutes: Number.isFinite(v) && v > 0 ? Math.max(5, v) : 30- })- }+ // A cleared/invalid field falls back to the default rather than 0 (zero minutes+ // would mean "the instant a turn ends"). Deliberately no floor mid-typing: a+ // per-keystroke `Math.max(5, v)` makes 45 untypable (4 snaps to 5, then 55). The+ // real guard is `planHibernation`, which refuses any non-positive window outright.+ onChange={(v) => update({ agentHibernationIdleMinutes: v || 30 })}/><span className="text-[13px] text-muted">min</span></div>diff --git a/src/renderer/state/agentStatus.ts b/src/renderer/state/agentStatus.tsindex 2620dff31..02de44d62 100644--- a/src/renderer/state/agentStatus.ts+++ b/src/renderer/state/agentStatus.ts@@ -6,8 +6,9 @@ import type { NodeTerminalApi } from '@shared/types'/*** Transient per-node status for agent (e.g. Claude Code) sessions, driven by the agent's hooks.- * `unread`, `session`, `sessionId` and `agentId` are persisted to localStorage so they survive- * a reload/restart; the live `state` (working/waiting/…) is not (it'd be stale on relaunch).+ * `unread`, `session`, `sessionId`, `agentId`, `loop` and `hibernated` are persisted to+ * localStorage so they survive a reload/restart; the live `state` (working/waiting/…) is not+ * (it'd be stale on relaunch), and neither are its two clocks (`stateAt`, `lastEventAt`).* `agentId` is durable because a PLAIN terminal's agent identity exists nowhere else: an* explicit agent node re-derives it from `data.agentId`, but a hand-launched `claude` in a* plain terminal is only known here, and its context links must keep classifying acrossdiff --git a/src/renderer/terminal/hibernation-policy.test.ts b/src/renderer/terminal/hibernation-policy.test.tsindex 9cd7cbc46..2d2103a53 100644--- a/src/renderer/terminal/hibernation-policy.test.ts+++ b/src/renderer/terminal/hibernation-policy.test.ts@@ -70,6 +70,17 @@ describe('planHibernation', () => {expect(planHibernation([base('a', { lastEventAt: NOW - 30 * 60_000 })], NOW, cfg)).toEqual(['a'])})+ it('refuses a non-positive / unreadable idle window — settings.json is hand-editable', () => {+ // settings.json is hand-edited and merged without clamping, so any of these can reach here.+ // Each must read as "off": a 0 or negative window makes EVERY done+offscreen node eligible on+ // the first sweep — Eco would exit live CLIs the instant a turn ends.+ for (const idleMinutes of [0, -1, -30, NaN, null as unknown as number, undefined as unknown as number]) {+ expect(planHibernation([base('a')], NOW, { ...cfg, idleMinutes }), String(idleMinutes)).toEqual([])+ }+ // …but a small positive window is honored, not floored away.+ expect(planHibernation([base('a', { lastEventAt: NOW - 60_000 })], NOW, { ...cfg, idleMinutes: 1 })).toEqual(['a'])+ })+it('refuses a node the restart gate itself refuses (no session id / not resumable)', () => {expect(planHibernation([base('a', { sessionId: undefined })], NOW, cfg)).toEqual([])expect(planHibernation([base('a', { agentId: 'opencode' })], NOW, cfg)).toEqual([])diff --git a/src/renderer/terminal/hibernation-policy.ts b/src/renderer/terminal/hibernation-policy.tsindex 7057a687b..ecfff6900 100644--- a/src/renderer/terminal/hibernation-policy.ts+++ b/src/renderer/terminal/hibernation-policy.ts@@ -68,6 +68,12 @@ export function planHibernation(cfg: HibernationConfig): string[] {if (!cfg.enabled) return []+ // The window is re-validated HERE, not trusted from the type: settings.json is hand-editable and+ // merged without clamping, so `idleMinutes` can arrive as null, NaN, 0 or negative — and the UI+ // clamp only guards keystrokes. Each of those would make the window zero or negative, i.e. EVERY+ // done+offscreen node eligible on the first sweep: Eco exiting live CLIs the instant a turn ends.+ // So an unreadable window reads as "off" — the same call `offscreenDisposeMs` makes one file over.+ if (!(cfg.idleMinutes > 0)) return []const idleMs = cfg.idleMinutes * 60_000return candidates.filter(