@devries-cameron20 / t3code Mirror · read-only / commits / 579a69eb77
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 25, 07:30 UTC

feat: add configurable model for git text generation (#1171)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Seif Almotaz Bellah committed Mar 18, 2026 at 00:33 UTC 579a69eb7756b2169d26299d36f936838db39caa
11 files changed +118 -9
apps/server/src/git/Layers/CodexTextGeneration.ts
+7 -2
@@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto";
3 import { Effect, FileSystem, Layer, Option, Path, Schema, Stream } from "effect";
4 import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
5
6 +import { DEFAULT_GIT_TEXT_GENERATION_MODEL } from "@t3tools/contracts";
7 import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
8
9 import { resolveAttachmentPath } from "../../attachmentStore.ts";
@@ -17,7 +18,6 @@ import {
18 TextGeneration,
19 } from "../Services/TextGeneration.ts";
20
20 -const CODEX_MODEL = "gpt-5.3-codex";
21 const CODEX_REASONING_EFFORT = "low";
22 const CODEX_TIMEOUT_MS = 180_000;
23
@@ -187,6 +187,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
187 outputSchemaJson,
188 imagePaths = [],
189 cleanupPaths = [],
190 + model,
191 }: {
192 operation: "generateCommitMessage" | "generatePrContent" | "generateBranchName";
193 cwd: string;
@@ -194,6 +195,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
195 outputSchemaJson: S;
196 imagePaths?: ReadonlyArray<string>;
197 cleanupPaths?: ReadonlyArray<string>;
198 + model?: string;
199 }): Effect.Effect<S["Type"], TextGenerationError, S["DecodingServices"]> =>
200 Effect.gen(function* () {
201 const schemaPath = yield* writeTempFile(
@@ -212,7 +214,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
214 "-s",
215 "read-only",
216 "--model",
215 - CODEX_MODEL,
217 + model ?? DEFAULT_GIT_TEXT_GENERATION_MODEL,
218 "--config",
219 `model_reasoning_effort="${CODEX_REASONING_EFFORT}"`,
220 "--output-schema",
@@ -353,6 +355,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
355 cwd: input.cwd,
356 prompt,
357 outputSchemaJson,
358 + ...(input.model ? { model: input.model } : {}),
359 }).pipe(
360 Effect.map(
361 (generated) =>
@@ -398,6 +401,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
401 title: Schema.String,
402 body: Schema.String,
403 }),
404 + ...(input.model ? { model: input.model } : {}),
405 }).pipe(
406 Effect.map(
407 (generated) =>
@@ -449,6 +453,7 @@ const makeCodexTextGeneration = Effect.gen(function* () {
453 branch: Schema.String,
454 }),
455 imagePaths,
456 + ...(input.model ? { model: input.model } : {}),
457 });
458
459 return {
apps/server/src/git/Layers/GitManager.ts
+11 -2
@@ -639,6 +639,7 @@ export const makeGitManager = Effect.gen(function* () {
639 /** When true, also produce a semantic feature branch name. */
640 includeBranch?: boolean;
641 filePaths?: readonly string[];
642 + model?: string;
643 }) =>
644 Effect.gen(function* () {
645 const context = yield* gitCore.prepareCommitContext(input.cwd, input.filePaths);
@@ -665,6 +666,7 @@ export const makeGitManager = Effect.gen(function* () {
666 stagedSummary: limitContext(context.stagedSummary, 8_000),
667 stagedPatch: limitContext(context.stagedPatch, 50_000),
668 ...(input.includeBranch ? { includeBranch: true } : {}),
669 + ...(input.model ? { model: input.model } : {}),
670 })
671 .pipe(Effect.map((result) => sanitizeCommitMessage(result)));
672
@@ -682,6 +684,7 @@ export const makeGitManager = Effect.gen(function* () {
684 commitMessage?: string,
685 preResolvedSuggestion?: CommitAndBranchSuggestion,
686 filePaths?: readonly string[],
687 + model?: string,
688 ) =>
689 Effect.gen(function* () {
690 const suggestion =
@@ -691,6 +694,7 @@ export const makeGitManager = Effect.gen(function* () {
694 branch,
695 ...(commitMessage ? { commitMessage } : {}),
696 ...(filePaths ? { filePaths } : {}),
697 + ...(model ? { model } : {}),
698 }));
699 if (!suggestion) {
700 return { status: "skipped_no_changes" as const };
@@ -704,7 +708,7 @@ export const makeGitManager = Effect.gen(function* () {
708 };
709 });
710
707 - const runPrStep = (cwd: string, fallbackBranch: string | null) =>
711 + const runPrStep = (cwd: string, fallbackBranch: string | null, model?: string) =>
712 Effect.gen(function* () {
713 const details = yield* gitCore.statusDetails(cwd);
714 const branch = details.branch ?? fallbackBranch;
@@ -748,6 +752,7 @@ export const makeGitManager = Effect.gen(function* () {
752 commitSummary: limitContext(rangeContext.commitSummary, 20_000),
753 diffSummary: limitContext(rangeContext.diffSummary, 20_000),
754 diffPatch: limitContext(rangeContext.diffPatch, 60_000),
755 + ...(model ? { model } : {}),
756 });
757
758 const bodyFile = path.join(tempDir, `t3code-pr-body-${process.pid}-${randomUUID()}.md`);
@@ -972,6 +977,7 @@ export const makeGitManager = Effect.gen(function* () {
977 branch: string | null,
978 commitMessage?: string,
979 filePaths?: readonly string[],
980 + model?: string,
981 ) =>
982 Effect.gen(function* () {
983 const suggestion = yield* resolveCommitAndBranchSuggestion({
@@ -980,6 +986,7 @@ export const makeGitManager = Effect.gen(function* () {
986 ...(commitMessage ? { commitMessage } : {}),
987 ...(filePaths ? { filePaths } : {}),
988 includeBranch: true,
989 + ...(model ? { model } : {}),
990 });
991 if (!suggestion) {
992 return yield* gitManagerError(
@@ -1028,6 +1035,7 @@ export const makeGitManager = Effect.gen(function* () {
1035 initialStatus.branch,
1036 input.commitMessage,
1037 input.filePaths,
1038 + input.textGenerationModel,
1039 );
1040 branchStep = result.branchStep;
1041 commitMessageForStep = result.resolvedCommitMessage;
@@ -1044,6 +1052,7 @@ export const makeGitManager = Effect.gen(function* () {
1052 commitMessageForStep,
1053 preResolvedCommitSuggestion,
1054 input.filePaths,
1055 + input.textGenerationModel,
1056 );
1057
1058 const push = wantsPush
@@ -1051,7 +1060,7 @@ export const makeGitManager = Effect.gen(function* () {
1060 : { status: "skipped_not_requested" as const };
1061
1062 const pr = wantsPr
1054 - ? yield* runPrStep(input.cwd, currentBranch)
1063 + ? yield* runPrStep(input.cwd, currentBranch, input.textGenerationModel)
1064 : { status: "skipped_not_requested" as const };
1065
1066 return {
apps/server/src/git/Services/TextGeneration.ts
+6
@@ -19,6 +19,8 @@ export interface CommitMessageGenerationInput {
19 stagedPatch: string;
20 /** When true, the model also returns a semantic branch name for the change. */
21 includeBranch?: boolean;
22 + /** Model to use for generation. Defaults to gpt-5.4-mini if not specified. */
23 + model?: string;
24 }
25
26 export interface CommitMessageGenerationResult {
@@ -35,6 +37,8 @@ export interface PrContentGenerationInput {
37 commitSummary: string;
38 diffSummary: string;
39 diffPatch: string;
40 + /** Model to use for generation. Defaults to gpt-5.4-mini if not specified. */
41 + model?: string;
42 }
43
44 export interface PrContentGenerationResult {
@@ -46,6 +50,8 @@ export interface BranchNameGenerationInput {
50 cwd: string;
51 message: string;
52 attachments?: ReadonlyArray<ChatAttachment> | undefined;
53 + /** Model to use for generation. Defaults to gpt-5.4-mini if not specified. */
54 + model?: string;
55 }
56
57 export interface BranchNameGenerationResult {
apps/server/src/orchestration/Layers/ProviderCommandReactor.ts
+2
@@ -1,6 +1,7 @@
1 import {
2 type ChatAttachment,
3 CommandId,
4 + DEFAULT_GIT_TEXT_GENERATION_MODEL,
5 EventId,
6 type OrchestrationEvent,
7 type ProviderModelOptions,
@@ -391,6 +392,7 @@ const make = Effect.gen(function* () {
392 cwd,
393 message: input.messageText,
394 ...(attachments.length > 0 ? { attachments } : {}),
395 + model: DEFAULT_GIT_TEXT_GENERATION_MODEL,
396 })
397 .pipe(
398 Effect.catch((error) =>
apps/web/src/appSettings.test.ts
+1
@@ -28,6 +28,7 @@ describe("getAppModelOptions", () => {
28
29 expect(options.map((option) => option.slug)).toEqual([
30 "gpt-5.4",
31 + "gpt-5.4-mini",
32 "gpt-5.3-codex",
33 "gpt-5.3-codex-spark",
34 "gpt-5.2-codex",
apps/web/src/appSettings.ts
+2 -1
@@ -1,6 +1,6 @@
1 import { useCallback } from "react";
2 import { Option, Schema } from "effect";
3 -import { type ProviderKind } from "@t3tools/contracts";
3 +import { TrimmedNonEmptyString, type ProviderKind } from "@t3tools/contracts";
4 import { getDefaultModel, getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
5 import { useLocalStorage } from "./hooks/useLocalStorage";
6
@@ -34,6 +34,7 @@ const AppSettingsSchema = Schema.Struct({
34 customCodexModels: Schema.Array(Schema.String).pipe(
35 Schema.withConstructorDefault(() => Option.some([])),
36 ),
37 + textGenerationModel: Schema.optional(TrimmedNonEmptyString),
38 });
39 export type AppSettings = typeof AppSettingsSchema.Type;
40 export interface AppModelOption {
apps/web/src/components/GitActionsControl.tsx
+7 -1
@@ -15,6 +15,7 @@ import {
15 resolveQuickAction,
16 summarizeGitResult,
17 } from "./GitActionsControl.logic";
18 +import { useAppSettings } from "~/appSettings";
19 import { Button } from "~/components/ui/button";
20 import { Checkbox } from "~/components/ui/checkbox";
21 import {
@@ -154,6 +155,7 @@ function GitQuickActionIcon({ quickAction }: { quickAction: GitQuickAction }) {
155 }
156
157 export default function GitActionsControl({ gitCwd, activeThreadId }: GitActionsControlProps) {
158 + const { settings } = useAppSettings();
159 const threadToastData = useMemo(
160 () => (activeThreadId ? { threadId: activeThreadId } : undefined),
161 [activeThreadId],
@@ -191,7 +193,11 @@ export default function GitActionsControl({ gitCwd, activeThreadId }: GitActions
193 const initMutation = useMutation(gitInitMutationOptions({ cwd: gitCwd, queryClient }));
194
195 const runImmediateGitActionMutation = useMutation(
194 - gitRunStackedActionMutationOptions({ cwd: gitCwd, queryClient }),
196 + gitRunStackedActionMutationOptions({
197 + cwd: gitCwd,
198 + queryClient,
199 + model: settings.textGenerationModel ?? null,
200 + }),
201 );
202 const pullMutation = useMutation(gitPullMutationOptions({ cwd: gitCwd, queryClient }));
203
apps/web/src/lib/gitReactQuery.ts
+2
@@ -112,6 +112,7 @@ export function gitCheckoutMutationOptions(input: {
112 export function gitRunStackedActionMutationOptions(input: {
113 cwd: string | null;
114 queryClient: QueryClient;
115 + model?: string | null;
116 }) {
117 return mutationOptions({
118 mutationKey: gitMutationKeys.runStackedAction(input.cwd),
@@ -134,6 +135,7 @@ export function gitRunStackedActionMutationOptions(input: {
135 ...(commitMessage ? { commitMessage } : {}),
136 ...(featureBranch ? { featureBranch } : {}),
137 ...(filePaths ? { filePaths } : {}),
138 + ...(input.model ? { model: input.model } : {}),
139 });
140 },
141 onSettled: async () => {
apps/web/src/routes/_chat.settings.tsx
+72 -2
@@ -1,9 +1,9 @@
1 import { createFileRoute } from "@tanstack/react-router";
2 import { useQuery } from "@tanstack/react-query";
3 import { useCallback, useState } from "react";
4 -import { type ProviderKind } from "@t3tools/contracts";
4 +import { type ProviderKind, DEFAULT_GIT_TEXT_GENERATION_MODEL } from "@t3tools/contracts";
5 import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
6 -import { MAX_CUSTOM_MODEL_LENGTH, useAppSettings } from "../appSettings";
6 +import { getAppModelOptions, MAX_CUSTOM_MODEL_LENGTH, useAppSettings } from "../appSettings";
7 import { resolveAndPersistPreferredEditor } from "../editorPreferences";
8 import { isElectron } from "../env";
9 import { useTheme } from "../hooks/useTheme";
@@ -112,6 +112,17 @@ function SettingsRouteView() {
112 const keybindingsConfigPath = serverConfigQuery.data?.keybindingsConfigPath ?? null;
113 const availableEditors = serverConfigQuery.data?.availableEditors;
114
115 + const gitTextGenerationModelOptions = getAppModelOptions(
116 + "codex",
117 + settings.customCodexModels,
118 + settings.textGenerationModel,
119 + );
120 + const selectedGitTextGenerationModelLabel =
121 + gitTextGenerationModelOptions.find(
122 + (option) =>
123 + option.slug === (settings.textGenerationModel ?? DEFAULT_GIT_TEXT_GENERATION_MODEL),
124 + )?.name ?? settings.textGenerationModel;
125 +
126 const openKeybindingsFile = useCallback(() => {
127 if (!keybindingsConfigPath) return;
128 setOpenKeybindingsError(null);
@@ -502,6 +513,65 @@ function SettingsRouteView() {
513 </div>
514 </section>
515
516 + <section className="rounded-2xl border border-border bg-card p-5">
517 + <div className="mb-4">
518 + <h2 className="text-sm font-medium text-foreground">Git</h2>
519 + <p className="mt-1 text-xs text-muted-foreground">
520 + Configure the model used for generating commit messages, PR titles, and branch
521 + names.
522 + </p>
523 + </div>
524 +
525 + <div className="flex flex-col gap-4 rounded-lg border border-border bg-background px-3 py-3 sm:flex-row sm:items-center sm:justify-between">
526 + <div className="min-w-0 flex-1">
527 + <p className="text-sm font-medium text-foreground">Text generation model</p>
528 + <p className="text-xs text-muted-foreground">
529 + Model used for auto-generated git content.
530 + </p>
531 + </div>
532 + <Select
533 + value={settings.textGenerationModel ?? DEFAULT_GIT_TEXT_GENERATION_MODEL}
534 + onValueChange={(value) => {
535 + if (value) {
536 + updateSettings({
537 + textGenerationModel: value,
538 + });
539 + }
540 + }}
541 + >
542 + <SelectTrigger
543 + className="w-full shrink-0 sm:w-48"
544 + aria-label="Git text generation model"
545 + >
546 + <SelectValue>{selectedGitTextGenerationModelLabel}</SelectValue>
547 + </SelectTrigger>
548 + <SelectPopup align="end">
549 + {gitTextGenerationModelOptions.map((option) => (
550 + <SelectItem key={option.slug} value={option.slug}>
551 + {option.name}
552 + </SelectItem>
553 + ))}
554 + </SelectPopup>
555 + </Select>
556 + </div>
557 +
558 + {settings.textGenerationModel !== defaults.textGenerationModel ? (
559 + <div className="mt-3 flex justify-end">
560 + <Button
561 + size="xs"
562 + variant="outline"
563 + onClick={() =>
564 + updateSettings({
565 + textGenerationModel: defaults.textGenerationModel,
566 + })
567 + }
568 + >
569 + Restore default
570 + </Button>
571 + </div>
572 + ) : null}
573 + </section>
574 +
575 <section className="rounded-2xl border border-border bg-card p-5">
576 <div className="mb-4">
577 <h2 className="text-sm font-medium text-foreground">Threads</h2>
packages/contracts/src/git.ts
+5 -1
@@ -1,5 +1,6 @@
1 -import { Schema } from "effect";
1 +import { Option, Schema } from "effect";
2 import { NonNegativeInt, PositiveInt, TrimmedNonEmptyString } from "./baseSchemas";
3 +import { DEFAULT_GIT_TEXT_GENERATION_MODEL } from "./model";
4
5 const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;
6
@@ -64,6 +65,9 @@ export const GitRunStackedActionInput = Schema.Struct({
65 filePaths: Schema.optional(
66 Schema.Array(TrimmedNonEmptyStringSchema).check(Schema.isMinLength(1)),
67 ),
68 + textGenerationModel: Schema.optional(TrimmedNonEmptyStringSchema).pipe(
69 + Schema.withConstructorDefault(() => Option.some(DEFAULT_GIT_TEXT_GENERATION_MODEL)),
70 + ),
71 });
72 export type GitRunStackedActionInput = typeof GitRunStackedActionInput.Type;
73
packages/contracts/src/model.ts
+3
@@ -23,6 +23,7 @@ type ModelOption = {
23 export const MODEL_OPTIONS_BY_PROVIDER = {
24 codex: [
25 { slug: "gpt-5.4", name: "GPT-5.4" },
26 + { slug: "gpt-5.4-mini", name: "GPT-5.4 Mini" },
27 { slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
28 { slug: "gpt-5.3-codex-spark", name: "GPT-5.3 Codex Spark" },
29 { slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
@@ -38,6 +39,8 @@ export const DEFAULT_MODEL_BY_PROVIDER = {
39 codex: "gpt-5.4",
40 } as const satisfies Record<ProviderKind, ModelSlug>;
41
42 +export const DEFAULT_GIT_TEXT_GENERATION_MODEL = "gpt-5.4-mini" as const;
43 +
44 export const MODEL_SLUG_ALIASES_BY_PROVIDER = {
45 codex: {
46 "5.4": "gpt-5.4",