Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/provider-acp/src/server/runtimeModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,38 @@ describe("AcpRuntimeModel", () => {
}
});

it("ends a tool call that ACP reports as cancelled", () => {
const toolCall = (status: EffectAcpSchema.ToolCallStatus) => {
const parsed = parseSessionUpdateEvent({
sessionId: "session-1",
update: {
sessionUpdate: status === "in_progress" ? "tool_call" : "tool_call_update",
toolCallId: "tool-1",
title: "Run `sleep 60`",
kind: "execute",
status,
},
} as EffectAcpSchema.SessionNotification);
const event = parsed.events[0];
if (event?._tag !== "ToolCallUpdated") {
throw new Error("expected a tool call update");
}
return event.toolCall;
};

const running = toolCall("in_progress");
const cancelled = mergeToolCallState(running, toolCall("cancelled"));
expect(cancelled.status).toBe("failed");
expect(
decideToolCallUpdateEmission({
previous: running,
next: cancelled,
lastEmittedDetailLength: 0,
skippedSinceEmit: 0,
}).emit,
).toBe(true);
});

it("clears prior ACP locations when an update explicitly replaces them", () => {
const toolCall = (locations?: EffectAcpSchema.ToolCallLocation[] | null) => {
const parsed = parseSessionUpdateEvent({
Expand Down
1 change: 1 addition & 0 deletions packages/provider-acp/src/server/runtimeModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ function normalizeToolCallStatus(
case "completed":
return "completed";
case "failed":
case "cancelled":
return "failed";
default:
return fallback;
Expand Down
Loading