Compare commits

...
2 changed files with 36 additions and 3 deletions
+27 -3
View File
@@ -4,13 +4,13 @@ import { buildAgentLsFetchOptions, listAgents } from "./ls.js";
const daemonTarget = { kind: "endpoint" as const, host: "example.test:12345" };
function createPagingClient() {
function createPagingClient(archivedAgentNumber?: number) {
const daemonAgents: AgentSnapshotPayload[] = [3, 2, 1].map((n) => ({
id: `${n}${n}${n}${n}${n}${n}${n}${n}-0000-4000-8000-000000000000`,
provider: "codex",
title: `agent ${n}`,
status: "closed",
archivedAt: null,
status: n === archivedAgentNumber ? "idle" : "closed",
archivedAt: n === archivedAgentNumber ? "2026-10-10T00:00:00.000Z" : null,
cwd: "/tmp/project",
createdAt: `2026-10-0${n}T00:00:00.000Z`,
updatedAt: `2026-10-0${n}T00:00:00.000Z`,
@@ -130,4 +130,28 @@ describe("runLsCommand", () => {
expect(result.data.map((item) => item.name)).toEqual(["agent 3", "agent 2", "agent 1"]);
});
it("marks archived agents in table and JSON list data", async () => {
const result = await listAgents({ daemonTarget, all: true, global: true }, async () =>
createPagingClient(2),
);
expect(
result.data.map(({ name, archived, archivedAt }) => ({ name, archived, archivedAt })),
).toEqual([
{ name: "agent 2", archived: true, archivedAt: "2026-10-10T00:00:00.000Z" },
{ name: "agent 3", archived: false, archivedAt: null },
{ name: "agent 1", archived: false, archivedAt: null },
]);
const archivedColumn = result.schema.columns.find((column) => column.header === "ARCHIVED");
expect(archivedColumn).toBeDefined();
expect(typeof archivedColumn?.field).toBe("function");
if (!archivedColumn || typeof archivedColumn.field !== "function") {
throw new Error("Expected the ARCHIVED column to have a display accessor");
}
expect(result.data[0]!.status).toBe("idle");
expect(archivedColumn.field(result.data[0]!)).toBe("yes");
expect(archivedColumn.field(result.data[1]!)).toBe("-");
});
});
+9
View File
@@ -33,6 +33,8 @@ export interface AgentListItem {
provider: string;
thinking: string;
status: string;
archived: boolean;
archivedAt: string | null;
cwd: string;
created: string;
}
@@ -84,6 +86,11 @@ export const agentLsSchema: OutputSchema<AgentListItem> = {
return undefined;
},
},
{
header: "ARCHIVED",
field: (item) => (item.archived ? "yes" : "-"),
width: 8,
},
{ header: "CWD", field: "cwd", width: 30 },
{ header: "CREATED", field: "created", width: 15 },
],
@@ -99,6 +106,8 @@ function toListItem(agent: AgentSnapshotPayload): AgentListItem {
provider: model ? `${agent.provider}/${model}` : agent.provider,
thinking: agent.effectiveThinkingOptionId ?? "auto",
status: agent.status,
archived: agent.archivedAt != null,
archivedAt: agent.archivedAt ?? null,
cwd: shortenPath(agent.cwd),
created: relativeTime(agent.createdAt),
};