The best way to control Claude Code, Codex and more from any computer or phone
perf(server): skip unused Git output line parsing (#23953)
Co-authored-by: Jet <jet@extremist.software> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Julius Marminge committed
Oct 22, 2026 at 23:29 UTC
9a6380263b0304494151d297a53210c10b1d07ef
2 files changed
+82
-5
apps/server/src/vcs/GitVcsDriverCore.test.ts
+73
@@ -87,6 +87,79 @@ const makeFailedHandle = (stderr: string) =>
87
stderr: Stream.encodeText(Stream.make(stderr)),
88
});
89
90
+describe("Git output collection", () => {
91
+ // Git writes in arbitrary chunk sizes; one byte per chunk splits every
92
+ // multibyte character across reads.
93
+ const byteChunks = (text: string) =>
94
+ Stream.fromIterable(Array.from(new TextEncoder().encode(text), (byte) => Uint8Array.of(byte)));
95
+ const makeDriver = (output: { stdout?: string; stderr?: string }) =>
96
+ makeGitVcsDriverCore().pipe(
97
+ Effect.provideService(
98
+ ChildProcessSpawner.ChildProcessSpawner,
99
+ ChildProcessSpawner.make(() =>
100
+ Effect.succeed(
101
+ ChildProcessSpawner.makeHandle({
102
+ ...makeSuccessfulHandle(""),
103
+ stdout: byteChunks(output.stdout ?? ""),
104
+ stderr: byteChunks(output.stderr ?? ""),
105
+ }),
106
+ ),
107
+ ),
108
+ ),
109
+ );
110
+
111
+ it.effect("returns the same split UTF-8 and NUL output with and without line callbacks", () =>
112
+ Effect.gen(function* () {
113
+ const stdout = "a\\b\0雪\nlast ";
114
+ const stderr = "Receiving é\r\nUpdating 雪\rdone";
115
+ const driver = yield* makeDriver({ stdout, stderr });
116
+ const input = { operation: "test.chunkedGitOutput", cwd: "/repo", args: ["status"] };
117
+ const expected = {
118
+ exitCode: 0,
119
+ stdout,
120
+ stderr,
121
+ stdoutTruncated: false,
122
+ stderrTruncated: false,
123
+ };
124
+
125
+ assert.deepEqual(yield* driver.execute(input), expected);
126
+
127
+ const stdoutLines: string[] = [];
128
+ const stderrLines: string[] = [];
129
+ const withCallbacks = yield* driver.execute({
130
+ ...input,
131
+ progress: {
132
+ onStdoutLine: (line) => Effect.sync(() => void stdoutLines.push(line)),
133
+ onStderrLine: (line) => Effect.sync(() => void stderrLines.push(line)),
134
+ },
135
+ });
136
+ assert.deepEqual(withCallbacks, expected);
137
+ assert.deepEqual(stdoutLines, ["a\\b\0雪", "last "]);
138
+ assert.deepEqual(stderrLines, ["Receiving é", "Updating 雪", "done"]);
139
+ }).pipe(Effect.provide(layerServerConfig.pipe(Layer.provideMerge(NodeServices.layer)))),
140
+ );
141
+
142
+ it.effect("caps output without line callbacks", () =>
143
+ Effect.gen(function* () {
144
+ const driver = yield* makeDriver({ stderr: "é雪\rdone" });
145
+ const input = {
146
+ operation: "test.cappedGitOutput",
147
+ cwd: "/repo",
148
+ args: ["status"],
149
+ maxOutputBytes: 3,
150
+ };
151
+
152
+ const truncated = yield* driver.execute({ ...input, appendTruncationMarker: true });
153
+ assert.equal(truncated.stderr, "é\uFFFD");
154
+ assert.isTrue(truncated.stderrTruncated);
155
+
156
+ const error = yield* driver.execute(input).pipe(Effect.flip);
157
+ assert.equal(error.outputLength, 4);
158
+ assert.include(error.detail, "exceeded 3 bytes");
159
+ }).pipe(Effect.provide(layerServerConfig.pipe(Layer.provideMerge(NodeServices.layer)))),
160
+ );
161
+});
162
+
163
const makeTmpDir = (
164
prefix = "git-vcs-driver-test-",
165
): Effect.Effect<string, PlatformError.PlatformError, FileSystem.FileSystem | Scope.Scope> =>
apps/server/src/vcs/GitVcsDriverCore.ts
+9
-5
@@ -900,8 +900,10 @@ const collectOutput = Effect.fnUntraced(function* (
900
901
const decoded = decoder.decode(chunkToDecode, { stream: !truncated });
902
text += decoded;
903
- lineBuffer += lineDecoder ? lineDecoder.decode(chunk, { stream: true }) : decoded;
904
- yield* emitCompleteLines(false);
903
+ if (onLine) {
904
+ lineBuffer += lineDecoder ? lineDecoder.decode(chunk, { stream: true }) : decoded;
905
+ yield* emitCompleteLines(false);
906
+ }
907
});
908
909
yield* Stream.runForEach(stream, processChunk).pipe(
@@ -917,9 +919,11 @@ const collectOutput = Effect.fnUntraced(function* (
919
920
const remainder = truncated ? "" : decoder.decode();
921
text += remainder;
920
- lineBuffer += remainder;
921
- if (lineDecoder) lineBuffer += lineDecoder.decode();
922
- yield* emitCompleteLines(true);
922
+ if (onLine) {
923
+ lineBuffer += remainder;
924
+ if (lineDecoder) lineBuffer += lineDecoder.decode();
925
+ yield* emitCompleteLines(true);
926
+ }
927
return {
928
text,
929
truncated,