History

Fix raw command output handling for PR #4083

Julius Marminge committed 3 months ago

Commit bf58a961 parent 86dc15c2 files · +12 −5Browse files

Unified · Split

2 files
  1. apps/web/src/session-logic.command-output.test.ts +5 −3
  2. apps/web/src/session-logic.ts +7 −2
apps/web/src/session-logic.command-output.test.ts+5−3
@@ -24,11 +24,12 @@ describe("deriveWorkLogEntries command output", () => { · 23 unmodified lines
24 makeCommandActivity("codex-command", {24 makeCommandActivity("codex-command", {
25 itemType: "command_execution",25 itemType: "command_execution",
26 title: "Ran command",26 title: "Ran command",
27 detail: "printf hello",27 detail: "/bin/zsh -lc \"printf 'hello\\n'\"",
28 data: {28 data: {
29 item: {29 item: {
30 type: "commandExecution",30 type: "commandExecution",
31 command: "printf hello",31 command: "/bin/zsh -lc \"printf 'hello\\n'\"",
32 commandActions: [{ command: "printf 'hello\\n'", type: "unknown" }],
32 aggregatedOutput: "hello\n<exited with exit code 0>",33 aggregatedOutput: "hello\n<exited with exit code 0>",
33 status: "completed",34 status: "completed",
34 },35 },
@@ -37,7 +38,8 @@ describe("deriveWorkLogEntries command output", () => { · 2 unmodified lines
37 ]);38 ]);
38 39
39 expect(entry).toMatchObject({40 expect(entry).toMatchObject({
40 command: "printf hello",41 command: "printf 'hello\\n'",
42 rawCommand: "/bin/zsh -lc \"printf 'hello\\n'\"",
41 detail: "hello",43 detail: "hello",
42 });44 });
43 });45 });
apps/web/src/session-logic.ts+7−2
@@ -1234,13 +1234,18 @@ function extractToolDetail( · 1233 unmodified lines
1234 const normalizedHeading = normalizePreviewForComparison(heading);1234 const normalizedHeading = normalizePreviewForComparison(heading);
1235 const normalizedDetail = normalizePreviewForComparison(detail);1235 const normalizedDetail = normalizePreviewForComparison(detail);
1236 const commandTool = isCommandToolDetail(payload, heading);1236 const commandTool = isCommandToolDetail(payload, heading);
1237 const command = commandTool ? extractToolCommand(payload).command : null;1237 const commandPreview = commandTool
1238 ? extractToolCommand(payload)
1239 : { command: null, rawCommand: null };
1240 const command = commandPreview.command;
1238 const normalizedCommand = normalizePreviewForComparison(command);1241 const normalizedCommand = normalizePreviewForComparison(command);
1242 const normalizedRawCommand = normalizePreviewForComparison(commandPreview.rawCommand);
1239 1243
1240 if (1244 if (
1241 detail &&1245 detail &&
1242 normalizedHeading !== normalizedDetail &&1246 normalizedHeading !== normalizedDetail &&
1243 (!commandTool || normalizedCommand !== normalizedDetail)1247 (!commandTool ||
1248 (normalizedCommand !== normalizedDetail && normalizedRawCommand !== normalizedDetail))
1244 ) {1249 ) {
1245 return detail;1250 return detail;
1246 }1251 }