authorgravatar for saiansh2525@gmail.comYash Singh <saiansh2525@gmail.com> 2026-10-02 23:11:24-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-02 23:11:24-05:00
log151c241cd2cc22c3b10ba8735e44f83fb723a511
tree939754ef198ae83e6f5899fdf325acf7ab832a72
parent4f7760e6a0037b06917adaae1b8a220e3ee6e5cc
signature Signed by PGP key B5690EEEBB952194

fix(client-runtime): format subagent descriptions as display names (#14999)


2 files changed, 50 insertions(+), 2 deletions(-)

packages/client-runtime/src/state/threadExecution.test.ts+43
...@@ -478,6 +478,49 @@ describe("threadRuntimeCanArchive", () => {...@@ -478,6 +478,49 @@ describe("threadRuntimeCanArchive", () => {
478});478});
479479
480describe("presentPendingBackgroundWork", () => {480describe("presentPendingBackgroundWork", () => {
481 it.each(["Subagent:", "Subagent: "])(
482 "falls back to the subagent noun when %s has no display name",
483 (description) => {
484 const presentation = presentPendingBackgroundWork([
485 { taskId: "unnamed", kind: "subagent", description },
486 ]);
487
488 expect(presentation?.title).toBe("Waiting on a subagent");
489 expect(presentation?.items[0]?.label).toBe("subagent");
490 },
491 );
492
493 it.each([
494 "/root/luna_window_properties",
495 "Subagent: /root/luna_window_properties",
496 "/root/parent/luna_window_properties",
497 ])("uses the subagent display name for %s", (description) => {
498 const childThreadId = ThreadId.make("thread:luna");
499 const presentation = presentPendingBackgroundWork([
500 { taskId: "luna", kind: "subagent", description, childThreadId },
501 ]);
502
503 expect(presentation).toEqual({
504 title: "Waiting on subagent Luna Window Properties",
505 items: [{ taskId: "luna", kind: "subagent", label: "Luna Window Properties", childThreadId }],
506 });
507 });
508
509 it("formats subagent names in a mixed roster and preserves command descriptions", () => {
510 const presentation = presentPendingBackgroundWork([
511 { taskId: "cmd", kind: "command", description: "/root/run_tests" },
512 { taskId: "luna", kind: "subagent", description: "/root/luna_window_properties" },
513 { taskId: "review", kind: "subagent", description: "Review src/math.ts" },
514 ]);
515
516 expect(presentation?.title).toBe("Waiting on 2 subagents and 1 command");
517 expect(presentation?.items.map((item) => item.label)).toEqual([
518 "Luna Window Properties",
519 "Review src/math.ts",
520 "/root/run_tests",
521 ]);
522 });
523
481 it("names a single piece of work by kind", () => {524 it("names a single piece of work by kind", () => {
482 expect(525 expect(
483 presentPendingBackgroundWork([526 presentPendingBackgroundWork([
packages/client-runtime/src/state/threadExecution.ts+7-2
...@@ -25,6 +25,7 @@ import {...@@ -25,6 +25,7 @@ import {
25 type ThreadRunSummary,25 type ThreadRunSummary,
26 type ThreadRuntimeSummary,26 type ThreadRuntimeSummary,
27} from "./models.ts";27} from "./models.ts";
28import { formatSubagentDisplayTitle } from "./subagentDisplay.ts";
2829
29const ACTIVITY_RUN_STATUSES = new Set(["preparing", "starting", "running", "waiting"]);30const ACTIVITY_RUN_STATUSES = new Set(["preparing", "starting", "running", "waiting"]);
30const INTERRUPTIBLE_RUN_STATUSES = new Set(["preparing", "starting", "running"]);31const INTERRUPTIBLE_RUN_STATUSES = new Set(["preparing", "starting", "running"]);
...@@ -295,13 +296,17 @@ export function presentPendingBackgroundWork(...@@ -295,13 +296,17 @@ export function presentPendingBackgroundWork(
295 const items = tasks296 const items = tasks
296 .map((task): PendingBackgroundWorkItem => {297 .map((task): PendingBackgroundWorkItem => {
297 const description = task.description?.trim();298 const description = task.description?.trim();
299 const label =
300 task.kind === "subagent" && description !== undefined
301 ? formatSubagentDisplayTitle(description).trim()
302 : description;
298 return {303 return {
299 taskId: task.taskId,304 taskId: task.taskId,
300 kind: task.kind,305 kind: task.kind,
301 label:306 label:
302 description === undefined || description.length === 0307 label === undefined || label.length === 0
303 ? BACKGROUND_WORK_KINDS[task.kind].singular308 ? BACKGROUND_WORK_KINDS[task.kind].singular
304 : description,309 : label,
305 childThreadId: task.kind === "subagent" ? task.childThreadId : undefined,310 childThreadId: task.kind === "subagent" ? task.childThreadId : undefined,
306 };311 };
307 })312 })