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(server): worktree handoff follows the project's start-from-origin setting (#29810)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Nov 3, 2026 at 23:22 UTC
ce89cd1cc38ad83f058a2b87e35510feca122a94
2 files changed
+33
-7
apps/server/src/mcp/WorktreeMcpService.test.ts
+21
-1
@@ -96,6 +96,7 @@ interface HarnessOptions {
96
readonly currentBranch?: string | null;
97
readonly notARepo?: boolean;
98
readonly newWorktreesStartFromOrigin?: boolean;
99
+ readonly projectNewWorktreesStartFromOrigin?: boolean;
100
readonly setupScript?: "started" | "no-script" | "fails" | "dies";
101
readonly dispatchFails?: boolean;
102
readonly dispatchDies?: boolean;
@@ -302,6 +303,15 @@ const makeHarness = (options: HarnessOptions = {}) => {
303
} satisfies Partial<ProjectService.ProjectService["Service"]>),
304
ServerSettings.layerTest({
305
newWorktreesStartFromOrigin: options.newWorktreesStartFromOrigin ?? false,
306
+ ...(options.projectNewWorktreesStartFromOrigin === undefined
307
+ ? {}
308
+ : {
309
+ projectSettingsOverrides: {
310
+ [projectId]: {
311
+ newWorktreesStartFromOrigin: options.projectNewWorktreesStartFromOrigin,
312
+ },
313
+ },
314
+ }),
315
}),
316
Layer.mock(GitWorkflowService.GitWorkflowService)({
317
listRefs,
@@ -522,6 +532,15 @@ describe("t3_worktree_handoff", () => {
532
});
533
});
534
535
+ it.effect("defaults startFromOrigin to the project's override", () => {
536
+ const harness = makeHarness({ projectNewWorktreesStartFromOrigin: true });
537
+ return Effect.gen(function* () {
538
+ const result = yield* runHandoff(harness, { branch: "feature/project-origin" });
539
+ expect(harness.fetchWorktreeBaseCommit).toHaveBeenCalled();
540
+ expect(result.startedFromOrigin).toBe(true);
541
+ });
542
+ });
543
+
544
it.effect("removes the created worktree when the thread update dies with a defect", () => {
545
const harness = makeHarness({ dispatchDies: true });
546
return Effect.gen(function* () {
@@ -679,6 +698,7 @@ describe("t3_worktree_status", () => {
698
worktreePath: "/worktrees/project/existing",
699
branch: "feature/existing",
700
},
701
+ projectNewWorktreesStartFromOrigin: true,
702
});
703
return Effect.gen(function* () {
704
const result = yield* runStatus(harness);
@@ -686,7 +706,7 @@ describe("t3_worktree_status", () => {
706
attached: true,
707
worktreePath: "/worktrees/project/existing",
708
branch: "feature/existing",
689
- defaultStartFromOrigin: false,
709
+ defaultStartFromOrigin: true,
710
});
711
});
712
});
apps/server/src/mcp/WorktreeMcpService.ts
+12
-6
@@ -9,6 +9,7 @@ import {
9
type WorktreeMcpSetupScriptStatus,
10
type WorktreeMcpStatusResult,
11
} from "@t3tools/contracts";
12
+import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
13
import * as Cause from "effect/Cause";
14
import * as Context from "effect/Context";
15
import * as SecureRandom from "effect/crypto/SecureRandom";
@@ -116,10 +117,14 @@ const make = Effect.gen(function* () {
117
),
118
);
119
119
- const readDefaultStartFromOrigin = serverSettings.getSettings.pipe(
120
- Effect.map((settings) => settings.newWorktreesStartFromOrigin),
121
- asOperationFailed("Unable to read server settings"),
122
- );
120
+ const readDefaultStartFromOrigin = (projectId: ProjectId) =>
121
+ serverSettings.getSettings.pipe(
122
+ Effect.map(
123
+ (settings) =>
124
+ resolveProjectSettings(settings, projectId).settings.newWorktreesStartFromOrigin,
125
+ ),
126
+ asOperationFailed("Unable to read server settings"),
127
+ );
128
129
const handoffIds = (scope: McpThreadInvocationScope) =>
130
random.uuidV4().pipe(
@@ -205,7 +210,8 @@ const make = Effect.gen(function* () {
210
baseRef = localStatus.refName;
211
}
212
208
- const startFromOrigin = input.startFromOrigin ?? (yield* readDefaultStartFromOrigin);
213
+ const startFromOrigin =
214
+ input.startFromOrigin ?? (yield* readDefaultStartFromOrigin(project.id));
215
216
let worktreeBaseRef = baseRef;
217
let baseRefName = baseRef;
@@ -415,7 +421,7 @@ const make = Effect.gen(function* () {
421
const projection = yield* loadThread(scope);
422
const project = yield* loadProject(scope, projection.thread.projectId);
423
418
- const defaultStartFromOrigin = yield* readDefaultStartFromOrigin;
424
+ const defaultStartFromOrigin = yield* readDefaultStartFromOrigin(project.id);
425
426
const result: WorktreeMcpStatusResult = {
427
attached: projection.thread.worktreePath !== null,