Skip to content

Commit 46afd69

Browse files
fix(server): scheduled task updates keep the saved workspace unless the binding changes (#32494)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 94f54a5 commit 46afd69

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2911,7 +2911,13 @@ describe("OrchestratorMcpService provider resolution", () => {
29112911
Effect.gen(function* () {
29122912
const saved = yield* Ref.make<ReadonlyArray<ScheduledTask["workspaceStrategy"]>>([]);
29132913
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService.pipe(
2914-
Effect.provide(service(masterRepository, saved)),
2914+
Effect.provide(
2915+
service(masterRepository, saved, {
2916+
...existing,
2917+
threadId: ThreadId.make("thread:scheduled-base"),
2918+
threadMode: "continue",
2919+
}),
2920+
),
29152921
);
29162922
yield* mcp.updateScheduledTask(client, {
29172923
scheduledTaskId: existing.id,
@@ -2923,6 +2929,20 @@ describe("OrchestratorMcpService provider resolution", () => {
29232929
}),
29242930
);
29252931

2932+
it.effect("keeps the saved workspace when an unbound task stays unbound", () =>
2933+
Effect.gen(function* () {
2934+
const saved = yield* Ref.make<ReadonlyArray<ScheduledTask["workspaceStrategy"]>>([]);
2935+
const mcp = yield* OrchestratorMcpService.OrchestratorMcpService.pipe(
2936+
Effect.provide(service(masterRepository, saved)),
2937+
);
2938+
yield* mcp.updateScheduledTask(client, {
2939+
scheduledTaskId: existing.id,
2940+
bindToCurrentThread: false,
2941+
});
2942+
assert.deepEqual(yield* Ref.get(saved), [{ type: "root" }]);
2943+
}),
2944+
);
2945+
29262946
it.effect.each([
29272947
{
29282948
name: "no remote, only master",

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,11 +2070,11 @@ const make = Effect.gen(function* () {
20702070
: input.bindToCurrentThread && parent !== undefined
20712071
? parent.thread.id
20722072
: null;
2073-
// Update workspace strategy on rebinding so unbound root tasks cannot run in the shared checkout.
2073+
// Reset the workspace only when the binding flips, so unbinding cannot leave runs in the shared checkout.
20742074
const workspaceStrategy =
2075-
input.bindToCurrentThread === undefined
2075+
(threadId === null) === (existing.threadId === null)
20762076
? existing.workspaceStrategy
2077-
: yield* scheduledTaskWorkspaceStrategy(input.bindToCurrentThread, existing.projectId);
2077+
: yield* scheduledTaskWorkspaceStrategy(threadId !== null, existing.projectId);
20782078
const upsertInput: ScheduledTaskUpsertInput = {
20792079
id: existing.id,
20802080
title: input.title ?? existing.title,

0 commit comments

Comments
 (0)