Skip to content

Commit f7fcd4a

Browse files
committed
2 parents c915c8a + 7f304f7 commit f7fcd4a

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎src/lib/format-utils.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ export function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOp
168168

169169
if (opts?.compactRounded) {
170170
if (days > 0) return `${days}d`;
171-
if (hours > 0) return `${hours}h`;
172-
return `${minutes}m`;
171+
const halfHours = Math.ceil(diffMinutes / 30);
172+
const h = Math.floor(halfHours / 2);
173+
if (h > 0) return halfHours % 2 === 1 ? `${h}.5h` : `${h}h`;
174+
return `0.5h`;
173175
}
174176

175177
if (days > 0) return `${days}d ${hours}h`;

‎tests/format.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe("formatQuotaRows", () => {
149149
});
150150

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

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

187-
expect(out).toContain("2h");
187+
expect(out).toContain("2.5h");
188188
expect(out).not.toContain("2h 14m");
189189
});
190190

@@ -207,7 +207,7 @@ describe("formatQuotaRows", () => {
207207
],
208208
});
209209

210-
expect(out).toContain("14m");
210+
expect(out).toContain("0.5h");
211211
expect(out).not.toContain("0h 14m");
212212
});
213213

‎tests/tui-sidebar-format.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ describe("buildSidebarQuotaPanelLines", () => {
332332
},
333333
});
334334

335-
expect(lines.join("\n")).toContain("2h");
335+
expect(lines.join("\n")).toContain("2.5h");
336336
expect(lines.join("\n")).not.toContain("2h 14m");
337337
});
338338

0 commit comments

Comments
 (0)