Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/loopover-engine/src/loop-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ function activityChanged(prev: readonly LoopProgressActivity[], next: readonly L

/** True when `next` differs from `prev` in a way worth pushing to the customer — so the surface streams
* ON CHANGE instead of polling on a fixed interval (#4800's acceptance). A null `prev` (the first snapshot)
* always pushes. Compares the displayed axes: phase, status, iteration, and the activity tail's contents. */
* always pushes. Compares the displayed axes: phase, status, iteration, maxIterations, percentComplete,
* and the activity tail's contents. */
export function progressChanged(prev: ProgressSnapshot | null, next: ProgressSnapshot): boolean {
if (prev === null) return true;
return (
prev.phase !== next.phase ||
prev.status !== next.status ||
prev.iteration !== next.iteration ||
prev.maxIterations !== next.maxIterations ||
prev.percentComplete !== next.percentComplete ||
activityChanged(prev.recentActivity, next.recentActivity)
);
}
11 changes: 10 additions & 1 deletion test/unit/loop-progress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,22 @@ describe("progressChanged — push on change, not on a fixed interval (#4800)",
expect(progressChanged(null, base)).toBe(true);
});

it("pushes when phase, status, iteration, or the activity tail changes", () => {
it("pushes when phase, status, iteration, maxIterations, percentComplete, or the activity tail changes", () => {
expect(progressChanged(base, buildProgressSnapshot(running({ phase: "reviewing", recentActivity: [{ step: "a" }] })))).toBe(true);
expect(progressChanged(base, buildProgressSnapshot(running({ status: "converged", recentActivity: [{ step: "a" }] })))).toBe(true);
expect(progressChanged(base, buildProgressSnapshot(running({ iteration: 3, recentActivity: [{ step: "a" }] })))).toBe(true);
expect(progressChanged(base, buildProgressSnapshot(running({ maxIterations: 10, recentActivity: [{ step: "a" }] })))).toBe(true);
expect(progressChanged(base, buildProgressSnapshot(running({ recentActivity: [{ step: "a" }, { step: "b" }] })))).toBe(true);
});

it("REGRESSION (#9323): pushes when maxIterations changes even if iteration/phase/status/activity are unchanged", () => {
const before = buildProgressSnapshot(running({ iteration: 2, maxIterations: 5, recentActivity: [{ step: "a" }] }));
const after = buildProgressSnapshot(running({ iteration: 2, maxIterations: 10, recentActivity: [{ step: "a" }] }));
expect(before.percentComplete).toBe(40);
expect(after.percentComplete).toBe(20);
expect(progressChanged(before, after)).toBe(true);
});

it("does not push when nothing displayed has changed", () => {
expect(progressChanged(base, buildProgressSnapshot(running({ recentActivity: [{ step: "a" }] })))).toBe(false);
});
Expand Down
Loading