Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

session-logic.command-output.test.ts

85 lines2.4 KB

1import { EventId, TurnId, type OrchestrationThreadActivity } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { deriveWorkLogEntries } from "./session-logic";
5​
6function makeCommandActivity(
7 id: string,
8 payload: Record<string, unknown>,
9): OrchestrationThreadActivity {
10 return {
11 id: EventId.make(id),
12 createdAt: "2026-07-17T10:00:00.000Z",
13 kind: "tool.completed",
14 summary: "Ran command",
15 tone: "tool",
16 payload,
17 turnId: TurnId.make("turn-1"),
18 };
20​
21describe("deriveWorkLogEntries command output", () => {
22 it("uses Codex aggregated output instead of repeating the command", () => {
23 const [entry] = deriveWorkLogEntries([
24 makeCommandActivity("codex-command", {
25 itemType: "command_execution",
26 title: "Ran command",
27 detail: "/bin/zsh -lc \"printf 'hello\\n'\"",
28 data: {
29 item: {
30 type: "commandExecution",
31 command: "/bin/zsh -lc \"printf 'hello\\n'\"",
32 commandActions: [{ command: "printf 'hello\\n'", type: "unknown" }],
33 aggregatedOutput: "hello\n<exited with exit code 0>",
34 status: "completed",
35 },
36 },
37 }),
38 ]);
39​
40 expect(entry).toMatchObject({
41 command: "printf 'hello\\n'",
42 rawCommand: "/bin/zsh -lc \"printf 'hello\\n'\"",
43 detail: "hello",
44 });
45 });
46​
47 it("uses a projected Claude output summary instead of repeating the command", () => {
48 const [entry] = deriveWorkLogEntries([
49 makeCommandActivity("claude-command", {
50 itemType: "command_execution",
51 title: "Ran command",
52 detail: "printf hello",
53 data: {
54 kind: "execute",
55 command: "printf hello",
56 rawOutput: {
57 content: "hello from claude",
58 },
59 },
60 }),
61 ]);
62​
63 expect(entry).toMatchObject({
64 command: "printf hello",
65 detail: "hello from claude",
66 });
67 });
68​
69 it("drops duplicated command detail when the command has no output", () => {
70 const [entry] = deriveWorkLogEntries([
71 makeCommandActivity("empty-command", {
72 itemType: "command_execution",
73 title: "Ran command",
74 detail: "true",
75 data: {
76 kind: "execute",
77 command: "true",
78 },
79 }),
80 ]);
81​
82 expect(entry?.command).toBe("true");
83 expect(entry?.detail).toBeUndefined();
84 });
85});