From 7eae504d158b5cdbc519684d6c5ce64f1fbdb079 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Wed, 22 Apr 2026 11:54:19 -0500 Subject: [PATCH] fix(tui): address Copilot round-2 on #14045 - delegate_task: use shared tool_error() for the paused-spawn early return so the error envelope matches the rest of the tool. - Disk snapshot label: treat orphaned nodes (parentId missing from the snapshot) as top-level, matching buildSubagentTree / summarizeLabel. --- tools/delegate_tool.py | 10 +++------- ui-tui/src/app/createGatewayEventHandler.ts | 7 ++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py index f6dccb8c..f2508561 100644 --- a/tools/delegate_tool.py +++ b/tools/delegate_tool.py @@ -1489,13 +1489,9 @@ def delegate_task( # when a runaway tree is detected, without interrupting already-running # children. Cleared via the matching `delegation.pause` RPC. if is_spawn_paused(): - return json.dumps( - { - "error": ( - "Delegation spawning is paused. Clear the pause via the TUI " - "(`p` in /agents) or the `delegation.pause` RPC before retrying." - ) - } + return tool_error( + "Delegation spawning is paused. Clear the pause via the TUI " + "(`p` in /agents) or the `delegation.pause` RPC before retrying." ) # Normalise the top-level role once; per-task overrides re-normalise. diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts index b3ef0d65..395c2d3a 100644 --- a/ui-tui/src/app/createGatewayEventHandler.ts +++ b/ui-tui/src/app/createGatewayEventHandler.ts @@ -66,7 +66,12 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev: return min === 0 ? s.startedAt : Math.min(min, s.startedAt) }, 0) - const top = subagents.filter(s => !s.parentId).slice(0, 2) + // Match buildSubagentTree semantics: an agent is top-level if it has + // no parent OR its parent isn't in the snapshot (orphan). Otherwise + // the disk label would fall back to `${N} subagents` for any turn + // whose roots got pruned mid-flight. + const ids = new Set(subagents.map(s => s.id)) + const top = subagents.filter(s => !s.parentId || !ids.has(s.parentId)).slice(0, 2) const label = top.length ? top