Skip to content
TypeScript

fix(web,mobile): snooze menu no longer offers the same wake time twice (#8741)

Vitaly Iegorov7980dfddb193
diff --git a/packages/client-runtime/src/state/threadSettled.ts b/packages/client-runtime/src/state/threadSettled.ts
index 8ccf0d230ef..eb965c6afe2 100644
--- a/packages/client-runtime/src/state/threadSettled.ts
+++ b/packages/client-runtime/src/state/threadSettled.ts
@@ -394,7 +394,9 @@ function addSnoozeDays(base: Date, days: number): Date {
/**
* Shared "snooze until" choices for every client. "This evening" only
* appears while it is meaningfully before evening; after that the calendar
- * choices start at "Tomorrow".
+ * choices start at "Tomorrow". Calendar presets that land on the same
+ * instant collapse: on Sundays "Tomorrow" and "Next week" are both Monday
+ * morning, so only "Tomorrow" is offered.
*/
export function resolveSnoozePresets(now: Date): ReadonlyArray<SnoozePreset> {
const inAnHour = new Date(now.getTime() + HOUR_MS);
@@ -434,12 +436,14 @@ export function resolveSnoozePresets(now: Date): ReadonlyArray<SnoozePreset> {
const daysUntilMonday = (1 - now.getDay() + 7) % 7 || 7;
const nextWeek = snoozeAtHour(addSnoozeDays(now, daysUntilMonday), MORNING_HOUR);
- presets.push({
- id: "next-week",
- label: "Next week",
- whenLabel: `${nextWeek.toLocaleDateString(undefined, { weekday: "short" })} ${snoozeTimeOfDayLabel(nextWeek)}`,
- snoozedUntil: nextWeek.toISOString(),
- });
+ if (nextWeek.getTime() !== tomorrow.getTime()) {
+ presets.push({
+ id: "next-week",
+ label: "Next week",
+ whenLabel: `${nextWeek.toLocaleDateString(undefined, { weekday: "short" })} ${snoozeTimeOfDayLabel(nextWeek)}`,
+ snoozedUntil: nextWeek.toISOString(),
+ });
+ }
return presets;
}
diff --git a/packages/client-runtime/src/state/threadSnoozed.test.ts b/packages/client-runtime/src/state/threadSnoozed.test.ts
index ff0c7d5d8e5..ab4c7fb0784 100644
--- a/packages/client-runtime/src/state/threadSnoozed.test.ts
+++ b/packages/client-runtime/src/state/threadSnoozed.test.ts
@@ -297,4 +297,17 @@ describe("resolveSnoozePresets", () => {
expect(nextWeek.getDay()).toBe(1);
expect(nextWeek.getDate()).toBe(13);
});
+
+ it("drops next week on Sundays, when it lands on the same Monday as tomorrow", () => {
+ // Sunday 2026-08-30 07:01: "Tomorrow" and "Next week" are both Monday 9:00.
+ const presets = resolveSnoozePresets(localDate(2026, 8, 30, 7, 1));
+ expect(presets.map((preset) => preset.id)).toEqual([
+ "hour",
+ "three-hours",
+ "evening",
+ "tomorrow",
+ ]);
+ const tomorrow = new Date(presets.find((preset) => preset.id === "tomorrow")!.snoozedUntil);
+ expect(tomorrow.getDay()).toBe(1);
+ });
});