@devries-cameron20 / t3code Mirror · read-only / commits / ec72de7d3f
Fork 0

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 21, 04:45 UTC

fix(server): t3_project_read shows the actions saved in Settings (#39676)

qdqqd committed Nov 20, 2026 at 12:59 UTC ec72de7d3ff225fe660686a724ea4eeebb191127
2 files changed +41 -11
apps/server/src/mcp/toolkits/project/handlers.test.ts
+26 -4
@@ -9,6 +9,7 @@ import {
9 type ServerProvider,
10 type Project as ProjectRecord,
11 type ModelSelection,
12 + type ProjectScript,
13 type RuntimeMode,
14 type OrchestrationV2ThreadShell,
15 ThreadId,
@@ -56,6 +57,7 @@ const clientLaunchHarness = (input: {
57 readonly providers?: readonly ServerProvider[];
58 /** Where Settings saves a project's model; the legacy project field stays null. */
59 readonly overrideModel?: ModelSelection;
60 + readonly overrideScripts?: readonly ProjectScript[];
61 readonly launched: Array<ThreadLaunch.ThreadLaunchInput>;
62 readonly workspaceRoot?: string;
63 readonly checkWorktreeBase?: ThreadLaunch.ThreadLaunchService["Service"]["checkWorktreeBase"];
@@ -93,7 +95,12 @@ const clientLaunchHarness = (input: {
95 : {
96 projectSettingsFolded: true,
97 projectSettingsOverrides: {
96 - [projectId]: { defaultModelSelection: input.overrideModel },
98 + [projectId]: {
99 + defaultModelSelection: input.overrideModel,
100 + ...(input.overrideScripts === undefined
101 + ? {}
102 + : { defaultProjectScripts: input.overrideScripts }),
103 + },
104 },
105 }),
106 }),
@@ -1167,15 +1174,19 @@ it.effect("an agent cannot delete the built-in scratch project, even with force"
1174 }),
1175 );
1176
1170 -it.effect("reading a project shows the default model saved in Settings", () =>
1177 +it.effect("reading a project shows the default model and actions saved in Settings", () =>
1178 Effect.gen(function* () {
1179 const overrideModel = {
1180 instanceId: ProviderInstanceId.make("claudeAgent"),
1181 model: "claude-sonnet",
1182 };
1183 + const overrideScripts = [
1184 + { id: "test", name: "Test", command: "pnpm test", icon: "test", runOnWorktreeCreate: false },
1185 + ] satisfies ProjectScript[];
1186 const harness = clientLaunchHarness({
1187 runtimeModeCeiling: "full-access",
1188 overrideModel,
1189 + overrideScripts,
1190 launched: [],
1191 });
1192 const dependencies = Layer.merge(
@@ -1187,7 +1198,15 @@ it.effect("reading a project shows the default model saved in Settings", () =>
1198 title: "Client target",
1199 workspaceRoot: "/projects/client-target",
1200 defaultModelSelection: null,
1190 - scripts: [],
1201 + scripts: [
1202 + {
1203 + id: "stale",
1204 + name: "Stale",
1205 + command: "true",
1206 + icon: "play",
1207 + runOnWorktreeCreate: false,
1208 + },
1209 + ],
1210 createdAt: "2026-01-01T00:00:00.000Z",
1211 updatedAt: "2026-01-01T00:00:00.000Z",
1212 deletedAt: null,
@@ -1204,7 +1223,10 @@ it.effect("reading a project shows the default model saved in Settings", () =>
1223 .handle("t3_project_read", { projectId: harness.projectId })
1224 .pipe(Stream.unwrap, Stream.runCollect, Effect.provide(dependencies));
1225
1207 - expect(read.at(-1)?.result).toMatchObject({ defaultModelSelection: overrideModel });
1226 + expect(read.at(-1)?.result).toMatchObject({
1227 + defaultModelSelection: overrideModel,
1228 + scripts: overrideScripts,
1229 + });
1230 }),
1231 );
1232
apps/server/src/mcp/toolkits/project/handlers.ts
+15 -7
@@ -33,6 +33,7 @@ import {
33 resolveProjectFileBackedSetting,
34 resolveProjectSettings,
35 } from "@t3tools/shared/projectSettings";
36 +import { resolveProjectScripts } from "@t3tools/shared/projectScripts";
37 import { parseT3ProjectFile } from "@t3tools/shared/t3ProjectFile";
38 import { resolveRuntimeMode } from "../../delegatedTaskModes.ts";
39 import * as McpInvocationContext from "../../McpInvocationContext.ts";
@@ -181,8 +182,8 @@ const access = Effect.gen(function* () {
182 return yield* Project.ProjectService;
183 });
184
184 -/** Settings, not the project record, hold the project default model that new threads use. */
185 -const withSavedDefaultModel = Effect.gen(function* () {
185 +/** Settings, not the project record, hold the default model and actions that new threads use. */
186 +const withSavedProjectSettings = Effect.gen(function* () {
187 const settings = yield* ServerSettings.ServerSettingsService.pipe(
188 Effect.flatMap((service) => service.getSettings),
189 Effect.mapError(unavailable),
@@ -195,10 +196,16 @@ const withSavedDefaultModel = Effect.gen(function* () {
196 resolved.sources.defaultModelSelection === "project"
197 ? resolved.settings.defaultModelSelection
198 : null,
199 + scripts: resolveProjectScripts(settings, project),
200 };
201 };
202 });
203
204 +// The project is already committed, so a failed Settings read must not report the create as failed.
205 +const withSavedProjectSettingsAfterCreate = withSavedProjectSettings.pipe(
206 + Effect.orElseSucceed(() => (project: ProjectRecord) => project),
207 +);
208 +
209 export const layer = McpToolAccess.toLayer(ProjectToolkit, {
210 t3_thread_launch: McpToolAccess.startsThreads(
211 (input) => input,
@@ -472,7 +479,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
479 const page = yield* projects
480 .listPage({ cursor: input.cursor ?? 0, limit: input.limit ?? 20 })
481 .pipe(Effect.mapError(unavailable));
475 - return { ...page, projects: page.projects.map(yield* withSavedDefaultModel) };
482 + return { ...page, projects: page.projects.map(yield* withSavedProjectSettings) };
483 }),
484 ),
485 t3_project_read: McpToolAccess.reads((input) =>
@@ -484,7 +491,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
491 code: "invalid_request",
492 message: "The project was not found.",
493 });
487 - return (yield* withSavedDefaultModel)(result.value);
494 + return (yield* withSavedProjectSettings)(result.value);
495 }),
496 ),
497 t3_project_create: McpToolAccess.writesEnvironment(
@@ -522,7 +529,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
529 ),
530 );
531 return {
525 - ...project,
532 + ...(yield* withSavedProjectSettingsAfterCreate)(project),
533 ...(created.commitError === undefined ? {} : { commitError: created.commitError }),
534 };
535 }
@@ -533,9 +540,10 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
540 "Creating a project does not set its default model; set defaultModelSelection afterwards with t3_project_update.",
541 });
542 const commandId = yield* newCommandId();
536 - return yield* projects
543 + const created = yield* projects
544 .create({ ...input, workspaceRoot, commandId, projectId: ProjectId.make(commandId) })
545 .pipe(Effect.mapError(projectFailure));
546 + return (yield* withSavedProjectSettingsAfterCreate)(created);
547 }),
548 // Linked work may bring the repository it works in; an existing
549 // registered workspace is still refused.
@@ -547,7 +555,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
555 const updated = yield* projects
556 .update({ ...input, commandId: yield* newCommandId() })
557 .pipe(Effect.mapError(projectFailure));
550 - return (yield* withSavedDefaultModel)(updated);
558 + return (yield* withSavedProjectSettings)(updated);
559 }),
560 ),
561 t3_project_delete: McpToolAccess.writesEnvironment((input) =>