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

fix(server): preserve byte-order marks in Git diff contents (#23421)

Aditya Garud committed Oct 31, 2026 at 02:16 UTC 14d56e18f94b73fc5a1cecf2078d8530ab1304ad
2 files changed +23 -2
apps/server/src/vcs/GitVcsDriverCore.test.ts
+21
@@ -2536,6 +2536,27 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
2536 }),
2537 );
2538
2539 + it.effect.each([
2540 + { scenario: "kept", before: "\uFEFFold\n", after: "\uFEFFnew\n" },
2541 + { scenario: "added", before: "same\n", after: "\uFEFFsame\n" },
2542 + { scenario: "removed", before: "\uFEFFsame\n", after: "same\n" },
2543 + ])("preserves byte-order marks in diff expansion when $scenario", ({ before, after }) =>
2544 + Effect.gen(function* () {
2545 + const cwd = yield* makeTmpDir();
2546 + yield* initRepoWithCommit(cwd);
2547 + yield* writeTextFile(cwd, "README.md", before);
2548 + yield* git(cwd, ["commit", "-am", "write original contents"]);
2549 + yield* writeTextFile(cwd, "README.md", after);
2550 + const driver = yield* GitVcsDriver.GitVcsDriver;
2551 +
2552 + const contents = yield* driver.getReviewDiffFileContents(
2553 + makeReviewDiffFileContentsInput(cwd),
2554 + );
2555 +
2556 + assert.deepStrictEqual(contents, { oldContents: before, newContents: after });
2557 + }),
2558 + );
2559 +
2560 it.effect("reads a base ref that looks like an option as a revision", () =>
2561 Effect.gen(function* () {
2562 const cwd = yield* makeTmpDir();
apps/server/src/vcs/GitVcsDriverCore.ts
+2 -2
@@ -844,7 +844,7 @@ const collectOutput = Effect.fnUntraced(function* (
844 onLine: ((line: string) => Effect.Effect<void, never>) | undefined,
845 keepLineCallbacksAfterTruncation = false,
846 ): Effect.fn.Return<{ readonly text: string; readonly truncated: boolean }, GitCommandError> {
847 - const decoder = new TextDecoder();
847 + const decoder = new TextDecoder("utf-8", { ignoreBOM: true });
848 const lineDecoder = keepLineCallbacksAfterTruncation && onLine ? new TextDecoder() : null;
849 let bytes = 0;
850 let text = "";
@@ -3562,7 +3562,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
3562 if (bytes.includes(0)) {
3563 return yield* fileError("fs.readFile", `Cannot expand binary file '${input.newPath}'.`);
3564 }
3565 - return new TextDecoder("utf-8").decode(bytes);
3565 + return new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
3566 });
3567
3568 const getReviewDiffFileContents = Effect.fn("getReviewDiffFileContents")(function* (