From eb1c80f26dae4d7024046805fdaec87ecc73045f Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 2 Oct 2026 22:50:24 -0500 Subject: [PATCH 1/2] fix(client-runtime): format subagent descriptions as display names --- .../src/state/threadExecution.test.ts | 31 +++++++++++++++++++ .../src/state/threadExecution.ts | 5 ++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index 70ed818cadc3..02973b657b36 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -478,6 +478,37 @@ describe("threadRuntimeCanArchive", () => { }); describe("presentPendingBackgroundWork", () => { + it.each([ + "/root/luna_window_properties", + "Subagent: /root/luna_window_properties", + "/root/parent/luna_window_properties", + ])("uses the subagent display name for %s", (description) => { + const childThreadId = ThreadId.make("thread:luna"); + const presentation = presentPendingBackgroundWork([ + { taskId: "luna", kind: "subagent", description, childThreadId }, + ]); + + expect(presentation).toEqual({ + title: "Waiting on subagent Luna Window Properties", + items: [{ taskId: "luna", kind: "subagent", label: "Luna Window Properties", childThreadId }], + }); + }); + + it("formats subagent names in a mixed roster and preserves command descriptions", () => { + const presentation = presentPendingBackgroundWork([ + { taskId: "cmd", kind: "command", description: "/root/run_tests" }, + { taskId: "luna", kind: "subagent", description: "/root/luna_window_properties" }, + { taskId: "review", kind: "subagent", description: "Review src/math.ts" }, + ]); + + expect(presentation?.title).toBe("Waiting on 2 subagents and 1 command"); + expect(presentation?.items.map((item) => item.label)).toEqual([ + "Luna Window Properties", + "Review src/math.ts", + "/root/run_tests", + ]); + }); + it("names a single piece of work by kind", () => { expect( presentPendingBackgroundWork([ diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 0893fadb62c2..62a7c54e657c 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -25,6 +25,7 @@ import { type ThreadRunSummary, type ThreadRuntimeSummary, } from "./models.ts"; +import { formatSubagentDisplayTitle } from "./subagentDisplay.ts"; const ACTIVITY_RUN_STATUSES = new Set(["preparing", "starting", "running", "waiting"]); const INTERRUPTIBLE_RUN_STATUSES = new Set(["preparing", "starting", "running"]); @@ -301,7 +302,9 @@ export function presentPendingBackgroundWork( label: description === undefined || description.length === 0 ? BACKGROUND_WORK_KINDS[task.kind].singular - : description, + : task.kind === "subagent" + ? formatSubagentDisplayTitle(description) + : description, childThreadId: task.kind === "subagent" ? task.childThreadId : undefined, }; }) From 77b1bc57c5bb2e886b5ea864940b0e512d823503 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 2 Oct 2026 23:00:06 -0500 Subject: [PATCH 2/2] fix(client-runtime): keep unnamed subagent waiting labels --- .../client-runtime/src/state/threadExecution.test.ts | 12 ++++++++++++ packages/client-runtime/src/state/threadExecution.ts | 10 ++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index 02973b657b36..7ebd468400f8 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -478,6 +478,18 @@ describe("threadRuntimeCanArchive", () => { }); describe("presentPendingBackgroundWork", () => { + it.each(["Subagent:", "Subagent: "])( + "falls back to the subagent noun when %s has no display name", + (description) => { + const presentation = presentPendingBackgroundWork([ + { taskId: "unnamed", kind: "subagent", description }, + ]); + + expect(presentation?.title).toBe("Waiting on a subagent"); + expect(presentation?.items[0]?.label).toBe("subagent"); + }, + ); + it.each([ "/root/luna_window_properties", "Subagent: /root/luna_window_properties", diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 62a7c54e657c..5101acc062ef 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -296,15 +296,17 @@ export function presentPendingBackgroundWork( const items = tasks .map((task): PendingBackgroundWorkItem => { const description = task.description?.trim(); + const label = + task.kind === "subagent" && description !== undefined + ? formatSubagentDisplayTitle(description).trim() + : description; return { taskId: task.taskId, kind: task.kind, label: - description === undefined || description.length === 0 + label === undefined || label.length === 0 ? BACKGROUND_WORK_KINDS[task.kind].singular - : task.kind === "subagent" - ? formatSubagentDisplayTitle(description) - : description, + : label, childThreadId: task.kind === "subagent" ? task.childThreadId : undefined, }; })