Skip to content

Commit a27b246

Browse files
t3dotggonly21milclaude
authored
fix(web): usage-limit banner reset time follows the Time format setting (pingdotgg#22915)
Co-authored-by: Victor Vogel <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 2050a12 commit a27b246

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,6 +2578,7 @@ export default function ChatView(props: ChatViewProps) {
25782578
stoppedAt: activeThreadShell.latestRun.completedAt ?? activeThreadShell.updatedAt,
25792579
recovery: activeThreadShell.limitRecovery ?? null,
25802580
snoozedUntil: activeThreadShell.snoozedUntil,
2581+
timestampFormat,
25812582
onChange: async (limitRecovery) => {
25822583
const result = await updateThreadMetadata({
25832584
environmentId,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { RunId } from "@t3tools/contracts";
2+
import type { TimestampFormat } from "@t3tools/contracts/settings";
3+
import { describe, expect, it, vi } from "vite-plus/test";
4+
5+
import { usageLimitRecoveryBannerItem } from "./UsageLimitRecoveryBanner";
6+
7+
const stoppedAt = new Date(2026, 9, 20, 12, 0);
8+
9+
function bannerDescription(resetAt: Date, timestampFormat: TimestampFormat) {
10+
return usageLimitRecoveryBannerItem({
11+
runId: RunId.make("run-1"),
12+
resetAt: resetAt.toISOString(),
13+
stoppedAt: stoppedAt.toISOString(),
14+
snoozedUntil: null,
15+
recovery: null,
16+
timestampFormat,
17+
onChange: async () => {},
18+
}).description;
19+
}
20+
21+
describe("usageLimitRecoveryBannerItem", () => {
22+
it.each([
23+
["12-hour", "Resets 5:30 PM"],
24+
["24-hour", "Resets 17:30"],
25+
] as const)("formats a same-day reset with the %s setting", (timestampFormat, expected) => {
26+
using _now = vi.spyOn(Date, "now").mockReturnValue(stoppedAt.getTime());
27+
expect(bannerDescription(new Date(2026, 9, 20, 17, 30), timestampFormat)).toBe(expected);
28+
});
29+
30+
it("names the day when the reset is tomorrow", () => {
31+
using _now = vi.spyOn(Date, "now").mockReturnValue(stoppedAt.getTime());
32+
expect(bannerDescription(new Date(2026, 9, 21, 17, 30), "24-hour")).toBe(
33+
"Resets tomorrow at 17:30",
34+
);
35+
});
36+
});

‎apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import {
33
type OrchestrationV2LimitRecoveryUpdate,
44
type RunId,
55
} from "@t3tools/contracts";
6+
import { type TimestampFormat } from "@t3tools/contracts/settings";
67
import { GaugeIcon } from "lucide-react";
78
import { useEffect, useState } from "react";
89
import { Button } from "../ui/button";
10+
import { formatUpcomingTimestamp } from "../../timestampFormat";
911
import { toastManager } from "../ui/toast";
1012
import type { ComposerBannerStackItem } from "./ComposerBannerStack";
1113

@@ -15,11 +17,12 @@ type RecoveryProps = {
1517
stoppedAt: string;
1618
snoozedUntil: string | null;
1719
recovery: OrchestrationV2LimitRecovery | null;
20+
timestampFormat: TimestampFormat;
1821
onChange: (recovery: OrchestrationV2LimitRecoveryUpdate) => Promise<void>;
1922
};
2023

2124
export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBannerStackItem {
22-
const { runId, resetAt, stoppedAt } = props;
25+
const { runId, resetAt, stoppedAt, timestampFormat } = props;
2326
const canSchedule = resetAt !== null && Date.parse(resetAt) > Date.parse(stoppedAt);
2427
return {
2528
id: `usage-limit-recovery:${runId}`,
@@ -28,7 +31,7 @@ export function usageLimitRecoveryBannerItem(props: RecoveryProps): ComposerBann
2831
icon: <GaugeIcon />,
2932
title: "Usage limit reached",
3033
description: resetAt
31-
? `Resets ${new Date(resetAt).toLocaleString()}`
34+
? `Resets ${formatUpcomingTimestamp(resetAt, timestampFormat)}`
3235
: "Reset time unavailable; retry manually",
3336
actions: canSchedule ? <RecoveryActions key={`${runId}:${resetAt}`} {...props} /> : null,
3437
};

0 commit comments

Comments
 (0)