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 22, 05:45 UTC
fix(provider-acp): ACP threads keep receiving events after a rollback (#28987)
Co-authored-by: Trevor Edwards <9443483+trevoedwards@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Trevor committed
Nov 3, 2026 at 16:11 UTC
b156a7d7f3190bf6921a91dc9b715ca3d0e600c7
2 files changed
+21
-2
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+13
@@ -4680,10 +4680,16 @@ describe("AcpAdapterV2", () => {
4680
browserToolsAvailable: false,
4681
});
4682
const runtimeInputs: Array<AcpAdapterV2RuntimeInput> = [];
4683
+ const nativeRuntimes: Array<AcpSessionRuntime.AcpSessionRuntime["Service"]> = [];
4684
+ let sessionEventCount = 0;
4685
const makeRuntime = makeMockRuntime({
4686
childProcessSpawner,
4687
mockAgentPath,
4688
environment: { T3_ACP_PROMPT_DELAY_MS: "100" },
4689
+ wrapRuntime: (nativeRuntime) => {
4690
+ nativeRuntimes.push(nativeRuntime);
4691
+ return nativeRuntime;
4692
+ },
4693
});
4694
const adapter = yield* makeAcpAdapterV2({
4695
instanceId,
@@ -4694,6 +4700,10 @@ describe("AcpAdapterV2", () => {
4700
Effect.sync(() => runtimeInputs.push(runtimeInput)).pipe(
4701
Effect.andThen(makeRuntime(runtimeInput)),
4702
),
4703
+ onSessionEvent: () =>
4704
+ Effect.sync(() => {
4705
+ sessionEventCount += 1;
4706
+ }),
4707
},
4708
selfInvocation,
4709
});
@@ -4788,6 +4798,7 @@ describe("AcpAdapterV2", () => {
4798
});
4799
assert.deepEqual(snapshotAfterRollback.providerTurns, []);
4800
assert.deepEqual(snapshotAfterRollback.messages, []);
4801
+ const sessionEventsBeforeSecondTurn = sessionEventCount;
4802
4803
yield* runtime.startTurn(
4804
makeTurnInput({
@@ -4814,6 +4825,8 @@ describe("AcpAdapterV2", () => {
4825
}
4826
}
4827
assert.equal(secondStatus, "completed");
4828
+ yield* nativeRuntimes[1]!.drainEvents;
4829
+ assert.isAbove(sessionEventCount, sessionEventsBeforeSecondTurn);
4830
}).pipe(Effect.provide(layerTest), Effect.scoped),
4831
);
4832
packages/provider-acp/src/server/adapter.ts
+8
-2
@@ -6300,6 +6300,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6300
readonly sessionUpdates?: boolean;
6301
readonly terminals?: boolean;
6302
readonly mcp?: boolean;
6303
+ readonly scope?: Scope.Scope;
6304
} = {},
6305
) {
6306
yield* targetRuntime.getEvents().pipe(
@@ -6312,7 +6313,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6313
flavor.onSessionEvent?.(event) ?? Effect.void,
6314
).pipe(Effect.asVoid);
6315
}),
6315
- Effect.forkIn(runtimeScope ?? sessionScope),
6316
+ Effect.forkIn(handlerOptions.scope ?? runtimeScope ?? sessionScope),
6317
);
6318
const requestUserInput = (
6319
request: AcpAdapterV2UserInputRequest,
@@ -6880,7 +6881,12 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
6881
yield* wireAcpRuntimeHandlers(
6882
replacementExit.value.replacementRuntime,
6883
replacementGeneration,
6883
- { sessionUpdates: false, terminals: false, mcp: false },
6884
+ {
6885
+ sessionUpdates: false,
6886
+ terminals: false,
6887
+ mcp: false,
6888
+ scope: replacementScope,
6889
+ },
6890
);
6891
const lifecycle = yield* Ref.modify(
6892
candidateLifecycle,