Skip to content

Commit b222883

Browse files
committed
fix(acp): forward empty plan replacements
1 parent 3b95e78 commit b222883

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,35 @@ describe("AcpRuntimeModel", () => {
328328
).toBe(true);
329329
});
330330

331+
it("forwards an empty ACP v1 plan to clear previous entries", () => {
332+
const entries = [
333+
[{ content: "Inspect state", priority: "high", status: "pending" }],
334+
[],
335+
] as const;
336+
const updates = entries.flatMap(
337+
(plan) =>
338+
parseSessionUpdateEvent({
339+
sessionId: "session-1",
340+
update: { sessionUpdate: "plan", entries: plan },
341+
}).events,
342+
);
343+
344+
expect(updates).toMatchObject([
345+
{
346+
_tag: "PlanUpdated",
347+
payload: {
348+
nativePlanId: "legacy",
349+
kind: "items",
350+
plan: [{ step: "Inspect state", status: "pending" }],
351+
},
352+
},
353+
{
354+
_tag: "PlanUpdated",
355+
payload: { nativePlanId: "legacy", kind: "items", plan: [] },
356+
},
357+
]);
358+
});
359+
331360
it("projects typed ACP plan and content updates", () => {
332361
const planResult = parseSessionUpdateEvent({
333362
sessionId: "session-1",

‎packages/provider-acp/src/server/runtimeModel.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,17 +1401,15 @@ export function parseSessionUpdateEvent(params: EffectAcpSchema.SessionNotificat
14011401
step: entry.content.trim().length > 0 ? entry.content.trim() : `Step ${index + 1}`,
14021402
status: normalizePlanStepStatus(entry.status),
14031403
}));
1404-
if (plan.length > 0) {
1405-
events.push({
1406-
_tag: "PlanUpdated",
1407-
payload: {
1408-
nativePlanId: "legacy",
1409-
kind: "items",
1410-
plan,
1411-
},
1412-
rawPayload: params,
1413-
});
1414-
}
1404+
events.push({
1405+
_tag: "PlanUpdated",
1406+
payload: {
1407+
nativePlanId: "legacy",
1408+
kind: "items",
1409+
plan,
1410+
},
1411+
rawPayload: params,
1412+
});
14151413
break;
14161414
}
14171415
case "plan_update": {

0 commit comments

Comments
 (0)