Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(notifications): add quiet hours for sounds and desktop alerts (#9453)
Jacob Beckerman6df24e08e7c1
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.mdindex 5899bc0ff7..794ab30d58 100644--- a/apps/web/AGENTS.md+++ b/apps/web/AGENTS.md@@ -976,7 +976,7 @@ See the [download walkthrough](../../docs/agent-guide/files.md#downloading-files- Reuse `CreateMenuItem` for explanatory New menu entries: original icons, a title, and muted wrapping descriptions, preserving the existing `ViewCreateButton` trigger and each action's feature gates.- Keep transient toasts in their bounded stack and persistent prompts/reminders in separate regions; preserve keyboard dismissal, full mobile descriptions, and remaining-time pause on hover/focus. Mobile toasts dismiss by swiping left or right and have no corner close button. Phone prompts stay in their own stack under the modal layer, never on `z-toast-region`, and never hide with a document-wide `:has()` (#8840).-- Notification sounds are off by default and saved per user per device; map each new notification event in `features/notification-sounds/core/categories.ts` and keep system alerts silent when Macro plays its own sound. See the [notification sounds walkthrough](../../docs/agent-guide/notifications.md#notification-sounds).+- Notification sounds are off by default and saved per user per device; map each new notification event in `features/notification-sounds/core/categories.ts` and keep system alerts silent when Macro plays its own sound. Quiet hours on the same page silence those sounds and skip desktop alerts on a per-device weekly schedule; incoming calls still ring. See the [notification sounds walkthrough](../../docs/agent-guide/notifications.md#notification-sounds).### Inline property valuesdiff --git a/apps/web/src/components/app/AppProviders.tsx b/apps/web/src/components/app/AppProviders.tsxindex f73ccd6127..b68719f4ea 100644--- a/apps/web/src/components/app/AppProviders.tsx+++ b/apps/web/src/components/app/AppProviders.tsx@@ -1,5 +1,7 @@import { useAccessRequestInvalidations } from '@app/features/access-requests/use-access-request-invalidations';import { IncomingMeetingInvitationsProvider } from '@app/features/meetings/incoming-meeting-invitations';+import { quietHoursMute } from '@app/features/notification-sounds/core/quiet-hours';+import { readNotificationSoundSettings } from '@app/features/notification-sounds/primitives/sound-settings';import {notificationSoundFor,useNotificationSounds,@@ -55,6 +57,17 @@ function ConfiguredGlobalAppStateProvider(props: ParentProps) {const userId = useUserId();let notificationUpdatePrompted = false;async function deliverNotification(notification: UnifiedNotification) {+ const id = userId();+ if (+ id &&+ quietHoursMute(+ notification.notification_metadata.tag,+ readNotificationSoundSettings(id).quietHours,+ new Date()+ )+ ) {+ return;+ }if (notifInterface === 'not-supported') return;const layoutManager = globalSplitManager();if (!layoutManager) return;diff --git a/apps/web/src/features/notification-sounds/browser-test/fixture.tsx b/apps/web/src/features/notification-sounds/browser-test/fixture.tsxindex c36b40b3ed..3ca4f10ce2 100644--- a/apps/web/src/features/notification-sounds/browser-test/fixture.tsx+++ b/apps/web/src/features/notification-sounds/browser-test/fixture.tsx@@ -9,6 +9,7 @@ import { macroDarkTheme } from '../../theme/themes/macro-dark';import { macroLightTheme } from '../../theme/themes/macro-light';import { themeCssVars } from '../../theme/utils/themeCssVars';import { NotificationSoundSection } from '../components/NotificationSoundSection';+import { QuietHoursSection } from '../components/QuietHoursSection';import { playNotificationSound } from '../primitives/sound-player';import { createNotificationSoundSettings } from '../primitives/sound-settings';import { useNotificationSounds } from '../use-notification-sounds';@@ -68,6 +69,10 @@ function Fixture() {)}/>+ <QuietHoursSection+ quietHours={sounds.settings().quietHours}+ onChange={sounds.setQuietHours}+ /></SettingsPage></main>);diff --git a/apps/web/src/features/notification-sounds/browser-test/notification-sounds.browser.e2e.ts b/apps/web/src/features/notification-sounds/browser-test/notification-sounds.browser.e2e.tsindex a714a70833..cc4ca144ec 100644--- a/apps/web/src/features/notification-sounds/browser-test/notification-sounds.browser.e2e.ts+++ b/apps/web/src/features/notification-sounds/browser-test/notification-sounds.browser.e2e.ts@@ -100,3 +100,65 @@ test('play buttons preview each type and a muted type stays quiet', async ({});await expect.poll(() => tonesPlayed(page)).toBe(3);});++test('quiet hours persist and silence sounds without stopping a preview', async ({+ page,+}) => {+ const quiet = page.getByRole('switch', { name: 'Quiet hours' });+ await expect(quiet).not.toBeChecked();+ await expect(page.getByRole('group', { name: 'Days' })).toHaveCount(0);++ await toggle(page, 'Quiet hours');+ await expect(page.getByRole('button', { name: 'Monday' })).toHaveAttribute(+ 'aria-pressed',+ 'true'+ );+ await page.getByRole('button', { name: 'Saturday' }).click();+ await expect(page.getByRole('button', { name: 'Saturday' })).toHaveAttribute(+ 'aria-pressed',+ 'false'+ );++ await page.reload();+ await expect(quiet).toBeChecked();+ await expect(page.getByRole('button', { name: 'Saturday' })).toHaveAttribute(+ 'aria-pressed',+ 'false'+ );+ await expect(page.getByRole('button', { name: 'Monday' })).toHaveAttribute(+ 'aria-pressed',+ 'true'+ );++ await page.evaluate(() => {+ const key = 'macro:notification-sounds:fixture-user';+ const saved = JSON.parse(localStorage.getItem(key) ?? '{}') as {+ enabled?: boolean;+ quietHours?: {+ enabled?: boolean;+ startMinutes?: number;+ endMinutes?: number;+ days?: string[];+ timeZone?: string;+ };+ };+ const now = new Date();+ const minutes = now.getUTCHours() * 60 + now.getUTCMinutes();+ saved.enabled = true;+ saved.quietHours = {+ ...saved.quietHours,+ enabled: true,+ startMinutes: (minutes + 1440 - 30) % 1440,+ endMinutes: (minutes + 30) % 1440,+ days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'],+ timeZone: 'UTC',+ };+ localStorage.setItem(key, JSON.stringify(saved));+ });+ await page.reload();+ await page.getByRole('heading', { name: 'Notifications' }).click();+ await page.evaluate(() => window.deliverNotification('channel_mention'));+ expect(await tonesPlayed(page)).toBe(0);+ await page.getByRole('button', { name: 'Play Mentions sound' }).click();+ await expect.poll(() => tonesPlayed(page)).toBe(2);+});diff --git a/apps/web/src/features/notification-sounds/components/QuietHoursSection.tsx b/apps/web/src/features/notification-sounds/components/QuietHoursSection.tsxnew file mode 100644index 0000000000..df99824657--- /dev/null+++ b/apps/web/src/features/notification-sounds/components/QuietHoursSection.tsx@@ -0,0 +1,179 @@+import {+ SettingsCard,+ SettingsRow,+ SettingsSection,+} from '@app/features/settings/primitives';+import { Button, ToggleSwitch } from '@ui';+import { createMemo, For, Show } from 'solid-js';+import {+ deviceTimeZone,+ type QuietHours,+ WEEKDAY_NAMES,+ WEEKDAYS,+ type Weekday,+} from '../core/quiet-hours';++function formatClock(minutes: number): string {+ return new Intl.DateTimeFormat(undefined, {+ hour: 'numeric',+ minute: '2-digit',+ }).format(new Date(2000, 0, 1, Math.floor(minutes / 60), minutes % 60));+}++function scheduleSummary(quiet: QuietHours): string {+ if (quiet.days.length === 0) return 'Pick at least one day.';+ if (quiet.startMinutes === quiet.endMinutes) {+ return 'Start and end match, so nothing is silenced.';+ }+ const start = formatClock(quiet.startMinutes);+ const end = formatClock(quiet.endMinutes);+ if (quiet.startMinutes > quiet.endMinutes) {+ return `From ${start} to ${end}, including overnight.`;+ }+ return `From ${start} to ${end}.`;+}++/** Quarter hours, plus a saved time that is not on that grid. */+function timeChoices(selected: number): { id: string; name: string }[] {+ const minutes = Array.from({ length: 96 }, (_, index) => index * 15);+ if (!minutes.includes(selected)) minutes.push(selected);+ minutes.sort((left, right) => left - right);+ return minutes.map((value) => ({+ id: String(value),+ name: formatClock(value),+ }));+}++function timeZoneChoices(selected: string): { id: string; name: string }[] {+ let zones: string[];+ try {+ zones = Intl.supportedValuesOf('timeZone');+ } catch {+ zones = [deviceTimeZone()];+ }+ if (selected && !zones.includes(selected)) zones = [selected, ...zones];+ return zones.map((id) => ({ id, name: id.replaceAll('_', ' ') }));+}++/** Weekly schedule that silences sounds and desktop notifications. */+export function QuietHoursSection(props: {+ quietHours: QuietHours;+ onChange: (change: Partial<QuietHours>) => void;+}) {+ const zones = createMemo(() => timeZoneChoices(props.quietHours.timeZone));+ const startTimes = createMemo(() =>+ timeChoices(props.quietHours.startMinutes)+ );+ const endTimes = createMemo(() => timeChoices(props.quietHours.endMinutes));+ const summary = () =>+ props.quietHours.enabled+ ? scheduleSummary(props.quietHours)+ : 'Off until you turn them on.';++ const setEnabled = (enabled: boolean) => {+ if (enabled && !props.quietHours.timeZone) {+ props.onChange({ enabled, timeZone: deviceTimeZone() });+ return;+ }+ props.onChange({ enabled });+ };++ const toggleDay = (day: Weekday) => {+ const selected = props.quietHours.days.includes(day)+ ? props.quietHours.days.filter((current) => current !== day)+ : [...props.quietHours.days, day];+ props.onChange({+ days: WEEKDAYS.filter((weekday) => selected.includes(weekday)),+ });+ };++ return (+ <SettingsSection+ title="Quiet hours"+ description="Silence notification sounds and desktop notifications during these hours. Inbox items still arrive, and incoming calls still ring. Saved on this device."+ >+ <SettingsCard>+ <SettingsRow label="Quiet hours" description={summary()}>+ <ToggleSwitch+ size="md"+ label="Quiet hours"+ labelClass="sr-only"+ checked={props.quietHours.enabled}+ onChange={setEnabled}+ />+ </SettingsRow>+ <Show when={props.quietHours.enabled}>+ <SettingsRow stackOnNarrow label="Days" align="start">+ <div+ role="group"+ aria-label="Days"+ class="flex max-w-full flex-wrap gap-1.5 @[460px]:justify-end"+ >+ <For each={WEEKDAYS}>+ {(day) => (+ <Button+ type="button"+ variant="secondary"+ size="sm"+ aria-label={WEEKDAY_NAMES[day]}+ aria-pressed={props.quietHours.days.includes(day)}+ onClick={() => toggleDay(day)}+ >+ {WEEKDAY_NAMES[day].slice(0, 3)}+ </Button>+ )}+ </For>+ </div>+ </SettingsRow>+ <SettingsRow stackOnNarrow label="From">+ <select+ aria-label="Quiet hours start"+ class="settings-input w-36"+ value={String(props.quietHours.startMinutes)}+ onChange={(event) => {+ const minutes = Number(event.currentTarget.value);+ if (!Number.isInteger(minutes)) return;+ props.onChange({ startMinutes: minutes });+ }}+ >+ <For each={startTimes()}>+ {(option) => <option value={option.id}>{option.name}</option>}+ </For>+ </select>+ </SettingsRow>+ <SettingsRow stackOnNarrow label="Until">+ <select+ aria-label="Quiet hours end"+ class="settings-input w-36"+ value={String(props.quietHours.endMinutes)}+ onChange={(event) => {+ const minutes = Number(event.currentTarget.value);+ if (!Number.isInteger(minutes)) return;+ props.onChange({ endMinutes: minutes });+ }}+ >+ <For each={endTimes()}>+ {(option) => <option value={option.id}>{option.name}</option>}+ </For>+ </select>+ </SettingsRow>+ <SettingsRow stackOnNarrow label="Time zone">+ {/* Native menu: the zone list is hundreds of rows. */}+ <select+ aria-label="Time zone"+ class="settings-input min-w-0 w-full @[460px]:w-72"+ value={props.quietHours.timeZone || deviceTimeZone()}+ onChange={(event) =>+ props.onChange({ timeZone: event.currentTarget.value })+ }+ >+ <For each={zones()}>+ {(zone) => <option value={zone.id}>{zone.name}</option>}+ </For>+ </select>+ </SettingsRow>+ </Show>+ </SettingsCard>+ </SettingsSection>+ );+}diff --git a/apps/web/src/features/notification-sounds/core/quiet-hours.test.ts b/apps/web/src/features/notification-sounds/core/quiet-hours.test.tsnew file mode 100644index 0000000000..2c6a96ed90--- /dev/null+++ b/apps/web/src/features/notification-sounds/core/quiet-hours.test.ts@@ -0,0 +1,125 @@+import { expect, it } from 'vitest';+import {+ DEFAULT_QUIET_HOURS,+ isWithinQuietHours,+ parseQuietHours,+ type QuietHours,+ quietHoursMute,+} from './quiet-hours';++function schedule(+ startHour: number,+ endHour: number,+ days: QuietHours['days'] = DEFAULT_QUIET_HOURS.days,+ timeZone = 'UTC'+): QuietHours {+ return {+ enabled: true,+ startMinutes: startHour * 60,+ endMinutes: endHour * 60,+ days,+ timeZone,+ };+}++it('stays off until quiet hours are turned on', () => {+ expect(+ isWithinQuietHours(DEFAULT_QUIET_HOURS, new Date('2026-11-04T04:00:00Z'))+ ).toBe(false);+ expect(parseQuietHours(undefined)).toEqual(DEFAULT_QUIET_HOURS);+});++it('includes the start of a same-day window and excludes the end', () => {+ const quiet = schedule(9, 17);+ expect(isWithinQuietHours(quiet, new Date('2026-11-04T08:59:00Z'))).toBe(+ false+ );+ expect(isWithinQuietHours(quiet, new Date('2026-11-04T09:00:00Z'))).toBe(+ true+ );+ expect(isWithinQuietHours(quiet, new Date('2026-11-04T16:59:00Z'))).toBe(+ true+ );+ expect(isWithinQuietHours(quiet, new Date('2026-11-04T17:00:00Z'))).toBe(+ false+ );+});++it('applies an overnight window to each selected calendar day', () => {+ const tuesday = schedule(22, 8, ['tue']);+ expect(isWithinQuietHours(tuesday, new Date('2026-11-03T23:30:00Z'))).toBe(+ true+ );+ expect(isWithinQuietHours(tuesday, new Date('2026-11-03T07:00:00Z'))).toBe(+ true+ );+ expect(isWithinQuietHours(tuesday, new Date('2026-11-03T12:00:00Z'))).toBe(+ false+ );+ // Wednesday morning belongs to Wednesday, not to Tuesday's late window.+ expect(isWithinQuietHours(tuesday, new Date('2026-11-04T01:00:00Z'))).toBe(+ false+ );+});++it('reads the clock in the schedule time zone', () => {+ const instant = new Date('2026-11-04T04:30:00Z');+ expect(+ isWithinQuietHours(schedule(22, 8, undefined, 'America/New_York'), instant)+ ).toBe(true);+ expect(+ isWithinQuietHours(+ schedule(22, 8, undefined, 'America/Los_Angeles'),+ instant+ )+ ).toBe(false);+});++it('covers nothing when the start and end match or no day is selected', () => {+ const noon = new Date('2026-11-04T12:00:00Z');+ expect(isWithinQuietHours(schedule(9, 9), noon)).toBe(false);+ expect(isWithinQuietHours(schedule(0, 23, []), noon)).toBe(false);+});++it('lets calls through and silences other alerts', () => {+ const quiet = schedule(0, 12);+ const during = new Date('2026-11-04T01:00:00Z');+ expect(quietHoursMute('channel_mention', quiet, during)).toBe(true);+ expect(quietHoursMute('call_started', quiet, during)).toBe(false);+ expect(+ quietHoursMute('channel_mention', quiet, new Date('2026-11-04T18:00:00Z'))+ ).toBe(false);+});++it('keeps a saved schedule and drops fields that cannot be a schedule', () => {+ expect(+ parseQuietHours({+ enabled: true,+ startMinutes: 22 * 60,+ endMinutes: 8 * 60,+ days: ['fri', 'nope', 'mon'],+ timeZone: 'America/New_York',+ })+ ).toEqual({+ enabled: true,+ startMinutes: 22 * 60,+ endMinutes: 8 * 60,+ days: ['mon', 'fri'],+ timeZone: 'America/New_York',+ });++ expect(+ parseQuietHours({+ enabled: true,+ timeZone: 'Not/AZone',+ startMinutes: 99.5,+ days: [],+ })+ ).toEqual({+ enabled: true,+ startMinutes: DEFAULT_QUIET_HOURS.startMinutes,+ endMinutes: DEFAULT_QUIET_HOURS.endMinutes,+ days: [],+ timeZone: '',+ });+});diff --git a/apps/web/src/features/notification-sounds/core/quiet-hours.ts b/apps/web/src/features/notification-sounds/core/quiet-hours.tsnew file mode 100644index 0000000000..9094cf1cf5--- /dev/null+++ b/apps/web/src/features/notification-sounds/core/quiet-hours.ts@@ -0,0 +1,171 @@+/** Days the schedule can select, Monday through Sunday. */+export const WEEKDAYS = [+ 'mon',+ 'tue',+ 'wed',+ 'thu',+ 'fri',+ 'sat',+ 'sun',+] as const;++export type Weekday = (typeof WEEKDAYS)[number];++export const WEEKDAY_NAMES: Record<Weekday, string> = {+ mon: 'Monday',+ tue: 'Tuesday',+ wed: 'Wednesday',+ thu: 'Thursday',+ fri: 'Friday',+ sat: 'Saturday',+ sun: 'Sunday',+};++const MINUTES_IN_DAY = 24 * 60;++/**+ * When notification sounds and desktop alerts stay quiet.+ * Saved with the other sound settings, per person and per device.+ */+export type QuietHours = {+ enabled: boolean;+ /** Minutes from midnight, 0–1439. A later start runs through midnight. */+ startMinutes: number;+ /** Minutes from midnight, 0–1439. The window ends at this minute. */+ endMinutes: number;+ /**+ * Calendar days, in the schedule's time zone, that use the clock window.+ * Tuesday morning is quiet only when Tuesday is selected.+ */+ days: readonly Weekday[];+ /** IANA zone. Empty means the device zone at the moment of evaluation. */+ timeZone: string;+};++/** Off until turned on, then every day from 10:00 PM to 8:00 AM. */+export const DEFAULT_QUIET_HOURS: QuietHours = {+ enabled: false,+ startMinutes: 22 * 60,+ endMinutes: 8 * 60,+ days: WEEKDAYS,+ timeZone: '',+};++const WEEKDAY_BY_NAME: Record<string, Weekday> = {+ Mon: 'mon',+ Monday: 'mon',+ Tue: 'tue',+ Tuesday: 'tue',+ Wed: 'wed',+ Wednesday: 'wed',+ Thu: 'thu',+ Thursday: 'thu',+ Fri: 'fri',+ Friday: 'fri',+ Sat: 'sat',+ Saturday: 'sat',+ Sun: 'sun',+ Sunday: 'sun',+};++function clockMinutes(value: unknown, fallback: number): number {+ if (typeof value !== 'number' || !Number.isInteger(value)) return fallback;+ if (value < 0 || value >= MINUTES_IN_DAY) return fallback;+ return value;+}++function isTimeZone(zone: string): boolean {+ try {+ Intl.DateTimeFormat('en-US', { timeZone: zone }).format(0);+ return true;+ } catch {+ return false;+ }+}++/** The device's IANA time zone, or UTC when the runtime cannot name one. */+export function deviceTimeZone(): string {+ try {+ const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;+ return zone && isTimeZone(zone) ? zone : 'UTC';+ } catch {+ return 'UTC';+ }+}++/** Reads a saved schedule, keeping each valid field and defaulting the rest. */+export function parseQuietHours(raw: unknown): QuietHours {+ if (!raw || typeof raw !== 'object') return DEFAULT_QUIET_HOURS;+ const value = raw as Record<string, unknown>;+ const storedDays = value.days;+ const days = Array.isArray(storedDays)+ ? WEEKDAYS.filter((day) => storedDays.includes(day))+ : DEFAULT_QUIET_HOURS.days;+ const timeZone = typeof value.timeZone === 'string' ? value.timeZone : '';+ return {+ enabled: value.enabled === true,+ startMinutes: clockMinutes(+ value.startMinutes,+ DEFAULT_QUIET_HOURS.startMinutes+ ),+ endMinutes: clockMinutes(value.endMinutes, DEFAULT_QUIET_HOURS.endMinutes),+ days,+ timeZone: timeZone && isTimeZone(timeZone) ? timeZone : '',+ };+}++function zonedClock(+ now: Date,+ timeZone: string+): { weekday: Weekday; minutes: number } | null {+ const zone = timeZone || deviceTimeZone();+ try {+ const parts = new Intl.DateTimeFormat('en-US', {+ timeZone: zone,+ weekday: 'short',+ hour: '2-digit',+ minute: '2-digit',+ hourCycle: 'h23',+ }).formatToParts(now);+ const read = (type: Intl.DateTimeFormatPartTypes) =>+ parts.find((part) => part.type === type)?.value;+ const weekday = WEEKDAY_BY_NAME[read('weekday') ?? ''];+ const hour = Number(read('hour'));+ const minute = Number(read('minute'));+ if (!weekday || Number.isNaN(hour) || Number.isNaN(minute)) return null;+ const normalizedHour = hour === 24 ? 0 : hour;+ if (normalizedHour > 23 || minute > 59) return null;+ return { weekday, minutes: normalizedHour * 60 + minute };+ } catch {+ if (timeZone) return zonedClock(now, '');+ return null;+ }+}++/** Whether `now` falls inside the schedule. An equal start and end covers nothing. */+export function isWithinQuietHours(quietHours: QuietHours, now: Date): boolean {+ if (!quietHours.enabled || quietHours.days.length === 0) return false;+ if (quietHours.startMinutes === quietHours.endMinutes) return false;+ const clock = zonedClock(now, quietHours.timeZone);+ if (!clock || !quietHours.days.includes(clock.weekday)) return false;+ const { minutes } = clock;+ if (quietHours.startMinutes < quietHours.endMinutes) {+ return (+ minutes >= quietHours.startMinutes && minutes < quietHours.endMinutes+ );+ }+ return minutes >= quietHours.startMinutes || minutes < quietHours.endMinutes;+}++/**+ * Whether this alert should stay silent and skip the desktop notification.+ * Incoming calls keep their own ring and alert.+ */+export function quietHoursMute(+ eventTag: string,+ quietHours: QuietHours,+ now: Date+): boolean {+ if (eventTag === 'call_started') return false;+ return isWithinQuietHours(quietHours, now);+}diff --git a/apps/web/src/features/notification-sounds/core/settings.test.ts b/apps/web/src/features/notification-sounds/core/settings.test.tsindex 777960b502..b9d1bcb552 100644--- a/apps/web/src/features/notification-sounds/core/settings.test.ts+++ b/apps/web/src/features/notification-sounds/core/settings.test.ts@@ -64,6 +64,39 @@ it('plays the sound chosen for the notification category', () => {expect(soundForNotification('new_email', settings)).toBeNull();});+it('stays quiet during quiet hours and plays again outside them', () => {+ const settings = parseNotificationSoundSettings(+ JSON.stringify({+ enabled: true,+ quietHours: {+ enabled: true,+ startMinutes: 22 * 60,+ endMinutes: 8 * 60,+ days: ['tue'],+ timeZone: 'UTC',+ },+ })+ );++ expect(+ soundForNotification(+ 'channel_mention',+ settings,+ new Date('2026-11-03T23:30:00Z')+ )+ ).toBeNull();+ expect(+ soundForNotification(+ 'channel_mention',+ settings,+ new Date('2026-11-03T12:00:00Z')+ )+ ).toBe('ding');+ expect(parseNotificationSoundSettings('{"enabled":true}').quietHours).toEqual(+ DEFAULT_NOTIFICATION_SOUND_SETTINGS.quietHours+ );+});+it('stays quiet for calls, muted volume, and unknown events', () => {const settings = parseNotificationSoundSettings(JSON.stringify({ enabled: true })diff --git a/apps/web/src/features/notification-sounds/core/settings.ts b/apps/web/src/features/notification-sounds/core/settings.tsindex 3da3e906b8..16d13eb30c 100644--- a/apps/web/src/features/notification-sounds/core/settings.ts+++ b/apps/web/src/features/notification-sounds/core/settings.ts@@ -4,6 +4,12 @@ import {notificationSoundCategory,soundCategoryForEvent,} from './categories';+import {+ DEFAULT_QUIET_HOURS,+ isWithinQuietHours,+ parseQuietHours,+ type QuietHours,+} from './quiet-hours';import { isNotificationSoundId, type NotificationSoundId } from './sounds';export type NotificationSoundCategorySettings = {@@ -20,6 +26,8 @@ export type NotificationSoundSettings = {NotificationSoundCategoryId,NotificationSoundCategorySettings>;+ /** Weekly schedule that silences sounds and desktop alerts. */+ quietHours: QuietHours;};function categorySettings(@@ -49,6 +57,7 @@ export const DEFAULT_NOTIFICATION_SOUND_SETTINGS: NotificationSoundSettings = {const category = notificationSoundCategory(id);return { enabled: category.defaultEnabled, sound: category.defaultSound };}),+ quietHours: DEFAULT_QUIET_HOURS,};const storedSettingsSchema = z.object({@@ -60,6 +69,7 @@ const storedSettingsSchema = z.object({z.object({ enabled: z.boolean().optional(), sound: z.unknown() })).optional(),+ quietHours: z.unknown().optional(),});/**@@ -84,6 +94,7 @@ export function parseNotificationSoundSettings(return {enabled: stored.enabled ?? defaults.enabled,volume: stored.volume ?? defaults.volume,+ quietHours: parseQuietHours(stored.quietHours),categories: categorySettings((id) => {const saved = stored.categories?.[id];const sound = saved?.sound;@@ -103,8 +114,10 @@ export function parseNotificationSoundSettings(*/export function soundForNotification(eventTag: string,- settings: NotificationSoundSettings+ settings: NotificationSoundSettings,+ now = new Date()): NotificationSoundId | null {+ if (isWithinQuietHours(settings.quietHours, now)) return null;if (!settings.enabled || settings.volume === 0) return null;const categoryId = soundCategoryForEvent(eventTag);if (!categoryId) return null;diff --git a/apps/web/src/features/notification-sounds/primitives/sound-settings.ts b/apps/web/src/features/notification-sounds/primitives/sound-settings.tsindex 55f9fed81b..cd10347ba6 100644--- a/apps/web/src/features/notification-sounds/primitives/sound-settings.ts+++ b/apps/web/src/features/notification-sounds/primitives/sound-settings.ts@@ -2,6 +2,7 @@ import { makePersistedState } from '@app/lib/persistence';import { createUserScopedStorage } from '@core/util/userScopedStorage';import { createSignal } from 'solid-js';import type { NotificationSoundCategoryId } from '../core/categories';+import type { QuietHours } from '../core/quiet-hours';import {DEFAULT_NOTIFICATION_SOUND_SETTINGS,type NotificationSoundCategorySettings,@@ -53,5 +54,10 @@ export function createNotificationSoundSettings(userId: string) {[id]: { ...current.categories[id], ...change },},})),+ setQuietHours: (change: Partial<QuietHours>) =>+ setSettings((current) => ({+ ...current,+ quietHours: { ...current.quietHours, ...change },+ })),};}diff --git a/apps/web/src/features/notification-sounds/use-notification-sounds.test.ts b/apps/web/src/features/notification-sounds/use-notification-sounds.test.tsindex 887fc1111b..fd76b345d9 100644--- a/apps/web/src/features/notification-sounds/use-notification-sounds.test.ts+++ b/apps/web/src/features/notification-sounds/use-notification-sounds.test.ts@@ -84,6 +84,27 @@ it('plays the chosen sound once for a burst of notifications', () => {dispose();});+it('does not play during quiet hours', () => {+ vi.setSystemTime(new Date('2026-11-03T23:30:00Z'));+ localStorage.setItem(+ SETTINGS_KEY,+ JSON.stringify({+ enabled: true,+ quietHours: {+ enabled: true,+ startMinutes: 22 * 60,+ endMinutes: 8 * 60,+ days: ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'],+ timeZone: 'UTC',+ },+ })+ );+ const { deliver, dispose } = mountSounds();+ deliver(notification('channel_mention'));+ expect(playNotificationSound).not.toHaveBeenCalled();+ dispose();+});+it('skips read notifications, muted categories, and tabs not in use', () => {localStorage.setItem(SETTINGS_KEY, JSON.stringify({ enabled: true }));const { deliver, dispose } = mountSounds();diff --git a/apps/web/src/features/notification-sounds/views/NotificationSoundSettingsView.tsx b/apps/web/src/features/notification-sounds/views/NotificationSoundSettingsView.tsxindex 7358d3ddd9..19e8209dbb 100644--- a/apps/web/src/features/notification-sounds/views/NotificationSoundSettingsView.tsx+++ b/apps/web/src/features/notification-sounds/views/NotificationSoundSettingsView.tsx@@ -2,6 +2,7 @@ import { useUserId } from '@core/context/user';import { fireAndForget } from '@core/util/fireAndForget';import { Show } from 'solid-js';import { NotificationSoundSection } from '../components/NotificationSoundSection';+import { QuietHoursSection } from '../components/QuietHoursSection';import { playNotificationSound } from '../primitives/sound-player';import { createNotificationSoundSettings } from '../primitives/sound-settings';@@ -13,18 +14,24 @@ export function NotificationSoundSettingsView() {{(id) => {const sounds = createNotificationSoundSettings(id);return (- <NotificationSoundSection- settings={sounds.settings()}- onEnabledChange={sounds.setEnabled}- onVolumeChange={sounds.setVolume}- onCategoryChange={sounds.setCategory}- onPreview={(sound) =>- fireAndForget(- playNotificationSound(sound, sounds.settings().volume),- 'notification-sounds'- )- }- />+ <>+ <NotificationSoundSection+ settings={sounds.settings()}+ onEnabledChange={sounds.setEnabled}+ onVolumeChange={sounds.setVolume}+ onCategoryChange={sounds.setCategory}+ onPreview={(sound) =>+ fireAndForget(+ playNotificationSound(sound, sounds.settings().volume),+ 'notification-sounds'+ )+ }+ />+ <QuietHoursSection+ quietHours={sounds.settings().quietHours}+ onChange={sounds.setQuietHours}+ />+ </>);}}</Show>diff --git a/apps/web/src/features/settings/core/settings-search.ts b/apps/web/src/features/settings/core/settings-search.tsindex a9b1184d92..a8a5573f31 100644--- a/apps/web/src/features/settings/core/settings-search.ts+++ b/apps/web/src/features/settings/core/settings-search.ts@@ -166,6 +166,12 @@ const SETTINGS: Setting[] = [target: 'Email digest',keywords: 'summary notification daily mail',},+ {+ tab: 'Notifications',+ title: 'Quiet hours',+ target: 'Quiet hours',+ keywords: 'schedule do not disturb dnd silence mute night timezone',+ },{tab: 'Notifications',title: 'Snoozed items',diff --git a/docs/agent-guide/notifications.md b/docs/agent-guide/notifications.mdindex e1a490daad..ad2823b651 100644--- a/docs/agent-guide/notifications.md+++ b/docs/agent-guide/notifications.md@@ -204,6 +204,17 @@ sent silent so the person hears one sound. macOS builds older than the`silent` argument on `send_macos_notification` ignore it and still play thesystem sound.+**Settings → Notifications → Quiet hours** silences those sounds and skips+desktop and browser alerts on a weekly schedule. It is off until turned on,+then covers every day from 10:00 PM to 8:00 AM in the device's time zone. The+person picks the days, the start and end, and the time zone. A later start+runs through midnight, and the window is the clock time on each selected day,+so Tuesday morning is quiet only when Tuesday is selected. An equal start and+end covers no time. Incoming calls still ring and still show an alert. Inbox+items still arrive. The schedule is saved on this device with the sound+settings, so a phone and a computer can differ. A sound preview still plays.+Mobile push sent while the app is not open is unchanged.+The backend-free desktop/phone regression drives the real settings section,persistence, previews, and delivery through a stand-in notification feed:`bunx playwright test --config src/features/notification-sounds/browser-test/playwright.config.ts`