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(status): timestamp stale transitions

Darren Kattanf29d07c3fe94
diff --git a/src/renderer/state/agentStatus.test.ts b/src/renderer/state/agentStatus.test.ts
index 87481be8f..c75deba79 100644
--- a/src/renderer/state/agentStatus.test.ts
+++ b/src/renderer/state/agentStatus.test.ts
@@ -56,7 +56,10 @@ describe('stale-working sweeper', () => {
useAgentStatus.getState().setState(id, 'working', 'claude')
vi.advanceTimersByTime(STALE_WORKING_MS + 60_000)
useAgentStatus.getState().sweepStaleWorking()
- expect(useAgentStatus.getState().byId[id].state).toBeUndefined()
+ expect(useAgentStatus.getState().byId[id]).toMatchObject({
+ state: undefined,
+ lastEventAt: Date.now()
+ })
})
it('keeps a working entry fresh as long as events keep arriving', () => {
diff --git a/src/renderer/state/agentStatus.ts b/src/renderer/state/agentStatus.ts
index e0e061322..85970d5fa 100644
--- a/src/renderer/state/agentStatus.ts
+++ b/src/renderer/state/agentStatus.ts
@@ -52,12 +52,12 @@ export interface AgentNodeStatus {
*/
stateVerified?: boolean
/**
- * When this node last CHANGED state — the idle clock the hibernation policy reads
- * (`terminal/hibernation-policy.ts`). Deliberately not `stateAt`: that one is refreshed by
- * every same-state event (freshness), while "how long has this session been idle" means "how
- * long since the turn ended". TRANSIENT — never persisted: a relaunch has seen no events yet,
- * and a stale stamp read as "idle since before the restart" would hibernate a session the
- * moment the app came back. Absent ⇒ unknown idle ⇒ never a hibernation candidate.
+ * When this node last CHANGED state (or was explicitly woken) — rendered as the status group's
+ * relative age and also read as the idle clock by `terminal/hibernation-policy.ts`. Deliberately
+ * not `stateAt`: that one is refreshed by every same-state event (freshness), while "how long in
+ * this state" means "how long since the transition". TRANSIENT — never persisted: a relaunch has
+ * seen no events yet, and a stale stamp read as "idle since before the restart" would hibernate a
+ * session the moment the app came back. Absent ⇒ unknown idle ⇒ never a hibernation candidate.
*/
lastEventAt?: number
/**
@@ -423,7 +423,9 @@ export function createAgentStatusSession(
const byId = { ...s.byId }
for (const [id, v] of Object.entries(byId)) {
if (v.state === 'working' && now - (v.stateAt ?? 0) > staleMs) {
- byId[id] = { ...v, state: undefined, stateAt: now }
+ // This is a real transition to Unknown, even though it did not arrive through a hook.
+ // Stamp both clocks so the sidebar age and Eco idle clock begin at the transition.
+ byId[id] = { ...v, state: undefined, stateAt: now, lastEventAt: now }
changed = true
}
}