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(agents): end an interrupted Claude turn from the transcript marker
review14c19b42a313
diff --git a/CLAUDE.md b/CLAUDE.mdindex 11a32ad80..e6a83bbb4 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -2375,6 +2375,60 @@ else, and its context links must keep classifying across restarts).Resume it offers still replays that dead id — but cold restore no longer creates the state: itprobes `transcript:exists` first and launches bare on a positive `absent`, saying so on the node(see **Cold restore** above). Re-measured on the same host 2026-09-09: **20** of 108.+- **An interrupted Claude turn (Esc / Ctrl+C) fires NO hook — the transcript marker ends it**+ (`core/claude-turn-interrupt.test.ts`, fixture `shared/agents/__fixtures__/claude/interrupt-capture.json`).+ MEASURED on Claude Code **2.1.285**, interactive TUI in a private tmux server, capture hooks via+ `--settings`, every `NODETERM_*` unset: Esc while it streams, Esc during a foreground tool call,+ Esc on a permission dialog, and Ctrl+C once mid-stream each fire **nothing** — no `Stop`, no+ `StopFailure`, no `PostToolUse(Failure)`, and **no `idle_prompt` either**: that notification came+ 60 s after a NORMAL `Stop` but not in 75 s / 80 s after an interrupt, so the `idle` rescue in+ `normalizeClaude` does not cover this case. Before this a node sat on RUNNING (or NEEDS YOU, for a+ dismissed permission dialog) until the 20-min stale sweep: `--after` dependents waited, Eco never+ saw it idle, the notch and the phone showed it working. What the interrupt DOES leave is a USER+ record, content `[{type:'text', text:'[Request interrupted by user]'}]` (`… for tool use]` when a+ tool call or its dialog was cancelled), whose **`promptId` equals the turn's `UserPromptSubmit`+ `prompt_id`** in every capture. Wiring, and the rules it rests on:+ - `normalizeClaude` puts `prompt_id` on the `UserPromptSubmit` event as **`turnId`**; the mirror+ keeps it (`MirrorEntry.turnId`, runtime-only, dropped at a session boundary).+ - The claude context tails (local, and the desktop's SSH one) scan COMPLETE lines with+ `parseTurnInterrupts` — a CLOSED set of the two texts, array content with exactly that one text+ part, non-sidechain (a typed prompt is a plain string, so typing the words matches nothing) —+ and call `onTurnInterrupted(sessionId, turnId)`.+ - **Both shells** hand that to `recordTurnInterrupt` (pinned in `hook-verified-parity.test.ts`),+ which ends the turn ONLY when the marker names the node's CURRENT turn (same session, same+ `turnId`, state working/blocked/waiting). That exact match is the whole safety story: a marker+ the local tail reads back from history on its first read, one from a finished turn or another+ session, one after a restart (no `turnId` then) changes nothing. The event is an ordinary+ `done` + `interrupted` (what a `Stop` with `is_interrupt` already produced), UNverified (a+ transcript read is not a hook POST), so no completion alert and the question/approval resets+ apply unchanged.+ - **`--after` does NOT release on an interrupted turn** (decision, 2026-09-30): the person+ stopped it, usually to redirect it, and the dependent would start on unfinished work — #521's+ reasoning for an errored turn. It is its OWN annotation, `agentStatus.lastTurnInterrupted`+ (transient; set by an interrupted `done`, cleared by a new turn or a `done` that is not+ interrupted), read only by `depSatisfied`, the QUEUED tooltip (`interruptedDeps`) and `list`+ (`LAST TURN INTERRUPTED`; an error outranks it). It is deliberately NOT `lastTurnError`: the+ TURN FAILED chip, the station-failure notice, team progress and issue runs do not treat an+ interrupt as a failure. ▶ / `run` still start the dependent. The renderer's older keystroke+ guess (`inferInterruptAfterSettle`, 1.5 s after a lone Esc/Ctrl-C typed into THAT terminal)+ now records an interrupted `done` too, so a guess cannot release dependents before the marker+ lands; it stays because it is the only signal for the next case.+ - **Residual, measured:** Esc or Ctrl+C BEFORE the first token rewinds the prompt into the input+ box and writes NO marker (the transcript ends at the prompt record). Only the renderer guess+ (keystroke in that canvas terminal) sees it; the mirror — notch, phone, Eco's mirror reads, the+ Server Edition's headless `--after` — keeps `working` until the next hook or the stale sweep.+ - **Esc "during a subagent":** on 2.1.285 the Agent tool launched ASYNC even when asked for a+ foreground run, so the parent turn had already ended (`Stop`) — Esc at the prompt then fires+ nothing and does NOT stop the child, whose `SubagentStop` and `<task-notification>` arrive as+ usual. Nothing to fix there; a truly synchronous child being interrupted was not reproducible.+ - Server Edition: same core path (its tail + handler); its own headless `--after` still ignores+ both #521 and this annotation (pre-existing gap). Mobile: gets the `done` through the mirror.+ - **Device checklist:** (a) macOS desktop: Esc mid-stream / mid-tool / on a dialog → RUNNING+ clears within ~1 s, no chime, an armed `--after` dependent stays QUEUED with the interrupted+ tooltip; (b) SSH node: the same over the remote tail; (c) Server Edition browser tab; (d) a+ Claude older than 2.1.285 — whether the marker text and `promptId` match there is unmeasured+ (a mismatch degrades to the old behaviour, never to a false end); (e) the phone's Live+ Activity ends on the interrupt.- **Hook server (loopback HTTP)** — `src/core/agents/hook-server.ts` is a main-processloopback HTTP server (per-session bearer token, fail-open) that the installed hook scriptsPOST to; it replaced the old `fs.watch` signal-log mechanism. `buildPtyEnv` injects thediff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex 363b89cbf..c645ee399 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -169,6 +169,16 @@ export interface MirrorEntry {* Runtime-only (not in `buildFile`'s allowlist); cleared by every state commit.*/sessionStarted?: { sessionId: string; agentId: NormalizedAgentEvent['agentId']; at: number }+ /**+ * Claude only: the CLI's id (`prompt_id`) for the turn this node is in, from the+ * `UserPromptSubmit` that opened it (`NormalizedAgentEvent.turnId`). What lets a transcript+ * interrupt marker end exactly THIS turn (`recordTurnInterrupt`) — no hook fires for an+ * Esc/Ctrl+C, so the marker is the only signal, and one read back from history names an older+ * turn and must change nothing. Runtime-only (not in `buildFile`'s allowlist): after a restart+ * no marker can match, which degrades to the stale sweep, never to a false end. Cleared by a+ * session boundary.+ */+ turnId?: string/*** The entry's state EXPIRED (no state commit for EXPIRE_MS) and was stripped: this is an* IDENTITY-ONLY entry kept so external readers can still find the node's session (see@@ -606,6 +616,9 @@ function reduceEffectiveEntry(// event without the label is a codex/gemini event or a payload with no transcript_path, neither// of which is evidence that this node stopped being on the account it was last seen on.if (ev.account) next.account = ev.account+ // The live turn's id rides the event that opens it; nothing else touches it until the next turn+ // or a session boundary (below). See `recordTurnInterrupt`.+ if (ev.kind === 'state' && ev.turnId) next.turnId = ev.turnIdif (ev.kind === 'state' && ev.state) {// An `idle` done (Claude went quiet at its prompt) is a RESCUE, not a turn end: it may only@@ -659,6 +672,7 @@ function reduceEffectiveEntry(// and is what makes a refusal retryable.commitState(undefined, false)next.awaitingInput = undefined+ delete next.turnId// The boundary proves nothing about a state (and leaves `verifiedAt` alone), but a VERIFIED// start arms the idle rescue above.if (ev.sessionPhase === 'start' && ev.verified === true && ev.sessionId) {@@ -2166,6 +2180,35 @@ export function recordQuestionResult(state: 'working', answeredQuestionId: toolUseId })}+/**+ * A Claude transcript recorded an interrupt marker (`parseTurnInterrupts`) for turn `turnId`.+ *+ * Claude Code sends NO hook when the user interrupts a turn — Esc while it streams, runs a tool or+ * shows a permission dialog, or Ctrl+C once (measured on 2.1.285,+ * `shared/agents/__fixtures__/claude/interrupt-capture.json`) — and its `idle_prompt` notification,+ * which the `idle` rescue listens for, fires after a normal turn but not after an interrupted one.+ * Without this the node sat on RUNNING (or NEEDS YOU, for a dismissed dialog) until the 20-minute+ * stale sweep: `--after` dependents waited, Eco never saw it idle, the phone showed it working.+ *+ * It ends the turn only when the marker names the turn the node is in NOW (same session, same+ * `turnId`, state still working/blocked/waiting). That exact match is the whole safety story: a+ * marker the tail reads back from history, one from a turn that already ended, one from another+ * session, or one arriving after a restart (turnId is runtime-only) changes nothing.+ *+ * The event is an ordinary interrupted `done` — the shape a `Stop` with `is_interrupt` already+ * produced — so every consumer handles it with the rules it already has (no completion alert,+ * the question/approval resets). It carries no `verified`: a transcript read is not a hook POST.+ */+export function recordTurnInterrupt(+ nodeId: string, sessionId: string, turnId: string+): NormalizedAgentEvent | undefined {+ const e = state.get(nodeId)+ if (!e || e.sessionId !== sessionId || !e.turnId || e.turnId !== turnId) return+ if (e.state !== 'working' && e.state !== 'blocked' && e.state !== 'waiting') return+ return recordAgentEvent({ nodeId, agentId: e.agentId ?? 'claude', sessionId, kind: 'state',+ state: 'done', interrupted: true })+}+/** A node's current main state, or undefined when unknown. Read-only peek for the shells. */export function nodeState(nodeId: string): AgentState | undefined {return state.get(nodeId)?.statediff --git a/src/core/agents/hook-verified-parity.test.ts b/src/core/agents/hook-verified-parity.test.tsindex 4f4cf6209..d13f3dd93 100644--- a/src/core/agents/hook-verified-parity.test.ts+++ b/src/core/agents/hook-verified-parity.test.ts@@ -217,6 +217,25 @@ describe('both shells register a 4-arg raw listener', () => {}})+ // Same rule, Claude's interrupt marker: no hook fires for an Esc/Ctrl+C, so the transcript marker is+ // the only end signal. A shell whose claude tail is not handed `onTurnInterrupted` (or whose handler+ // does not go through the mirror's `recordTurnInterrupt`) leaves that shell's nodes on RUNNING+ // after every interrupt, and nothing else would notice.+ it('both shells end an interrupted Claude turn from the transcript marker, through the mirror', () => {+ for (const rel of ['src/main/index.ts', 'src/server/agent-status.ts']) {+ const src = code(rel)+ expect(src, `${rel}: the claude context tail is not given onTurnInterrupted`).toMatch(+ /createContextTail\(pushContextUpdate, \{ onTaskNotification, onToolResult, onTurnInterrupted \}\)/+ )+ expect(src, `${rel}: the handler bypasses the mirror`).toMatch(+ /const ev = recordTurnInterrupt\(nodeId, sessionId, turnId\)/+ )+ }+ expect(code('src/main/index.ts'), 'the desktop remote (SSH) tail is not given onTurnInterrupted').toMatch(+ /createRemoteContextTail\(win, remoteFile, \{ onTaskNotification, onToolResult, onTurnInterrupted \}\)/+ )+ })+it('both raw listeners carry the codex subagent branch (trackFile + agent_id gate)', () => {for (const rel of ['src/main/index.ts', 'src/server/agent-status.ts']) {const src = code(rel)diff --git a/src/core/canvas-control-core.ts b/src/core/canvas-control-core.tsindex cd6e07a38..f362ea83f 100644--- a/src/core/canvas-control-core.ts+++ b/src/core/canvas-control-core.ts@@ -775,7 +775,9 @@ export function buildCanvasControlInstructions(shimPath: string): string {' their work with get-linked-context when it wakes — nothing to `link`. Use it for "B needs what',' A produced" instead of polling. A station whose turn ended on an API error does NOT release its',' dependents even though it is idle (`list` marks it LAST TURN ERRORED); nudge or retry it, or',- ' run the armed node yourself. Only',+ ' run the armed node yourself. The same holds for a Claude station whose last turn the user',+ ' interrupted (Esc / Ctrl+C; `list` marks it LAST TURN INTERRUPTED): a finished next turn releases',+ ' it. Only',` status-reporting agent nodes (${statusAgents}, or custom agents based on them) may be waited on; a plain terminal never`,' reports finishing, so waiting on one is refused.',' AN OPEN NEVER SWITCHES THE USER\'S VIEW. If your own project is not the one on screen, the',@@ -1310,6 +1312,9 @@ Verbs:it is idle, but it produced nothing, so do not read its output or build on it. The markeris on the row on purpose — a fan-out of seven stations should cost one call to learn this,not seven. It clears itself the moment that station completes another turn.+ A row ending **LAST TURN INTERRUPTED** is a Claude station whose last turn the user stopped+ (Esc / Ctrl+C) before it finished: idle, but its work is unfinished. It clears itself when+ that station finishes another turn.- \`help\` — print the verb list. The shim answers this itself, without reaching the app, so itis also what to run when you are unsure whether the control endpoint is alive.- \`open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>] [--after-success <id,id>] [--success-deadline <90m|12h|3d>] [--after-pr <N:checks|N:merged>] [--pr-deadline <90m|12h|3d>] [--project <id>] [--run-now]\` — open N plain terminals (default 1). \`--cmd\` requires verified node identity.@@ -1330,6 +1335,9 @@ Verbs:though it is idle: it reached idle immediately and produced nothing, so firing would startthe chain on bad ground. \`list\` marks it LAST TURN ERRORED. Nudge or retry that station —one successful turn releases everything armed behind it — or run the armed node yourself.+ The same holds for a Claude station whose last turn the user INTERRUPTED (Esc / Ctrl+C):+ it is idle but did not finish, so its dependents stay held (\`list\` marks it LAST TURN+ INTERRUPTED) until it finishes a turn, or until you run the armed node yourself.\`--project <id>\` opens the node(s) in another project instead of yours. It accepts exactlytwo things — any other id is refused: your OWN project id, which behaves exactly as if the flagwere omitted; or an id \`open-project\` returned to YOUdiff --git a/src/core/claude-turn-interrupt.test.ts b/src/core/claude-turn-interrupt.test.tsnew file mode 100644index 000000000..d3cd18eb6--- /dev/null+++ b/src/core/claude-turn-interrupt.test.ts@@ -0,0 +1,209 @@+// An interrupted Claude turn (Esc / Ctrl+C) fires NO hook — measured on 2.1.285, the capture is+// `shared/agents/__fixtures__/claude/interrupt-capture.json`. The one trace it leaves is a USER+// record in the transcript, `[Request interrupted by user]` (or `… for tool use]`), carrying the+// same `promptId` as the turn's UserPromptSubmit `prompt_id`. These tests replay the capture+// through the real normalizer, the real transcript parser and the real status mirror.+import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import fs from 'fs'+import path from 'path'+import { normalizeClaude, type NormalizedAgentEvent } from '@shared/agents/normalize'+import { parseTurnInterrupts, CLAUDE_INTERRUPT_MARKERS, createContextTail } from './context-tail'+import {+ recordAgentEvent,+ recordTurnInterrupt,+ initAgentStatusMirror,+ _resetForTest,+ _snapshot+} from './agent-status-mirror'+import { testTmpDir } from './test-tmp'++type Payload = Record<string, unknown>+interface Scenario { description: string; hooks: Payload[]; transcript: Payload[] }+const fixture = JSON.parse(+ fs+ .readFileSync(path.join(__dirname, '../shared/agents/__fixtures__/claude/interrupt-capture.json'), 'utf8')+ .replace(/\r\n/g, '\n')+) as { claudeVersion: string; scenarios: Record<string, Scenario>; idlePrompt: { fired: Payload[] } }++const MARKED = ['esc_streaming', 'esc_tool_call', 'esc_permission_prompt', 'ctrl_c_streaming', 'esc_tool_call_then_80s_idle']+const REWOUND = ['ctrl_c_before_first_token', 'esc_before_first_token']+const sc = (k: string): Scenario => {+ const s = fixture.scenarios[k]+ if (!s) throw new Error(`no scenario ${k}`)+ return s+}+const promptIdOf = (s: Scenario): string =>+ String(s.hooks.find((h) => h.hook_event_name === 'UserPromptSubmit')!.prompt_id)+const lines = (s: Scenario): string[] => s.transcript.map((r) => JSON.stringify(r))++describe('the capture itself (facts the design rests on)', () => {+ it('no hook fires for the interrupt: every interrupted turn ends with no Stop/StopFailure/PostToolUse', () => {+ for (const k of [...MARKED, ...REWOUND]) {+ const names = sc(k).hooks.map((h) => h.hook_event_name)+ expect(names[0], k).toBe('UserPromptSubmit')+ for (const n of ['Stop', 'StopFailure', 'PostToolUse', 'PostToolUseFailure', 'SubagentStop', 'Notification'])+ expect(names, `${k} fired ${n}`).not.toContain(n)+ }+ })++ it('idle_prompt fired only after a NORMAL turn — so the idle rescue does not cover an interrupt', () => {+ const idle = fixture.idlePrompt.fired+ expect(idle.map((p) => p.notification_type)).toEqual(['idle_prompt'])+ const turnsWithIdle = new Set(idle.map((p) => p.prompt_id))+ for (const k of MARKED) expect(turnsWithIdle.has(promptIdOf(sc(k))), k).toBe(false)+ })++ it('the marker carries the SAME id as the turn’s UserPromptSubmit prompt_id', () => {+ for (const k of MARKED) {+ const markers = sc(k).transcript.filter(+ (r) =>+ r.type === 'user' &&+ Array.isArray((r.message as { content?: unknown })?.content) &&+ CLAUDE_INTERRUPT_MARKERS.has(String(((r.message as { content: { text?: string }[] }).content[0])?.text))+ )+ expect(markers.length, k).toBe(1)+ expect(markers[0].promptId, k).toBe(promptIdOf(sc(k)))+ }+ })++ it('an interrupt before the first token leaves NO marker (the prompt is rewound into the input)', () => {+ for (const k of REWOUND) expect(parseTurnInterrupts(lines(sc(k))), k).toEqual([])+ })+})++describe('parseTurnInterrupts', () => {+ it('finds exactly the captured turn id in every marked scenario, and nothing elsewhere', () => {+ for (const k of MARKED) expect(parseTurnInterrupts(lines(sc(k))), k).toEqual([promptIdOf(sc(k))])+ expect(parseTurnInterrupts(lines(sc('esc_after_background_subagent')))).toEqual([])+ })++ const rec = (over: Payload): string =>+ JSON.stringify({+ type: 'user',+ promptId: 'p-1',+ message: { role: 'user', content: [{ type: 'text', text: '[Request interrupted by user]' }] },+ ...over+ })++ it('refuses shapes that are not the CLI’s marker', () => {+ expect(parseTurnInterrupts([rec({})])).toEqual(['p-1'])+ // A prompt the user typed is a plain string, even when it says the same words.+ expect(parseTurnInterrupts([rec({ message: { role: 'user', content: '[Request interrupted by user]' } })])).toEqual([])+ // Other wording: closed set, a future spelling degrades to nothing.+ expect(parseTurnInterrupts([rec({ message: { content: [{ type: 'text', text: '[Request interrupted by user!]' }] } })])).toEqual([])+ // Extra parts, a sidechain, an assistant record, a hostile id, no id, a torn line.+ expect(parseTurnInterrupts([rec({ message: { content: [{ type: 'text', text: '[Request interrupted by user]' }, { type: 'text', text: 'x' }] } })])).toEqual([])+ expect(parseTurnInterrupts([rec({ isSidechain: true })])).toEqual([])+ expect(parseTurnInterrupts([rec({ type: 'assistant' })])).toEqual([])+ expect(parseTurnInterrupts([rec({ promptId: 'a b;rm' })])).toEqual([])+ expect(parseTurnInterrupts([rec({ promptId: undefined })])).toEqual([])+ expect(parseTurnInterrupts([rec({}).slice(0, 60)])).toEqual([])+ })+})++describe('normalizeClaude carries the turn id', () => {+ it('on UserPromptSubmit only, and only as a plain token', () => {+ const s = sc('esc_tool_call')+ const evs = s.hooks.map((payload) => normalizeClaude({ nodeId: 'n', agentId: 'claude', payload }))+ expect(evs[0]).toMatchObject({ state: 'working', newTurn: true, turnId: promptIdOf(s) })+ expect(evs[1]?.turnId).toBeUndefined()+ const hostile = normalizeClaude({ nodeId: 'n', agentId: 'claude', payload: { ...s.hooks[0], prompt_id: 'x y' } })+ expect(hostile?.turnId).toBeUndefined()+ })+})++describe('recordTurnInterrupt (the status mirror decides)', () => {+ let dir: string+ beforeEach(() => {+ _resetForTest()+ dir = testTmpDir('nt-turn-interrupt-')+ initAgentStatusMirror(path.join(dir, 'agent-status.json'))+ })+ afterEach(() => {+ _resetForTest()+ fs.rmSync(dir, { recursive: true, force: true })+ })++ const NODE = 'node-1'+ const replayHooks = (s: Scenario): NormalizedAgentEvent[] =>+ s.hooks+ .map((payload) => normalizeClaude({ nodeId: NODE, agentId: 'claude', payload }))+ .filter((e): e is NormalizedAgentEvent => !!e)+ .map((e) => recordAgentEvent(e))+ const sessionOf = (s: Scenario): string => String(s.hooks[0].session_id)++ it('ends the live turn for every captured interrupt: working (or blocked) → interrupted done', () => {+ for (const k of MARKED) {+ _resetForTest()+ const s = sc(k)+ replayHooks(s)+ const before = _snapshot()[NODE]?.state+ expect(before, k).toBe(k === 'esc_permission_prompt' ? 'blocked' : 'working')+ const [turn] = parseTurnInterrupts(lines(s))+ const ev = recordTurnInterrupt(NODE, sessionOf(s), turn)+ expect(ev, k).toMatchObject({ nodeId: NODE, kind: 'state', state: 'done', interrupted: true })+ expect(ev?.verified, k).toBeUndefined()+ expect(_snapshot()[NODE]?.state, k).toBe('done')+ // Idempotent: the same marker read twice ends nothing more.+ expect(recordTurnInterrupt(NODE, sessionOf(s), turn), k).toBeUndefined()+ }+ })++ it('a marker from an OLDER turn changes nothing (e.g. read back from history on a first read)', () => {+ const a = sc('esc_streaming')+ replayHooks(a)+ const [oldTurn] = parseTurnInterrupts(lines(a))+ // A new turn in the same session.+ recordAgentEvent({ nodeId: NODE, agentId: 'claude', sessionId: sessionOf(a), kind: 'state', state: 'working', newTurn: true, turnId: 'next-turn' })+ expect(recordTurnInterrupt(NODE, sessionOf(a), oldTurn)).toBeUndefined()+ expect(_snapshot()[NODE]?.state).toBe('working')+ })++ it('refuses another session, a finished turn, and an entry with no turn id (after a restart)', () => {+ const s = sc('esc_tool_call')+ replayHooks(s)+ const turn = promptIdOf(s)+ expect(recordTurnInterrupt(NODE, 'another-session', turn)).toBeUndefined()+ expect(recordTurnInterrupt('another-node', sessionOf(s), turn)).toBeUndefined()+ recordAgentEvent({ nodeId: NODE, agentId: 'claude', sessionId: sessionOf(s), kind: 'state', state: 'done' })+ expect(recordTurnInterrupt(NODE, sessionOf(s), turn)).toBeUndefined()++ _resetForTest()+ recordAgentEvent({ nodeId: NODE, agentId: 'claude', sessionId: sessionOf(s), kind: 'state', state: 'working' })+ expect(recordTurnInterrupt(NODE, sessionOf(s), turn)).toBeUndefined()+ expect(_snapshot()[NODE]?.state).toBe('working')+ })++ it('a session boundary forgets the turn', () => {+ const s = sc('esc_tool_call')+ replayHooks(s)+ recordAgentEvent({ nodeId: NODE, agentId: 'claude', sessionId: sessionOf(s), kind: 'session', sessionPhase: 'start' })+ recordAgentEvent({ nodeId: NODE, agentId: 'claude', sessionId: sessionOf(s), kind: 'state', state: 'working' })+ expect(recordTurnInterrupt(NODE, sessionOf(s), promptIdOf(s))).toBeUndefined()+ })+})++it('the local context tail reports a marker appended to a tracked transcript, torn line included', async () => {+ const dir = testTmpDir('nt-interrupt-tail-')+ const file = path.join(dir, 'session.jsonl')+ const s = sc('esc_streaming')+ const onTurnInterrupted = (sessionId: string, turnId: string): void => void got.push([sessionId, turnId])+ const got: [string, string][] = []+ const tail = createContextTail(() => {}, { onTurnInterrupted })+ try {+ fs.writeFileSync(file, lines(s).slice(0, -1).join('\n') + '\n')+ tail.track('session', file)+ await new Promise((r) => setTimeout(r, 1200))+ expect(got).toEqual([])+ const marker = lines(s).at(-1)!+ fs.appendFileSync(file, marker.slice(0, 50))+ await new Promise((r) => setTimeout(r, 1200))+ expect(got).toEqual([])+ fs.appendFileSync(file, marker.slice(50) + '\n')+ await new Promise((r) => setTimeout(r, 1200))+ expect(got).toEqual([['session', promptIdOf(s)]])+ } finally {+ tail.untrack('session')+ fs.rmSync(dir, { recursive: true, force: true })+ }+}, 8000)diff --git a/src/core/context-tail.ts b/src/core/context-tail.tsindex a8945aa6a..83d248947 100644--- a/src/core/context-tail.ts+++ b/src/core/context-tail.ts@@ -133,6 +133,57 @@ export function parseToolResultIds(text: string | string[]): string[] {return ids}+/**+ * The two texts Claude Code writes as a USER record when the user interrupts a turn (Esc, or+ * Ctrl+C once). A CLOSED set: measured on 2.1.285 (`shared/agents/__fixtures__/claude/+ * interrupt-capture.json`) — `[Request interrupted by user]` after streamed text,+ * `… for tool use]` when a tool call or its permission dialog was cancelled. Any other wording is+ * ignored, so a future CLI that words it differently degrades to what happened before this+ * existed (the node waits for its next hook, or the stale sweep), never to a guess.+ */+export const CLAUDE_INTERRUPT_MARKERS: ReadonlySet<string> = new Set([+ '[Request interrupted by user]',+ '[Request interrupted by user for tool use]'+])++const PROMPT_ID_RE = /^[A-Za-z0-9_-]{1,128}$/++/**+ * Turn ids (`promptId`) of the interrupt markers in these transcript lines, in file order. Pure.+ *+ * No hook fires when the user interrupts a Claude turn (Esc during streaming, a tool call or a+ * permission dialog; Ctrl+C once) — measured on 2.1.285 — and the CLI's `idle_prompt`+ * notification does not follow an interrupted turn either. This marker is the one trace the+ * interrupt leaves. The id is only a CANDIDATE: the status mirror acts on it only when it names+ * the turn the node is in right now (`recordTurnInterrupt`), which is what makes a marker read+ * back from history on the tail's first read harmless.+ *+ * Only a main-thread user record whose content is an ARRAY holding exactly one text part with a+ * marker text counts. A prompt the user typed is stored as a plain string, so typing the marker's+ * words cannot produce one.+ */+export function parseTurnInterrupts(text: string | string[]): string[] {+ const out: string[] = []+ for (const line of toLines(text)) {+ // Cheap pre-filter before the parse — this runs over every transcript chunk.+ if (!line.includes('Request interrupted by user')) continue+ let o: { type?: unknown; isSidechain?: unknown; promptId?: unknown; message?: { content?: unknown } }+ try {+ o = JSON.parse(line)+ } catch {+ continue+ }+ if (o?.type !== 'user' || o.isSidechain === true) continue+ if (typeof o.promptId !== 'string' || !PROMPT_ID_RE.test(o.promptId)) continue+ const content = o.message?.content+ if (!Array.isArray(content) || content.length !== 1) continue+ const part = content[0] as { type?: unknown; text?: unknown } | null+ if (part?.type !== 'text' || typeof part.text !== 'string' || !CLAUDE_INTERRUPT_MARKERS.has(part.text)) continue+ out.push(o.promptId)+ }+ return out+}+/** Legacy presence scanner; answer consumers must use parseToolResultIds. */export function hasToolResult(text: string | string[]): boolean {for (const line of toLines(text)) {@@ -157,6 +208,9 @@ export interface ContextTailOptions {onTaskNotification?: (sessionId: string, n: TaskNotification) => void/** Fired when a tracked session's transcript records a tool RESULT — see `parseToolResultIds`. */onToolResult?: (sessionId: string, toolUseId: string) => void+ /** Fired when a tracked session's transcript records a turn INTERRUPT marker, with that turn's id+ * — see `parseTurnInterrupts`. Claude only; the consumer decides whether it is the live turn. */+ onTurnInterrupted?: (sessionId: string, turnId: string) => void/*** How to read the used/window numbers out of this agent's transcript. Defaults to claude's* `parseLatestUsage`. gemini and codex pass their own (`core/gemini-session.ts`@@ -312,6 +366,8 @@ export function createContextTail(}if (opts?.onToolResult)for (const id of parseToolResultIds(completeLines)) opts.onToolResult(sessionId, id)+ if (opts?.onTurnInterrupted)+ for (const id of parseTurnInterrupts(completeLines)) opts.onTurnInterrupted(sessionId, id)}}diff --git a/src/main/index.ts b/src/main/index.tsindex efe14f8a9..4e890dedc 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -181,6 +181,7 @@ import {flush as flushAgentStatusMirror,recordAgentEvent,recordQuestionResult,+ recordTurnInterrupt,ignoreQuestionHook,ackDone,recordRawToolEvent,@@ -2476,6 +2477,19 @@ app.whenReady().then(async () => {const ev = recordQuestionResult(nodeId, sessionId, toolUseId)if (ev) sendToMain(IPC.agentStatus, ev)}+ /**+ * The transcript recorded an interrupt marker (Esc / Ctrl+C). Claude sends no hook for an+ * interrupted turn, so without this the node stayed RUNNING until the stale sweep. The mirror+ * acts only when the marker names the node's CURRENT turn (`recordTurnInterrupt`), so a marker+ * read back from history changes nothing. Same handler in src/server/agent-status.ts.+ */+ const onTurnInterrupted = (sessionId: string, turnId: string): void => {+ let nodeId: string | undefined+ for (const [nid, sid] of nodeContextSession) if (sid === sessionId) nodeId = nid+ if (!nodeId) return+ const ev = recordTurnInterrupt(nodeId, sessionId, turnId)+ if (ev) sendToMain(IPC.agentStatus, ev)+ }const onTaskNotification = (sessionId: string, n: TaskNotification): void => {let nodeId: string | undefinedfor (const [nid, sid] of nodeContextSession) if (sid === sessionId) nodeId = nid@@ -2515,7 +2529,7 @@ app.whenReady().then(async () => {}}}- const contextTail = createContextTail(pushContextUpdate, { onTaskNotification, onToolResult })+ const contextTail = createContextTail(pushContextUpdate, { onTaskNotification, onToolResult, onTurnInterrupted })// ONE TAIL PER AGENT, each with its own parser — not one tail switching on an agent id, which// would mean changing `ContextTail.track(sessionId, path)` and the four call sites that depend on// it. The poller (offset reads, torn-line carry, change-gated push) is written once in@@ -2546,7 +2560,7 @@ app.whenReady().then(async () => {const remoteFile = new RemoteFile((args) =>sshProjectManager ? sshProjectManager.sshRun(args) : Promise.resolve({ code: 1, stdout: '' }))- const remoteContextTail = createRemoteContextTail(win, remoteFile, { onTaskNotification, onToolResult })+ const remoteContextTail = createRemoteContextTail(win, remoteFile, { onTaskNotification, onToolResult, onTurnInterrupted })const remoteCodexContextTail = createRemoteContextTail((usage) => {const scoped = remoteCodexContext.publish(usage)if (scoped) pushContextUpdate(scoped)diff --git a/src/main/remote-context-tail.ts b/src/main/remote-context-tail.tsindex 35c67e885..d1d477c84 100644--- a/src/main/remote-context-tail.ts+++ b/src/main/remote-context-tail.ts@@ -12,6 +12,7 @@ import {parseLatestUsage,parseTaskNotifications,parseToolResultIds,+ parseTurnInterrupts,type ContextTailOptions} from '../core/context-tail'import { splitCompleteLines } from '../core/subagent-tail'@@ -125,6 +126,8 @@ export function createRemoteContextTail(if (opts?.onTaskNotification) {for (const n of parseTaskNotifications(eventLines)) opts.onTaskNotification(sessionId, n)}+ if (opts?.onTurnInterrupted)+ for (const id of parseTurnInterrupts(eventLines)) opts.onTurnInterrupted(sessionId, id)}const push = (sessionId: string, t: Tracked): void => {diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex e2152bd09..7083e3942 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -14984,7 +14984,8 @@ export function Canvas() {e.pendingId,e.verified,e.errored,- e.held+ e.held,+ e.interrupted)// Claude's Stop names the BACKGROUND tasks still running (async subagents, nested ones,// background shells). A background subagent that ends its turn while its own work runsdiff --git a/src/renderer/canvas/control-after-pr.source.test.ts b/src/renderer/canvas/control-after-pr.source.test.tsindex 7728e8e37..e79537914 100644--- a/src/renderer/canvas/control-after-pr.source.test.ts+++ b/src/renderer/canvas/control-after-pr.source.test.ts@@ -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\)/)+ expect(node).toMatch(/launchTooltip\([^)]*prTooltip, successTooltip, pendingInterruptedOn\)/)})})diff --git a/src/renderer/lib/controlRouting.ts b/src/renderer/lib/controlRouting.tsindex 9db4cf9f5..366f6adf4 100644--- a/src/renderer/lib/controlRouting.ts+++ b/src/renderer/lib/controlRouting.ts@@ -225,6 +225,7 @@ export function storedNodeListing(id: n.id, kind: n.kind ?? 'terminal', title: n.title ?? '',...(issue ? { issue } : {}),...(status?.lastTurnError ? { lastTurnErrored: true } : {}),+ ...(status?.lastTurnInterrupted && !status.lastTurnError ? { lastTurnInterrupted: true } : {}),...(launchState ? { launchState } : {}),...(launchState === 'queued' && prHold && !prHold.invalid ? { prWait: formatPrWaits(prHold) } : {}),...(successWait ? { successWait } : {}),@@ -262,6 +263,7 @@ export function controlListingText(rows: ReturnType<typeof storedNodeListing>):(n.successWait ? ` — needs success from: ${n.successWait}` : '') +(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 --git a/src/renderer/lib/erroredTurn.test.ts b/src/renderer/lib/erroredTurn.test.tsindex c039f07d3..3c8519562 100644--- a/src/renderer/lib/erroredTurn.test.ts+++ b/src/renderer/lib/erroredTurn.test.ts@@ -38,7 +38,9 @@ describe('the hook says it (normalize)', () => {})it('an INTERRUPTED turn is not an errored one', () => {- // The user pressed Esc. Nothing failed, and the station should still release its dependents.+ // The user pressed Esc. Nothing failed, so it is not `errored` (no TURN FAILED chip, no+ // station-failure notice). It still holds `--after` dependents, through its OWN annotation —+ // `lastTurnInterrupted`, see turnInterrupt.test.ts.const e = normalizeClaude(env({ hook_event_name: 'Stop', is_interrupt: true }))expect(e).toMatchObject({ state: 'done', interrupted: true })expect(e?.errored).toBeFalsy()diff --git a/src/renderer/lib/pendingLaunch.ts b/src/renderer/lib/pendingLaunch.tsindex 21bdc1862..2205dea37 100644--- a/src/renderer/lib/pendingLaunch.ts+++ b/src/renderer/lib/pendingLaunch.ts@@ -26,7 +26,7 @@ export interface ArmedNode {/** The subset of the agentStatus store this module reads. */export type StatusById = Record<string,- { state?: AgentState; lastTurnError?: { at: number } } | undefined+ { state?: AgentState; lastTurnError?: { at: number }; lastTurnInterrupted?: { at: number } } | undefined>export interface LaunchToFire {@@ -211,12 +211,16 @@ 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).*/function depSatisfied(depId: string, status: StatusById, live: ReadonlySet<string>): boolean {if (!live.has(depId)) return trueconst 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 ERRORED rather than@@ -231,6 +235,23 @@ export function erroredDeps()}+/** Of the deps this node is still waiting on, which are held because the user INTERRUPTED their+ * last turn? Named by the QUEUED tooltip, like `erroredDeps`. An errored dep is left to+ * `erroredDeps` — that is the stronger fact, and one reason is enough. */+export function interruptedDeps(+ node: ArmedNode,+ status: StatusById,+ live: ReadonlySet<string>+): string[] {+ return (node.data.pendingLaunch?.after ?? []).filter(+ (d) =>+ live.has(d) &&+ status[d]?.state === 'done' &&+ !status[d]?.lastTurnError &&+ !!status[d]?.lastTurnInterrupted+ )+}+/*** Which armed nodes are ready to launch, given the live canvas and the current agent states.* `live` is passed in (rather than derived from `nodes`) because the caller already holds the@@ -367,7 +388,9 @@ export function launchTooltip(pr?: { expired: boolean; summary: string; deadline: string },/** 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 }+ success?: { status: 'met' | 'waiting' | 'blocked' | 'expired'; summary: string; deadline: string },+ /** The deps held because the user interrupted their last turn (`interruptedDeps`). */+ interruptedOn?: 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}`@@ -395,6 +418,13 @@ export function launchTooltip('what it did not produce.\n' +`Retry or nudge it — a successful turn releases this — or press ▶ to run it now.\n${runs}`)+ // Same shape: an interrupted upstream is idle, and nothing will release this on its own.+ if (interruptedOn)+ return (+ `${interruptedOn} was interrupted before its turn finished, so this is held rather than ` ++ 'started on unfinished work.\n' ++ `Give it its next prompt — a turn that finishes releases this — or press ▶ to run it now.\n${runs}`+ )// A wait that passed its deadline will not end on its own either — the one other case where// "waiting for" would be a promise nobody keeps.if (pr?.expired)diff --git a/src/renderer/lib/turnInterrupt.test.ts b/src/renderer/lib/turnInterrupt.test.tsnew file mode 100644index 000000000..8e211d10b--- /dev/null+++ b/src/renderer/lib/turnInterrupt.test.ts@@ -0,0 +1,117 @@+// An interrupted turn (Esc / Ctrl+C) holds `--after` dependents, like an errored one (#521), but+// through its OWN annotation — an interrupt is not a failure. Claude sends no hook for it (measured+// on 2.1.285); the `done` comes from the transcript marker the core reads (`recordTurnInterrupt`,+// core/claude-turn-interrupt.test.ts) or from the renderer's own keystroke guess.+import { beforeEach, describe, expect, it, vi } from 'vitest'+import { useAgentStatus, inferInterruptAfterSettle, interruptVerdict } from '../state/agentStatus'+import { interruptedDeps, erroredDeps, launchesToFire, launchTooltip, unmetDeps, type StatusById } from './pendingLaunch'+import { storedNodeListing, controlListingText } from './controlRouting'++const LIVE = new Set(['up'])+const armed = (after: string[]) => ({ id: 'down', data: { pendingLaunch: { after, command: 'go' } } })++let n = 0+const nid = () => `ti${++n}`++describe('the store keeps the verdict beside the state', () => {+ beforeEach(() => useAgentStatus.setState({ byId: {} }))++ const interruptedDone = (id: string) =>+ useAgentStatus.getState().setState(id, 'done', 'claude', undefined, undefined, undefined, undefined, undefined, true)++ it('an interrupted done records it; it is NOT an error', () => {+ const id = nid()+ useAgentStatus.getState().setState(id, 'working', 'claude', true)+ interruptedDone(id)+ const e = useAgentStatus.getState().byId[id]+ expect(e.state).toBe('done')+ expect(e.lastTurnInterrupted?.at).toBeGreaterThan(0)+ expect(e.lastTurnError).toBeUndefined()+ })++ it('lands even when the node is ALREADY done (the renderer guess ran first)', () => {+ const id = nid()+ useAgentStatus.getState().setState(id, 'done', 'claude')+ interruptedDone(id)+ expect(useAgentStatus.getState().byId[id].lastTurnInterrupted).toBeDefined()+ })++ it('a new turn, or a turn that then ends normally, retires it; intermediate states leave it', () => {+ const id = nid()+ const s = useAgentStatus.getState()+ interruptedDone(id)+ s.setState(id, 'blocked', 'claude')+ expect(useAgentStatus.getState().byId[id].lastTurnInterrupted).toBeDefined()+ s.setState(id, 'working', 'claude', true)+ expect(useAgentStatus.getState().byId[id].lastTurnInterrupted).toBeUndefined()++ const id2 = nid()+ interruptedDone(id2)+ s.setState(id2, 'done', 'claude') // e.g. an injected <task-notification> turn that finished+ expect(useAgentStatus.getState().byId[id2].lastTurnInterrupted).toBeUndefined()+ })++ it('interruptVerdict is the whole rule', () => {+ const prev = { at: 1 }+ expect(interruptVerdict(undefined, 'done', false, true)).toBe('set')+ expect(interruptVerdict(prev, 'done', false, false)).toBeUndefined()+ expect(interruptVerdict(prev, 'working', true)).toBeUndefined()+ expect(interruptVerdict(prev, 'working', false)).toBe(prev)+ expect(interruptVerdict(prev, undefined)).toBe(prev)+ })++ it('the keystroke guess records an INTERRUPTED done, so it cannot release dependents early', () => {+ vi.useFakeTimers()+ try {+ const id = nid()+ useAgentStatus.getState().setState(id, 'working', 'claude')+ inferInterruptAfterSettle(id, 1500)+ vi.advanceTimersByTime(1500)+ const e = useAgentStatus.getState().byId[id]+ expect(e.state).toBe('done')+ expect(e.lastTurnInterrupted).toBeDefined()+ } finally {+ vi.useRealTimers()+ }+ })+})++describe('--after holds on an interrupted upstream', () => {+ const done: StatusById = { up: { state: 'done' } }+ const interrupted: StatusById = { up: { state: 'done', lastTurnInterrupted: { at: 1 } } }++ it('does not fire, names the upstream, and says why', () => {+ expect(launchesToFire([armed(['up'])], done, LIVE)).toHaveLength(1)+ expect(launchesToFire([armed(['up'])], interrupted, LIVE)).toEqual([])+ expect(unmetDeps(armed(['up']), interrupted, LIVE)).toEqual(['up'])+ expect(interruptedDeps(armed(['up']), interrupted, LIVE)).toEqual(['up'])+ expect(erroredDeps(armed(['up']), interrupted, LIVE)).toEqual([])+ })++ it('an errored dep is named as errored only, and a deleted one is still satisfied', () => {+ const both: StatusById = { up: { state: 'done', lastTurnError: { at: 1 }, lastTurnInterrupted: { at: 1 } } }+ expect(interruptedDeps(armed(['up']), both, LIVE)).toEqual([])+ expect(launchesToFire([armed(['up'])], interrupted, new Set())).toHaveLength(1)+ })++ it('the QUEUED tooltip says the upstream was interrupted and offers ▶', () => {+ const t = launchTooltip(undefined, 'A', 'go', undefined, false, undefined, undefined, 'A')+ expect(t).toContain('was interrupted before its turn finished')+ expect(t).toContain('▶')+ expect(t).not.toContain('Waiting for')+ })++ it('`list` marks the row LAST TURN INTERRUPTED (and an error outranks it)', () => {+ const rows = storedNodeListing(+ [{ id: 'i', agentId: 'claude' }, { id: 'e', agentId: 'claude' }],+ {+ i: { state: 'done', lastTurnInterrupted: { at: 1 } },+ e: { state: 'done', lastTurnError: { at: 1 }, lastTurnInterrupted: { at: 1 } }+ }+ )+ const text = controlListingText(rows)+ expect(text).toContain('i [terminal] — LAST TURN INTERRUPTED')+ expect(text).toContain('e [terminal] — LAST TURN ERRORED')+ expect(text).not.toMatch(/e \[terminal\].*INTERRUPTED/)+ })+})diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 2f3bb3dd6..fd0eb13ef 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -234,7 +234,7 @@ import { useCodexIdentity, codexSharedIdentity, codexFallbackText } from '../staimport { codexApprovalCaps } from '../state/codexCli'import { useAgentStatus, agentStatusForApi, inferInterruptAfterSettle } from '../state/agentStatus'import { useLaunchDelivery } from '../state/launchDelivery'-import { erroredDeps, launchTooltip } from '../lib/pendingLaunch'+import { erroredDeps, interruptedDeps, launchTooltip } from '../lib/pendingLaunch'import { useSuccessWait } from '../lib/useSuccessWait'import { StationFailedChip } from '../components/StationFailedChip'import { prHoldExpired, prHoldSummary } from '../lib/prWait'@@ -2097,6 +2097,13 @@ export function TerminalNode({const live = new Set(after.filter((d) => !!getNode(d)))return erroredDeps({ id, data: { pendingLaunch } }, s.byId, live).join(',')})+ // Same selector shape for deps held because the user interrupted their last turn (Esc/Ctrl+C).+ const interruptedDepIds = useAgentStatus((s) => {+ const after = pendingLaunch?.after ?? []+ if (!after.length) return ''+ const live = new Set(after.filter((d) => !!getNode(d)))+ return interruptedDeps({ id, data: { pendingLaunch } }, s.byId, live).join(',')+ })// `--after-pr`: what the pull requests this node waits on look like, from the same status the// launch loop judges (the canvas's watch keeps it coming). Selected only for a node that has a// PR wait, so no other node re-renders on a GitHub update.@@ -2128,6 +2135,12 @@ export function TerminalNode({.map((depId) => ((getNode(depId) as CanvasNode | undefined)?.data.title as string) || depId).join(', '): ''+ const pendingInterruptedOn = interruptedDepIds+ ? interruptedDepIds+ .split(',')+ .map((depId) => ((getNode(depId) as CanvasNode | undefined)?.data.title as string) || depId)+ .join(', ')+ : ''// Use the chat panel only for a chat-capable agent with a known session; otherwise the// markdown-of-output view (computed in the capture effect below) is shown as a fallback.// `chatAvailable` is split out because the label-row ⌘M hint names the face BEFORE it is open:@@ -6009,7 +6022,7 @@ export function TerminalNode({? ' term-node__status--queued-warn': ''}`}- title={launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip)}+ title={launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn)}><span className="term-node__status-dot" />{startingNowdiff --git a/src/renderer/nodes/session-ready-signal.test.ts b/src/renderer/nodes/session-ready-signal.test.tsindex 05e2e8eeb..c08f18421 100644--- a/src/renderer/nodes/session-ready-signal.test.ts+++ b/src/renderer/nodes/session-ready-signal.test.ts@@ -102,7 +102,7 @@ describe('the QUEUED badge carries the delivery state (source pins)', () => {// 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)"+ "launchTooltip(launchDelivery, pendingWaitingOn, pendingLaunch.command, pendingErroredOn, session.source === 'relay', prTooltip, successTooltip, pendingInterruptedOn)")})diff --git a/src/renderer/state/agentStatus.test.ts b/src/renderer/state/agentStatus.test.tsindex c70d25a6e..ba691d261 100644--- a/src/renderer/state/agentStatus.test.ts+++ b/src/renderer/state/agentStatus.test.ts@@ -305,7 +305,7 @@ describe('the verified evidence for a transition', () => {// argument list: nothing else in the suite would notice if the last argument disappeared.const src = readFileSync(resolve(__dirname, '../../..', 'src/renderer/canvas/Canvas.tsx'), 'utf8')expect(src).toMatch(- /cs\.setState\(\s*e\.nodeId,\s*e\.state,\s*e\.agentId,\s*e\.newTurn,\s*e\.pendingId,\s*e\.verified,\s*e\.errored,\s*e\.held\s*\)/+ /cs\.setState\(\s*e\.nodeId,\s*e\.state,\s*e\.agentId,\s*e\.newTurn,\s*e\.pendingId,\s*e\.verified,\s*e\.errored,\s*e\.held,\s*e\.interrupted\s*\)/)})diff --git a/src/renderer/state/agentStatus.ts b/src/renderer/state/agentStatus.tsindex f41a1c595..d030b1575 100644--- a/src/renderer/state/agentStatus.ts+++ b/src/renderer/state/agentStatus.ts@@ -229,6 +229,23 @@ export interface AgentNodeStatus {* `NormalizedAgentEvent.errored`. Reading the error itself is still owed.*/lastTurnError?: { at: number }+ /**+ * The station's LAST turn was interrupted by the user (Esc / Ctrl+C) instead of finishing — from+ * an interrupted `done` (`NormalizedAgentEvent.interrupted`: the transcript marker Claude writes,+ * a `Stop` with `is_interrupt`, or the `idle_prompt` rescue).+ *+ * Read by exactly one rule: `--after` does not release a dependent on it (`depSatisfied`). The+ * turn the dependent was waiting for did not produce its result — the person stopped it,+ * usually to redirect it — so starting the next station on it is the same mistake #521 closed+ * for an errored turn. It is deliberately NOT `lastTurnError`: an interrupt is not a failure, so+ * the TURN FAILED chip, the station-failure notice, team progress and issue runs stay as they+ * were. ▶ still runs the dependent by hand.+ *+ * Cleared by the next genuine new turn, and by any `done` that is not interrupted (a turn that+ * then ends normally — an injected `<task-notification>` turn has no newTurn — is the last turn+ * now). TRANSIENT, like `lastTurnError`.+ */+ lastTurnInterrupted?: { at: number }/** Set when running /loop, /schedule or /cron (heuristic); shown as a connected node. */loop?: {count: number@@ -256,6 +273,22 @@ export interface AgentNodeStatus {}}+/**+ * The next `lastTurnInterrupted` for one `setState` edge: `'set'` to stamp it now, the previous value+ * to keep it, `undefined` to clear it. Pure. A new turn clears; an interrupted `done` sets; any+ * other `done` clears (that turn ended normally); every other edge keeps.+ */+export function interruptVerdict(+ prev: { at: number } | undefined,+ state: AgentState | undefined,+ newTurn?: boolean,+ interrupted?: boolean+): { at: number } | 'set' | undefined {+ if (newTurn) return undefined+ if (state === 'done') return interrupted === true ? 'set' : undefined+ return prev+}+export interface AgentStatusStore {byId: Record<string, AgentNodeStatus>/** The terminal node the user is currently focused in (for unread decisions). */@@ -276,7 +309,8 @@ export interface AgentStatusStore {pendingId?: string,verified?: boolean,errored?: boolean,- held?: HeldPermission+ held?: HeldPermission,+ interrupted?: boolean): void/*** Subscribe to EVERY hook event `setState` records for node `id` — same-state ones included, and@@ -383,7 +417,11 @@ export interface AgentStatusSession {store: UseBoundStore<StoreApi<AgentStatusStore>>/*** Esc/Ctrl-C interrupt inference: Claude Code fires NO hook when the user- * cancels a turn, so a node interrupted mid-work would sit on "working" forever. Called+ * cancels a turn (measured on 2.1.285), so a node interrupted mid-work would sit on "working"+ * forever. The core now ends such a turn from the transcript's interrupt marker+ * (`recordTurnInterrupt`), for every surface; this renderer-only GUESS stays because it is the+ * one thing that covers a cancel BEFORE the first token, which the CLI rewinds without writing+ * a marker at all — and it covers only keystrokes typed into THIS terminal. Called* from the terminal's input path on a lone Esc / Ctrl-C: wait one settle window; if the* node is still `working` and NOT ONE hook event arrived since the keystroke (stateAt* unchanged), conclude the turn was cancelled and flip it to done. A wrong guess@@ -556,7 +594,7 @@ export function createAgentStatusSession(return s.activeId === id ? { activeId: null } : s}),- setState: (id, state, agentId, newTurn, pendingId, verified, errored, held) => {+ setState: (id, state, agentId, newTurn, pendingId, verified, errored, held, interrupted) => {set((s) => {const prev = s.byId[id] ?? EMPTYconst now = Date.now()@@ -565,6 +603,9 @@ export function createAgentStatusSession(// a badge appearing or disappearing needs, so an event that moves this must not take it.const turnErrorMoves =errored === true || (newTurn === true && prev.lastTurnError !== undefined)+ // The interrupt verdict moves on the same kinds of edge (see `lastTurnInterrupted`).+ const interruptNext = interruptVerdict(prev.lastTurnInterrupted, state, newTurn, interrupted)+ const turnInterruptMoves = (interruptNext === undefined) !== (prev.lastTurnInterrupted === undefined)// Done-holdoff: a late working event (parallel hook curls arrive out of order, or a// tool POST that was in flight when the user interrupted) must not resurrect a turn// that just finished. Only a genuine new turn (UserPromptSubmit) may.@@ -589,7 +630,8 @@ export function createAgentStatusSession((agentId === undefined || prev.agentId === agentId) &&samePendingWhileBlocked &&sameHeld &&- !turnErrorMoves+ !turnErrorMoves &&+ !turnInterruptMoves) {// Same-state event: refresh freshness in place — stateAt is never rendered, and a// new object here would re-render every node header on each tool event.@@ -620,6 +662,7 @@ export function createAgentStatusSession(// error and the next prompt say nothing about whether that turn produced anything.if (newTurn) next.lastTurnError = undefinedelse if (errored) next.lastTurnError = { at: now }+ next.lastTurnInterrupted = interruptNext === 'set' ? { at: now } : interruptNext// A LIVE state is proof the CLI is running, so the hibernated flag is simply wrong and is// dropped here — the one self-heal this flag has. It is set by a controller that watched// the CLI let go of the pane, but the world moves on without us: the user relaunches the@@ -978,7 +1021,11 @@ export function createAgentStatusSession(const cur = store.getState()const now = cur.byId[id]if (now?.state === 'working' && now.stateAt === baseline) {- cur.setState(id, 'done', now.agentId)+ // Recorded as an INTERRUPTED done, like the transcript marker the core reads a moment+ // later (`recordTurnInterrupt`): a guess that released `--after` dependents would race+ // the authoritative signal and could start them on unfinished work. A wrong guess heals —+ // the turn's next hook puts it back to working and its normal `done` clears the verdict.+ cur.setState(id, 'done', now.agentId, undefined, undefined, undefined, undefined, undefined, true)}}, settleMs)}diff --git a/src/server/agent-status.ts b/src/server/agent-status.tsindex 5024f4a88..b27240337 100644--- a/src/server/agent-status.ts+++ b/src/server/agent-status.ts@@ -12,7 +12,7 @@ import { join, resolve } from 'path'import { homedir } from 'os'import { hookServer } from '../core/agents/hook-server'import { recordAgentEvent, recordRawToolEvent, recordContextUsage,- recordQuestionResult, ignoreQuestionHook+ recordQuestionResult, recordTurnInterrupt, ignoreQuestionHook} from '../core/agent-status-mirror'import { createSubagentTail, type SubagentTail } from '../core/subagent-tail'import { ClaudeSubagentLifecycle } from '../core/claude-subagent-lifecycle'@@ -125,6 +125,16 @@ export function wireAgentStatus(if (ev) platform.broadcast(IPC.agentStatus, ev)}+ /** See the identical handler in src/main/index.ts: an interrupt marker in the transcript ends the+ * node's CURRENT turn (Claude sends no hook for an Esc/Ctrl+C), else the node stayed RUNNING. */+ const onTurnInterrupted = (sessionId: string, turnId: string): void => {+ let nodeId: string | undefined+ for (const [nid, sid] of nodeContextSession) if (sid === sessionId) nodeId = nid+ if (!nodeId) return+ const ev = recordTurnInterrupt(nodeId, sessionId, turnId)+ if (ev) platform.broadcast(IPC.agentStatus, ev)+ }+// Every context tail pushes through here, so an agent's meter reaches the browser and the phone's// context ring identically whichever CLI produced the numbers.const pushContextUpdate = (payload: unknown): void => {@@ -140,7 +150,7 @@ export function wireAgentStatus(}}const contextTail =- opts.contextTail ?? createContextTail(pushContextUpdate, { onTaskNotification, onToolResult })+ opts.contextTail ?? createContextTail(pushContextUpdate, { onTaskNotification, onToolResult, onTurnInterrupted })// ONE TAIL PER AGENT, each with its own parser — not one tail switching on an agent id, which// would mean changing `ContextTail.track(sessionId, path)` and the four call sites that depend on// it. The poller (offset reads, torn-line carry, change-gated push) is written once indiff --git a/src/shared/agents/__fixtures__/claude/interrupt-capture.json b/src/shared/agents/__fixtures__/claude/interrupt-capture.jsonnew file mode 100644index 000000000..1ae50d98c--- /dev/null+++ b/src/shared/agents/__fixtures__/claude/interrupt-capture.json@@ -0,0 +1,1281 @@+{+ "_provenance": "captured live from Claude Code 2.1.285 (linux-x64) on 2026-09-30, logged-in account, interactive TUI inside a private tmux server (tmux -L nt-esc-probe) with every NODETERM_* variable unset, capture hooks passed via `claude --settings <tmp>` (the real settings untouched). Keys sent with tmux send-keys. Session ids, paths and scratch dirs redacted; prompt ids, tool_use ids, message ids, KEYS AND SHAPES UNCHANGED; long free text trimmed; thinking signatures and usage detail removed.",+ "claudeVersion": "2.1.285",+ "scenarios": {+ "esc_streaming": {+ "description": "Esc while the model streams a long text answer (no tools)",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000001",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000001.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46a618b4-a12e-4819-a8c4-955811bd8842",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Write a 1500-word essay about the history of the ocean. Do not use any tools."+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": null,+ "isSidechain": false,+ "promptId": "46a618b4-a12e-4819-a8c4-955811bd8842",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Write a 1500-word essay about the history of the ocean. Do not use any tools."+ },+ "uuid": "d6d8172c-7ffc-42da-bfa2-8330ae175140",+ "timestamp": "2026-09-29T23:37:14.615Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 1,+ "turnIndex": 1+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000001",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "f9f7df64-81e8-4b80-a21a-e95e5251abb0",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcLcEu8FhWPUjruyXjV",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "thinking",+ "thinking": "",+ "signature": "[redacted]"+ }+ ],+ "container": null,+ "stop_reason": null,+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 3+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYcLaU17LxAuW1t4gaTk",+ "type": "assistant",+ "uuid": "4a7655f3-6b6b-4fc6-ba81-3e662e033941",+ "timestamp": "2026-09-29T23:37:18.916Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000001",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000001",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "4a7655f3-6b6b-4fc6-ba81-3e662e033941",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcLcEu8FhWPUjruyXjV",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "text",+ "text": "# The Long Life of the Ocean\n\nSeen from space, Earth is mostly blue. Its oceans cover abou…"+ }+ ],+ "container": null,+ "stop_reason": null,+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 3+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "apiBlockIndex": 1,+ "requestId": "req_011CfYcLaU17LxAuW1t4gaTk",+ "type": "assistant",+ "uuid": "6a418bb0-ebda-4930-ba7b-63c17e8ca880",+ "timestamp": "2026-09-29T23:37:23.662Z",+ "isAbortedMidStream": true,+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000001",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000001",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "6a418bb0-ebda-4930-ba7b-63c17e8ca880",+ "isSidechain": false,+ "promptId": "46a618b4-a12e-4819-a8c4-955811bd8842",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "[Request interrupted by user]"+ }+ ]+ },+ "uuid": "2cdb299d-3ce3-48a5-add8-7fa953338ac1",+ "timestamp": "2026-09-29T23:37:23.665Z",+ "interruptedMessageId": "msg_011CfYcLcEu8FhWPUjruyXjV",+ "session_id": "00000000-0000-4000-8000-000000000001",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000001",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "esc_tool_call": {+ "description": "Esc while an allowed foreground Bash call (ping -c 60) runs",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "f8c0e8b2-180e-4aae-9afc-12e5e750e72d",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Run exactly this bash command in the foreground and nothing else: ping -c 60 127.0.0.1"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "f8c0e8b2-180e-4aae-9afc-12e5e750e72d",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PreToolUse",+ "tool_name": "Bash",+ "tool_input": {+ "command": "ping -c 60 127.0.0.1",+ "timeout": 120000,+ "description": "Ping localhost 60 times"+ },+ "tool_use_id": "toolu_01RvvyPRJrDxq5EzXhfVXSXX"+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": null,+ "isSidechain": false,+ "promptId": "f8c0e8b2-180e-4aae-9afc-12e5e750e72d",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Run exactly this bash command in the foreground and nothing else: ping -c 60 127.0.0.1"+ },+ "uuid": "8d313138-0e36-4e6f-aa6d-febd74bf9fe6",+ "timestamp": "2026-09-29T23:42:30.258Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 1,+ "turnIndex": 1+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "23618318-da74-4700-b20b-ad3260983bfe",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcjs3HH5UKmhfJLaJtY",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "tool_use",+ "id": "toolu_01RvvyPRJrDxq5EzXhfVXSXX",+ "name": "Bash",+ "input": {+ "command": "ping -c 60 127.0.0.1",+ "description": "Ping localhost 60 times",+ "timeout": 120000+ },+ "caller": {+ "type": "direct"+ }+ }+ ],+ "container": null,+ "stop_reason": "tool_use",+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 114+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "wireToolInputs": {+ "toolu_01RvvyPRJrDxq5EzXhfVXSXX": {+ "command": "ping -c 60 127.0.0.1",+ "description": "Ping localhost 60 times",+ "timeout": 120000+ }+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYcjrKPMi3ZUU56YHuTU",+ "type": "assistant",+ "uuid": "992327d8-7bb9-4bf6-92ad-ff7f8fb7804b",+ "timestamp": "2026-09-29T23:42:35.428Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "992327d8-7bb9-4bf6-92ad-ff7f8fb7804b",+ "isSidechain": false,+ "promptId": "f8c0e8b2-180e-4aae-9afc-12e5e750e72d",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "tool_result",+ "content": "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to…",+ "is_error": true,+ "tool_use_id": "toolu_01RvvyPRJrDxq5EzXhfVXSXX"+ }+ ]+ },+ "uuid": "ad1b2ac9-a04b-4652-bb13-c2756fdc1e67",+ "timestamp": "2026-09-29T23:42:45.226Z",+ "toolUseResult": "User rejected tool use",+ "toolDenialKind": "user-rejected",+ "sourceToolAssistantUUID": "992327d8-7bb9-4bf6-92ad-ff7f8fb7804b",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "311a08c2-0f80-490c-9987-3b8415aa1bf9",+ "isSidechain": false,+ "promptId": "f8c0e8b2-180e-4aae-9afc-12e5e750e72d",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "[Request interrupted by user for tool use]"+ }+ ]+ },+ "uuid": "91c7f723-144c-4580-ae1e-cf49f8ac5aac",+ "timestamp": "2026-09-29T23:42:45.231Z",+ "interruptedMessageId": "msg_011CfYcjs3HH5UKmhfJLaJtY",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "esc_permission_prompt": {+ "description": "Esc while the Bash permission dialog is showing (manual mode)",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Run exactly this bash command and nothing else: touch probe-file.txt"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PreToolUse",+ "tool_name": "Bash",+ "tool_input": {+ "command": "touch probe-file.txt",+ "description": "Create empty probe file"+ },+ "tool_use_id": "toolu_016aJzwUGEbZyuGw2CU6iPPC"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PermissionRequest",+ "tool_name": "Bash",+ "tool_input": {+ "command": "touch probe-file.txt",+ "description": "Create empty probe file"+ },+ "permission_suggestions": [+ {+ "type": "addDirectories",+ "directories": [+ "/work/project"+ ],+ "destination": "session"+ },+ {+ "type": "setMode",+ "mode": "acceptEdits",+ "destination": "session"+ }+ ]+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": "91c7f723-144c-4580-ae1e-cf49f8ac5aac",+ "isSidechain": false,+ "promptId": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Run exactly this bash command and nothing else: touch probe-file.txt"+ },+ "uuid": "91eccf2a-ba9e-48b2-aaec-4b12b6ed09f3",+ "timestamp": "2026-09-29T23:43:24.000Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 2,+ "turnIndex": 2+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "5b870ca2-66df-4fcd-b04e-a02e9653916e",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcooybkJxaEdG5EoZMA",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "tool_use",+ "id": "toolu_016aJzwUGEbZyuGw2CU6iPPC",+ "name": "Bash",+ "input": {+ "command": "touch probe-file.txt",+ "description": "Create empty probe file"+ },+ "caller": {+ "type": "direct"+ }+ }+ ],+ "container": null,+ "stop_reason": "tool_use",+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 82+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "wireToolInputs": {+ "toolu_016aJzwUGEbZyuGw2CU6iPPC": {+ "command": "touch probe-file.txt",+ "description": "Create empty probe file"+ }+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYcooY4K8aHDCaiYXMiK",+ "type": "assistant",+ "uuid": "94196c3b-885b-4274-9086-db298ea073e3",+ "timestamp": "2026-09-29T23:43:26.150Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "94196c3b-885b-4274-9086-db298ea073e3",+ "isSidechain": false,+ "promptId": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "tool_result",+ "content": "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to…",+ "is_error": true,+ "tool_use_id": "toolu_016aJzwUGEbZyuGw2CU6iPPC"+ }+ ]+ },+ "uuid": "df07688c-1196-4d9b-9ad5-d8bda2915efa",+ "timestamp": "2026-09-29T23:43:30.051Z",+ "toolUseResult": "User rejected tool use",+ "toolDenialKind": "user-rejected",+ "sourceToolAssistantUUID": "94196c3b-885b-4274-9086-db298ea073e3",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "df07688c-1196-4d9b-9ad5-d8bda2915efa",+ "isSidechain": false,+ "promptId": "61a27b8f-c8b5-4878-a3b7-1f9fc38992c6",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "[Request interrupted by user for tool use]"+ }+ ]+ },+ "uuid": "49f07b53-a780-45aa-9809-03350c68c048",+ "timestamp": "2026-09-29T23:43:30.052Z",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "49f07b53-a780-45aa-9809-03350c68c048",+ "isSidechain": false,+ "type": "system",+ "subtype": "turn_duration",+ "durationMs": 2204,+ "messageCount": 24,+ "timestamp": "2026-09-29T23:43:30.056Z",+ "uuid": "c951c1e0-d35d-40a7-ace4-dc66763723a9",+ "isMeta": false,+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "ctrl_c_streaming": {+ "description": "Ctrl+C once while the model streams text",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "f061b72e-674c-4de6-978b-f67c5f0b6dd5",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Write a 2000-word essay about the history of rivers. Do not use any tools."+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": "a3fdd567-b2f0-4488-a4a1-1dc2cbf386cd",+ "isSidechain": false,+ "promptId": "f061b72e-674c-4de6-978b-f67c5f0b6dd5",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Write a 2000-word essay about the history of rivers. Do not use any tools."+ },+ "uuid": "cd8783c8-dc90-4d63-a214-1dbe902e7edd",+ "timestamp": "2026-09-29T23:45:33.713Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 4,+ "turnIndex": 4+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "78e3def5-a2e1-4d69-8cf2-a1b7cbec2007",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcyNQzWM7puXfmdfKod",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "thinking",+ "thinking": "",+ "signature": "[redacted]"+ }+ ],+ "container": null,+ "stop_reason": null,+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 2+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYcyMzveLXN2xufy6U98",+ "type": "assistant",+ "uuid": "d9cc6585-144f-4835-a94b-b683b507bb36",+ "timestamp": "2026-09-29T23:45:35.272Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "d9cc6585-144f-4835-a94b-b683b507bb36",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYcyNQzWM7puXfmdfKod",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "text",+ "text": "# The Moving Road: A History of Rivers\n\nA river is never the same thing twice. He"+ }+ ],+ "container": null,+ "stop_reason": null,+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 2+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "apiBlockIndex": 1,+ "requestId": "req_011CfYcyMzveLXN2xufy6U98",+ "type": "assistant",+ "uuid": "63181361-7f96-4113-b031-d90464bdf31a",+ "timestamp": "2026-09-29T23:45:35.707Z",+ "isAbortedMidStream": true,+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "63181361-7f96-4113-b031-d90464bdf31a",+ "isSidechain": false,+ "promptId": "f061b72e-674c-4de6-978b-f67c5f0b6dd5",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "[Request interrupted by user]"+ }+ ]+ },+ "uuid": "e092327f-6a22-4645-b5c1-3e45fca8e314",+ "timestamp": "2026-09-29T23:45:35.710Z",+ "interruptedMessageId": "msg_011CfYcyNQzWM7puXfmdfKod",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "ctrl_c_before_first_token": {+ "description": "Ctrl+C once BEFORE any assistant output: the CLI restores the prompt into the input box",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "2f6532a7-5173-40fd-8c54-ad348287d10d",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Write a 1500-word essay about the history of mountains. Do not use any tools."+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": "c951c1e0-d35d-40a7-ace4-dc66763723a9",+ "isSidechain": false,+ "promptId": "2f6532a7-5173-40fd-8c54-ad348287d10d",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Write a 1500-word essay about the history of mountains. Do not use any tools."+ },+ "uuid": "cdfa9221-4239-4c94-a538-39bcb0356551",+ "timestamp": "2026-09-29T23:43:57.348Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 3,+ "turnIndex": 3+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "esc_before_first_token": {+ "description": "Esc ~1 s after Enter, before any assistant output: same rewind",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "c570871d-3d0d-4914-96be-db4ad803b912",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Write a 2000-word essay about the history of deserts. Do not use any tools."+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": "e092327f-6a22-4645-b5c1-3e45fca8e314",+ "isSidechain": false,+ "promptId": "c570871d-3d0d-4914-96be-db4ad803b912",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Write a 2000-word essay about the history of deserts. Do not use any tools."+ },+ "uuid": "48926bea-8f59-447e-a6ea-530b49d244b3",+ "timestamp": "2026-09-29T23:45:50.928Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 5,+ "turnIndex": 5+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "esc_after_background_subagent": {+ "description": "Agent tool asked for a foreground subagent; 2.1.285 launched it async anyway, the parent turn ENDED (Stop), then Esc at the prompt while the child ran. The child was NOT stopped and its SubagentStop arrived normally later.",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Use the Agent tool (subagent_type general-purpose, run in the foreground, NOT in background) with this task: 'Write a 1500-word essay about volcanoes and return it. Do not use tools.' Do nothing else."+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PreToolUse",+ "tool_name": "Agent",+ "tool_input": {+ "description": "Write volcano essay",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools.",+ "subagent_type": "general-purpose"+ },+ "tool_use_id": "toolu_01SSfpMeBLj4YwHJHq9Hatp6"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "agent_id": "a9cce211e7110825e",+ "agent_type": "general-purpose",+ "hook_event_name": "SubagentStart"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PostToolUse",+ "tool_name": "Agent",+ "tool_input": {+ "description": "Write volcano essay",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools.",+ "subagent_type": "general-purpose"+ },+ "tool_response": {+ "isAsync": true,+ "status": "async_launched",+ "agentId": "a9cce211e7110825e",+ "description": "Write volcano essay",+ "resolvedModel": "claude-opus-5-5",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools.",+ "outputFile": "/tmp/scratch/00000000-0000-4000-8000-000000000002/tasks/a9cce211e7110825e.output",+ "canReadOutputFile": true+ },+ "tool_use_id": "toolu_01SSfpMeBLj4YwHJHq9Hatp6",+ "duration_ms": 28+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "Stop",+ "stop_hook_active": false,+ "last_assistant_message": "You asked for the volcano-essay agent to run in the foreground, but it launched in the bac…",+ "background_tasks": [+ {+ "id": "a9cce211e7110825e",+ "type": "subagent",+ "status": "running",+ "description": "Write volcano essay",+ "agent_type": "general-purpose"+ }+ ],+ "session_crons": []+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "agent_id": "acf7f57bf3824a75f",+ "agent_type": "",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "SubagentStop",+ "stop_hook_active": false,+ "agent_transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002/subagents/agent-acf7f57bf3824a75f.jsonl",+ "background_tasks": [+ {+ "id": "a9cce211e7110825e",+ "type": "subagent",+ "status": "running",+ "description": "Write volcano essay",+ "agent_type": "general-purpose"+ }+ ],+ "session_crons": []+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "permission_mode": "default",+ "agent_id": "a9cce211e7110825e",+ "agent_type": "general-purpose",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "SubagentStop",+ "stop_hook_active": false,+ "agent_transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002/subagents/agent-a9cce211e7110825e.jsonl",+ "last_assistant_message": "# Volcanoes: The Earth's Restless Architects\n\nFew natural phenomena capture the human imag…",+ "background_tasks": [+ {+ "id": "a9cce211e7110825e",+ "type": "subagent",+ "status": "running",+ "description": "Write volcano essay",+ "agent_type": "general-purpose"+ }+ ],+ "session_crons": []+ }+ ],+ "hooksAfterKey": "none from the Esc; the child SubagentStop and the <task-notification> turn came when the child finished",+ "transcript": [+ {+ "parentUuid": "e092327f-6a22-4645-b5c1-3e45fca8e314",+ "isSidechain": false,+ "promptId": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Use the Agent tool (subagent_type general-purpose, run in the foreground, NOT in background) with this task: 'Write a 1500-word essay about volcanoes and return it. Do not use tools.' Do nothing else."+ },+ "uuid": "5541fbc0-226b-48d9-9bb8-448ba10f975e",+ "timestamp": "2026-09-29T23:46:43.819Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 5,+ "turnIndex": 5+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "01ccb460-85ca-4594-be4f-e1a37c70c308",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYd4Yd35vmJtWsXhX5nx",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "tool_use",+ "id": "toolu_01SSfpMeBLj4YwHJHq9Hatp6",+ "name": "Agent",+ "input": {+ "description": "Write volcano essay",+ "subagent_type": "general-purpose",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools."+ },+ "caller": {+ "type": "direct"+ }+ }+ ],+ "container": null,+ "stop_reason": "tool_use",+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 131+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "wireToolInputs": {+ "toolu_01SSfpMeBLj4YwHJHq9Hatp6": {+ "description": "Write volcano essay",+ "subagent_type": "general-purpose",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools."+ }+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYd4YC162tQoEznhUXYr",+ "type": "assistant",+ "uuid": "bd9d54e3-ffac-4d8f-a1c8-5f0c581f7c71",+ "timestamp": "2026-09-29T23:46:46.224Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "bd9d54e3-ffac-4d8f-a1c8-5f0c581f7c71",+ "isSidechain": false,+ "promptId": "46696376-e7b6-499d-a8af-b0c66b5a11fa",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "tool_use_id": "toolu_01SSfpMeBLj4YwHJHq9Hatp6",+ "type": "tool_result",+ "content": [+ {+ "type": "text",+ "text": "Async agent launched successfully. (This tool result is internal metadata — never quote or…"+ }+ ]+ }+ ]+ },+ "uuid": "664232c7-c4e4-4d2c-83ef-3fe708111f7b",+ "timestamp": "2026-09-29T23:46:46.450Z",+ "toolUseResult": {+ "isAsync": true,+ "status": "async_launched",+ "agentId": "a9cce211e7110825e",+ "description": "Write volcano essay",+ "resolvedModel": "claude-opus-5-5",+ "prompt": "Write a 1500-word essay about volcanoes and return it. Do not use tools.",+ "outputFile": "/tmp/scratch/00000000-0000-4000-8000-000000000002/tasks/a9cce211e7110825e.output",+ "canReadOutputFile": true+ },+ "sourceToolAssistantUUID": "bd9d54e3-ffac-4d8f-a1c8-5f0c581f7c71",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ },+ "esc_tool_call_then_80s_idle": {+ "description": "Esc during a foreground Bash call, then 80 s idle: no hook at all, not even idle_prompt",+ "hooks": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "3c1778ac-d5aa-4d2f-b4e1-fbd5816a46e2",+ "permission_mode": "default",+ "hook_event_name": "UserPromptSubmit",+ "prompt": "Run exactly this bash command in the foreground and nothing else: ping -c 60 127.0.0.1"+ },+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "3c1778ac-d5aa-4d2f-b4e1-fbd5816a46e2",+ "permission_mode": "default",+ "effort": {+ "level": "medium"+ },+ "hook_event_name": "PreToolUse",+ "tool_name": "Bash",+ "tool_input": {+ "command": "ping -c 60 127.0.0.1",+ "timeout": 120000,+ "description": "Ping localhost 60 times"+ },+ "tool_use_id": "toolu_01L5Bw193WJt3dU3n6gVaFtX"+ }+ ],+ "hooksAfterKey": "none (every hook listed above fired BEFORE the key was pressed)",+ "transcript": [+ {+ "parentUuid": "116627d2-635e-4023-a6a6-770a7adada91",+ "isSidechain": false,+ "promptId": "3c1778ac-d5aa-4d2f-b4e1-fbd5816a46e2",+ "type": "user",+ "message": {+ "role": "user",+ "content": "Run exactly this bash command in the foreground and nothing else: ping -c 60 127.0.0.1"+ },+ "uuid": "b4e65bc2-73cd-44a9-bbde-62ceeb704f8e",+ "timestamp": "2026-09-29T23:51:01.286Z",+ "permissionMode": "default",+ "origin": {+ "kind": "human"+ },+ "promptSource": "typed",+ "turnOrigin": "human",+ "turnPosition": {+ "promptIndex": 7,+ "turnIndex": 9+ },+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "59c07b93-823b-4551-9a77-24d401012e34",+ "isSidechain": false,+ "message": {+ "model": "claude-opus-5-5",+ "id": "msg_011CfYdPXHwoG2EwKbdukDea",+ "type": "message",+ "role": "assistant",+ "content": [+ {+ "type": "tool_use",+ "id": "toolu_01L5Bw193WJt3dU3n6gVaFtX",+ "name": "Bash",+ "input": {+ "command": "ping -c 60 127.0.0.1",+ "description": "Ping localhost 60 times",+ "timeout": 120000+ },+ "caller": {+ "type": "direct"+ }+ }+ ],+ "container": null,+ "stop_reason": "tool_use",+ "stop_sequence": null,+ "stop_details": null,+ "usage": {+ "input_tokens": 2,+ "output_tokens": 114+ },+ "input_transformations": [],+ "diagnostics": null,+ "context_management": null+ },+ "wireToolInputs": {+ "toolu_01L5Bw193WJt3dU3n6gVaFtX": {+ "command": "ping -c 60 127.0.0.1",+ "description": "Ping localhost 60 times",+ "timeout": 120000+ }+ },+ "apiBlockIndex": 0,+ "requestId": "req_011CfYdPWtdg4o8MMTqoHcVh",+ "type": "assistant",+ "uuid": "b0ba07b0-772a-4f40-8d29-29d37ea97f5e",+ "timestamp": "2026-09-29T23:51:03.565Z",+ "advisorModel": "claude-opus-5-5",+ "effort": "medium",+ "perTurnEffort": "medium",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "b0ba07b0-772a-4f40-8d29-29d37ea97f5e",+ "isSidechain": false,+ "promptId": "3c1778ac-d5aa-4d2f-b4e1-fbd5816a46e2",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "tool_result",+ "content": "The user doesn't want to proceed with this tool use. The tool use was rejected (eg. if it was a file edit, the new_string was NOT written to the file). STOP what you are doing and wait for the user to…",+ "is_error": true,+ "tool_use_id": "toolu_01L5Bw193WJt3dU3n6gVaFtX"+ }+ ]+ },+ "uuid": "cc592793-0cbe-4847-94fc-71c604935be5",+ "timestamp": "2026-09-29T23:51:08.379Z",+ "toolUseResult": "User rejected tool use",+ "toolDenialKind": "user-rejected",+ "sourceToolAssistantUUID": "b0ba07b0-772a-4f40-8d29-29d37ea97f5e",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ },+ {+ "parentUuid": "cc592793-0cbe-4847-94fc-71c604935be5",+ "isSidechain": false,+ "promptId": "3c1778ac-d5aa-4d2f-b4e1-fbd5816a46e2",+ "type": "user",+ "message": {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "[Request interrupted by user for tool use]"+ }+ ]+ },+ "uuid": "83a18827-6797-4805-94f1-2adc37ad481b",+ "timestamp": "2026-09-29T23:51:08.381Z",+ "interruptedMessageId": "msg_011CfYdPXHwoG2EwKbdukDea",+ "session_id": "00000000-0000-4000-8000-000000000002",+ "userType": "external",+ "entrypoint": "cli",+ "cwd": "/work/project",+ "sessionId": "00000000-0000-4000-8000-000000000002",+ "version": "2.1.285",+ "gitBranch": "main"+ }+ ]+ }+ },+ "idlePrompt": {+ "fired": [+ {+ "session_id": "00000000-0000-4000-8000-000000000002",+ "transcript_path": "/home/user/.claude/projects/-work-project/00000000-0000-4000-8000-000000000002.jsonl",+ "cwd": "/work/project",+ "scratchpad_dir": "/tmp/scratch",+ "prompt_id": "5607c785-57b6-40ce-bc4d-bad8ca08f82a",+ "hook_event_name": "Notification",+ "message": "Claude is waiting for your input",+ "notification_type": "idle_prompt"+ }+ ],+ "note": "idle_prompt fired 60 s after a NORMAL Stop. It did NOT fire in 75 s (esc_streaming) or 80 s (esc_tool_call_then_80s_idle) after an interrupted turn."+ }+}diff --git a/src/shared/agents/normalize.ts b/src/shared/agents/normalize.tsindex f1a34c549..93ce6d3d4 100644--- a/src/shared/agents/normalize.ts+++ b/src/shared/agents/normalize.ts@@ -56,6 +56,17 @@ export interface NormalizedAgentEvent {// true only for a genuine new turn (Claude UserPromptSubmit), so the renderer can// clear per-turn fan-out without clearing on every mid-turn tool event.newTurn?: boolean+ /**+ * Claude only, on the `UserPromptSubmit` that opens a turn: the CLI's own id for that turn+ * (`prompt_id`). Claude writes the SAME id as `promptId` on every transcript record of the+ * turn, including the `[Request interrupted by user]` marker it appends when the user presses+ * Esc / Ctrl+C — the one trace an interrupted turn leaves, because no hook fires for it+ * (measured on 2.1.285, `__fixtures__/claude/interrupt-capture.json`). The status mirror keeps+ * this id so a marker can be matched to exactly the turn it ends (`recordTurnInterrupt`), never+ * to an older one read back from the transcript. Absent when the payload has none or it is not+ * a plain token.+ */+ turnId?: stringsessionId?: stringlastMessage?: string// blocked (Claude PermissionRequest) only: the deterministic-approval ticket the managed hook@@ -180,6 +191,12 @@ export interface RawHookEnvelope {const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])const RECURRING_TOOLS = new Set(['Skill', 'CronCreate', 'ScheduleWakeup'])+/** A Claude turn id (`prompt_id`, a uuid today) as a plain bounded token, else nothing. */+const TURN_ID_RE = /^[A-Za-z0-9_-]{1,128}$/+function turnIdOf(v: unknown): { turnId?: string } {+ return typeof v === 'string' && TURN_ID_RE.test(v) ? { turnId: v } : {}+}+interface ClaudePayload {/** SubagentStart/SubagentStop: the child. Any other event: the child that produced it. */agent_id?: unknown@@ -200,6 +217,8 @@ interface ClaudePayload {is_interrupt?: booleanlast_assistant_message?: stringprompt?: string+ /** The CLI's id for the turn this event belongs to (see `NormalizedAgentEvent.turnId`). */+ prompt_id?: unknowntool_name?: stringtool_use_id?: stringtool_input?: {@@ -372,9 +391,9 @@ export function normalizeClaude(env: RawHookEnvelope): NormalizedAgentEvent | nu// genuine user turn — flagging it newTurn would clear the subagent fan-out at the exact moment// one of the cards completes.if (isInjectedSubagentPrompt(p.prompt ?? '')) {- return { ...base, kind: 'state', state: 'working' }+ return { ...base, kind: 'state', state: 'working', ...turnIdOf(p.prompt_id) }}- return { ...base, kind: 'state', state: 'working', task: p.prompt, newTurn: true }+ return { ...base, kind: 'state', state: 'working', task: p.prompt, newTurn: true, ...turnIdOf(p.prompt_id) }}if (ev === 'Stop') {const backgroundTaskIds = liveBackgroundTaskIds(p.background_tasks)@@ -430,6 +449,10 @@ export function normalizeClaude(env: RawHookEnvelope): NormalizedAgentEvent | nu// while a turn runs, which makes it the ONE signal that rescues a node stuck on `working` when// no turn-end hook ever fired — the Esc-during-a-tool-call case, where Claude aborts the tool// and returns to "Interrupted · What should Claude do instead?" without running Stop.+ // MEASURED on 2.1.285: it does NOT follow an interrupted turn (it came 60 s after a normal Stop,+ // and not in 80 s after an Esc). The interrupt is now ended from the transcript's marker+ // instead (`recordTurnInterrupt`, core/agent-status-mirror.ts); this rescue stays for any CLI+ // build that does send it.//// Marked `idle` (and `interrupted`, since nothing was accomplished) so consumers can apply the// narrow rule this needs: it may only move a node that is still WORKING. It also fires after a