Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix: respect time format for sidebar snooze (#4438)

Hugo Bloma483337a02d4
diff --git a/apps/web/src/components/Sidebar.snooze.test.ts b/apps/web/src/components/Sidebar.snooze.test.ts
index 88c1d9ea5..bd1057142 100644
--- a/apps/web/src/components/Sidebar.snooze.test.ts
+++ b/apps/web/src/components/Sidebar.snooze.test.ts
@@ -10,7 +10,7 @@ function localDate(year: number, month: number, day: number, hour: number, minut
describe("resolveSnoozePresets", () => {
it("offers hour, evening, tomorrow, next week in the morning", () => {
// Wednesday 2026-04-08 10:00 local.
- const presets = resolveSnoozePresets(localDate(2026, 4, 8, 10));
+ const presets = resolveSnoozePresets(localDate(2026, 4, 8, 10), "locale");
expect(presets.map((preset) => preset.id)).toEqual([
"hour",
"evening",
@@ -30,7 +30,7 @@ describe("resolveSnoozePresets", () => {
});
it("whenLabel complements the label instead of repeating it", () => {
- const presets = resolveSnoozePresets(localDate(2026, 4, 8, 10));
+ const presets = resolveSnoozePresets(localDate(2026, 4, 8, 10), "locale");
for (const preset of presets) {
// Day words live in the label column; the time column is time-only
// (plus a weekday for next week, which names a different day).
@@ -43,37 +43,51 @@ describe("resolveSnoozePresets", () => {
});
it("drops the evening preset once evening is near or past", () => {
- expect(resolveSnoozePresets(localDate(2026, 4, 8, 17, 30)).map((preset) => preset.id)).toEqual([
- "hour",
- "tomorrow",
- "next-week",
- ]);
- expect(resolveSnoozePresets(localDate(2026, 4, 8, 21)).map((preset) => preset.id)).toEqual([
- "hour",
- "tomorrow",
- "next-week",
- ]);
+ expect(
+ resolveSnoozePresets(localDate(2026, 4, 8, 17, 30), "locale").map((preset) => preset.id),
+ ).toEqual(["hour", "tomorrow", "next-week"]);
+ expect(
+ resolveSnoozePresets(localDate(2026, 4, 8, 21), "locale").map((preset) => preset.id),
+ ).toEqual(["hour", "tomorrow", "next-week"]);
});
it("puts next week a full week out when today is Monday", () => {
// Monday 2026-04-06.
- const presets = resolveSnoozePresets(localDate(2026, 4, 6, 10));
+ const presets = resolveSnoozePresets(localDate(2026, 4, 6, 10), "locale");
const nextWeek = new Date(presets.find((preset) => preset.id === "next-week")!.snoozedUntil);
expect(nextWeek.getDay()).toBe(1);
expect(nextWeek.getDate()).toBe(13);
});
+ it("formats preset times with the selected clock preference", () => {
+ const twelveHour = resolveSnoozePresets(localDate(2026, 4, 8, 10), "12-hour");
+ const twentyFourHour = resolveSnoozePresets(localDate(2026, 4, 8, 10), "24-hour");
+
+ expect(twelveHour.find((preset) => preset.id === "evening")!.whenLabel).toMatch(/PM/i);
+ expect(twentyFourHour.find((preset) => preset.id === "evening")!.whenLabel).toBe("18:00");
+ });
});
describe("snoozeWakeDescription", () => {
const now = localDate(2026, 4, 8, 10);
it("uses bare time today, 'tomorrow' next day, weekday within the week", () => {
- expect(snoozeWakeDescription(localDate(2026, 4, 8, 18).toISOString(), now)).not.toContain(
+ expect(
+ snoozeWakeDescription(localDate(2026, 4, 8, 18).toISOString(), now, "locale"),
+ ).not.toContain("tomorrow");
+ expect(snoozeWakeDescription(localDate(2026, 4, 9, 9).toISOString(), now, "locale")).toContain(
"tomorrow",
);
- expect(snoozeWakeDescription(localDate(2026, 4, 9, 9).toISOString(), now)).toContain(
- "tomorrow",
+ expect(snoozeWakeDescription(localDate(2026, 4, 13, 9).toISOString(), now, "locale")).toMatch(
+ /Mon/,
+ );
+ });
+
+ it("formats wake descriptions with the selected clock preference", () => {
+ expect(snoozeWakeDescription(localDate(2026, 4, 8, 18).toISOString(), now, "12-hour")).toMatch(
+ /PM/i,
+ );
+ expect(snoozeWakeDescription(localDate(2026, 4, 8, 18).toISOString(), now, "24-hour")).toBe(
+ "18:00",
);
- expect(snoozeWakeDescription(localDate(2026, 4, 13, 9).toISOString(), now)).toMatch(/Mon/);
});
});
diff --git a/apps/web/src/components/Sidebar.snooze.ts b/apps/web/src/components/Sidebar.snooze.ts
index adbc361a8..e7b980279 100644
--- a/apps/web/src/components/Sidebar.snooze.ts
+++ b/apps/web/src/components/Sidebar.snooze.ts
@@ -1,22 +1,50 @@
-import { snoozeWakeLabel } from "@t3tools/client-runtime/state/thread-settled";
-import { parseTimestampDate } from "../timestampFormat";
-
-export {
- resolveSnoozePresets,
+import type { TimestampFormat } from "@t3tools/contracts/settings";
+import {
+ resolveSnoozePresets as resolveSharedSnoozePresets,
+ snoozeWakeLabel,
type SnoozePreset,
} from "@t3tools/client-runtime/state/thread-settled";
-export { snoozeWakeLabel };
+
+import { formatShortTimestamp, parseTimestampDate } from "../timestampFormat";
+
+export { snoozeWakeLabel, type SnoozePreset };
const DAY_MS = 24 * 60 * 60 * 1_000;
+function timeOfDayLabel(date: Date, timestampFormat: TimestampFormat): string {
+ return formatShortTimestamp(date.toISOString(), timestampFormat);
+}
+
+export function resolveSnoozePresets(
+ now: Date,
+ timestampFormat: TimestampFormat,
+): ReadonlyArray<SnoozePreset> {
+ return resolveSharedSnoozePresets(now).map((preset) => {
+ const wake = parseTimestampDate(preset.snoozedUntil);
+ if (wake === null) return preset;
+ const time = timeOfDayLabel(wake, timestampFormat);
+ return {
+ ...preset,
+ whenLabel:
+ preset.id === "next-week"
+ ? `${wake.toLocaleDateString(undefined, { weekday: "short" })} ${time}`
+ : time,
+ };
+ });
+}
+
/**
* Human wake time for menus and toasts: "tomorrow 9:00", "Mon 9:00",
* "17:30" (today).
*/
-export function snoozeWakeDescription(snoozedUntil: string, now: Date): string {
+export function snoozeWakeDescription(
+ snoozedUntil: string,
+ now: Date,
+ timestampFormat: TimestampFormat,
+): string {
const wake = parseTimestampDate(snoozedUntil);
if (wake === null) return "";
- const time = wake.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
+ const time = timeOfDayLabel(wake, timestampFormat);
const startOfToday = new Date(now);
startOfToday.setHours(0, 0, 0, 0);
const dayDelta = Math.floor((wake.getTime() - startOfToday.getTime()) / DAY_MS);
diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsx
index 6e4bdc0fc..1444d72e6 100644
--- a/apps/web/src/components/SidebarV2.tsx
+++ b/apps/web/src/components/SidebarV2.tsx
@@ -13,6 +13,7 @@ import {
scopedThreadKey,
} from "@t3tools/client-runtime/environment";
import type { ScopedThreadRef, SidebarProjectGroupingMode } from "@t3tools/contracts";
+import type { TimestampFormat } from "@t3tools/contracts/settings";
import {
AlarmClockIcon,
AlarmClockOffIcon,
@@ -341,11 +342,15 @@ function SnoozePopoverButton(props: {
open: boolean;
onOpenChange: (open: boolean) => void;
onSnooze: (preset: SnoozePreset) => void;
+ timestampFormat: TimestampFormat;
}) {
- const { open, onOpenChange, onSnooze } = props;
+ const { open, onOpenChange, onSnooze, timestampFormat } = props;
// Presets resolve at open time so "In 1 hour" is relative to the click,
// not to when the row mounted.
- const presets = useMemo(() => (open ? resolveSnoozePresets(new Date()) : []), [open]);
+ const presets = useMemo(
+ () => (open ? resolveSnoozePresets(new Date(), timestampFormat) : []),
+ [open, timestampFormat],
+ );
return (
<Popover open={open} onOpenChange={onOpenChange}>
<PopoverTrigger
@@ -412,6 +417,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
projectCwd: string | null;
projectTitle: string | null;
providerEntryByInstanceId: ReadonlyMap<string, ProviderInstanceEntry>;
+ timestampFormat: TimestampFormat;
onThreadClick: (event: ReactMouseEvent, threadRef: ScopedThreadRef) => void;
onThreadActivate: (threadRef: ScopedThreadRef) => void;
onStartRename: (threadRef: ScopedThreadRef, title: string) => void;
@@ -1020,6 +1026,7 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
open={snoozeMenuOpen}
onOpenChange={setSnoozeMenuOpen}
onSnooze={handleSnoozePreset}
+ timestampFormat={props.timestampFormat}
/>
) : null}
{props.settlementSupported ? (
@@ -1207,6 +1214,7 @@ export default function SidebarV2() {
const autoSettleAfterDays = useClientSettings((s) => s.sidebarAutoSettleAfterDays);
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
+ const timestampFormat = useClientSettings((s) => s.timestampFormat);
const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
const {
settleThread,
@@ -2156,7 +2164,7 @@ export default function SidebarV2() {
toastManager.add(
stackedThreadToast({
type: "success",
- title: `Snoozed until ${snoozeWakeDescription(preset.snoozedUntil, new Date())}`,
+ title: `Snoozed until ${snoozeWakeDescription(preset.snoozedUntil, new Date(), timestampFormat)}`,
timeout: 5_000,
actionProps: {
children: "Undo",
@@ -2174,7 +2182,7 @@ export default function SidebarV2() {
}
})();
},
- [attemptUnsnooze, planForwardNavigation, snoozeThread],
+ [attemptUnsnooze, planForwardNavigation, snoozeThread, timestampFormat],
);
const removeFromSelection = useThreadSelectionStore((s) => s.removeFromSelection);
@@ -2215,7 +2223,7 @@ export default function SidebarV2() {
supportedCount: titleRegenerationThreads.length,
actionableCount: regeneratableTitleThreads.length,
});
- const snoozePresets = resolveSnoozePresets(new Date());
+ const snoozePresets = resolveSnoozePresets(new Date(), timestampFormat);
const clicked = await settlePromise(() =>
api.contextMenu.show(
[
@@ -2352,6 +2360,7 @@ export default function SidebarV2() {
removeFromSelection,
serverConfigs,
updateThreadMetadata,
+ timestampFormat,
],
);
@@ -2391,7 +2400,7 @@ export default function SidebarV2() {
const isSnoozed = snoozedThreadKeysRef.current.has(threadKey);
const isPinned = thread.pinnedAt != null;
// Presets resolve at menu-open time (same as the popover).
- const snoozePresets = resolveSnoozePresets(new Date());
+ const snoozePresets = resolveSnoozePresets(new Date(), timestampFormat);
const clicked = await settlePromise(() =>
api.contextMenu.show(
[
@@ -2590,6 +2599,7 @@ export default function SidebarV2() {
serverConfigs,
startThreadRename,
updateThreadMetadata,
+ timestampFormat,
],
);
@@ -2998,6 +3008,7 @@ export default function SidebarV2() {
) ?? null
}
providerEntryByInstanceId={providerEntryByInstanceId}
+ timestampFormat={timestampFormat}
onThreadClick={handleThreadClick}
onThreadActivate={navigateToThread}
onStartRename={startThreadRename}