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, 19:45 UTC
Use gpt-5.3-codex-spark for git text generation
- Add `gpt-5.3-codex-spark` with medium reasoning effort to commit/PR generation calls - Inject process runner into `CodexTextGenerator` and add tests for model selection and failure passthrough - Update PR modal to use status/result PR URLs and keep a single Open PR action path
Julius Marminge committed
Feb 12, 2026 at 14:42 UTC
8f6cd244e79913b4b55daf8ed14c7573726dfe62
3 files changed
+162
-21
apps/server/src/codexTextGenerator.test.ts
new
+123
@@ -0,0 +1,123 @@
1
+import fs from "node:fs/promises";
2
+
3
+import { describe, expect, it } from "vitest";
4
+
5
+import { CodexTextGenerator } from "./codexTextGenerator";
6
+import type { ProcessRunOptions, ProcessRunResult } from "./processRunner";
7
+
8
+type ProcessRunner = (
9
+ command: string,
10
+ args: readonly string[],
11
+ options?: ProcessRunOptions,
12
+) => Promise<ProcessRunResult>;
13
+
14
+function getArgValue(args: readonly string[], flag: string): string {
15
+ const index = args.indexOf(flag);
16
+ if (index < 0 || index + 1 >= args.length) {
17
+ throw new Error(`Missing argument value for ${flag}`);
18
+ }
19
+ const value = args[index + 1];
20
+ if (!value) {
21
+ throw new Error(`Missing argument value for ${flag}`);
22
+ }
23
+ return value;
24
+}
25
+
26
+function okResult(): ProcessRunResult {
27
+ return {
28
+ stdout: "",
29
+ stderr: "",
30
+ code: 0,
31
+ signal: null,
32
+ timedOut: false,
33
+ };
34
+}
35
+
36
+function commitInput() {
37
+ return {
38
+ cwd: process.cwd(),
39
+ branch: "feat/example",
40
+ stagedSummary: "M apps/server/src/gitManager.ts",
41
+ stagedPatch: "diff --git a/file b/file",
42
+ };
43
+}
44
+
45
+describe("CodexTextGenerator", () => {
46
+ it("uses gpt-5.3-codex-spark when available with medium reasoning effort", async () => {
47
+ const models: string[] = [];
48
+ const configs: string[] = [];
49
+
50
+ const runner: ProcessRunner = async (command, args) => {
51
+ expect(command).toBe("codex");
52
+ models.push(getArgValue(args, "--model"));
53
+ configs.push(getArgValue(args, "--config"));
54
+
55
+ const outputPath = getArgValue(args, "--output-last-message");
56
+ await fs.writeFile(
57
+ outputPath,
58
+ JSON.stringify({
59
+ subject: "Add stacked git actions menu behavior",
60
+ body: "- Keep menu actions visible\n- Improve disabled states",
61
+ }),
62
+ "utf8",
63
+ );
64
+ return okResult();
65
+ };
66
+
67
+ const generator = new CodexTextGenerator({ runProcess: runner });
68
+ const result = await generator.generateCommitMessage(commitInput());
69
+
70
+ expect(result.subject).toBe("Add stacked git actions menu behavior");
71
+ expect(models).toEqual(["gpt-5.3-codex-spark"]);
72
+ expect(configs).toEqual(['model_reasoning_effort="medium"']);
73
+ });
74
+
75
+ it("uses gpt-5.3-codex-spark for PR content generation", async () => {
76
+ const models: string[] = [];
77
+
78
+ const runner: ProcessRunner = async (command, args) => {
79
+ expect(command).toBe("codex");
80
+ models.push(getArgValue(args, "--model"));
81
+
82
+ const outputPath = getArgValue(args, "--output-last-message");
83
+ await fs.writeFile(
84
+ outputPath,
85
+ JSON.stringify({
86
+ title: "Improve Git action modal behavior",
87
+ body: "## Summary\n- Update PR generation model\n\n## Testing\n- Not run",
88
+ }),
89
+ "utf8",
90
+ );
91
+ return okResult();
92
+ };
93
+
94
+ const generator = new CodexTextGenerator({ runProcess: runner });
95
+ const result = await generator.generatePrContent({
96
+ cwd: process.cwd(),
97
+ baseBranch: "main",
98
+ headBranch: "feat/example",
99
+ commitSummary: "abc123 Update model",
100
+ diffSummary: "1 file changed",
101
+ diffPatch: "diff --git a/file b/file",
102
+ });
103
+
104
+ expect(result.title).toBe("Improve Git action modal behavior");
105
+ expect(models).toEqual(["gpt-5.3-codex-spark"]);
106
+ });
107
+
108
+ it("propagates generation failures without retrying a second model", async () => {
109
+ const models: string[] = [];
110
+
111
+ const runner: ProcessRunner = async (_command, args) => {
112
+ models.push(getArgValue(args, "--model"));
113
+ throw new Error("Request timed out while contacting Codex.");
114
+ };
115
+
116
+ const generator = new CodexTextGenerator({ runProcess: runner });
117
+
118
+ await expect(generator.generateCommitMessage(commitInput())).rejects.toThrow(
119
+ "Request timed out while contacting Codex.",
120
+ );
121
+ expect(models).toEqual(["gpt-5.3-codex-spark"]);
122
+ });
123
+});
apps/server/src/codexTextGenerator.ts
+33
-3
@@ -10,7 +10,20 @@ import type {
10
PrContentGenerationResult,
11
TextGenerationService,
12
} from "./coreServices";
13
-import { runProcess } from "./processRunner";
13
+import {
14
+ type ProcessRunOptions,
15
+ type ProcessRunResult,
16
+ runProcess,
17
+} from "./processRunner";
18
+
19
+type ProcessRunner = (
20
+ command: string,
21
+ args: readonly string[],
22
+ options?: ProcessRunOptions,
23
+) => Promise<ProcessRunResult>;
24
+
25
+const CODEX_MODEL = "gpt-5.3-codex-spark";
26
+const CODEX_REASONING_EFFORT = "medium";
27
28
const COMMIT_OUTPUT_SCHEMA_JSON = {
29
type: "object",
@@ -107,11 +120,13 @@ async function runCodexJson<T>({
120
prompt,
121
outputSchemaJson,
122
parse,
123
+ run,
124
}: {
125
cwd: string;
126
prompt: string;
127
outputSchemaJson: object;
128
parse: (raw: unknown) => T;
129
+ run: ProcessRunner;
130
}): Promise<T> {
131
const schemaPath = await writeTempFile(
132
"codex-schema",
@@ -121,14 +136,17 @@ async function runCodexJson<T>({
136
137
try {
138
outputPath = await writeTempFile("codex-output", "");
124
-
125
- await runProcess(
139
+ await run(
140
"codex",
141
[
142
"exec",
143
"--ephemeral",
144
"-s",
145
"read-only",
146
+ "--model",
147
+ CODEX_MODEL,
148
+ "--config",
149
+ `model_reasoning_effort="${CODEX_REASONING_EFFORT}"`,
150
"--output-schema",
151
schemaPath,
152
"--output-last-message",
@@ -163,7 +181,17 @@ async function runCodexJson<T>({
181
}
182
}
183
184
+interface CodexTextGeneratorDeps {
185
+ runProcess?: ProcessRunner;
186
+}
187
+
188
export class CodexTextGenerator implements TextGenerationService {
189
+ private readonly run: ProcessRunner;
190
+
191
+ constructor(deps: CodexTextGeneratorDeps = {}) {
192
+ this.run = deps.runProcess ?? runProcess;
193
+ }
194
+
195
async generateCommitMessage(
196
input: CommitMessageGenerationInput,
197
): Promise<CommitMessageGenerationResult> {
@@ -189,6 +217,7 @@ export class CodexTextGenerator implements TextGenerationService {
217
prompt,
218
outputSchemaJson: COMMIT_OUTPUT_SCHEMA_JSON,
219
parse: (raw) => parseCommitOutput(raw),
220
+ run: this.run,
221
});
222
223
return {
@@ -227,6 +256,7 @@ export class CodexTextGenerator implements TextGenerationService {
256
prompt,
257
outputSchemaJson: PR_OUTPUT_SCHEMA_JSON,
258
parse: (raw) => parsePrOutput(raw),
259
+ run: this.run,
260
});
261
262
return {
apps/web/src/components/GitActionsControl.tsx
+6
-18
@@ -291,6 +291,7 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
291
[gitModalActionOptions, gitModalSelectedAction],
292
);
293
const visibleGitActionError = gitActionError ?? gitStatusError?.message;
294
+ const gitModalOpenPrUrl = gitModalResult?.pr.url ?? gitStatus?.openPr?.url ?? null;
295
const gitModalHasProgress = gitModalProgress.length > 0;
296
const gitModalSelectionMode = !gitModalHasProgress && gitModalResult === null;
297
const gitModalSteps = gitModalProgress;
@@ -348,19 +349,19 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
349
});
350
}, [api, gitStatus?.openPr?.url]);
351
351
- const openPrFromResult = useCallback(() => {
352
+ const openPrFromModal = useCallback(() => {
353
if (!api) {
354
setGitModalError("Link opening is unavailable.");
355
return;
356
}
357
357
- const prUrl = gitModalResult?.pr.url ?? null;
358
+ const prUrl = gitModalOpenPrUrl;
359
if (!prUrl) return;
360
361
void api.shell.openExternal(prUrl).catch((error) => {
362
setGitModalError(error instanceof Error ? error.message : "Unable to open PR link.");
363
});
363
- }, [api, gitModalResult?.pr.url]);
364
+ }, [api, gitModalOpenPrUrl]);
365
366
const runGitAction = useCallback(async () => {
367
if (!api || !gitCwd || !isGitModalOpen) return;
@@ -784,25 +785,12 @@ export default function GitActionsControl({ api, gitCwd }: GitActionsControlProp
785
{gitModalError ?? visibleGitActionError}
786
</div>
787
)}
787
- {gitModalResult?.pr.url && (
788
- <div className="mt-4 rounded-lg border border-border bg-card/40 px-3 py-2 text-xs text-muted-foreground/80">
789
- PR:{" "}
790
- <a
791
- href={gitModalResult.pr.url}
792
- target="_blank"
793
- rel="noreferrer"
794
- className="text-foreground underline underline-offset-2"
795
- >
796
- {gitModalResult.pr.url}
797
- </a>
798
- </div>
799
- )}
788
<div className="mt-6 flex justify-end gap-2">
801
- {gitModalResult?.pr.url && (
789
+ {gitModalResult && gitModalOpenPrUrl && (
790
<button
791
type="button"
792
className="rounded-xl border border-border px-4 py-2 text-sm text-foreground transition-colors duration-150 hover:bg-accent disabled:cursor-not-allowed disabled:opacity-60"
805
- onClick={openPrFromResult}
793
+ onClick={openPrFromModal}
794
disabled={isGitActionRunning}
795
>
796
Open PR