@devries-cameron20 / t3code Mirror · read-only / commits / 78201b07d0
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 22, 00:45 UTC

fix(server): text generation fallback respects project provider settings (#33741)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Muzammil Hussain committed Nov 11, 2026 at 02:33 UTC 78201b07d0b68dc9d410c14a1a3fe13d0b20ed03
7 files changed +52 -11
apps/server/src/git/GitManager.ts
+5
@@ -114,6 +114,7 @@ export type GitBranchPullRequest = NonNullable<VcsStatusResult["pr"]> & {
114
115 interface SourceControlTextGenerationSettings {
116 readonly modelSelection: ModelSelection;
117 + readonly projectId: ProjectId | null;
118 readonly style: SourceControlWritingStyleSettings;
119 }
120
@@ -2156,6 +2157,7 @@ export const make = Effect.gen(function* () {
2157 ...(input.includeBranch ? { includeBranch: true } : {}),
2158 ...(policy ? { policy } : {}),
2159 modelSelection: input.settings.modelSelection,
2160 + projectId: input.settings.projectId,
2161 })
2162 .pipe(Effect.map((result) => sanitizeCommitMessage(result)));
2163
@@ -2386,6 +2388,7 @@ export const make = Effect.gen(function* () {
2388 ...(threadContext ? { threadContext } : {}),
2389 ...(policy ? { policy } : {}),
2390 modelSelection: settings.modelSelection,
2391 + projectId: settings.projectId,
2392 });
2393
2394 const bodyFile = path.join(
@@ -3231,6 +3234,7 @@ export const make = Effect.gen(function* () {
3234 settings.sourceControlWriterModelSelection === null
3235 ? Effect.succeed({
3236 modelSelection: settings.textGenerationModelSelection,
3237 + projectId,
3238 style: settings.sourceControlWritingStyle,
3239 })
3240 : providerRegistry.getProviders.pipe(
@@ -3240,6 +3244,7 @@ export const make = Effect.gen(function* () {
3244 providers,
3245 projectId,
3246 ),
3247 + projectId,
3248 style: settings.sourceControlWritingStyle,
3249 })),
3250 ),
apps/server/src/orchestration-v2/ThreadLaunchService.ts
+1
@@ -361,6 +361,7 @@ const make = Effect.gen(function* () {
361 attachments: message.attachments,
362 ...(message.context ? { context: message.context } : {}),
363 modelSelection,
364 + projectId: input.projectId,
365 })
366 .pipe(
367 Effect.map((result) => ({
apps/server/src/orchestration-v2/ThreadTitleRegenerationService.ts
+1
@@ -175,6 +175,7 @@ const make = Effect.gen(function* () {
175 ...(inherited === undefined ? {} : { forkSource: inherited }),
176 instructions: settings.threadTitleInstructions,
177 modelSelection: settings.textGenerationModelSelection,
178 + projectId: projection.thread.projectId,
179 });
180 const generatedTitle = result.title.trim();
181 return generatedTitle === "New thread" ||
apps/server/src/pullRequest/PullRequestReviewGuideService.ts
+1
@@ -403,6 +403,7 @@ const make = Effect.gen(function* () {
403 ...reviewGuideInputFromPullRequest(detail, activity, checkout.baseCommit),
404 cwd: checkout.path,
405 modelSelection,
406 + projectId: input.projectId,
407 instructions: projectSettings.reviewGuideInstructions,
408 stack: checkout.stack,
409 }),
apps/server/src/textGeneration/CodexTextGeneration.test.ts
+13 -1
@@ -1,5 +1,6 @@
1 import {
2 DEFAULT_TEXT_GENERATION_MODEL_BY_PROVIDER,
3 + ProjectId,
4 ProviderDriverKind,
5 type ModelSelection,
6 type ServerProvider,
@@ -542,6 +543,7 @@ const PREFLIGHT_PRIMARY_STATES = [
543 "pending",
544 "exhausted",
545 "not installed",
546 + "not installed, fallback disabled for project",
547 "signed out",
548 "signed out, fallback failed",
549 ] as const;
@@ -550,6 +552,7 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
552 Effect.gen(function* () {
553 const primary = ProviderInstanceId.make("codex");
554 const fallback = ProviderInstanceId.make("claude_work");
555 + const projectId = ProjectId.make("project-a");
556 const selection = {
557 instanceId: primary,
558 model: "chat-model",
@@ -573,7 +576,7 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
576 ...(primaryState === "pending" && instanceId === primary
577 ? { installed: false, status: "warning", auth: { status: "unknown" } }
578 : {}),
576 - ...(primaryState === "not installed" && instanceId === primary
579 + ...(primaryState.startsWith("not installed") && instanceId === primary
580 ? { installed: false, status: "error", auth: { status: "unknown" } }
581 : {}),
582 ...(primaryState.startsWith("signed out") && instanceId === primary
@@ -625,6 +628,13 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
628 providerInstances: {
629 [fallback]: { driver: ProviderDriverKind.make("claudeAgent"), config: {} },
630 },
631 + ...(primaryState === "not installed, fallback disabled for project"
632 + ? {
633 + projectSettingsOverrides: {
634 + [projectId]: { providerInstances: { [fallback]: { enabled: false } } },
635 + },
636 + }
637 + : {}),
638 }),
639 Layer.mock(TextGenerators.TextGenerators)({ runner: () => Effect.undefined }),
640 Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
@@ -639,11 +649,13 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
649 message: "hello",
650 linkedContext: "",
651 modelSelection: selection,
652 + projectId,
653 }),
654 ).toEqual({ title: "Generated title" });
655 expect(calls).toEqual([
656 primaryState === "ready" ||
657 primaryState === "pending" ||
658 + primaryState === "not installed, fallback disabled for project" ||
659 primaryState === "signed out, fallback failed"
660 ? selection
661 : {
apps/server/src/textGeneration/TextGeneration.ts
+25 -10
@@ -1,7 +1,7 @@
1 import * as Context from "effect/Context";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 -import type { ModelSelection, ProviderInstanceId } from "@t3tools/contracts";
4 +import type { ModelSelection, ProjectId, ProviderInstanceId } from "@t3tools/contracts";
5 import {
6 isProviderAvailable,
7 isProviderTextGenerationCapable,
@@ -81,6 +81,7 @@ export const make = Effect.gen(function* () {
81 const generate = Effect.fn("TextGeneration.generate")(function* <A>(
82 operation: TextGenerationOp,
83 selection: ModelSelection,
84 + projectId: ProjectId | null | undefined,
85 invoke: (
86 service: ProviderTextGeneration,
87 modelSelection: ModelSelection,
@@ -129,7 +130,7 @@ export const make = Effect.gen(function* () {
130 return (
131 instanceId !== selection.instanceId &&
132 provider?.enabled === true &&
132 - resolveProjectProviderInstanceEnabled(settings, null, instanceId) &&
133 + resolveProjectProviderInstanceEnabled(settings, projectId ?? null, instanceId) &&
134 provider.installed &&
135 provider.auth.status !== "unauthenticated" &&
136 provider.status !== "error" &&
@@ -155,23 +156,35 @@ export const make = Effect.gen(function* () {
156 });
157 return TextGeneration.of({
158 generateCommitMessage: Effect.fn("TextGeneration.generateCommitMessage")(function (input) {
158 - return generate("generateCommitMessage", input.modelSelection, (service, modelSelection) =>
159 - service.generateCommitMessage({ ...input, modelSelection }),
159 + return generate(
160 + "generateCommitMessage",
161 + input.modelSelection,
162 + input.projectId,
163 + (service, modelSelection) => service.generateCommitMessage({ ...input, modelSelection }),
164 );
165 }),
166 generatePrContent: Effect.fn("TextGeneration.generatePrContent")(function (input) {
163 - return generate("generatePrContent", input.modelSelection, (service, modelSelection) =>
164 - service.generatePrContent({ ...input, modelSelection }),
167 + return generate(
168 + "generatePrContent",
169 + input.modelSelection,
170 + input.projectId,
171 + (service, modelSelection) => service.generatePrContent({ ...input, modelSelection }),
172 );
173 }),
174 generateBranchName: Effect.fn("TextGeneration.generateBranchName")(function (input) {
168 - return generate("generateBranchName", input.modelSelection, (service, modelSelection) =>
169 - service.generateBranchName({ ...input, modelSelection }),
175 + return generate(
176 + "generateBranchName",
177 + input.modelSelection,
178 + input.projectId,
179 + (service, modelSelection) => service.generateBranchName({ ...input, modelSelection }),
180 );
181 }),
182 generateReviewGuide: Effect.fn("TextGeneration.generateReviewGuide")(function (input) {
173 - return generate("generateReviewGuide", input.modelSelection, (service, modelSelection) =>
174 - service.generateReviewGuide({ ...input, modelSelection }),
183 + return generate(
184 + "generateReviewGuide",
185 + input.modelSelection,
186 + input.projectId,
187 + (service, modelSelection) => service.generateReviewGuide({ ...input, modelSelection }),
188 );
189 }),
190 generateTranscriptionPostProcessing: Effect.fn(
@@ -180,6 +193,7 @@ export const make = Effect.gen(function* () {
193 return generate(
194 "generateTranscriptionPostProcessing",
195 input.modelSelection,
196 + null,
197 (service, modelSelection) =>
198 service.generateTranscriptionPostProcessing({ ...input, modelSelection }),
199 );
@@ -188,6 +202,7 @@ export const make = Effect.gen(function* () {
202 return generate(
203 "generateThreadTitle",
204 input.modelSelection,
205 + input.projectId,
206 (textGeneration, modelSelection) =>
207 Effect.gen(function* () {
208 const linkedContext =
packages/provider-core/src/server/textGeneration.ts
+6
@@ -2,6 +2,7 @@ import type {
2 BranchNamingOptions,
3 ChatAttachment,
4 ModelSelection,
5 + ProjectId,
6 PullRequestReviewGuide,
7 TextGenerationError,
8 } from "@t3tools/contracts";
@@ -18,6 +19,7 @@ export interface CommitMessageGenerationInput {
19 includeBranch?: boolean;
20 policy?: TextGenerationPolicy | undefined;
21 modelSelection: ModelSelection;
22 + projectId?: ProjectId | null | undefined;
23 }
24
25 export interface CommitMessageGenerationResult {
@@ -37,6 +39,7 @@ export interface PrContentGenerationInput {
39 threadContext?: string | undefined;
40 policy?: TextGenerationPolicy | undefined;
41 modelSelection: ModelSelection;
42 + projectId?: ProjectId | null | undefined;
43 }
44
45 export interface PrContentGenerationResult {
@@ -50,6 +53,7 @@ export interface BranchNameGenerationInput {
53 message: string;
54 attachments?: ReadonlyArray<ChatAttachment> | undefined;
55 modelSelection: ModelSelection;
56 + projectId?: ProjectId | null | undefined;
57 }
58
59 export interface BranchNameGenerationResult {
@@ -65,6 +69,7 @@ export interface ThreadTitleGenerationInput {
69 attachments?: ReadonlyArray<ChatAttachment> | undefined;
70 instructions?: string | undefined;
71 modelSelection: ModelSelection;
72 + projectId?: ProjectId | null | undefined;
73 }
74
75 export interface ThreadTitleGenerationResult {
@@ -90,6 +95,7 @@ export interface ReviewGuideGenerationInput {
95 instructions?: string | undefined;
96 stack?: ReadonlyArray<ReviewGuideStackLayer> | undefined;
97 modelSelection: ModelSelection;
98 + projectId?: ProjectId | null | undefined;
99 }
100
101 export type ReviewGuideGenerationResult = Omit<