TypeScript
fix(claude): command approvals show the command, not Claude's description of it (#20145)
maria5eebf77b373b
diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.tsindex ba4b7444b7b..47457be6609 100644--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts@@ -893,8 +893,11 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {assert.isFunction(canUseTool);const requestEvent = yield* runtime.events.pipe(- Stream.filter((event) => event.type === "runtime_request.updated"),- Stream.runHead,+ Stream.takeUntil(+ (event) =>+ event.type === "turn_item.updated" && event.turnItem.type === "approval_request",+ ),+ Stream.runCollect,Effect.forkScoped,);const command = { command: "node -e 'console.log(42)'" };@@ -903,6 +906,7 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {signal: new AbortController().signal,toolUseID: "tool-bash-accept-edits",requestId: "request-bash-accept-edits",+ description: "Check the Node runtime",}),).pipe(Effect.forkScoped);const first = yield* Effect.raceFirst(@@ -915,12 +919,16 @@ describe("ClaudeAdapterV2 Auto-accept edits", () => {);assert.equal(first.type, "request", "the command ran without asking");if (first.type !== "request") return;- const event = first.event;- if (Option.isNone(event) || event.value.type !== "runtime_request.updated") return;- assert.equal(event.value.runtimeRequest.kind, "command");+ const event = first.event.find((event) => event.type === "runtime_request.updated");+ assert.equal(event?.runtimeRequest.kind, "command");+ const approval = first.event.findLast((event) => event.type === "turn_item.updated");+ assert.equal(+ approval?.turnItem.type === "approval_request" ? approval.turnItem.prompt : undefined,+ command.command,+ );yield* runtime.respondToRuntimeRequest({- requestId: event.value.runtimeRequest.id,+ requestId: event!.runtimeRequest.id,decision: "accept",});assert.equal((yield* Fiber.join(decision))?.behavior, "allow");diff --git a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.tsindex 030fb5785e6..dd4fc8f30af 100644--- a/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts+++ b/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts@@ -9551,7 +9551,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (}const requestKind = providerRequestKindFromClaudeTool(toolName);+ // The user approves the command itself; Claude's title and description only summarize it.+ const command = inputRecordValue(nativeToolInput, "command");const prompt =+ (typeof command === "string" && command.trim() !== "" ? command : undefined) ??callbackOptions.title ??callbackOptions.description ??callbackOptions.decisionReason ??