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, 10:45 UTC
fix(chat): commands that exit 0 no longer show as failed (#23351)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
Victor Vogel committed
Oct 30, 2026 at 16:26 UTC
469afd8b53d070c5e2dccad450fddce3a440c590
4 files changed
+41
-8
apps/server/src/orchestration-v2/WireProjection.test.ts
+15
@@ -261,6 +261,21 @@ describe("orchestration V2 wire projection", () => {
261
});
262
});
263
264
+ it.each([
265
+ "logs/app.log:12: Error: ENOENT: no such file or directory",
266
+ "fixtures/ci.txt:3: Process exited with exit code 2",
267
+ ])("trusts a zero exit code over failure text in the output: %s", (output) => {
268
+ const projected = projectTurnItemForWire({
269
+ ...base,
270
+ type: "command_execution" as const,
271
+ input: "rg -n error logs fixtures",
272
+ output,
273
+ exitCode: 0,
274
+ });
275
+ expect(projected).not.toHaveProperty("outputIndicatesFailure");
276
+ expect(projected).toMatchObject({ exitCode: 0, outputOmitted: true });
277
+ });
278
+
279
it("omits inline file bodies but preserves file identity and change counts", () => {
280
const item = {
281
...base,
apps/server/src/orchestration-v2/WireProjection.ts
+7
-4
@@ -157,11 +157,14 @@ export function projectTurnItemForWire(item: OrchestrationV2TurnItem): Orchestra
157
}
158
case "command_execution": {
159
const { output, ...projected } = item;
160
+ // A successful search can print "ENOENT" or "exit code 2", so output text
161
+ // decides only when the provider reported no exit code.
162
const failed =
161
- item.outputIndicatesFailure === true ||
162
- (item.exitCode !== undefined && item.exitCode !== 0) ||
163
- (output !== undefined &&
164
- toolOutputIndicatesFailure(output.slice(0, MAX_DETAIL_STRING_BYTES)));
163
+ item.exitCode === undefined
164
+ ? item.outputIndicatesFailure === true ||
165
+ (output !== undefined &&
166
+ toolOutputIndicatesFailure(output.slice(0, MAX_DETAIL_STRING_BYTES)))
167
+ : item.exitCode !== 0;
168
return {
169
...projected,
170
...(failed ? { outputIndicatesFailure: true } : {}),
packages/client-runtime/src/work-log/presentation.test.ts
+16
-1
@@ -31,7 +31,6 @@ function commandItem(
31
updatedAt: DateTime.makeUnsafe("2026-09-08T00:00:00.000Z"),
32
type: "command_execution",
33
input: 'rg "command not found"',
34
- exitCode: 0,
34
...fields,
35
};
36
}
@@ -63,6 +62,22 @@ describe("workEntryIndicatesToolFailure", () => {
62
},
63
);
64
65
+ it.each([
66
+ "logs/app.log:12: Error: ENOENT: no such file or directory",
67
+ "fixtures/ci.txt:3: Process exited with exit code 2",
68
+ ])("trusts a zero exit code over failure text in the output and command: %s", (output) => {
69
+ const entry: WorkLogPresentationEntry = {
70
+ ...base,
71
+ tone: "tool",
72
+ itemType: "command_execution",
73
+ toolLifecycleStatus: "completed",
74
+ command: 'rg -n "ENOENT|exit code" logs fixtures',
75
+ structuredPayload: commandItem({ output, exitCode: 0, outputIndicatesFailure: true }),
76
+ };
77
+ expect(workEntryIndicatesToolFailure(entry)).toBe(false);
78
+ expect(workEntryDisplayIndicatesToolFailure(entry)).toBe(false);
79
+ });
80
+
81
it("ignores failure phrases in reasoning text", () => {
82
const entry: WorkLogPresentationEntry = {
83
...base,
packages/client-runtime/src/work-log/presentation.ts
+3
-3
@@ -278,9 +278,9 @@ function workEntryIndicatesToolFailureFromOutput(
278
}
279
const item = entry.structuredPayload;
280
if (item?.type === "command_execution") {
281
- if (item.outputIndicatesFailure || (item.exitCode !== undefined && item.exitCode !== 0)) {
282
- return true;
283
- }
281
+ // The exit code outranks text in the output or the command itself.
282
+ if (item.exitCode !== undefined) return item.exitCode !== 0;
283
+ if (item.outputIndicatesFailure) return true;
284
if (item.output && toolOutputIndicatesFailure(item.output.slice(0, 32_768))) {
285
return true;
286
}