@devries-cameron20 / t3code-1 / commits / e2cc34f1e4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

perf(server): skip unused diffs for user-written commit messages (#19605)

Microck committed Oct 18, 2026 at 13:15 UTC e2cc34f1e47a9a9f0798080ecbad44a196b2923c
5 files changed +39 -3
apps/server/src/git/GitManager.test.ts
+7
@@ -3804,6 +3804,13 @@ it.layer(layerGitManagerTest)("GitManager", (it) => {
3804 Effect.gen(function* () {
3805 const repoDir = yield* makeTempDir("t3code-git-manager-");
3806 yield* initRepo(repoDir);
3807 + // Patch generation would invoke this unavailable converter. A supplied
3808 + // message must commit without generating a patch it will not use.
3809 + NodeFS.writeFileSync(
3810 + NodePath.join(repoDir, ".git/info/attributes"),
3811 + "README.md diff=probe\n",
3812 + );
3813 + yield* runGit(repoDir, ["config", "diff.probe.textconv", "t3-missing-textconv-for-test"]);
3814 NodeFS.writeFileSync(NodePath.join(repoDir, "README.md"), "hello\ncustom\n");
3815 let generatedCount = 0;
3816
apps/server/src/git/GitManager.ts
+4 -2
@@ -2037,12 +2037,14 @@ export const make = Effect.gen(function* () {
2037 filePaths?: readonly string[];
2038 settings: SourceControlTextGenerationSettings;
2039 }) {
2040 - const context = yield* gitCore.prepareCommitContext(input.cwd, input.filePaths);
2040 + const customCommit = parseCustomCommitMessage(input.commitMessage ?? "");
2041 + const context = yield* gitCore.prepareCommitContext(input.cwd, input.filePaths, {
2042 + includePatch: customCommit === null,
2043 + });
2044 if (!context) {
2045 return null;
2046 }
2047
2045 - const customCommit = parseCustomCommitMessage(input.commitMessage ?? "");
2048 if (customCommit) {
2049 return {
2050 subject: customCommit.subject,
apps/server/src/vcs/GitVcsDriver.ts
+1
@@ -306,6 +306,7 @@ export class GitVcsDriver extends Context.Service<
306 readonly prepareCommitContext: (
307 cwd: string,
308 filePaths?: readonly string[],
309 + options?: { readonly includePatch?: boolean },
310 ) => Effect.Effect<GitPreparedCommitContext | null, GitCommandError>;
311 readonly commit: (
312 cwd: string,
apps/server/src/vcs/GitVcsDriverCore.test.ts
+23
@@ -3984,6 +3984,29 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
3984 });
3985
3986 describe("commit context", () => {
3987 + it.effect("can omit the patch while preserving change detection and the real index", () =>
3988 + Effect.gen(function* () {
3989 + const cwd = yield* makeTmpDir();
3990 + yield* initRepoWithCommit(cwd);
3991 + const driver = yield* GitVcsDriver.GitVcsDriver;
3992 + assert.isNull(yield* driver.prepareCommitContext(cwd, undefined, { includePatch: false }));
3993 + yield* writeTextFile(cwd, "selected.txt", "selected content\n");
3994 + yield* writeTextFile(cwd, "other.txt", "other content\n");
3995 + yield* git(cwd, ["add", "other.txt"]);
3996 + const before = yield* git(cwd, ["diff", "--cached"]);
3997 + const summaryOnly = yield* driver.prepareCommitContext(cwd, ["selected.txt"], {
3998 + includePatch: false,
3999 + });
4000 + assert.include(summaryOnly?.stagedSummary ?? "", "selected.txt");
4001 + assert.notInclude(summaryOnly?.stagedSummary ?? "", "other.txt");
4002 + assert.equal(summaryOnly?.stagedPatch, "");
4003 + const full = yield* driver.prepareCommitContext(cwd, ["selected.txt"]);
4004 + assert.equal(full?.stagedSummary, summaryOnly?.stagedSummary);
4005 + assert.include(full?.stagedPatch ?? "", "+selected content");
4006 + assert.equal(yield* git(cwd, ["diff", "--cached"]), before);
4007 + }),
4008 + );
4009 +
4010 it.effect("prepares selected files without staging and commits only those files", () =>
4011 Effect.gen(function* () {
4012 const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+4 -1
@@ -2235,7 +2235,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2235 });
2236
2237 const prepareCommitContext: GitVcsDriver.GitVcsDriver["Service"]["prepareCommitContext"] =
2238 - Effect.fn("prepareCommitContext")(function* (cwd, filePaths) {
2238 + Effect.fn("prepareCommitContext")(function* (cwd, filePaths, options) {
2239 return yield* Effect.scoped(
2240 Effect.gen(function* () {
2241 const indexValue = yield* runGitStdout(
@@ -2288,6 +2288,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2288 return null;
2289 }
2290
2291 + // A user-supplied message needs change detection, but no patch for generation.
2292 + if (options?.includePatch === false) return { stagedSummary, stagedPatch: "" };
2293 +
2294 const stagedPatch = yield* runGitStdoutWithOptions(
2295 "GitVcsDriver.prepareCommitContext.stagedPatch",
2296 cwd,