@devries-cameron20 / t3code Mirror · read-only / commits / f22331240e
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 23, 23:00 UTC

fix(server): generate PR diffs from branch changes (#13170)

Yash Singh committed Sep 22, 2026 at 19:40 UTC f22331240ed1a97fae560e314bffb75fe39db8ca
2 files changed +22 -5
apps/server/src/git/GitManager.test.ts
+16 -1
@@ -4071,7 +4071,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
4071 }),
4072 );
4073
4074 - it.effect("generates PR content against the remote base when the local base is stale", () =>
4074 + it.effect("generates PR content from branch changes when the remote base advances", () =>
4075 Effect.gen(function* () {
4076 const repoDir = yield* makeTempDir("t3code-git-manager-");
4077 yield* initRepo(repoDir);
@@ -4103,7 +4103,15 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
4103 yield* runGit(repoDir, ["push", "-u", "origin", "feature/remote-base"]);
4104 yield* runGit(repoDir, ["config", "branch.feature/remote-base.gh-merge-base", "main"]);
4105
4106 + NodeFS.writeFileSync(NodePath.join(peerDir, "later-main.txt"), "unrelated\n");
4107 + yield* runGit(peerDir, ["add", "later-main.txt"]);
4108 + yield* runGit(peerDir, ["commit", "-m", "Later main commit"]);
4109 + yield* runGit(peerDir, ["push", "origin", "main"]);
4110 + yield* runGit(repoDir, ["fetch", "origin"]);
4111 +
4112 let generatedCommitSummary = "";
4113 + let generatedDiffSummary = "";
4114 + let generatedDiffPatch = "";
4115 const { manager } = yield* makeManager({
4116 ghScenario: {
4117 prListSequence: ["[]", "[]"],
@@ -4111,6 +4119,8 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
4119 textGeneration: {
4120 generatePrContent: (input) => {
4121 generatedCommitSummary = input.commitSummary;
4122 + generatedDiffSummary = input.diffSummary;
4123 + generatedDiffPatch = input.diffPatch;
4124 return Effect.succeed({ title: "Feature PR", body: "Feature body" });
4125 },
4126 },
@@ -4124,6 +4134,11 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
4134 expect(result.pr.status).toBe("created");
4135 expect(generatedCommitSummary).toContain("Feature commit");
4136 expect(generatedCommitSummary).not.toContain("Remote base commit");
4137 + expect(generatedCommitSummary).not.toContain("Later main commit");
4138 + expect(generatedDiffSummary).toContain("feature.txt");
4139 + expect(generatedDiffSummary).not.toContain("later-main.txt");
4140 + expect(generatedDiffPatch).toContain("feature.txt");
4141 + expect(generatedDiffPatch).not.toContain("later-main.txt");
4142 }),
4143 );
4144
apps/server/src/vcs/GitVcsDriverCore.ts
+6 -4
@@ -2285,13 +2285,15 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2285 const readRangeContext: GitVcsDriver.GitVcsDriver["Service"]["readRangeContext"] = Effect.fn(
2286 "readRangeContext",
2287 )(function* (cwd, baseRef) {
2288 - const range = `${baseRef}..HEAD`;
2288 + const commitRange = `${baseRef}..HEAD`;
2289 + // PR diffs start at the common ancestor when the base branch has advanced.
2290 + const diffRange = `${baseRef}...HEAD`;
2291 const [commitSummary, diffSummary, diffPatch] = yield* Effect.all(
2292 [
2293 runGitStdoutWithOptions(
2294 "GitVcsDriver.readRangeContext.log",
2295 cwd,
2294 - ["log", "--oneline", range],
2296 + ["log", "--oneline", commitRange],
2297 {
2298 maxOutputBytes: RANGE_COMMIT_SUMMARY_MAX_OUTPUT_BYTES,
2299 appendTruncationMarker: true,
@@ -2300,7 +2302,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2302 runGitStdoutWithOptions(
2303 "GitVcsDriver.readRangeContext.diffStat",
2304 cwd,
2303 - ["diff", "--stat", range],
2305 + ["diff", "--stat", diffRange],
2306 {
2307 maxOutputBytes: RANGE_DIFF_SUMMARY_MAX_OUTPUT_BYTES,
2308 appendTruncationMarker: true,
@@ -2309,7 +2311,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
2311 runGitStdoutWithOptions(
2312 "GitVcsDriver.readRangeContext.diffPatch",
2313 cwd,
2312 - ["diff", "--no-ext-diff", "--patch", "--minimal", range],
2314 + ["diff", "--no-ext-diff", "--patch", "--minimal", diffRange],
2315 {
2316 maxOutputBytes: RANGE_DIFF_PATCH_MAX_OUTPUT_BYTES,
2317 appendTruncationMarker: true,