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(claude): detect loop/schedule/cron from tools, not just the /prompt prefix

enesc2c1c187dd52
diff --git a/src/main/claude-hooks.ts b/src/main/claude-hooks.ts
index e9f1f75fe..031a78d2e 100644
--- a/src/main/claude-hooks.ts
+++ b/src/main/claude-hooks.ts
@@ -25,8 +25,10 @@ const CLAUDE_EVENTS = [
'PostToolUse'
]
-// Tool names that represent a spawned subagent (the only PreToolUse/PostToolUse we forward).
+// Tool names that represent a spawned subagent.
const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])
+// Tools that set up a recurring task (drive the loop/schedule/cron node).
+const RECURRING_TOOLS = new Set(['Skill', 'CronCreate', 'ScheduleWakeup'])
// The single managed hook command, registered under each event above. Must stay byte-stable
// so install is idempotent and uninstall can find it. Reads the hook payload from stdin and
@@ -143,7 +145,13 @@ export function initClaudeHooks(win: BrowserWindow): void {
prompt?: string
tool_name?: string
tool_use_id?: string
- tool_input?: { subagent_type?: string; description?: string; prompt?: string }
+ tool_input?: {
+ subagent_type?: string
+ description?: string
+ prompt?: string
+ skill?: string
+ cron?: string
+ }
tool_response?: {
status?: string
content?: { type?: string; text?: string }[]
@@ -153,11 +161,12 @@ export function initClaudeHooks(win: BrowserWindow): void {
}
}
if (!p.hook_event_name || win.isDestroyed()) continue
- // Tool events flood (every Bash/Edit) — only forward subagent spawns.
+ // Tool events flood (every Bash/Edit) — only forward subagent + recurring tools.
+ const name = p.tool_name ?? ''
const isTool = p.hook_event_name === 'PreToolUse' || p.hook_event_name === 'PostToolUse'
- if (isTool && !SUBAGENT_TOOLS.has(p.tool_name ?? '')) continue
- // Tail the subagent's live transcript while it runs.
- if (p.tool_use_id) {
+ if (isTool && !SUBAGENT_TOOLS.has(name) && !RECURRING_TOOLS.has(name)) continue
+ // Tail the subagent's live transcript while it runs (subagent tools only).
+ if (SUBAGENT_TOOLS.has(name) && p.tool_use_id) {
if (p.hook_event_name === 'PreToolUse') subagentTail.track(p.tool_use_id, p.transcript_path)
else if (p.hook_event_name === 'PostToolUse') subagentTail.finish(p.tool_use_id)
}
@@ -177,6 +186,8 @@ export function initClaudeHooks(win: BrowserWindow): void {
toolUseId: p.tool_use_id,
subagentType: p.tool_input?.subagent_type,
taskLabel: p.tool_input?.description || p.tool_input?.prompt,
+ skill: p.tool_input?.skill,
+ schedule: p.tool_input?.cron,
status: tr?.status,
durationMs: tr?.totalDurationMs,
tokens: tr?.totalTokens,
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 97bcee14e..c4fd0a579 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -969,15 +969,31 @@ export function Canvas() {
alert('needs input', 'Claude is waiting for your response.')
}
break
- case 'PreToolUse':
- if (e.toolUseId) {
- an.start(e.toolUseId, {
- parentNodeId: e.nodeId,
- type: e.subagentType,
- label: e.taskLabel
- })
+ case 'PreToolUse': {
+ const tool = e.toolName
+ if (tool === 'Agent' || tool === 'Task') {
+ if (e.toolUseId) {
+ an.start(e.toolUseId, {
+ parentNodeId: e.nodeId,
+ type: e.subagentType,
+ label: e.taskLabel
+ })
+ }
+ } else {
+ // Recurring-task tools → loop/schedule/cron node.
+ let kind: 'loop' | 'schedule' | 'cron' | undefined
+ if (tool === 'Skill') {
+ const sk = (e.skill ?? '').split(':').pop()
+ if (sk === 'loop' || sk === 'schedule' || sk === 'cron') kind = sk
+ } else if (tool === 'CronCreate') kind = 'cron'
+ else if (tool === 'ScheduleWakeup') kind = 'loop'
+ if (kind) {
+ const label = [e.schedule, e.taskLabel].filter(Boolean).join(' · ')
+ cs.setLoop(e.nodeId, true, kind, label || undefined)
+ }
}
break
+ }
case 'PostToolUse':
if (e.toolUseId)
an.finish(e.toolUseId, {
diff --git a/src/renderer/nodes/LoopNode.tsx b/src/renderer/nodes/LoopNode.tsx
index c6705f77d..759dd6f34 100644
--- a/src/renderer/nodes/LoopNode.tsx
+++ b/src/renderer/nodes/LoopNode.tsx
@@ -30,7 +30,7 @@ export function LoopNode({ data }: NodeProps<CanvasNode>) {
>
<span className="loop-node__dot" />
<span className="loop-node__type">{label}</span>
- <span className="loop-node__count">×{count}</span>
+ {count > 0 && <span className="loop-node__count">×{count}</span>}
</div>
{data.title && !expanded && <div className="loop-node__task">{data.title as string}</div>}
{expanded && (
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index bbd91ba79..853d75ddb 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -293,7 +293,8 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
title={`Running /${status.loop.kind}`}
>
<span className="term-node__status-dot" />
- {status.loop.kind.toUpperCase()} ×{status.loop.count}
+ {status.loop.kind.toUpperCase()}
+ {status.loop.count > 0 ? ` ×${status.loop.count}` : ''}
</span>
)}
{(status?.state === 'waiting' || status?.state === 'blocked') && (
diff --git a/src/renderer/state/claudeStatus.ts b/src/renderer/state/claudeStatus.ts
index 23d677d5d..e3e28d448 100644
--- a/src/renderer/state/claudeStatus.ts
+++ b/src/renderer/state/claudeStatus.ts
@@ -136,7 +136,8 @@ export const useClaudeStatus = create<ClaudeStatusState>((set) => ({
bumpLoop: (id, message) =>
set((s) => {
const prev = s.byId[id]
- if (!prev?.loop) return s
+ // Only count in-session /loop turns; /schedule and /cron run in the background.
+ if (!prev?.loop || prev.loop.kind !== 'loop') return s
const items = message
? [...prev.loop.items, message.replace(/\s+/g, ' ').trim().slice(0, 200)].slice(-50)
: prev.loop.items
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 41191659d..4e142119e 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -323,6 +323,9 @@ export interface ClaudeStatusEvent {
toolUseId?: string
subagentType?: string
taskLabel?: string
+ /** Recurring-task tools: skill name (Skill) and cron expression (CronCreate). */
+ skill?: string
+ schedule?: string
/** Subagent result metadata (PostToolUse tool_response). */
status?: string
durationMs?: number