@@ -12946,6 +12946,67 @@ describe("ClaudeAdapterV2 background wake turns", () => {
1294612946 ),
1294712947 );
1294812948
12949+ it.effect("keeps a foreground fork running past the placeholder result for its own launch", () =>
12950+ Effect.scoped(
12951+ Effect.gen(function* () {
12952+ const harness = yield* makeWakeHarness;
12953+ yield* harness.runtime.startTurn(
12954+ makeClaudeTestTurnInput({
12955+ threadId: harness.threadId,
12956+ providerThread: harness.providerThread,
12957+ now: yield* DateTime.now,
12958+ attemptId: RunAttemptId.make("attempt-claude-foreground-fork"),
12959+ text: "Fork this.",
12960+ attachments: [],
12961+ }),
12962+ );
12963+ yield* harness.offerAndWait(
12964+ makeSubagentTaskStartedFrame({
12965+ taskId: "agent-fork",
12966+ toolUseId: "toolu-fork",
12967+ uuid: "00000000-0000-4000-8000-000000000901",
12968+ }),
12969+ );
12970+ // Claude Code opens a foreground fork's own stream with a placeholder result for its launch.
12971+ yield* harness.offerAndWait(
12972+ claudeSdkFrame({
12973+ type: "user",
12974+ message: {
12975+ role: "user",
12976+ content: [
12977+ {
12978+ type: "tool_result",
12979+ tool_use_id: "toolu-fork",
12980+ content: "Fork started — that fork is you.",
12981+ },
12982+ ],
12983+ },
12984+ parent_tool_use_id: "toolu-fork",
12985+ uuid: "00000000-0000-4000-8000-000000000902",
12986+ session_id: WAKE_NATIVE_SESSION,
12987+ }),
12988+ );
12989+ yield* harness.offerAndWait(
12990+ makeSubagentNotificationFrame({
12991+ taskId: "agent-fork",
12992+ toolUseId: "toolu-fork",
12993+ summary: "FORK-DONE",
12994+ uuid: "00000000-0000-4000-8000-000000000903",
12995+ }),
12996+ );
12997+ let settled = yield* Queue.take(harness.subagentReceipts);
12998+ while (settled.subagent.status === "running") {
12999+ settled = yield* Queue.take(harness.subagentReceipts);
13000+ }
13001+ assert.equal(settled.subagent.result, "FORK-DONE");
13002+ }).pipe(
13003+ Effect.provide(
13004+ Layer.mergeAll(IdAllocator.layer, McpProviderSessions.layer, NodeServices.layer),
13005+ ),
13006+ ),
13007+ ),
13008+ );
13009+
1294913010 it.effect("releases the idle pin when a post-settle subagent stops without completing", () =>
1295013011 Effect.scoped(
1295113012 Effect.gen(function* () {
0 commit comments