Skip to content

Commit a46b4b2

Browse files
committed
fix(server): bind handoff to the latest active run
1 parent 5e04c00 commit a46b4b2

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎apps/server/src/mcp/WorktreeMcpService.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ const makeProjection = (
7474
sourceRunId?: RunId,
7575
): OrchestrationV2ThreadProjection =>
7676
({
77-
runs: sourceRunId === undefined ? [] : [{ id: sourceRunId, status: "running" }],
77+
runs:
78+
sourceRunId === undefined
79+
? []
80+
: [
81+
{ id: RunId.make("run:older-background-work"), ordinal: 1, status: "waiting" },
82+
{ id: sourceRunId, ordinal: 2, status: "running" },
83+
],
7884
thread: {
7985
id: threadId,
8086
projectId,

‎apps/server/src/mcp/WorktreeMcpService.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import * as Option from "effect/Option";
2323
import type * as PlatformError from "effect/PlatformError";
2424

2525
import * as GitWorkflowService from "../git/GitWorkflowService.ts";
26-
import { isActiveRun } from "../orchestration-v2/CommandPolicy.ts";
26+
import { followUpOwnerRun } from "../orchestration-v2/CommandPolicy.ts";
2727
import * as ThreadManagementService from "../orchestration-v2/ThreadManagementService.ts";
2828
import * as ProjectService from "../project/ProjectService.ts";
2929
import * as ProjectSetupScriptRunner from "../project/ProjectSetupScriptRunner.ts";
@@ -171,7 +171,7 @@ const make = Effect.gen(function* () {
171171
);
172172

173173
const projection = yield* loadThread(scope, true);
174-
const sourceRun = projection.runs.find(isActiveRun);
174+
const sourceRun = followUpOwnerRun(projection.runs);
175175
if (projection.thread.worktreePath !== null) {
176176
return yield* alreadyInWorktree(projection.thread.worktreePath);
177177
}
@@ -314,7 +314,7 @@ const make = Effect.gen(function* () {
314314
worktreeContinuation: {
315315
messageId: ids.continuationMessageId,
316316
text: input.continuationPrompt,
317-
...(sourceRun === undefined ? {} : { sourceRunId: sourceRun.id }),
317+
...(sourceRun === null ? {} : { sourceRunId: sourceRun.id }),
318318
},
319319
}),
320320
})

‎apps/server/src/orchestration-v2/ProviderSessionManager.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,7 @@ it.effect("ProviderSessionManagerV2 stops a session still opening when its layer
17661766
);
17671767

17681768
it.effect.each(["pending", "running", "completed"] as const)(
1769-
"orders detach after a selected %s turn and interrupts it before ending the subscription",
1769+
"orders detach after a selected %s turn and only interrupts active native work",
17701770
(status) =>
17711771
Effect.gen(function* () {
17721772
const state = yield* Ref.make(emptyState);

0 commit comments

Comments
 (0)