Skip to content

Commit 3d9a534

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-33670
2 parents ef98664 + 4c36119 commit 3d9a534

4 files changed

Lines changed: 54 additions & 15 deletions

File tree

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

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { beforeEach, vi } from "vite-plus/test";
99

1010
import type {
1111
ElicitationRequest,
12+
ElicitationResult,
1213
Query as ClaudeQuery,
1314
SDKMessage,
1415
SDKResultMessage,
@@ -5703,6 +5704,7 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57035704
options: [
57045705
{ decision: "cancel", label: "Cancel" },
57055706
{ decision: "decline", label: "Decline" },
5707+
{ decision: "acceptForSession", label: "Always allow this session" },
57065708
{ decision: "accept", label: "Approve" },
57075709
],
57085710
});
@@ -5732,16 +5734,41 @@ describe("ClaudeAdapterV2 background wake turns", () => {
57325734
}).pipe(Effect.scoped, Effect.provide(testLayer)),
57335735
);
57345736

5735-
it.effect.each(["acceptForSession", "acceptAlways"] as const)(
5736-
"declines an unsupported %s decision",
5737-
(decision) =>
5738-
Effect.gen(function* () {
5739-
const { harness, elicit, awaitCard } = yield* startElicitationTurn();
5740-
const answer = yield* elicit(approvalOnly);
5741-
const request = yield* awaitCard(1);
5742-
yield* harness.runtime.respondToRuntimeRequest({ requestId: request.id, decision });
5743-
assert.deepEqual(yield* Fiber.join(answer), { action: "decline" });
5744-
}).pipe(Effect.scoped, Effect.provide(testLayer)),
5737+
it.effect("declines an unsupported acceptAlways decision", () =>
5738+
Effect.gen(function* () {
5739+
const { harness, elicit, awaitCard } = yield* startElicitationTurn();
5740+
const answer = yield* elicit(approvalOnly);
5741+
const request = yield* awaitCard(1);
5742+
yield* harness.runtime.respondToRuntimeRequest({
5743+
requestId: request.id,
5744+
decision: "acceptAlways",
5745+
});
5746+
assert.deepEqual(yield* Fiber.join(answer), { action: "decline" });
5747+
}).pipe(Effect.scoped, Effect.provide(testLayer)),
5748+
);
5749+
5750+
it.effect("answers a repeated prompt from a session grant without a card", () =>
5751+
Effect.gen(function* () {
5752+
const { harness, elicit, awaitCard, runtimeRequests } = yield* startElicitationTurn();
5753+
const first = yield* elicit(approvalOnly);
5754+
const request = yield* awaitCard(1);
5755+
yield* harness.runtime.respondToRuntimeRequest({
5756+
requestId: request.id,
5757+
decision: "acceptForSession",
5758+
});
5759+
const granted = { action: "accept", content: {} } satisfies ElicitationResult;
5760+
assert.deepEqual(yield* Fiber.join(first), granted);
5761+
5762+
assert.deepEqual(yield* Fiber.join(yield* elicit(approvalOnly)), granted);
5763+
assert.equal(runtimeRequests().length, 1);
5764+
5765+
const otherMessage = yield* elicit({ ...approvalOnly, message: "Deploy api?" });
5766+
yield* awaitCard(2);
5767+
const otherServer = yield* elicit({ ...approvalOnly, serverName: "builds" });
5768+
yield* awaitCard(3);
5769+
assert.isUndefined(otherMessage.pollUnsafe());
5770+
assert.isUndefined(otherServer.pollUnsafe());
5771+
}).pipe(Effect.scoped, Effect.provide(testLayer)),
57455772
);
57465773

57475774
it.effect("declines URL and value forms without a card", () =>

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,11 +3825,12 @@ export const awaitClaudeApprovalDecision = Effect.fn("awaitClaudeApprovalDecisio
38253825
return yield* Effect.raceFirst(Deferred.await(decision), cancellation);
38263826
});
38273827

3828-
// Web and mobile offer a session grant when options are omitted, and this
3829-
// path only ever answers once.
3828+
// MCP servers such as Computer Use ask on every call and expect the client to
3829+
// remember a session grant, as Codex does. The CLI drops a reply's `_meta.persist`.
38303830
const CLAUDE_MCP_ELICITATION_OPTIONS: ReadonlyArray<ProviderApprovalOption> = [
38313831
{ decision: "cancel", label: "Cancel" },
38323832
{ decision: "decline", label: "Decline" },
3833+
{ decision: "acceptForSession", label: "Always allow this session" },
38333834
{ decision: "accept", label: "Approve" },
38343835
];
38353836

@@ -5212,6 +5213,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
52125213
const pendingRuntimeRequests = yield* Ref.make(
52135214
new Map<string, PendingClaudeRuntimeRequest>(),
52145215
);
5216+
const mcpElicitationSessionGrants = yield* Ref.make(new Set<string>());
52155217
// Background local_bash tasks can trigger wake turns on the query stream with no active provider turn.
52165218
const lastTurnRouteByNativeThread = yield* Ref.make(
52175219
new Map<
@@ -10620,6 +10622,10 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1062010622
);
1062110623
return { action: "decline" } satisfies ElicitationResult;
1062210624
}
10625+
const grantKey = `${request.serverName}\u0000${request.message}`;
10626+
if ((yield* Ref.get(mcpElicitationSessionGrants)).has(grantKey)) {
10627+
return acceptance;
10628+
}
1062310629
// The CLI waits on this answer, so a turn held for its prompt echo
1062410630
// must show its output now, as canUseTool does.
1062510631
if (context.heldRootFrames.length > 0) {
@@ -10706,8 +10712,14 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
1070610712
runtimeRequest: { ...artifacts.request, status: "cancelled", resolvedAt: now },
1070710713
});
1070810714
}
10715+
if (resolved === "acceptForSession") {
10716+
yield* Ref.update(mcpElicitationSessionGrants, (current) =>
10717+
new Set(current).add(grantKey),
10718+
);
10719+
return acceptance;
10720+
}
1070910721
// Never null: the SDK reads null as answered out of band and leaves
10710-
// the server waiting. Every accept is one-time; no grant is offered.
10722+
// the server waiting.
1071110723
return resolved === "accept"
1071210724
? acceptance
1071310725
: ({

‎apps/web/src/components/chat/ThreadDetailsControl.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function ThreadDetailsControl({
5252
className: cn(
5353
"relative inline-flex shrink-0 cursor-pointer items-center whitespace-nowrap border outline-none transition-[box-shadow,scale] [&:not([aria-haspopup]):not(:disabled):not([aria-disabled=true])]:will-change-[scale] [&:active:not([aria-haspopup])]:scale-[0.97] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 disabled:pointer-events-none disabled:opacity-64 aria-disabled:cursor-not-allowed aria-disabled:opacity-64 [&_svg]:shrink-0",
5454
parts[part],
55-
multiline && "h-auto min-h-8 py-0.75 disabled:opacity-100 sm:h-auto",
55+
multiline && "h-auto min-h-8 py-1.5 disabled:opacity-100 sm:h-auto",
5656
tone === "muted" && "text-muted-foreground hover:text-foreground/80",
5757
tone === "primary" &&
5858
// The row surface forces a faint hover fill with !important; the solid pill keeps its own.

‎apps/web/src/components/chat/ThreadDetailsPrRow.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export function ThreadDetailsPrRow({
409409
size="sm"
410410
part={part}
411411
multiline={wrap}
412-
className={wrap ? "items-start [&>svg]:mt-0.5" : undefined}
412+
className={wrap ? "items-start [&>svg]:mt-px" : undefined}
413413
aria-label={openAriaLabel}
414414
onClick={onOpen}
415415
onAuxClick={onOpen}

0 commit comments

Comments
 (0)