Skip to content

Commit 553a9cb

Browse files
fix(acp): explicitly cleared permission fields are not refilled from the tracked call
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 27ae771 commit 553a9cb

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@ describe("AcpRuntimeModel", () => {
450450
expect(parsePermissionRequest(request)).toMatchObject({ kind: "read", detail: "git status" });
451451
});
452452

453+
it("keeps explicitly cleared permission request fields over the tracked tool call", () => {
454+
const request = withTrackedPermissionToolCall(
455+
{
456+
sessionId: "session-1",
457+
options: [{ optionId: "allow-once", name: "Allow once", kind: "allow_once" }],
458+
toolCall: { toolCallId: "tool-1", kind: null, title: null, rawInput: null },
459+
},
460+
{
461+
toolCallId: "tool-1",
462+
kind: "execute",
463+
data: { toolCallId: "tool-1", title: "git status", rawInput: { command: "git status" } },
464+
},
465+
);
466+
467+
expect(parsePermissionRequest(request).kind).toBe("unknown");
468+
});
469+
453470
it("bounds an oversized cumulative tool_call_update content buffer to a tail window", () => {
454471
const hugeText = Array.from({ length: 2_000 }, (_, i) => `line ${i}: ${"x".repeat(50)}`).join(
455472
"\n",

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,25 +1179,25 @@ export function embeddedTerminalIdsFromSessionUpdate(
11791179
return terminalIds.length === 0 ? undefined : { toolCallId: update.toolCallId, terminalIds };
11801180
}
11811181

1182-
/** ACP lets a permission request name its tool call by ID only; omitted fields come from the tracked call. */
1182+
/** ACP lets a permission request name its tool call by ID only; omitted (not null) fields come from the tracked call. */
11831183
export function withTrackedPermissionToolCall(
11841184
params: EffectAcpSchema.RequestPermissionRequest,
11851185
tracked: AcpToolCallState | undefined,
11861186
): EffectAcpSchema.RequestPermissionRequest {
11871187
if (tracked === undefined) return params;
1188-
const title =
1189-
params.toolCall.title ??
1190-
(typeof tracked.data.title === "string" ? tracked.data.title : undefined);
1191-
// Unrecognised kinds map to command approvals, so only a tracked execute kind may grant execution.
1192-
const kind = params.toolCall.kind ?? (tracked.kind === "execute" ? "execute" : undefined);
1193-
const rawInput = params.toolCall.rawInput ?? tracked.data.rawInput;
1188+
const { title, kind, rawInput } = params.toolCall;
11941189
return {
11951190
...params,
11961191
toolCall: {
11971192
...params.toolCall,
1198-
...(title === undefined ? {} : { title }),
1199-
...(kind === undefined ? {} : { kind }),
1200-
...(rawInput === undefined ? {} : { rawInput }),
1193+
...(title === undefined && typeof tracked.data.title === "string"
1194+
? { title: tracked.data.title }
1195+
: {}),
1196+
// Unrecognised kinds map to command approvals, so only a tracked execute kind may grant execution.
1197+
...(kind === undefined && tracked.kind === "execute" ? { kind: "execute" as const } : {}),
1198+
...(rawInput === undefined && tracked.data.rawInput !== undefined
1199+
? { rawInput: tracked.data.rawInput }
1200+
: {}),
12011201
},
12021202
};
12031203
}

0 commit comments

Comments
 (0)