Skip to content

Commit a202c35

Browse files
committed
fix(claude): command approvals show the command, not Claude's description of it
1 parent 8ff9ae1 commit a202c35

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,11 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {
893893
assert.isFunction(canUseTool);
894894

895895
const requestEvent = yield* runtime.events.pipe(
896-
Stream.filter((event) => event.type === "runtime_request.updated"),
897-
Stream.runHead,
896+
Stream.takeUntil(
897+
(event) =>
898+
event.type === "turn_item.updated" && event.turnItem.type === "approval_request",
899+
),
900+
Stream.runCollect,
898901
Effect.forkScoped,
899902
);
900903
const command = { command: "node -e 'console.log(42)'" };
@@ -903,6 +906,7 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {
903906
signal: new AbortController().signal,
904907
toolUseID: "tool-bash-accept-edits",
905908
requestId: "request-bash-accept-edits",
909+
description: "Check the Node runtime",
906910
}),
907911
).pipe(Effect.forkScoped);
908912
const first = yield* Effect.raceFirst(
@@ -915,12 +919,16 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {
915919
);
916920
assert.equal(first.type, "request", "the command ran without asking");
917921
if (first.type !== "request") return;
918-
const event = first.event;
919-
if (Option.isNone(event) || event.value.type !== "runtime_request.updated") return;
920-
assert.equal(event.value.runtimeRequest.kind, "command");
922+
const event = first.event.find((event) => event.type === "runtime_request.updated");
923+
assert.equal(event?.runtimeRequest.kind, "command");
924+
const approval = first.event.findLast((event) => event.type === "turn_item.updated");
925+
assert.equal(
926+
approval?.turnItem.type === "approval_request" ? approval.turnItem.prompt : undefined,
927+
command.command,
928+
);
921929

922930
yield* runtime.respondToRuntimeRequest({
923-
requestId: event.value.runtimeRequest.id,
931+
requestId: event!.runtimeRequest.id,
924932
decision: "accept",
925933
});
926934
assert.equal((yield* Fiber.join(decision))?.behavior, "allow");

‎apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9551,7 +9551,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
95519551
}
95529552

95539553
const requestKind = providerRequestKindFromClaudeTool(toolName);
9554+
// The user approves the command itself; Claude's title and description only summarize it.
9555+
const command = inputRecordValue(nativeToolInput, "command");
95549556
const prompt =
9557+
(typeof command === "string" && command.trim() !== "" ? command : undefined) ??
95559558
callbackOptions.title ??
95569559
callbackOptions.description ??
95579560
callbackOptions.decisionReason ??

0 commit comments

Comments
 (0)