fix(workboard): scope default positions by board (#104410)

This commit is contained in:
qingminlong
2026-07-11 10:16:18 -07:00
committed by GitHub
parent e5578f6652
commit f348b291bc
2 changed files with 23 additions and 7 deletions
+14 -1
View File
@@ -1976,6 +1976,8 @@ describe("WorkboardStore", () => {
expect(repeatedOps.id).toBe(ops.id);
expect(product.id).not.toBe(ops.id);
expect(ops.position).toBe(1000);
expect(product.position).toBe(1000);
await expect(store.list({ boardId: "ops" })).resolves.toHaveLength(1);
await expect(store.listBoards()).resolves.toMatchObject({
boards: expect.arrayContaining([
@@ -1989,13 +1991,24 @@ describe("WorkboardStore", () => {
byStatus: { todo: 1 },
});
const prototypeAgentId = ["__", "proto__"].join("");
await store.create({
const secondProduct = await store.create({
title: "Prototype safe",
boardId: "product",
agentId: prototypeAgentId,
});
expect(secondProduct.position).toBe(2000);
const stats = await store.stats({ boardId: "product" });
expect(stats.byAgent[prototypeAgentId]).toBe(1);
const metadataBoardFirst = await store.create({
title: "Metadata board first",
metadata: { automation: { boardId: "metadata-board" } },
});
const metadataBoardSecond = await store.create({
title: "Metadata board second",
metadata: { automation: { boardId: "metadata-board" } },
});
expect(metadataBoardFirst.position).toBe(1000);
expect(metadataBoardSecond.position).toBe(2000);
});
it("rejects completed manifests for cards not created from the parent", async () => {
+9 -6
View File
@@ -2561,12 +2561,6 @@ export class WorkboardStore {
automation,
);
const normalizedPosition = normalizePosition(input.position, Number.NaN);
const position = Number.isFinite(normalizedPosition)
? normalizedPosition
: Math.max(
0,
...cards.filter((card) => card.status === status).map((card) => card.position),
) + POSITION_STEP;
const notes = normalizeNotes(input.notes);
const agentId = normalizeOptionalString(input.agentId);
const sessionKey = normalizeOptionalString(input.sessionKey);
@@ -2601,6 +2595,15 @@ export class WorkboardStore {
const syncedMetadata = trimMetadataToBudget(
syncExecutionAttemptMetadata(metadata, execution, now),
);
const boardId = syncedMetadata.automation?.boardId ?? "default";
const position = Number.isFinite(normalizedPosition)
? normalizedPosition
: Math.max(
0,
...cards
.filter((card) => card.status === status && cardBoardId(card) === boardId)
.map((card) => card.position),
) + POSITION_STEP;
let card: WorkboardCard = {
id: randomUUID(),
title: normalizeTitle(input.title),