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): a SessionStart disproves the hibernated flag
enes1a880c3f2edd
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex bbda37d44..7d7e169e3 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -7042,7 +7042,18 @@ export function Canvas() {breakcase 'session':if (e.sessionTitle) cs.setSession(e.nodeId, e.sessionTitle)- if (e.sessionPhase === 'start') cs.setState(e.nodeId, undefined, e.agentId)+ if (e.sessionPhase === 'start') {+ cs.setState(e.nodeId, undefined, e.agentId)+ // A SessionStart is proof a CLI just LAUNCHED in that pane, so a hibernated flag on+ // this node is now false — our own `/exit` produces a SessionEnd, never a+ // SessionStart. This is the residual `setState`'s live-state self-heal cannot reach:+ // a user who relaunches the agent by hand and then takes no turn would keep a SLEEPING+ // chip on a running CLI (and the sweep, which skips hibernated nodes, would leave that+ // session exempt from Eco for good). Deliberately NOT the same as clearing on `done`,+ // which would let a late Stop POST undo a hibernation we just performed. The setter+ // bails when the flag is already unset, so this is free for every other session start.+ cs.setHibernated(e.nodeId, false)+ }if (e.sessionPhase === 'end') {cs.setState(e.nodeId, undefined, e.agentId)// In-session /loop dies with its session; cron (and scheduled cloud routines)diff --git a/src/renderer/state/agentStatus.persist.test.ts b/src/renderer/state/agentStatus.persist.test.tsindex 9e1f4a28a..33c980fd3 100644--- a/src/renderer/state/agentStatus.persist.test.ts+++ b/src/renderer/state/agentStatus.persist.test.ts@@ -96,6 +96,22 @@ describe('loop persistence (cron/schedule survive an app restart)', () => {expect(Date.now() - st.lastEventAt!).toBeLessThan(5000) // hours-old clock replaced})+ it('setHibernated(false) on a node that is not hibernated changes NOTHING', async () => {+ // Load-bearing since Canvas calls it on every SessionStart (a fresh launch disproves the+ // flag): the bail must not create an entry, must not touch the idle clock — which would hide+ // a genuinely idle session from the sweep — and must not write.+ const store = memStorage()+ vi.stubGlobal('localStorage', store)+ const { useAgentStatus } = await import('./agentStatus')+ useAgentStatus.getState().setHibernated('n13', false)+ expect(useAgentStatus.getState().byId['n13']).toBeUndefined()+ const idle = Date.now() - 45 * 60_000+ useAgentStatus.setState({ byId: { n14: { unread: false, state: 'done', lastEventAt: idle } } })+ useAgentStatus.getState().setHibernated('n14', false)+ expect(useAgentStatus.getState().byId['n14'].lastEventAt).toBe(idle)+ expect(store.getItem('nodeterm.agentStatus')).toBeNull()+ })+it('restores `hibernated` on load (the CLI stays exited across an app restart)', async () => {vi.stubGlobal('localStorage',