Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(agents): clear subagent fan-out only on new turn; restore /loop prompt-prefix fallback

enes55766d5dbe1a
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index cf1311c12..73716850b 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -1213,7 +1213,13 @@ export function Canvas() {
switch (e.kind) {
case 'state':
if (e.state) cs.setState(e.nodeId, e.state, e.agentId)
- if (e.state === 'working') an.clearForParent(e.nodeId) // new turn → drop the previous fan-out
+ if (e.newTurn) an.clearForParent(e.nodeId) // genuine new turn → drop the previous fan-out
+ if (e.newTurn && e.task) {
+ // Prompt-prefix fallback for /loop|/schedule|/cron when the natural-language
+ // phrasing doesn't trigger the tool-based (recurring) detection.
+ const m = e.task.match(/^\s*\/(loop|schedule|cron)\b/)
+ if (m) cs.setLoop(e.nodeId, true, m[1] as 'loop' | 'schedule' | 'cron', { task: e.task })
+ }
if (e.state === 'done') {
cs.bumpLoop(e.nodeId, e.lastMessage) // count loop iterations + summary (no-op if not looping)
alert('finished', 'Claude finished its turn.')
diff --git a/src/shared/agents/normalize.ts b/src/shared/agents/normalize.ts
index aaf3af78e..1f41028b7 100644
--- a/src/shared/agents/normalize.ts
+++ b/src/shared/agents/normalize.ts
@@ -9,6 +9,9 @@ export interface NormalizedAgentEvent {
agentId: AgentId
kind: 'state' | 'subagent-start' | 'subagent-end' | 'recurring' | 'session'
state?: AgentState
+ // 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
sessionId?: string
lastMessage?: string
// session
@@ -113,7 +116,7 @@ export function normalizeClaude(env: RawHookEnvelope): NormalizedAgentEvent | nu
}
if (ev === 'UserPromptSubmit') {
- return { ...base, kind: 'state', state: 'working', task: p.prompt }
+ return { ...base, kind: 'state', state: 'working', task: p.prompt, newTurn: true }
}
if (ev === 'Stop') {
return { ...base, kind: 'state', state: 'done', lastMessage: p.last_assistant_message }