Skip to content

Commit 9bc1a93

Browse files
fix(server): t3_thread_launch says when its project does not exist
A new launch into a project id that names no project now fails with invalid_request "The project was not found." for every workspace strategy, as t3_project_read does, instead of "The operation could not be completed." from the launch service. The project is read once, before the strategy checks, and the existing_worktree check and the project defaults reuse it. Replays of an accepted launch still skip the read. Fixes #29094 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b105c71 commit 9bc1a93

3 files changed

Lines changed: 54 additions & 21 deletions

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from "@t3tools/contracts";
1717
import * as Effect from "effect/Effect";
1818
import * as Layer from "effect/Layer";
19+
import * as Option from "effect/Option";
1920
import { McpSchema, McpServer } from "effect/ai";
2021

2122
import * as ServerConfig from "../config.ts";
@@ -133,7 +134,21 @@ const layerTools = Layer.mergeAll(
133134
Layer.provide(Layer.mock(ScheduledTaskService.ScheduledTaskService)({})),
134135
Layer.provide(
135136
Layer.mock(ProjectService.ProjectService)({
136-
getById: () => Effect.succeedNone,
137+
getById: (id) =>
138+
Effect.succeed(
139+
id === projectId
140+
? Option.some({
141+
id,
142+
title: "t3code",
143+
workspaceRoot: "/p/t3code",
144+
defaultModelSelection: null,
145+
scripts: [],
146+
createdAt: "2026-10-18T00:00:00.000Z",
147+
updatedAt: "2026-10-18T00:00:00.000Z",
148+
deletedAt: null,
149+
})
150+
: Option.none(),
151+
),
137152
create: (input) =>
138153
Effect.succeed({
139154
id: input.projectId,

‎apps/server/src/mcp/toolkits/project/handlers.ts‎

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
126126
),
127127
)).projectId
128128
: yield* resolveProjectId(context, input.projectId);
129-
const readProject = Project.ProjectService.pipe(
130-
Effect.flatMap((projects) => projects.getById(projectId)),
131-
Effect.mapError(unavailable),
132-
Effect.map(Option.getOrUndefined),
133-
);
134129
// A retry of an accepted launch replays it: it keeps the model it started
135130
// with and skips the checks only a new launch needs, which the project
136131
// may no longer pass, such as a base branch deleted since.
@@ -141,15 +136,26 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
141136
const launchedModel =
142137
launched === null || launched.deletedAt !== null ? undefined : launched.modelSelection;
143138
const replaying = launchedModel !== undefined;
144-
if (!replaying && input.workspaceStrategy?.type === "existing_worktree") {
145-
const project = yield* readProject;
146-
if (project === undefined)
147-
return yield* new OrchestratorMcpFailure({
148-
code: "invalid_request",
149-
message: "The project was not found.",
150-
});
139+
const project = replaying
140+
? undefined
141+
: yield* Project.ProjectService.pipe(
142+
Effect.flatMap((projects) => projects.getById(projectId)),
143+
Effect.mapError(unavailable),
144+
Effect.flatMap(
145+
Option.match({
146+
onNone: () =>
147+
Effect.fail(
148+
new OrchestratorMcpFailure({
149+
code: "invalid_request",
150+
message: "The project was not found.",
151+
}),
152+
),
153+
onSome: Effect.succeed,
154+
}),
155+
),
156+
);
157+
if (project !== undefined && input.workspaceStrategy?.type === "existing_worktree")
151158
yield* assertProjectWorktree(project.workspaceRoot, input.workspaceStrategy.worktreePath);
152-
}
153159
// Reject unresolved base refs before accepting a launch; worktree provisioning happens later.
154160
const strategy = input.workspaceStrategy;
155161
if (!replaying && strategy?.type === "worktree")
@@ -173,15 +179,12 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
173179
// project's effective defaults, as the composer does. Its mode stays
174180
// within the ceiling it was approved with.
175181
const projectDefaults =
176-
caller === undefined && !replaying
182+
caller === undefined && project !== undefined
177183
? yield* ServerSettings.ServerSettingsService.pipe(
178184
Effect.flatMap((settings) => settings.getSettings),
179185
Effect.mapError(unavailable),
180-
Effect.flatMap((settings) =>
181-
Effect.map(
182-
readProject,
183-
(project) => resolveProjectSettings(settings, projectId, project).settings,
184-
),
186+
Effect.map(
187+
(settings) => resolveProjectSettings(settings, projectId, project).settings,
185188
),
186189
)
187190
: undefined;

‎apps/server/src/peer/PeerForwarding.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { expect, it } from "@effect/vitest";
1616
import * as Context from "effect/Context";
1717
import * as Effect from "effect/Effect";
1818
import * as Layer from "effect/Layer";
19+
import * as Option from "effect/Option";
1920
import * as Ref from "effect/Ref";
2021
import { McpSchema, McpServer } from "effect/ai";
2122

@@ -166,7 +167,21 @@ const boxLaunches = (seen: Ref.Ref<Seen>) =>
166167
const boxProjects = (seen: Ref.Ref<Seen>) =>
167168
Layer.merge(
168169
Layer.mock(ProjectService.ProjectService)({
169-
getById: () => Effect.succeedNone,
170+
getById: (id) =>
171+
Effect.succeed(
172+
id === boxProject
173+
? Option.some({
174+
id,
175+
title: "t3code",
176+
workspaceRoot: "/box/t3code",
177+
defaultModelSelection: null,
178+
scripts: [],
179+
createdAt: "2026-10-18T00:00:00.000Z",
180+
updatedAt: "2026-10-18T00:00:00.000Z",
181+
deletedAt: null,
182+
})
183+
: Option.none(),
184+
),
170185
create: (input) =>
171186
Ref.update(seen, (current) => ({
172187
...current,

0 commit comments

Comments
 (0)