diff --git a/src/main/persistence.test.ts b/src/main/persistence.test.ts index 9da11bc67..c6b4924b9 100644 --- a/src/main/persistence.test.ts +++ b/src/main/persistence.test.ts @@ -435,6 +435,7 @@ describe('Store', () => { expect(settings.floatingTerminalDefaultedForAllUsers).toBe(true) expect(settings.notifications.customSoundPath).toBeNull() expect(settings.notifications.customSoundVolume).toBe(100) + expect(settings.notifications.suppressWhenFocused).toBe(true) }) it('returns default UI state when no data file exists', async () => { diff --git a/src/renderer/src/components/onboarding/NotificationStep.test.tsx b/src/renderer/src/components/onboarding/NotificationStep.test.tsx index bd086bf6f..9eb516cb8 100644 --- a/src/renderer/src/components/onboarding/NotificationStep.test.tsx +++ b/src/renderer/src/components/onboarding/NotificationStep.test.tsx @@ -11,7 +11,7 @@ function createSettings( enabled: true, agentTaskComplete: true, terminalBell: true, - suppressWhenFocused: false, + suppressWhenFocused: true, customSoundId: 'system', customSoundPath: null, customSoundVolume: 80, diff --git a/src/renderer/src/components/onboarding/NotificationStep.tsx b/src/renderer/src/components/onboarding/NotificationStep.tsx index afdfcd3c3..29bd0c87a 100644 --- a/src/renderer/src/components/onboarding/NotificationStep.tsx +++ b/src/renderer/src/components/onboarding/NotificationStep.tsx @@ -17,12 +17,6 @@ import { getNotificationSoundOptions } from '@/components/notification-sound-opt import { useMountedRef } from '@/hooks/useMountedRef' import { translate } from '@/i18n/i18n' -export type NotificationDraft = { - agentTaskComplete: boolean - terminalBell: boolean - notifyWhenFocused: boolean -} - type NotificationStepProps = { settings: GlobalSettings | null updateSettings: (updates: Partial) => Promise | void diff --git a/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.test.ts b/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.test.ts index b37b9a817..6a16417a7 100644 --- a/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.test.ts +++ b/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.test.ts @@ -7,6 +7,7 @@ vi.mock('@/lib/telemetry', () => ({ })) import { + buildCompletedOnboardingNotificationSettings, buildOnboardingDismissedPayload, trackOnboardingDismissed } from './use-onboarding-flow-persistence' @@ -41,4 +42,26 @@ describe('onboarding flow persistence', () => { advanced_via: 'keyboard' }) }) + + it('preserves explicit focus notification suppression when completing onboarding', () => { + const notifications = buildCompletedOnboardingNotificationSettings({ + enabled: false, + agentTaskComplete: false, + terminalBell: false, + suppressWhenFocused: false, + customSoundId: 'two-tone', + customSoundPath: null, + customSoundVolume: 60 + }) + + expect(notifications).toEqual({ + enabled: true, + agentTaskComplete: true, + terminalBell: true, + suppressWhenFocused: false, + customSoundId: 'two-tone', + customSoundPath: null, + customSoundVolume: 60 + }) + }) }) diff --git a/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.ts b/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.ts index cfec07c00..8c1f726eb 100644 --- a/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.ts +++ b/src/renderer/src/components/onboarding/use-onboarding-flow-persistence.ts @@ -22,6 +22,17 @@ function selectedAgentOrBlank(agent: TuiAgent | null): TuiAgent | 'blank' { return agent ?? 'blank' } +export function buildCompletedOnboardingNotificationSettings( + notifications: GlobalSettings['notifications'] +): GlobalSettings['notifications'] { + return { + ...notifications, + enabled: true, + agentTaskComplete: true, + terminalBell: true + } +} + type CloseWithDeps = { onOnboardingChange: (state: OnboardingState) => void onboardingChecklist: OnboardingState['checklist'] @@ -188,12 +199,7 @@ export function usePersistCurrentStep({ } if (currentStepId === 'notifications') { await updateSettings({ - notifications: { - ...settings.notifications, - enabled: true, - agentTaskComplete: true, - terminalBell: true - } + notifications: buildCompletedOnboardingNotificationSettings(settings.notifications) }) useAppStore.getState().recordFeatureInteraction('notifications') onOnboardingChange(await persistStep(ONBOARDING_FINAL_STEP)) diff --git a/src/shared/constants.test.ts b/src/shared/constants.test.ts index fcf4ac33e..b074070c9 100644 --- a/src/shared/constants.test.ts +++ b/src/shared/constants.test.ts @@ -1,5 +1,9 @@ import { describe, expect, it } from 'vitest' -import { getDefaultPrimarySelectionMiddleClickPaste, getDefaultSettings } from './constants' +import { + getDefaultNotificationSettings, + getDefaultPrimarySelectionMiddleClickPaste, + getDefaultSettings +} from './constants' describe('getDefaultSettings', () => { it('uses platform-consistent separators for the default workspace directory', () => { @@ -61,6 +65,11 @@ describe('getDefaultSettings', () => { expect(getDefaultSettings('/tmp').compactWorktreeCards).toBe(false) }) + it('suppresses notifications for the focused worktree by default for new users', () => { + expect(getDefaultNotificationSettings().suppressWhenFocused).toBe(true) + expect(getDefaultSettings('/tmp').notifications.suppressWhenFocused).toBe(true) + }) + it('defaults agent launch args to yolo mode where the CLI supports it', () => { const settings = getDefaultSettings('/tmp')