fix(client-runtime): format subagent descriptions as display names (#14999)
This commit is contained in:
1 parent
4f7760e6a0
commit
151c241cd2
2 files changed
+50
-2
No files matched your search
@@ -478,6 +478,49 @@ 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",
|
||||
"/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([
|
||||
|
||||
@@ -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"]);
|
||||
@@ -295,13 +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
|
||||
: description,
|
||||
: label,
|
||||
childThreadId: task.kind === "subagent" ? task.childThreadId : undefined,
|
||||
};
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user