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.

Merge origin/main (#1053 interrupt hold, #1051 board dispatch) into fix/after-stale-done

review01726371c0fa
diff --cc src/renderer/canvas/control-after-pr.source.test.ts
index c2aa242f8,e79537914..26b1eb6e7
--- a/src/renderer/canvas/control-after-pr.source.test.ts
+++ b/src/renderer/canvas/control-after-pr.source.test.ts
@@@ -134,6 -134,6 +134,6 @@@ describe('the node badge', () =>
it('reads EXPIRED and hands the PR wait to the tooltip', () => {
expect(node).toMatch(/prExpired \|\| successExpired\s*\?\s*'⚠ EXPIRED'/)
- expect(node).toMatch(/launchTooltip\([^)]*prTooltip, successTooltip, pendingHandedOverOn\)/)
- expect(node).toMatch(/launchTooltip\([^)]*prTooltip, successTooltip, pendingInterruptedOn\)/)
++ expect(node).toMatch(/launchTooltip\([^)]*prTooltip, successTooltip, pendingInterruptedOn, pendingHandedOverOn\)/)
})
})
diff --cc src/renderer/lib/controlRouting.ts
index 4ecbaaf49,366f6adf4..f2062fdca
--- a/src/renderer/lib/controlRouting.ts
+++ b/src/renderer/lib/controlRouting.ts
@@@ -295,10 -261,9 +296,11 @@@ export function controlListingText(rows
(n.launchState ? ` — ${launchLabels[n.launchState]}` : '') +
(n.prWait ? ` — waits on ${n.prWait}` : '') +
(n.successWait ? ` — needs success from: ${n.successWait}` : '') +
+ (n.handoverWait ? ` — waiting for ${n.handoverWait} to finish the work handed to it` : '') +
+ (n.backgroundWait ? ` — waiting for ${n.backgroundWait} to finish the tasks still running in its background` : '') +
(n.outcome ? ` — REPORTED ${n.outcome === 'succeeded' ? 'SUCCESS' : 'FAILURE'}${n.outcomeNote ? ` ("${n.outcomeNote}")` : ''}` : '') +
(n.outcomeSuperseded ? ' (before new work queued for it; not counted until it reports again)' : '') +
- (n.lastTurnErrored ? ' — LAST TURN ERRORED' : '')
+ (n.lastTurnErrored ? ' — LAST TURN ERRORED' : '') +
+ (n.lastTurnInterrupted ? ' — LAST TURN INTERRUPTED' : '')
).join('\n')
}
diff --cc src/renderer/lib/pendingLaunch.test.ts
index db2360281,159a956ae..d9f43150a
--- a/src/renderer/lib/pendingLaunch.test.ts
+++ b/src/renderer/lib/pendingLaunch.test.ts
@@@ -555,52 -554,6 +555,52 @@@ describe('--after-success: a success wa
})
})
+describe('plain --after on a station handed new work (core/station-handover.ts)', () => {
+ const live = new Set(['a', 'b', 'c'])
+ const status: StatusById = { a: { state: 'done' }, b: { state: 'done' } }
+ const handovers = { a: { nodeId: 'a', since: 10 } }
+
+ it('a handed-over station is never a satisfied dep, whatever its state reads', () => {
+ expect(launchesToFire([armed('c', ['a', 'b'])], status, live, undefined, undefined, undefined, undefined, handovers)).toEqual([])
+ expect(unmetDeps(armed('c', ['a', 'b']), status, live, handovers)).toEqual(['a'])
+ expect(handedOverDeps(armed('c', ['a', 'b']), live, handovers)).toEqual(['a'])
+ })
+
+ it('without a hand-over the same state fires as before', () => {
+ expect(launchesToFire([armed('c', ['a', 'b'])], status, live, undefined, undefined, undefined, undefined, {})).toEqual([
+ { id: 'c', command: 'echo c' }
+ ])
+ })
+
+ it('a deleted station still counts as satisfied, hand-over or not', () => {
+ expect(launchesToFire([armed('c', ['a'])], {}, new Set(['c']), undefined, undefined, undefined, undefined, handovers)).toEqual([
+ { id: 'c', command: 'echo c' }
+ ])
+ expect(handedOverDeps(armed('c', ['a']), new Set(['c']), handovers)).toEqual([])
+ })
+
+ it('a success wait on a handed-over station holds: its turn is not over', () => {
+ expect(successDepFacts('a', status, live, {}, handovers).turnDone).toBe(false)
+ expect(successDepFacts('a', status, live, {}).turnDone).toBe(true)
+ })
+
+ it('a prototype key is not a hand-over', () => {
+ const bare = Object.create(null) as Record<string, undefined>
+ expect(handedOverDeps(armed('c', ['constructor', '__proto__']), new Set(['constructor', '__proto__']), bare)).toEqual([])
+ expect(handedOverDeps(armed('c', ['constructor']), new Set(['constructor']), {})).toEqual([])
+ })
+
+ it('the tooltip says what the wait is for, not "waiting for X to finish" about an idle X', () => {
- const text = launchTooltip(undefined, 'Builder, Tester', 'claude go', undefined, false, undefined, undefined, 'Builder')
++ const text = launchTooltip(undefined, 'Builder, Tester', 'claude go', undefined, false, undefined, undefined, undefined, 'Builder')
+ expect(text).toBe(
+ 'Waiting for Builder to finish — a turn that ended before that work was done does not count ' +
+ '(all waits: Builder, Tester), then runs:\nclaude go'
+ )
+ // An errored upstream is still named first: it will not end on its own.
+ expect(launchTooltip(undefined, 'Builder', 'claude go', 'Tester', false, undefined, undefined, 'Builder')).toMatch(/^Tester ended/)
+ })
+})
+
describe('withSuccessHold — the sibling of withPrHold', () => {
const hold = { deps: ['a'], deadlineAt: 9 }
it('adds the hold to a node that already holds its launch, and only then', () => {
diff --cc src/renderer/lib/pendingLaunch.ts
index 97b53ff08,2205dea37..d2f70a44d
--- a/src/renderer/lib/pendingLaunch.ts
+++ b/src/renderer/lib/pendingLaunch.ts
@@@ -224,43 -211,18 +224,48 @@@ export function controlLaunchState
* run-now escape, so the human — or the orchestrator, after a retry — is never stuck.
*
* The refusal ends by itself: `lastTurnError` is cleared by the upstream's next genuine new turn,
- * so a station that is nudged and answers successfully satisfies its dependents on that turn. *
+ * so a station that is nudged and answers successfully satisfies its dependents on that turn.
+ *
+ * A dep whose last turn the user INTERRUPTED (Esc / Ctrl+C — `lastTurnInterrupted`) is refused
+ * for the same reason: an interrupted station is idle too, and its turn did not produce what the
+ * dependent was waiting for. Claude sends no hook for an interrupt; the `done` comes from the
+ * transcript marker (`recordTurnInterrupt`). Same escape (▶), same self-healing (next turn).
++ *
+ * A dep that has been HANDED NEW WORK it has not finished (`handovers`, core/station-handover.ts)
+ * is refused too. A station is reused: an orchestrator hands it its next task and then arms a
+ * dependent on it, and until the station starts that task its state is still the PREVIOUS task's
+ * `done` — the dependent would start at once, on the old output. Core decides when the hand-over
+ * is answered (a turn that started after it has ended); here it is only a membership test, so the
+ * renderer and the Server Edition's factory cannot disagree.
*/
-function depSatisfied(depId: string, status: StatusById, live: ReadonlySet<string>): boolean {
+function depSatisfied(
+ depId: string,
+ status: StatusById,
+ live: ReadonlySet<string>,
+ handovers?: HandoverById
+): boolean {
if (!live.has(depId)) return true
+ if (handedOver(handovers, depId)) return false
const st = status[depId]
- return st?.state === 'done' && !st.lastTurnError
+ return st?.state === 'done' && !st.lastTurnError && !st.lastTurnInterrupted
}
- /** Of the deps this node is still waiting on, which are held because they were handed new work
- * they have not finished — what the QUEUED tooltip and `list` name. */
+/** Why a dep is held (see `handedOverDeps`): new work handed to it, or ONLY tasks its last turn left
+ * running in the background. Named differently in the tooltip and in `list`. */
+export function holdReason(record: StationHandoverRecord | undefined): 'work' | 'background' {
+ return record?.background && !record.queued && record.since === undefined ? 'background' : 'work'
+}
+
++/** Of the deps this node is still waiting on, which are held because they were handed new work
++ * they have not finished — what the QUEUED tooltip and `list` name. */
+export function handedOverDeps(
+ node: ArmedNode,
+ live: ReadonlySet<string>,
+ handovers: HandoverById | undefined
+): string[] {
+ return (node.data.pendingLaunch?.after ?? []).filter((d) => live.has(d) && handedOver(handovers, d))
+}
+
/** Of the deps this node is still waiting on, which are held because they ERRORED rather than
* because they have not finished? What the QUEUED tooltip names (issue #521). */
export function erroredDeps(
@@@ -413,8 -389,8 +435,10 @@@ export function launchTooltip
/** The node's `--after-success` wait: where it stands (`successWaitStatus`), the unmet stations
* (`successWaitSummary`), and its deadline as the caller formats it. */
success?: { status: 'met' | 'waiting' | 'blocked' | 'expired'; summary: string; deadline: string },
+ /** The deps held because the user interrupted their last turn (`interruptedDeps`). */
- interruptedOn?: string
++ interruptedOn?: string,
+ /** The deps that were handed new work they have not finished (core/station-handover.ts), named. */
+ handedOverOn?: string
): string {
if (delivery?.kind === 'starting') return 'Starting in the background — an agent asked for this session to run now.'
const runs = `Runs:\n${command}`
diff --cc src/renderer/nodes/TerminalNode.tsx
index ee3e673da,fd0eb13ef..4d5e0739f
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@@ -234,8 -234,7 +234,8 @@@ import { useCodexIdentity, codexSharedI
import { codexApprovalCaps } from '../state/codexCli'
import { useAgentStatus, agentStatusForApi, inferInterruptAfterSettle } from '../state/agentStatus'
import { useLaunchDelivery } from '../state/launchDelivery'
- import { erroredDeps, handedOverDeps, holdReason, launchTooltip } from '../lib/pendingLaunch'
-import { erroredDeps, interruptedDeps, launchTooltip } from '../lib/pendingLaunch'
++import { erroredDeps, handedOverDeps, holdReason, interruptedDeps, launchTooltip } from '../lib/pendingLaunch'
+import { useStationHandovers } from '../state/stationHandovers'
import { useSuccessWait } from '../lib/useSuccessWait'
import { StationFailedChip } from '../components/StationFailedChip'
import { prHoldExpired, prHoldSummary } from '../lib/prWait'
@@@ -6032,7 -6022,7 +6045,7 @@@ export function TerminalNode(
? ' term-node__status--queued-warn'
: ''
}`}
- title={launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingHandedOverOn)}
- title={launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn)}
++ title={launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn, pendingHandedOverOn)}
>
<span className="term-node__status-dot" />
{startingNow
diff --cc src/renderer/nodes/session-ready-signal.test.ts
index ad85ad8b3,c08f18421..5b4d868fb
--- a/src/renderer/nodes/session-ready-signal.test.ts
+++ b/src/renderer/nodes/session-ready-signal.test.ts
@@@ -102,7 -102,7 +102,7 @@@ describe('the QUEUED badge carries the
// arguments name an `--after-pr` wait and an `--after-success` wait (with their deadlines)
// beside the stations.
expect(src).toContain(
- "launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingHandedOverOn)"
- "launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn)"
++ "launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn, pendingHandedOverOn)"
)
})