@@ -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");
0 commit comments