GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): delegate_task worktree isolation works in a project fold… · mediavee/t3code@62d6abf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/mcp
    • OrchestratorMcpService.test.ts
    • OrchestratorMcpService.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/mcp/OrchestratorMcpService.test.ts
+100Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,106 @@ describe("OrchestratorMcpService provider resolution", () => {
27152715
}),
27162716
);
27172717

2718+
it.effect("gives a worktree child in a project whose folder holds several repositories", () =>
2719+
Effect.gen(function* () {
2720+
// A plain project folder: Git finds no repository at its root, only in a/ and b/.
2721+
const workspaceRoot = "/work/several-repos";
2722+
const commands: Array<unknown> = [];
2723+
const task = {
2724+
id: taskId,
2725+
threadId: parentThreadId,
2726+
origin: "app_owned",
2727+
childThreadId,
2728+
providerInstanceId: codexInstanceId,
2729+
model: "gpt-5.4",
2730+
status: "running",
2731+
result: null,
2732+
};
2733+
const dependencies = Layer.mergeAll(
2734+
NodeServices.layer,
2735+
NodeCrypto.layer,
2736+
Layer.mock(ThreadManagementService.ThreadManagementService)({
2737+
hasReceipt: () => Effect.succeed(false),
2738+
getThreadRecords: (threadId) =>
2739+
Effect.succeed(
2740+
threadId === parentThreadId
2741+
? (() => {
2742+
const parent = parentProjection(commands.length > 0 ? [task] : []);
2743+
return {
2744+
...parent,
2745+
thread: { ...parent.thread, worktreePath: null },
2746+
} as OrchestrationV2ThreadProjection;
2747+
})()
2748+
: childProjection,
2749+
),
2750+
dispatch: (command) =>
2751+
Effect.sync(() => {
2752+
commands.push(command);
2753+
return {
2754+
sequence: 1,
2755+
storedEvents: [{ event: { type: "subagent.updated", payload: task } }],
2756+
} as never;
2757+
}),
2758+
}),
2759+
ServerSettings.layerTest(),
2760+
providerRegistryLayer([
2761+
providerSnapshot({
2762+
instanceId: codexInstanceId,
2763+
driver: ProviderDriverKind.make("codex"),
2764+
model: "gpt-5.4",
2765+
}),
2766+
]),
2767+
adapterRegistryLayer([codexInstanceId]),
2768+
Layer.mock(ProjectService.ProjectService)({
2769+
getById: () =>
2770+
Effect.succeedSome({ id: projectId, title: "parent", workspaceRoot } as never),
2771+
}),
2772+
Layer.mock(SecretRequests.SecretRequests)({}),
2773+
Layer.mock(RemoteDelegation.RemoteDelegation)({}),
2774+
Layer.mock(ScheduledTaskService.ScheduledTaskService)({}),
2775+
);
2776+
const notARepository = (cwd: string) =>
2777+
new GitCommandError({
2778+
operation: "GitVcsDriver.resolveCommit",
2779+
command: "git rev-parse --verify HEAD^{commit}",
2780+
cwd,
2781+
detail: "fatal: not a git repository (or any of the parent directories): .git",
2782+
});
2783+
const layerService = OrchestratorMcpService.layer.pipe(
2784+
Layer.provide(
2785+
Layer.mock(ThreadLaunchService.ThreadLaunchService)({
2786+
isNonGitProject: () => Effect.succeed(true),
2787+
}),
2788+
),
2789+
Layer.provide(
2790+
Layer.mock(GitVcsDriver.GitVcsDriver)({
2791+
resolveCommit: ({ cwd }) => Effect.fail(notARepository(cwd)),
2792+
}),
2793+
),
2794+
Layer.provide(dependencies),
2795+
);
2796+
yield* Effect.gen(function* () {
2797+
const service = yield* OrchestratorMcpService.OrchestratorMcpService;
2798+
const result = yield* service
2799+
.delegateTask(scope, {
2800+
task: "Add a line to a/README.md.",
2801+
isolation: "worktree",
2802+
mode: "async",
2803+
clientRequestId: "worktree-several-repos",
2804+
})
2805+
.pipe(Effect.result);
2806+
assert.isTrue(
2807+
Result.isSuccess(result),
2808+
`worktree isolation was refused: ${Result.isFailure(result) ? result.failure.message : ""}`,
2809+
);
2810+
assert.equal(
2811+
(commands[0] as { workspaceStrategy?: { type: string } }).workspaceStrategy?.type,
2812+
"worktree",
2813+
);
2814+
}).pipe(Effect.provide(layerService));
2815+
}),
2816+
);
2817+
27182818
it.effect("rejects delegation to a provider without a registered adapter", () =>
27192819
Effect.gen(function* () {
27202820
const forkOnlyInstanceId = ProviderInstanceId.make("forkOnly");
Collapse file

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

Copy file name to clipboardExpand all lines: apps/server/src/mcp/OrchestratorMcpService.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2975,7 +2975,14 @@ const make = Effect.gen(function* () {
29752975
input.interactionMode,
29762976
);
29772977
let workspaceStrategy: OrchestrationV2ThreadLaunchWorkspaceStrategy | undefined;
2978-
if (input.isolation === "worktree" && !isRetryOfAcceptedDelegation) {
2978+
if (
2979+
input.isolation === "worktree" &&
2980+
!isRetryOfAcceptedDelegation &&
2981+
(yield* threadLaunch.isNonGitProject(parent.thread.projectId))
2982+
) {
2983+
// A plain project folder has no commit of its own; `HEAD` leaves each repository on its default branch.
2984+
workspaceStrategy = { type: "worktree", baseRef: "HEAD" };
2985+
} else if (input.isolation === "worktree" && !isRetryOfAcceptedDelegation) {
29792986
const project = yield* requireProject(parent.thread.projectId);
29802987
const base = yield* gitDriver
29812988
.resolveCommit({

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.