@devries-cameron20 / t3code Mirror · read-only / commits / 6d6c4614aa
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

fix(server): request_secret opens a new card when a later run reuses a clientRequestId (#38167)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Svetlomir committed Nov 19, 2026 at 21:13 UTC 6d6c4614aa009f0be00fbbd9142ae1f7a874a86f
2 files changed +71 -1
apps/server/src/mcp/OrchestratorMcpService.test.ts
+70
@@ -1950,6 +1950,76 @@ describe("OrchestratorMcpService provider resolution", () => {
1950 }),
1951 );
1952
1953 + // Command receipts dedupe by commandId, so a later run reusing the identity gets no card.
1954 + it.effect("opens a new secret card when a later run reuses a clientRequestId", () =>
1955 + Effect.gen(function* () {
1956 + const runId = yield* Ref.make(parentRunId);
1957 + const pending = yield* Queue.unbounded<{
1958 + readonly commandId: CommandId;
1959 + readonly turnItemId: string;
1960 + }>();
1961 + const dependencies = Layer.mergeAll(
1962 + NodeServices.layer,
1963 + NodeCrypto.layer,
1964 + Layer.mock(ThreadManagementService.ThreadManagementService)({
1965 + getThreadRecords: () =>
1966 + Ref.get(runId).pipe(
1967 + Effect.map((id) => {
1968 + const projection = parentProjection([]);
1969 + return {
1970 + ...projection,
1971 + runs: projection.runs.map((run) => ({ ...run, id })),
1972 + turnItems: [],
1973 + };
1974 + }),
1975 + ),
1976 + dispatch: (command) => {
1977 + if (command.type !== "secret_request.record") return Effect.die("Unexpected command");
1978 + return (
1979 + command.secretStatus === "pending"
1980 + ? Queue.offer(pending, {
1981 + commandId: command.commandId,
1982 + turnItemId: command.turnItemId,
1983 + })
1984 + : Effect.void
1985 + ).pipe(Effect.as({} as never));
1986 + },
1987 + }),
1988 + ServerSettings.layerTest(),
1989 + providerRegistryLayer([]),
1990 + adapterRegistryLayer([]),
1991 + Layer.mock(ProjectService.ProjectService)({}),
1992 + Layer.mock(SecretRequests.SecretRequests)({}),
1993 + Layer.mock(RemoteDelegation.RemoteDelegation)({}),
1994 + Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
1995 + );
1996 + yield* Effect.gen(function* () {
1997 + const service = yield* OrchestratorMcpService.OrchestratorMcpService;
1998 + const ask = Effect.gen(function* () {
1999 + const call = yield* service
2000 + .requestSecret(scope, {
2001 + label: "Router API key",
2002 + reason: "Reads the firewall rules.",
2003 + clientRequestId: "router-key",
2004 + timeoutMs: 1_000,
2005 + })
2006 + .pipe(Effect.forkChild);
2007 + const card = yield* Queue.take(pending);
2008 + yield* TestClock.adjust(Duration.seconds(1));
2009 + assert.include(yield* Fiber.join(call), { status: "timed_out" });
2010 + return card;
2011 + });
2012 +
2013 + const first = yield* ask;
2014 + assert.deepEqual(yield* ask, first);
2015 + yield* Ref.set(runId, RunId.make("run:mcp-providers-parent-later"));
2016 + const later = yield* ask;
2017 + assert.notEqual(later.commandId, first.commandId);
2018 + assert.notEqual(later.turnItemId, first.turnItemId);
2019 + }).pipe(Effect.provide(layerOrchestratorService.pipe(Layer.provide(dependencies))));
2020 + }),
2021 + );
2022 +
2023 it.effect(
2024 "advertises orchestration capability from registered adapters rather than a driver allowlist",
2025 () =>
apps/server/src/mcp/OrchestratorMcpService.ts
+1 -1
@@ -2519,7 +2519,7 @@ const make = Effect.gen(function* () {
2519 }
2520 const runId = run.id;
2521 const nodeId = run.rootNodeId;
2522 - const key = yield* requestKey(input.clientRequestId);
2522 + const key = `${runId}:${yield* requestKey(input.clientRequestId)}`;
2523 const turnItemId = TurnItemId.make(
2524 `turn-item:secret-request:${stablePart(threadId)}:${stablePart(key)}`,
2525 );