Skip to content
Merged
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
6 changes: 4 additions & 2 deletions src/lib/format-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ export function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOp

if (opts?.compactRounded) {
if (days > 0) return `${days}d`;
if (hours > 0) return `${hours}h`;
return `${minutes}m`;
const halfHours = Math.ceil(diffMinutes / 30);
const h = Math.floor(halfHours / 2);
if (h > 0) return halfHours % 2 === 1 ? `${h}.5h` : `${h}h`;
return `0.5h`;
}

if (days > 0) return `${days}d ${hours}h`;
Expand Down
6 changes: 3 additions & 3 deletions tests/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe("formatQuotaRows", () => {
});

// We don't assert exact time math; just that some countdown marker appears.
expect(out).toMatch(/(\d+[dhms]|reset)/);
expect(out).toMatch(/([\d.]+[dhms]|reset)/);
});

it("does not show reset countdown when quota is fully available", () => {
Expand Down Expand Up @@ -184,7 +184,7 @@ describe("formatQuotaRows", () => {
],
});

expect(out).toContain("2h");
expect(out).toContain("2.5h");
expect(out).not.toContain("2h 14m");
});

Expand All @@ -207,7 +207,7 @@ describe("formatQuotaRows", () => {
],
});

expect(out).toContain("14m");
expect(out).toContain("0.5h");
expect(out).not.toContain("0h 14m");
});

Expand Down
2 changes: 1 addition & 1 deletion tests/tui-sidebar-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe("buildSidebarQuotaPanelLines", () => {
},
});

expect(lines.join("\n")).toContain("2h");
expect(lines.join("\n")).toContain("2.5h");
expect(lines.join("\n")).not.toContain("2h 14m");
});

Expand Down