Skip to content

Commit bb396e1

Browse files
committed
fix(workboard): count claimed review cards as active
1 parent 39eeaf8 commit bb396e1

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,33 @@ describe("dispatchAndStartWorkboardCards", () => {
111111
expect(run).toHaveBeenCalledOnce();
112112
});
113113

114+
it("keeps claimed review cards in the owner running slot", async () => {
115+
const store = new WorkboardStore(createMemoryStore());
116+
const review = await store.create({
117+
title: "Claimed operator review",
118+
status: "review",
119+
priority: "normal",
120+
agentId: "codex-main",
121+
});
122+
await store.claim(review.id, { ownerId: "codex-main", token: "review-token" });
123+
await store.create({
124+
title: "Next ready card",
125+
status: "ready",
126+
priority: "high",
127+
agentId: "codex-main",
128+
});
129+
const run = vi.fn().mockResolvedValue({ runId: "run-next" });
130+
131+
const result = await dispatchAndStartWorkboardCards({
132+
store,
133+
subagent: { run },
134+
options: { now: 10, maxStarts: 3 },
135+
});
136+
137+
expect(result.started).toEqual([]);
138+
expect(run).not.toHaveBeenCalled();
139+
});
140+
114141
it("blocks a card when worker start fails after claim", async () => {
115142
const store = new WorkboardStore(createMemoryStore());
116143
const card = await store.create({ title: "Fail worker", status: "ready" });

‎extensions/workboard/src/dispatcher.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
22
import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime";
33
import { WorkboardStore, type WorkboardDispatchResult } from "./store.js";
4-
import type { WorkboardCard, WorkboardExecution, WorkboardStatus } from "./types.js";
4+
import type { WorkboardCard, WorkboardExecution } from "./types.js";
55

66
const DEFAULT_DISPATCH_MAX_STARTS = 3;
77
const DEFAULT_DISPATCH_OWNER = "workboard-dispatcher";
@@ -126,10 +126,13 @@ function selectStartableCards(cards: WorkboardCard[], limit: number): WorkboardC
126126
if (limit <= 0) {
127127
return [];
128128
}
129-
const activeStatuses = new Set<WorkboardStatus>(["running"]);
130129
const runningByOwner = new Map<string, number>();
131130
for (const card of cards) {
132-
if (!activeStatuses.has(card.status) || cardIsArchived(card)) {
131+
const consumesOwnerSlot =
132+
card.status === "running" ||
133+
Boolean(card.metadata?.claim) ||
134+
card.execution?.status === "running";
135+
if (!consumesOwnerSlot || cardIsArchived(card)) {
133136
continue;
134137
}
135138
const owner = card.agentId ?? DEFAULT_DISPATCH_OWNER;

0 commit comments

Comments
 (0)