History

Drop merged unified diffs from turn summaries

- Stop propagating `diff` when merging turn file changes in session logic - Update tests to assert required retry callbacks are functions before invoking - Replace fragile unifiedDiff key check with `not.toHaveProperty`

Julius Marminge committed 8 months ago

Commit c50b2161 parent 6a604d83 files · +16 −13Browse files

Unified · Split

3 files
  1. apps/web/src/lib/providerReactQuery.test.ts +15 −9
  2. apps/web/src/session-logic.test.ts +1 −1
  3. apps/web/src/session-logic.ts +0 −3
apps/web/src/lib/providerReactQuery.test.ts+15−9
@@ -62,24 +62,26 @@ describe("checkpointDiffQueryOptions", () => { · 61 unmodified lines
62 cacheScope: "turn:abc",62 cacheScope: "turn:abc",
63 });63 });
64 const retry = options.retry;64 const retry = options.retry;
65 expect(typeof retry).toBe("function");
66 if (typeof retry !== "function") {
67 throw new Error("Expected retry to be a function.");
68 }
65 69
66 expect(retry?.(1, new Error("Checkpoint turn count 2 exceeds current turn count 1."))).toBe(70 expect(retry(1, new Error("Checkpoint turn count 2 exceeds current turn count 1."))).toBe(true);
67 true,
68 );
69 expect(71 expect(
70 retry?.(72 retry(
71 11,73 11,
72 new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."),74 new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."),
73 ),75 ),
74 ).toBe(true);76 ).toBe(true);
75 expect(77 expect(
76 retry?.(78 retry(
77 12,79 12,
78 new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."),80 new Error("Filesystem checkpoint is unavailable for turn 2 in thread thread-1."),
79 ),81 ),
80 ).toBe(false);82 ).toBe(false);
81 expect(retry?.(2, new Error("Something else failed."))).toBe(true);83 expect(retry(2, new Error("Something else failed."))).toBe(true);
82 expect(retry?.(3, new Error("Something else failed."))).toBe(false);84 expect(retry(3, new Error("Something else failed."))).toBe(false);
83 });85 });
84 86
85 it("backs off longer for checkpoint-not-ready errors", () => {87 it("backs off longer for checkpoint-not-ready errors", () => {
@@ -91,12 +93,16 @@ describe("checkpointDiffQueryOptions", () => { · 5 unmodified lines
91 cacheScope: "turn:abc",93 cacheScope: "turn:abc",
92 });94 });
93 const retryDelay = options.retryDelay;95 const retryDelay = options.retryDelay;
96 expect(typeof retryDelay).toBe("function");
97 if (typeof retryDelay !== "function") {
98 throw new Error("Expected retryDelay to be a function.");
99 }
94 100
95 const checkpointDelay = retryDelay?.(101 const checkpointDelay = retryDelay(
96 4,102 4,
97 new Error("Checkpoint turn count 2 exceeds current turn count 1."),103 new Error("Checkpoint turn count 2 exceeds current turn count 1."),
98 );104 );
99 const genericDelay = retryDelay?.(4, new Error("Network failure"));105 const genericDelay = retryDelay(4, new Error("Network failure"));
100 106
101 expect(typeof checkpointDelay).toBe("number");107 expect(typeof checkpointDelay).toBe("number");
102 expect(typeof genericDelay).toBe("number");108 expect(typeof genericDelay).toBe("number");
apps/web/src/session-logic.test.ts+1−1
@@ -497,7 +497,7 @@ describe("deriveTurnDiffSummaries", () => { · 496 unmodified lines
497 expect(summaries[0]?.files[0]?.kind).toBe("modified");497 expect(summaries[0]?.files[0]?.kind).toBe("modified");
498 expect(summaries[0]?.files[0]?.additions).toBe(1);498 expect(summaries[0]?.files[0]?.additions).toBe(1);
499 expect(summaries[0]?.files[0]?.deletions).toBe(1);499 expect(summaries[0]?.files[0]?.deletions).toBe(1);
500 expect("unifiedDiff" in (summaries[0] as Record<string, unknown>)).toBe(false);500 expect(summaries[0]).not.toHaveProperty("unifiedDiff");
501 });501 });
502 502
503 it("includes completed turns even when no fileChange tool events were emitted", () => {503 it("includes completed turns even when no fileChange tool events were emitted", () => {
apps/web/src/session-logic.ts+0−3
@@ -506,9 +506,6 @@ function mergeTurnDiffFileChange( · 505 unmodified lines
506 if (existing.kind === undefined && incoming.kind !== undefined) {506 if (existing.kind === undefined && incoming.kind !== undefined) {
507 existing.kind = incoming.kind;507 existing.kind = incoming.kind;
508 }508 }
509 if (existing.diff === undefined && incoming.diff !== undefined) {
510 existing.diff = incoming.diff;
511 }
512 if (existing.additions === undefined && incoming.additions !== undefined) {509 if (existing.additions === undefined && incoming.additions !== undefined) {
513 existing.additions = incoming.additions;510 existing.additions = incoming.additions;
514 }511 }