The best way to control Claude Code, Codex and more from any computer or phone
fix(acp): preserve Windows shim stdio pipes (#30544)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Elliot Drel committed
Nov 13, 2026 at 23:05 UTC
0aeb9457067b6d1a73ad92cd2c6a5f13d804d165
2 files changed
+35
-2
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+31
@@ -53,6 +53,7 @@ import * as Stream from "effect/Stream";
53
import * as Scope from "effect/Scope";
54
import * as TestClock from "effect/testing/TestClock";
55
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
56
+import * as ChildProcess from "effect/process/ChildProcess";
57
import * as EffectAcpErrors from "effect-acp/errors";
58
import type * as EffectAcpProtocol from "effect-acp/protocol";
59
import type * as EffectAcpSchema from "effect-acp/compat";
@@ -571,6 +572,36 @@ function makeMockRuntime(input: {
572
});
573
}
574
575
+it.effect("detaches owned ACP processes on POSIX hosts but not on Windows", () =>
576
+ Effect.gen(function* () {
577
+ for (const [platform, expected] of [
578
+ ["win32", false],
579
+ ["linux", true],
580
+ ] as const) {
581
+ let detached: boolean | undefined;
582
+ yield* AcpSessionRuntime.make({
583
+ spawn: { command: "acp-agent", args: [] },
584
+ cwd: process.cwd(),
585
+ clientInfo: { name: "test", version: "1" },
586
+ ownDetachedProcessGroup: true,
587
+ processGroupPlatform: platform,
588
+ }).pipe(
589
+ Effect.provideService(HostProcess.Platform, platform),
590
+ Effect.provideService(
591
+ ChildProcessSpawner.ChildProcessSpawner,
592
+ ChildProcessSpawner.make((command) => {
593
+ if (ChildProcess.isStandardCommand(command)) detached = command.options.detached;
594
+ return Effect.die("spawn stopped by test");
595
+ }),
596
+ ),
597
+ Effect.scoped,
598
+ Effect.exit,
599
+ );
600
+ assert.equal(detached, expected, platform);
601
+ }
602
+ }).pipe(Effect.provide(layerTest)),
603
+);
604
+
605
const isProviderAdapterProtocolError = Schema.is(ProviderAdapter.ProviderAdapterProtocolError);
606
607
const makePromptInactivityHarness = Effect.fnUntraced(function* (input: {
packages/provider-acp/src/server/AcpSessionRuntime.ts
+4
-2
@@ -1255,6 +1255,7 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
1255
> {
1256
const random = yield* SecureRandom.SecureRandom;
1257
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
1258
+ const hostPlatform = yield* HostProcess.Platform;
1259
const runtimeScope = yield* Scope.fork(yield* Scope.Scope);
1260
const eventQueue = yield* Queue.unbounded<AcpSessionRuntimeEvent>();
1261
const modeStateRef = yield* Ref.make<AcpSessionModeState | undefined>(undefined);
@@ -1464,9 +1465,11 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
1465
...(options.spawn.cwd ? { cwd: options.spawn.cwd } : {}),
1466
...(spawnEnvironment ? { env: spawnEnvironment } : {}),
1467
extendEnv: options.spawn.extendEnv ?? true,
1468
+ // Windows `detached` gives the child its own console, which breaks stdio pipes through
1469
+ // `.cmd` shims; taskkill /T cleans up the tree there without it.
1470
...(options.ownDetachedProcessGroup === undefined
1471
? {}
1469
- : { detached: options.ownDetachedProcessGroup }),
1472
+ : { detached: options.ownDetachedProcessGroup && hostPlatform !== "win32" }),
1473
shell: containedSpawnCommand.shell,
1474
}),
1475
)
@@ -1628,7 +1631,6 @@ export const make = Effect.fn("AcpSessionRuntime.make")(function* (
1631
Effect.uninterruptible(terminateOwnedProcessGroupImpl),
1632
);
1633
if (options.ownDetachedProcessGroup === true) {
1631
- const hostPlatform = yield* HostProcess.Platform;
1634
const forceTerminateOwnedProcessGroup =
1635
hostPlatform === "win32"
1636
? terminateWindowsProcessTreeWithTaskkill(Number(child.pid)).pipe(