diff --git a/packages/cli/src/commands/agent/ls.test.ts b/packages/cli/src/commands/agent/ls.test.ts index 82d6c09a6..f2a09d290 100644 --- a/packages/cli/src/commands/agent/ls.test.ts +++ b/packages/cli/src/commands/agent/ls.test.ts @@ -15,7 +15,8 @@ function createPagingClient() { cwd: "/tmp/project", createdAt: `2026-10-0${n}T00:00:00.000Z`, updatedAt: `2026-10-0${n}T00:00:00.000Z`, - labels: {}, + labels: n === 3 ? { bot: "worker", issue: "42" } : {}, + workspaceId: n === 3 ? "workspace-3" : undefined, model: null, lastUserMessageAt: null, currentModeId: null, @@ -124,6 +125,19 @@ describe("buildAgentLsFetchOptions", () => { }); describe("runLsCommand", () => { + it("includes labels and workspace IDs in JSON listings", async () => { + const result = await listAgents({ daemonTarget, global: true }, async () => + createPagingClient(), + ); + const rows = JSON.parse(render(result, { format: "json" })); + + expect(rows).toMatchObject([ + { name: "agent 3", labels: { bot: "worker", issue: "42" }, workspaceId: "workspace-3" }, + { name: "agent 2", labels: {}, workspaceId: null }, + { name: "agent 1", labels: {}, workspaceId: null }, + ]); + }); + it("lists agents on every page, including one updated during the listing", async () => { const result = await listAgents({ daemonTarget, all: true, global: true }, async () => createPagingClient(), diff --git a/packages/cli/src/commands/agent/ls.ts b/packages/cli/src/commands/agent/ls.ts index d60ad0ce9..2e6bf6833 100644 --- a/packages/cli/src/commands/agent/ls.ts +++ b/packages/cli/src/commands/agent/ls.ts @@ -36,6 +36,8 @@ export interface AgentListItem { cwd: string; created: string; background: boolean; + labels: Record; + workspaceId: string | null; } /** Helper to get relative time string */ @@ -112,6 +114,8 @@ function toListItem(agent: AgentSnapshotPayload): AgentListItem { cwd: shortenPath(agent.cwd), created: relativeTime(agent.createdAt), background: agent.background === true, + labels: agent.labels, + workspaceId: agent.workspaceId ?? null, }; }