Skip to content

Commit b552c06

Browse files
committed
fix(workboard): expose archived active cards
1 parent 3974276 commit b552c06

8 files changed

Lines changed: 80 additions & 32 deletions

File tree

‎docs/plugins/workboard.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ Diagnostics are computed from local card metadata. Built-in checks flag:
375375
| `repeated_failures` | Card's tracked failure count reaches 2 or more. |
376376
| `missing_proof` | `done` card with no proof, artifacts, or attachments. |
377377
| `orphaned_session` | `running` card with a `sessionKey` but no `execution` metadata. |
378+
| `archived_but_active` | Archived card remains in any non-`done` lifecycle status. |
378379

379380
## Permissions
380381

‎extensions/workboard/src/cli.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ describe("registerWorkboardCli", () => {
140140
expect(defaultOutput).not.toContain("Archived card");
141141
expect(includeOutput).toContain("Active card");
142142
expect(includeOutput).toContain("Archived card");
143+
expect(includeOutput).toContain("(archived)");
144+
});
145+
146+
it("marks archived cards in show output", async () => {
147+
const store = new WorkboardStore(createMemoryStore());
148+
const archived = await store.create({ title: "Archived card", status: "ready" });
149+
await store.archive(archived.id, true);
150+
const program = createProgram(store);
151+
152+
const output = await captureStdout(async () => {
153+
await program.parseAsync(["workboard", "show", archived.id], { from: "user" });
154+
});
155+
156+
expect(output).toContain("Archived card (archived)");
143157
});
144158

145159
it("preserves archived cards in JSON list output by default", async () => {

‎extensions/workboard/src/cli.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ function isWorkboardStatus(value: string): value is WorkboardStatus {
6969
function formatCardLine(card: WorkboardCard): string {
7070
const boardId = card.metadata?.automation?.boardId ?? "default";
7171
const agent = card.agentId ? ` ${card.agentId}` : "";
72-
return `${card.id.slice(0, 8)} ${card.status.padEnd(8)} ${card.priority.padEnd(6)} ${boardId}${agent} ${card.title}`;
72+
const archived = card.metadata?.archivedAt ? " (archived)" : "";
73+
return `${card.id.slice(0, 8)} ${card.status.padEnd(8)} ${card.priority.padEnd(6)} ${boardId}${agent} ${card.title}${archived}`;
7374
}
7475

7576
function redactDispatchResult(result: WorkboardDispatchResult): WorkboardDispatchResult {

‎extensions/workboard/src/command.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ describe("handleWorkboardCommand", () => {
291291
await expect(store.get(card.id)).resolves.toMatchObject({ status: "ready" });
292292
});
293293

294+
it("shows when an archived card is excluded from dispatch", async () => {
295+
const store = new WorkboardStore(createMemoryStore());
296+
const api = createApi();
297+
const card = await store.create({ title: "Archived slash card", status: "ready" });
298+
await store.archive(card.id, true);
299+
300+
await expect(runWorkboardCommand({ api, store, args: `show ${card.id}` })).resolves.toEqual(
301+
expect.objectContaining({
302+
text: expect.stringContaining("archived: yes (excluded from dispatch)"),
303+
}),
304+
);
305+
});
306+
294307
it("moves claimed cards for operators on slash-command surfaces", async () => {
295308
const store = new WorkboardStore(createMemoryStore());
296309
const api = createApi();

‎extensions/workboard/src/command.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ function formatCardDetails(card: WorkboardCard): string {
5858
if (card.runId) {
5959
lines.push(`run: ${card.runId}`);
6060
}
61+
if (card.metadata?.archivedAt) {
62+
lines.push("archived: yes (excluded from dispatch)");
63+
}
6164
if (card.notes) {
6265
lines.push("", card.notes);
6366
}

‎extensions/workboard/src/store-card-helpers.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,8 @@ export function mergeDiagnostics(
395395

396396
export function computeCardDiagnostics(card: WorkboardCard, now: number): WorkboardDiagnostic[] {
397397
if (card.metadata?.archivedAt) {
398-
// An archived card is correctly excluded from automation, but if it is
399-
// still in an active status (not done) it is silently undispatchable with
400-
// no signal on any surface. Surface a diagnostic so `workboard show` and
401-
// `store.diagnostics()` report it instead of leaving the operator to find
402-
// it by reading the database (#116359).
398+
// Archived cards intentionally skip automation. Keep nonterminal cards
399+
// visible as a transient diagnostic without rewriting archived metadata.
403400
if (card.status !== "done") {
404401
return [
405402
diagnostic(
@@ -408,7 +405,7 @@ export function computeCardDiagnostics(card: WorkboardCard, now: number): Workbo
408405
severity: "warning",
409406
title: "Archived card is still in an active status",
410407
detail: `Card status is "${card.status}" but it is archived, so it is excluded from dispatch without any start failure or error. Unarchive it or move it to "done" to stop the silent skip.`,
411-
actions: [{ kind: "unarchive", label: "Unarchive" }],
408+
actions: [],
412409
},
413410
now,
414411
),

‎extensions/workboard/src/store.test.ts‎

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
55
import { DatabaseSync } from "node:sqlite";
6+
import { WORKBOARD_STATUSES } from "@openclaw/workboard-contract";
67
import { MAX_DATE_TIMESTAMP_MS } from "openclaw/plugin-sdk/number-runtime";
78
import { describe, expect, it, vi } from "vitest";
89
import type {
@@ -2618,31 +2619,57 @@ describe("WorkboardStore", () => {
26182619
});
26192620
});
26202621

2621-
it("diagnoses archived cards that are still in an active status", async () => {
2622-
// An archived card with an active status (ready) is silently excluded from
2623-
// dispatch with no signal. computeCardDiagnostics must surface an
2624-
// archived_but_active warning so workboard show / store.diagnostics report
2625-
// it (#116359).
2622+
it.each(WORKBOARD_STATUSES)(
2623+
"reports archived %s cards according to terminal state",
2624+
async (status) => {
2625+
const store = new WorkboardStore(createMemoryStore());
2626+
const card = await store.create({ title: `Archived ${status}`, status });
2627+
2628+
await store.archive(card.id, true);
2629+
2630+
const result = await store.diagnostics(Date.now());
2631+
if (status === "done") {
2632+
expect(result).toEqual({ diagnostics: [], count: 0 });
2633+
return;
2634+
}
2635+
expect(result).toMatchObject({
2636+
diagnostics: [
2637+
expect.objectContaining({
2638+
card: expect.objectContaining({ id: card.id }),
2639+
diagnostics: [
2640+
expect.objectContaining({
2641+
kind: "archived_but_active",
2642+
severity: "warning",
2643+
actions: [],
2644+
}),
2645+
],
2646+
}),
2647+
],
2648+
count: 1,
2649+
});
2650+
},
2651+
);
2652+
2653+
it("keeps archived-card diagnostics transient across lifecycle changes", async () => {
26262654
const store = new WorkboardStore(createMemoryStore());
26272655
const card = await store.create({ title: "Archived but ready", status: "ready" });
26282656
const now = Date.now();
26292657

26302658
await store.archive(card.id, true);
26312659

2660+
await expect(store.refreshDiagnostics(now)).resolves.toEqual({ diagnostics: [], count: 0 });
2661+
await expect(store.get(card.id)).resolves.not.toHaveProperty("metadata.diagnostics");
26322662
await expect(store.diagnostics(now)).resolves.toMatchObject({
2633-
diagnostics: [
2634-
expect.objectContaining({
2635-
card: expect.objectContaining({ id: card.id }),
2636-
diagnostics: [
2637-
expect.objectContaining({
2638-
kind: "archived_but_active",
2639-
severity: "warning",
2640-
}),
2641-
],
2642-
}),
2643-
],
2663+
diagnostics: [expect.objectContaining({ card: expect.objectContaining({ id: card.id }) })],
26442664
count: 1,
26452665
});
2666+
2667+
await store.archive(card.id, false);
2668+
await expect(store.diagnostics(now + 1)).resolves.toEqual({ diagnostics: [], count: 0 });
2669+
2670+
await store.archive(card.id, true);
2671+
await store.move(card.id, "done", undefined);
2672+
await expect(store.diagnostics(now + 2)).resolves.toEqual({ diagnostics: [], count: 0 });
26462673
});
26472674

26482675
it("does not drop concurrent updates while refreshing diagnostics", async () => {

‎packages/workboard-contract/src/index.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,7 @@ export type WorkboardClaim = {
206206
};
207207

208208
export type WorkboardDiagnosticAction = {
209-
kind:
210-
| "claim"
211-
| "unblock"
212-
| "promote"
213-
| "reclaim"
214-
| "reassign"
215-
| "add_proof"
216-
| "open_session"
217-
| "unarchive";
209+
kind: "claim" | "unblock" | "promote" | "reclaim" | "reassign" | "add_proof" | "open_session";
218210
label: string;
219211
};
220212

0 commit comments

Comments
 (0)