Skip to content

Commit 863187b

Browse files
committed
fix(conversation): format thinking past an hour in hours
summarizeActivity only knew seconds and minutes, so an hour of thinking read "Thought for 60m 00s". Durations of an hour or more now read as hours and minutes ("1h 30m"); shorter ones are unchanged.
1 parent b211002 commit 863187b

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/lib/conversation-activity.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ describe("summarizeActivity", () => {
218218
expect(summarizeActivity([thought(65_000)])).toBe("Thought for 1m 05s");
219219
});
220220

221+
test("formats durations past an hour in hours and minutes", () => {
222+
expect(summarizeActivity([thought(3_599_000)])).toBe("Thought for 59m 59s");
223+
expect(summarizeActivity([thought(3_600_000)])).toBe("Thought for 1h 00m");
224+
expect(summarizeActivity([thought(5_400_000)])).toBe("Thought for 1h 30m");
225+
});
226+
221227
test("reads as work when nothing was thought", () => {
222228
expect(summarizeActivity([batch("b", [tool("b1"), tool("b2")])])).toBe(
223229
"Worked through 2 steps",

‎src/lib/conversation-activity.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ export function groupActivity(
8181
function formatDuration(ms: number): string {
8282
const seconds = Math.max(1, Math.round(ms / 1000));
8383
if (seconds < 60) return `${seconds}s`;
84-
return `${Math.floor(seconds / 60)}m ${String(seconds % 60).padStart(2, "0")}s`;
84+
const minutes = Math.floor(seconds / 60);
85+
if (minutes < 60) {
86+
return `${minutes}m ${String(seconds % 60).padStart(2, "0")}s`;
87+
}
88+
return `${Math.floor(minutes / 60)}h ${String(minutes % 60).padStart(2, "0")}m`;
8589
}
8690

8791
function countSteps(steps: readonly ActivityStep[]): number {

0 commit comments

Comments
 (0)