Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(mobile): dictation step example fallback; move Private mode to AI Models (#2566)
Chad Piha95f21960d1c0
diff --git a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swiftindex 5edcd9708..98c3d0475 100644--- a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift+++ b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift@@ -1796,7 +1796,7 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDe// when locked. The header costs one row of the height-capped menu, so on// shorter keyboards the last tone ("Excited") can fall into the scroll// region instead of showing inline.- let menuTitle = applicable ? "Dictation Tone" : "Turn on Cloud to use tones"+ let menuTitle = applicable ? "Dictation Tone" : "Turn off Private mode to use tones"toneButton.menu = UIMenu(title: menuTitle, children: actions)toneButton.isUserInteractionEnabled = truetoneButton.alpha = applicable ? 1.0 : 0.4@@ -3059,11 +3059,11 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDelet provider = KeyboardHandoffProvider.sharedguard provider.isAgentEnabled() else { return }- // Not applicable ⇒ locked behind Cloud. Point at the app, swallow the tap.+ // Not applicable ⇒ Private mode is on. Point at it, swallow the tap.guard provider.isAgentApplicable() else {playKeyClick()showTransientRecordState(- title: "Turn on Cloud in app",+ title: "Turn off Private mode",systemImage: "lock.fill",background: Palette.issue,duration: 1.6diff --git a/openwhispr-mobile/src/components/settings/OnDeviceModelSection.tsx b/openwhispr-mobile/src/components/settings/OnDeviceModelSection.tsxindex 4261dae94..db9bd9d5f 100644--- a/openwhispr-mobile/src/components/settings/OnDeviceModelSection.tsx+++ b/openwhispr-mobile/src/components/settings/OnDeviceModelSection.tsx@@ -20,6 +20,9 @@ import { useModelDownloadStore } from '@/store/useModelDownloadStore';type Props = {scope: 'dictation' | 'upload';picked: LocalModelKey | undefined;+ // The workflow is saved to a mode Private mode locks and shown as Automatic, so tapping+ // Automatic must not replace that choice; picking a model still does.+ lockedChoice?: boolean;};function modelInUse(languages: string[], availability: LocalEngineAvailability): string {@@ -40,7 +43,11 @@ function radio(selected: boolean): { icon: string; mdIcon: 'CircleCheck' | 'Circ: { icon: 'circle', mdIcon: 'Circle' };}-export function OnDeviceModelSection({ scope, picked }: Props): React.JSX.Element | null {+export function OnDeviceModelSection({+ scope,+ picked,+ lockedChoice = false,+}: Props): React.JSX.Element | null {const [availability, setAvailability] = useState<LocalEngineAvailability | null>(null);const completedCount = useModelDownloadStore((state) => state.completedCount);@@ -81,7 +88,7 @@ export function OnDeviceModelSection({ scope, picked }: Props): React.JSX.Elemendescription={`Best downloaded model for your languages. ${modelInUse(languages, availability)}`}selected={!effectivePick}showChevron={false}- onPress={() => pickLocalModel(scope, undefined)}+ onPress={lockedChoice ? undefined : () => pickLocalModel(scope, undefined)}/>{catalog.map((entry) =>entry.downloaded ? (diff --git a/openwhispr-mobile/src/components/settings/__tests__/OnDeviceModelSection.test.tsx b/openwhispr-mobile/src/components/settings/__tests__/OnDeviceModelSection.test.tsxindex 713b77269..c93bfcec4 100644--- a/openwhispr-mobile/src/components/settings/__tests__/OnDeviceModelSection.test.tsx+++ b/openwhispr-mobile/src/components/settings/__tests__/OnDeviceModelSection.test.tsx@@ -69,6 +69,17 @@ it('picks a downloaded model for the workflow', async () => {expect(mockPickLocalModel).toHaveBeenCalledWith('upload', 'parakeet-v3');});+// Private mode shows a workflow saved to Cloud or Bring Your Own Key as Automatic; tapping that+// row must not quietly replace the saved choice, which applies again when Private mode is off.+it('keeps a locked choice when Automatic is tapped, but still picks a model', async () => {+ render(<OnDeviceModelSection scope="upload" picked={undefined} lockedChoice />);+ fireEvent.press(await screen.findByText('Automatic'));+ expect(mockPickLocalModel).not.toHaveBeenCalled();+ expect(isSelected('Automatic')).toBe(true);+ fireEvent.press(screen.getByText('Parakeet v3'));+ expect(mockPickLocalModel).toHaveBeenCalledWith('upload', 'parakeet-v3');+});+it('shows the picked model as selected and can go back to Automatic', async () => {render(<OnDeviceModelSection scope="dictation" picked="parakeet-v3" />);await screen.findByText('Parakeet v3');diff --git a/openwhispr-mobile/src/components/ui/CloudIcon.tsx b/openwhispr-mobile/src/components/ui/CloudIcon.tsxdeleted file mode 100644index f76768626..000000000--- a/openwhispr-mobile/src/components/ui/CloudIcon.tsx+++ /dev/null@@ -1,39 +0,0 @@-import Svg, { Path } from 'react-native-svg';--/**- * Inline SVG cloud / cloud-off glyph for the Home mode toggle.- *- * Rendered with react-native-svg (synchronous) rather than `SystemIcon`, whose- * iOS path loads SF Symbols through expo-image asynchronously — that left the- * toggle icon blank on first mount until a re-render. SVG paints immediately.- */-export function CloudIcon({- size = 16,- color = '#FFFFFF',- off = false,-}: {- size?: number;- color?: string;- off?: boolean;-}) {- return (- <Svg width={size} height={size} viewBox="0 0 24 24" fill="none">- <Path- d="M7 18a4 4 0 0 1 .6-7.96 5 5 0 0 1 9.65 1.06A3.5 3.5 0 0 1 17 18z"- stroke={color}- strokeWidth={2}- strokeLinecap="round"- strokeLinejoin="round"- />- {off ? (- <Path- d="M3 3l18 18"- stroke={color}- strokeWidth={2}- strokeLinecap="round"- strokeLinejoin="round"- />- ) : null}- </Svg>- );-}diff --git a/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts b/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.tsindex 87dd86437..ffd25c552 100644--- a/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts+++ b/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts@@ -50,7 +50,7 @@ jest.mock('@/components/ui/UsageMeter', () => ({function expectQuotaGuidance(): void {expect(Alert.alert).toHaveBeenCalledWith('Weekly Limit Reached',- expect.stringContaining('Switch to Private Mode'),+ expect.stringContaining('Turn on Private Mode in Account → AI Models'),expect.arrayContaining([expect.objectContaining({ text: 'View Usage', onPress: expect.any(Function) }),expect.objectContaining({ text: 'Upgrade', onPress: expect.any(Function) }),diff --git a/openwhispr-mobile/src/hooks/useFileUpload.ts b/openwhispr-mobile/src/hooks/useFileUpload.tsindex 25aef0e5f..b5770e223 100644--- a/openwhispr-mobile/src/hooks/useFileUpload.ts+++ b/openwhispr-mobile/src/hooks/useFileUpload.ts@@ -148,7 +148,7 @@ export function useFileUpload(options: UseFileUploadOptions = {}) {// decodes Opus, so route private-mode Opus uploads there instead.if (transcriptionProvider === 'local' && isOggOpus(file.name, file.mimeType, file.uri)) {throw new Error(- 'Opus audio can only be transcribed in Cloud mode right now. Switch to Cloud mode and try again.',+ "Opus audio can't be transcribed on this iPhone yet. In Account → AI Models, turn off Private Mode or set Uploads to OpenWhispr Cloud, then try again.",);}diff --git a/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts b/openwhispr-mobile/src/hooks/useUsageLimitRecovery.tsindex 6fce11f19..45360d619 100644--- a/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts+++ b/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts@@ -27,7 +27,7 @@ function showUsageLimitFallback(): void {Alert.alert('Weekly Limit Reached',- `You've used ${words} for this week.${resetLabel ? ` ${resetLabel}.` : ''} Switch to Private Mode for unlimited on-device dictation, or upgrade to Pro for unlimited cloud transcription.`,+ `You've used ${words} for this week.${resetLabel ? ` ${resetLabel}.` : ''} Turn on Private Mode in Account → AI Models for unlimited on-device dictation, or upgrade to Pro for unlimited cloud transcription.`,[{ text: 'OK', style: 'cancel' },{ text: 'View Usage', onPress: () => router.push('/(account)') },diff --git a/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts b/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.tsindex 2e87f041f..8f126bd25 100644--- a/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts@@ -1,6 +1,8 @@import {getDictationAgentName,isDictationAgentApplicable,+ isNoteChatEnabled,+ voiceAssistantToggleConfig,detectAgentMention,} from '@/lib/dictationAgent';import type { UserConfig } from '@/types';@@ -55,6 +57,33 @@ describe('isDictationAgentApplicable', () => {});});+// Note chat once shared the voice assistant's switch, so an existing choice carries over.+describe('note chat', () => {+ it('is on by default', () => {+ expect(isNoteChatEnabled(baseConfig)).toBe(true);+ });++ it('follows the old shared switch until set on its own', () => {+ expect(isNoteChatEnabled({ ...baseConfig, dictationAgentEnabled: false })).toBe(false);+ expect(+ isNoteChatEnabled({ ...baseConfig, dictationAgentEnabled: false, noteChatEnabled: true }),+ ).toBe(true);+ });++ it('keeps its state when only the voice assistant is switched', () => {+ expect(voiceAssistantToggleConfig(baseConfig, false)).toEqual({+ dictationAgentEnabled: false,+ noteChatEnabled: true,+ });+ expect(+ voiceAssistantToggleConfig({ ...baseConfig, dictationAgentEnabled: false }, true),+ ).toEqual({ dictationAgentEnabled: true, noteChatEnabled: false });+ expect(voiceAssistantToggleConfig({ ...baseConfig, noteChatEnabled: false }, true)).toEqual({+ dictationAgentEnabled: true,+ });+ });+});+describe('detectAgentMention — Layer 1: word-boundary exact match', () => {it('detects the name at word boundaries', () => {expect(detectAgentMention('Hey OpenWhispr write a follow-up email', 'OpenWhispr')).toBe(true);diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.tsindex 8beac0445..410d04d7b 100644--- a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts@@ -43,7 +43,7 @@ it('keeps an explicit upload choice when toggling between Cloud and On-Device',expect(dictationModeConfig(explicit, 'private').inference?.upload).toEqual({ mode: 'local' });});-it('keeps the dictation selection in step with the Cloud toggle', () => {+it('keeps the dictation selection in step with Private mode', () => {const config = {defaultMode: 'private' as const,inference: {@@ -162,6 +162,91 @@ describe('workflowSaveConfig', () => {inference: { dictation: { mode: 'openwhispr' } },});});++ describe('where Private mode returns to', () => {+ const fromProviders: UserConfig = {+ defaultMode: 'private',+ privateModeReturn: { pinned: { upload: { mode: 'openwhispr' } } },+ inference: { dictation: { mode: 'local' } },+ };++ it('is Bring Your Own Key, with what it held, when Private mode is turned on from it', () => {+ const config: UserConfig = {+ defaultMode: 'providers',+ inference: {+ dictation: groqDictation,+ upload: { mode: 'openwhispr' },+ notes: { mode: 'local' },+ },+ pinnedInference: ['upload'],+ };+ const next = workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'providers');+ // Notes is the user's own choice, so only the held upload is recorded.+ expect(next.privateModeReturn).toEqual({ pinned: { upload: { mode: 'openwhispr' } } });+ expect(next.inference).toEqual({ dictation: { mode: 'local' }, notes: { mode: 'local' } });+ });++ it('is not set when Private mode is turned on from Cloud', () => {+ const config: UserConfig = { defaultMode: 'cloud' };+ expect(+ workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'cloud'),+ ).not.toHaveProperty('privateModeReturn');+ });++ it('survives picking another on-device model', () => {+ const next = workflowSaveConfig(+ fromProviders,+ 'dictation',+ { mode: 'local', modelId: 'whisper-base' },+ 'private',+ );+ expect(next.privateModeReturn).toEqual(fromProviders.privateModeReturn);+ });++ it.each([+ ['Cloud', { mode: 'openwhispr' as const }],+ ['Bring Your Own Key', groqDictation],+ ])('is cleared when dictation leaves Private mode for %s', (_label, selection) => {+ const next = workflowSaveConfig(fromProviders, 'dictation', selection, 'private');+ expect(next).toHaveProperty('privateModeReturn', undefined);+ });++ it('holds what Bring Your Own Key held when dictation goes back to it', () => {+ const next = workflowSaveConfig(fromProviders, 'dictation', groqDictation, 'private');+ expect(next.inference).toEqual({ dictation: groqDictation, upload: { mode: 'openwhispr' } });+ expect(next.pinnedInference).toEqual(['upload']);+ });++ it('keeps a choice made in Private mode over what Bring Your Own Key held', () => {+ const config: UserConfig = {+ ...fromProviders,+ inference: {+ dictation: { mode: 'local' },+ upload: { mode: 'local', modelId: 'whisper-base' },+ },+ };+ const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');+ expect(next.inference?.upload).toEqual({ mode: 'local', modelId: 'whisper-base' });+ expect(next).not.toHaveProperty('pinnedInference');+ });++ it('holds workflows on this phone when Private mode was not turned on from it', () => {+ const config: UserConfig = {+ defaultMode: 'private',+ inference: { dictation: { mode: 'local' } },+ };+ const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');+ expect(next.pinnedInference).toEqual(['upload', 'notes', 'agent']);+ });++ // Replaying onboarding writes the mode directly, and must not leave a stale return behind.+ it.each(['cloud', 'private'] as const)('is cleared by choosing %s outright', (mode) => {+ expect(dictationModeConfig(fromProviders, mode)).toHaveProperty(+ 'privateModeReturn',+ undefined,+ );+ });+ });});describe('getInferenceModes', () => {diff --git a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.tsindex 3dcae43cf..2aef10a3a 100644--- a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts@@ -28,6 +28,10 @@ jest.mock('@/store/useOnboardingStore', () => ({getState: () => ({ currentStep: mockCurrentStep, chooseMode: mockChooseMode }),},}));+let mockAccountHistory = false;+jest.mock('@/sync/syncIdentity', () => ({+ hasRealAccountHistory: () => mockAccountHistory,+}));jest.mock('@/store/useAuthStore', () => ({useAuthStore: {getState: () => ({@@ -43,6 +47,7 @@ beforeEach(() => {mockError = null;mockUser = null;mockGuest = false;+ mockAccountHistory = false;mockCurrentStep = 'privacy-mode';mockConfig = { defaultMode: 'private' };mockUpdateConfig.mockResolvedValue(undefined);@@ -136,3 +141,24 @@ it('moves the dictation route with the chosen mode and restores both on failure'pinnedInference: ['upload'],});});++// A new identity there would read as an account switch and wipe the synced account's notes.+describe('on a device that synced an account, signed out', () => {+ beforeEach(() => {+ mockAccountHistory = true;+ });++ it('refuses Cloud at the mode choice without opening a session', async () => {+ const attempt = chooseOnboardingMode('cloud', 'privacy-mode');+ await expect(attempt).rejects.toThrow('Cloud needs you signed in');+ expect(mockEnsureSession).not.toHaveBeenCalled();+ expect(mockUpdateConfig).not.toHaveBeenCalled();+ });++ it('saves Cloud for after sign-in when leaving a stuck download', async () => {+ mockCurrentStep = 'private-download';+ await chooseOnboardingMode('cloud', 'private-download');+ expect(mockEnsureSession).not.toHaveBeenCalled();+ expect(mockChooseMode).toHaveBeenCalledWith('cloud', 'private-download');+ });+});diff --git a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.tsindex 70000613c..8f57f2eaf 100644--- a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts@@ -7,6 +7,9 @@ const mockPrivateReadiness = jest.fn();const mockLocalReasoningReadiness = jest.fn();let mockConfig: Record<string, unknown> | null = null;let mockUser: Record<string, unknown> | null = { id: 'user-1' };+let mockActiveMode = 'cloud';+const mockPolicy = jest.fn();+const mockKeyStatus = jest.fn();jest.mock('expo-router', () => ({ router: { push: (...args: unknown[]) => mockPush(...args) } }));jest.mock('@/store/useConfigStore', () => ({@@ -15,7 +18,9 @@ jest.mock('@/store/useConfigStore', () => ({},}));jest.mock('@/store/useProcessingModeStore', () => ({- useProcessingModeStore: { getState: () => ({ setActiveMode: mockSetActiveMode }) },+ useProcessingModeStore: {+ getState: () => ({ activeMode: mockActiveMode, setActiveMode: mockSetActiveMode }),+ },}));jest.mock('@/store/useAuthStore', () => ({useAuthStore: { getState: () => ({ user: mockUser }) },@@ -28,8 +33,14 @@ jest.mock('@/lib/localReasoning', () => ({getLocalReasoningReadiness: () => mockLocalReasoningReadiness(),getLocalReasoningUnavailableMessage: () => 'Apple Intelligence is turned off.',}));+jest.mock('@/services/providers/ProviderPolicy', () => ({+ getProviderPolicy: () => mockPolicy(),+}));+jest.mock('@/services/providers/ProviderCredentials', () => ({+ getProviderCredentialStatus: (reference: string) => mockKeyStatus(reference),+}));-import { pickLocalModel, switchWorkflowMode } from '../workflowModeSwitch';+import { pickLocalModel, setPrivateMode, switchWorkflowMode } from '../workflowModeSwitch';let alert: jest.SpyInstance;@@ -37,16 +48,39 @@ beforeEach(() => {jest.clearAllMocks();mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };mockUser = { id: 'user-1' };+ mockActiveMode = 'cloud';mockPrivateReadiness.mockResolvedValue({ status: 'ready', modelName: 'Parakeet v2' });mockLocalReasoningReadiness.mockResolvedValue({ status: 'ready', tokenCounting: false });alert = jest.spyOn(Alert, 'alert').mockImplementation(() => undefined);+ mockPolicy.mockResolvedValue({ status: 'unmanaged' });+ mockKeyStatus.mockImplementation(async (reference: string) => ({+ reference,+ isConfigured: true,+ }));});+const OPENAI = {+ mode: 'providers',+ providerId: 'openai',+ modelId: 'gpt-4o-transcribe',+ credentialRef: 'provider.openai',+} as const;+const GROQ = {+ mode: 'providers',+ providerId: 'groq',+ modelId: 'whisper-large-v3',+ credentialRef: 'provider.groq',+} as const;+it('asks a signed-out user to sign in before switching to Cloud', async () => {mockUser = null;mockConfig = { defaultMode: 'private' };await expect(switchWorkflowMode('cleanup', 'openwhispr')).resolves.toBe('refused');- expect(alert).toHaveBeenCalledWith('Sign in required', expect.any(String), expect.any(Array));+ expect(alert).toHaveBeenCalledWith(+ 'Sign in required',+ 'Sign in to use cloud AI with cloud processing, or turn on Private Mode in Account → AI Models.',+ expect.any(Array),+ );expect(mockUpdateConfig).not.toHaveBeenCalled();});@@ -150,3 +184,188 @@ describe('a workflow held on its old mode when dictation moved to your own key',});});});++describe('setPrivateMode', () => {+ it('turns on by switching dictation, and with it the app, to On-Device', async () => {+ await expect(setPrivateMode(true)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('private', true);+ expect(mockUpdateConfig).toHaveBeenCalledWith({+ defaultMode: 'private',+ inference: { dictation: { mode: 'local' } },+ });+ });++ it('opens the model list instead of turning on when no model is downloaded', async () => {+ mockPrivateReadiness.mockResolvedValue({ status: 'missing', modelName: 'Parakeet v2' });+ await expect(setPrivateMode(true)).resolves.toBe('needs-model');+ expect(mockPush).toHaveBeenCalledWith('/(account)/model-download');+ expect(mockSetActiveMode).not.toHaveBeenCalled();+ });++ it('turns off by switching dictation back to Cloud', async () => {+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);+ expect(mockUpdateConfig).toHaveBeenCalledWith({+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' } },+ });+ });++ it('remembers Bring Your Own Key, and what it held, when turned on from it', async () => {+ mockActiveMode = 'providers';+ mockConfig = {+ defaultMode: 'providers',+ inference: { dictation: OPENAI, upload: { mode: 'openwhispr' } },+ pinnedInference: ['upload'],+ };+ await expect(setPrivateMode(true)).resolves.toBe('switched');+ expect(mockUpdateConfig).toHaveBeenCalledWith(+ expect.objectContaining({+ defaultMode: 'private',+ privateModeReturn: { pinned: { upload: { mode: 'openwhispr' } } },+ }),+ );+ });++ // Turning it off must not send audio to Cloud for someone who was using their own key.+ it('turns off into the last provider used when it was turned on from Bring Your Own Key', async () => {+ mockActiveMode = 'private';+ mockConfig = {+ defaultMode: 'private',+ privateModeReturn: {+ pinned: { upload: { mode: 'openwhispr' }, notes: { mode: 'openwhispr' } },+ },+ inference: { dictation: { mode: 'local' } },+ rememberedInference: {+ dictation: {+ local: { mode: 'local', modelId: 'whisper-base' },+ groq: GROQ,+ openai: OPENAI,+ },+ },+ };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);+ const update = mockUpdateConfig.mock.calls[0][0];+ expect(update).toMatchObject({+ defaultMode: 'providers',+ // The provider held these on Cloud before Private mode was turned on, and does again.+ inference: { dictation: GROQ, upload: { mode: 'openwhispr' }, notes: { mode: 'openwhispr' } },+ pinnedInference: ['upload', 'notes'],+ });+ expect(update.inference).not.toHaveProperty('agent');+ expect(update).toHaveProperty('privateModeReturn', undefined);+ });++ it('ends a round trip from Bring Your Own Key where it started', async () => {+ const start = {+ defaultMode: 'providers',+ inference: {+ dictation: OPENAI,+ upload: { mode: 'openwhispr' },+ notes: { mode: 'openwhispr' },+ },+ rememberedInference: { dictation: { openai: OPENAI } },+ pinnedInference: ['upload', 'notes'],+ };+ mockActiveMode = 'providers';+ mockConfig = start;+ await setPrivateMode(true);+ const on = { ...start, ...mockUpdateConfig.mock.calls[0][0] };+ expect(on.inference).toEqual({ dictation: { mode: 'local' } });++ mockActiveMode = 'private';+ mockConfig = on;+ await setPrivateMode(false);+ const off = { ...on, ...mockUpdateConfig.mock.calls[1][0] };+ expect(off).toMatchObject({+ defaultMode: 'providers',+ inference: start.inference,+ pinnedInference: start.pinnedInference,+ });+ expect(off.privateModeReturn).toBeUndefined();+ });++ it.each([+ ['its key was removed', () => mockKeyStatus.mockResolvedValue({ isConfigured: false })],+ [+ 'the organization no longer allows it',+ () =>+ mockPolicy.mockResolvedValue({+ status: 'managed',+ transcription: { allowedModes: ['openwhispr', 'local'], allowedByokProviders: [] },+ llm: { allowedModes: ['openwhispr', 'local'], allowedByokProviders: [] },+ }),+ ],+ ])('turns off into Cloud when the provider can no longer run because %s', async (_, setUp) => {+ setUp();+ mockActiveMode = 'private';+ mockConfig = {+ defaultMode: 'private',+ privateModeReturn: { pinned: {} },+ inference: { dictation: { mode: 'local' } },+ rememberedInference: { dictation: { openai: OPENAI } },+ };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);+ expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' } },+ });+ });++ it('still returns to the provider while the organization policy is loading', async () => {+ mockPolicy.mockResolvedValue({ status: 'pending' });+ mockActiveMode = 'private';+ mockConfig = {+ defaultMode: 'private',+ privateModeReturn: { pinned: {} },+ inference: { dictation: { mode: 'local' } },+ rememberedInference: { dictation: { openai: OPENAI } },+ };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);+ });++ // Needs no account, so a guest kept in Private mode can still leave it this way.+ it('turns off into the provider dictation is saved to without signing in', async () => {+ mockUser = null;+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'providers', inference: { dictation: OPENAI } };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);+ expect(mockUpdateConfig).toHaveBeenCalledWith(+ expect.objectContaining({+ defaultMode: 'providers',+ inference: expect.objectContaining({ dictation: OPENAI }),+ }),+ );+ expect(alert).not.toHaveBeenCalled();+ });++ it('turns off into Cloud, not an old provider, when it was turned on from Cloud', async () => {+ mockActiveMode = 'private';+ mockConfig = {+ defaultMode: 'private',+ inference: { dictation: { mode: 'local' } },+ rememberedInference: { dictation: { openai: OPENAI } },+ };+ await expect(setPrivateMode(false)).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);+ });++ it('stays on when a signed-out user would need Cloud', async () => {+ mockUser = null;+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ await expect(setPrivateMode(false)).resolves.toBe('refused');+ // Private mode is already on, so the sign-in prompt doesn't offer it as the alternative.+ expect(alert).toHaveBeenCalledWith(+ 'Sign in required',+ 'Sign in to use cloud transcription with cloud processing.',+ expect.any(Array),+ );+ expect(mockSetActiveMode).not.toHaveBeenCalled();+ });+});diff --git a/openwhispr-mobile/src/lib/accountAccess.ts b/openwhispr-mobile/src/lib/accountAccess.tsindex 299d2dcf8..88759543e 100644--- a/openwhispr-mobile/src/lib/accountAccess.ts+++ b/openwhispr-mobile/src/lib/accountAccess.ts@@ -2,6 +2,7 @@ import { Alert } from 'react-native';import { router } from 'expo-router';import { isAccountRequiredError } from '@/lib/accountRequiredError';import { useAuthStore } from '@/store/useAuthStore';+import { useProcessingModeStore } from '@/store/useProcessingModeStore';import type { AuthUser } from '@/lib/authClient';import type { ProcessingMode } from '@/types';@@ -34,7 +35,11 @@ export function canRunCloudMeeting(user: AuthUser | null, mode: ProcessingMode):}export function getCloudAccountRequiredMessage(feature: string, anonymous = false): string {- return `${anonymous ? 'Create an account' : 'Sign in'} to use ${feature} with cloud processing, or switch to Private Mode after downloading the local model.`;+ const action = `${anonymous ? 'Create an account' : 'Sign in'} to use ${feature} with cloud processing`;+ // Already in Private Mode, which is what turning it off asks Cloud for, so don't offer it back.+ return useProcessingModeStore.getState().activeMode === 'private'+ ? `${action}.`+ : `${action}, or turn on Private Mode in Account → AI Models.`;}// For features with no local model (AI actions, AI chat): Private Mode is notdiff --git a/openwhispr-mobile/src/lib/aiWorkflows.ts b/openwhispr-mobile/src/lib/aiWorkflows.tsindex d806dfc56..811edd318 100644--- a/openwhispr-mobile/src/lib/aiWorkflows.ts+++ b/openwhispr-mobile/src/lib/aiWorkflows.ts@@ -2,7 +2,7 @@ import type { InferenceSelection } from '@/lib/mobileProviders';import { MODE_LABELS } from '@/lib/inferenceModes';import { isLocalModelKey, LOCAL_MODEL_TITLES } from '@/lib/localModelCatalog';import { providerDisplayName, type MobileInferenceScope } from '@/lib/mobileProviders';-import type { ProcessingMode, UserConfig } from '@/types';+import type { InferenceMode, ProcessingMode, UserConfig } from '@/types';export const WORKFLOW_LABELS: Record<MobileInferenceScope, string> = {dictation: 'Dictation',@@ -21,27 +21,37 @@ export const UNSET_PROVIDER_NOTES: Partial<Record<MobileInferenceScope, string>>'Not saved yet. The voice assistant is skipped until you save a selection; note chat uses OpenWhispr Cloud.',};-// On-Device mode skips cleanup until On-Device or a provider is saved for it, so the unset+// Private mode skips cleanup until On-Device or a provider is saved for it, so the unset// page picks nothing.export const UNSET_ON_DEVICE_CLEANUP_NOTE =- 'Not saved yet. On-Device mode skips cleanup until you choose On-Device or Bring Your Own Key.';+ 'Not saved yet. Private mode skips cleanup until you choose On-Device or Bring Your Own Key.';// The same, on an iPhone that can never run On-Device cleanup.export const UNSET_UNSUPPORTED_CLEANUP_NOTE =- "Not saved yet. This iPhone can't run On-Device cleanup, so On-Device mode skips it until you choose Bring Your Own Key.";+ "Not saved yet. This iPhone can't run On-Device cleanup, so Private mode skips it until you choose Bring Your Own Key.";-// What On-Device mode means for each workflow other than dictation.+// What Private mode means for each workflow other than dictation.export const ON_DEVICE_MODE_NOTES: Partial<Record<MobileInferenceScope, string>> = {- upload:- 'On-Device mode keeps this on your iPhone. Your choice applies when dictation leaves On-Device.',+ upload: 'Private mode keeps uploads on this iPhone.',notes:- 'On-Device mode formats notes on this iPhone and asks before sending one to your choice here.',+ 'Private mode formats notes on this iPhone and asks before sending one to your choice here.',cleanup:- 'In On-Device mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until dictation leaves On-Device.',+ 'In Private mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until Private mode is off.',agent:- 'In On-Device mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',+ 'In Private mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',};+// Modes Private mode never runs for a workflow, so its page can't offer them as if they would.+// Dictation keeps Bring Your Own Key, since saving it leaves Private mode (no account needed).+// Notes and chat keep every mode: Private mode asks before sending a note to the one chosen.+export const PRIVATE_MODE_LOCKED: Partial<Record<MobileInferenceScope, InferenceMode[]>> = {+ dictation: ['openwhispr'],+ upload: ['openwhispr', 'providers'],+ cleanup: ['openwhispr'],+};++export const PRIVATE_MODE_LOCKED_REASON = 'Off while Private mode is on. Turn it off in AI Models.';+// A local transcript is cleaned on the phone when cleanup is saved as On-Device.export function cleanupSavedOnDevice(config: UserConfig | null): boolean {return config?.inference?.cleanup?.mode === 'local';diff --git a/openwhispr-mobile/src/lib/dictationAgent.ts b/openwhispr-mobile/src/lib/dictationAgent.tsindex aead7fabf..70f9f92ba 100644--- a/openwhispr-mobile/src/lib/dictationAgent.ts+++ b/openwhispr-mobile/src/lib/dictationAgent.ts@@ -15,6 +15,24 @@ export function isDictationAgentApplicable(mode: ProcessingMode, config: UserConreturn (mode === 'cloud' || mode === 'providers') && isDictationAgentEnabled(config);}+export function isNoteChatEnabled(config: UserConfig): boolean {+ return config.noteChatEnabled ?? isDictationAgentEnabled(config);+}++// Switching the voice assistant also saves note chat as it stands, so chat stops following the+// voice assistant's switch from then on.+export function voiceAssistantToggleConfig(+ config: UserConfig | null,+ enabled: boolean,+): Partial<UserConfig> {+ return {+ dictationAgentEnabled: enabled,+ ...(config?.noteChatEnabled === undefined+ ? { noteChatEnabled: config ? isNoteChatEnabled(config) : true }+ : {}),+ };+}+function levenshteinDistance(a: string, b: string): number {const m = a.length;const n = b.length;diff --git a/openwhispr-mobile/src/lib/inferenceModes.ts b/openwhispr-mobile/src/lib/inferenceModes.tsindex 6f07f43db..c0dc8621b 100644--- a/openwhispr-mobile/src/lib/inferenceModes.ts+++ b/openwhispr-mobile/src/lib/inferenceModes.ts@@ -60,7 +60,10 @@ export const MODE_LABELS: Record<InferenceMode, string> = {local: 'On-Device',};-type DictationModeConfig = Pick<UserConfig, 'defaultMode' | 'inference' | 'pinnedInference'>;+type DictationModeConfig = Pick<+ UserConfig,+ 'defaultMode' | 'inference' | 'pinnedInference' | 'privateModeReturn'+>;// These workflows follow the dictation mode until they have a selection of their own, so they// would silently change destination when dictation moves to Bring Your Own Key. Cleanup is left@@ -70,7 +73,7 @@ function scopesToPin(leavingMode: ProcessingMode): MobileInferenceScope[] {return leavingMode === 'private' ? ['upload', 'notes', 'agent'] : ['upload', 'notes'];}-// The Home toggle and the Dictation page both own the dictation mode;+// The Private Mode switch and the Dictation page both own the dictation mode;// writing the scope selection alongside defaultMode keeps routing and UI in step.export function dictationModeConfig(config: UserConfig | null,@@ -95,6 +98,8 @@ export function dictationModeConfig(: { mode: 'openwhispr' },},...(config?.pinnedInference ? { pinnedInference: undefined } : {}),+ // Only a switch from Bring Your Own Key sets where Private mode returns to (workflowSaveConfig).+ ...(config?.privateModeReturn ? { privateModeReturn: undefined } : {}),};}@@ -105,12 +110,24 @@ function providerDictationConfig(): DictationModeConfig {const inference = { ...config?.inference, dictation };const pinnedInference = [...(config?.pinnedInference ?? [])];- if (leavingMode !== 'providers') {- for (const scope of scopesToPin(leavingMode)) {- if (inference[scope]) continue;- inference[scope] = { mode: processingToInferenceMode(leavingMode) };- pinnedInference.push(scope);- }+ // Leaving Private mode for the provider it was turned on from holds what that provider held,+ // so the round trip ends where it started.+ const pins: [MobileInferenceScope, InferenceSelection][] =+ leavingMode === 'providers'+ ? []+ : leavingMode === 'private' && config?.privateModeReturn+ ? (Object.entries(config.privateModeReturn.pinned) as [+ MobileInferenceScope,+ InferenceSelection,+ ][])+ : scopesToPin(leavingMode).map((scope) => [+ scope,+ { mode: processingToInferenceMode(leavingMode) },+ ]);+ for (const [scope, selection] of pins) {+ if (inference[scope]) continue;+ inference[scope] = selection;+ pinnedInference.push(scope);}return {defaultMode: 'providers',@@ -119,6 +136,18 @@ function providerDictationConfig(};}+// What Bring Your Own Key holds on the mode dictation came from, kept while Private mode is on.+function pinnedSelections(+ config: UserConfig | null,+): Partial<Record<MobileInferenceScope, InferenceSelection>> {+ return Object.fromEntries(+ (config?.pinnedInference ?? []).flatMap((scope) => {+ const selection = config?.inference?.[scope];+ return selection ? [[scope, selection]] : [];+ }),+ );+}+// The config a workflow page writes when the user saves `selection` for `scope`.export function workflowSaveConfig(config: UserConfig | null,@@ -141,11 +170,21 @@ export function workflowSaveConfig(: {};if (scope === 'dictation') {const mode = inferenceToProcessingMode(selection.mode);+ // Picking another on-device model keeps where Private mode returns to; leaving it clears it.+ const privateModeReturn =+ mode !== 'private'+ ? undefined+ : activeMode === 'private'+ ? config?.privateModeReturn+ : activeMode === 'providers'+ ? { pinned: pinnedSelections(config) }+ : undefined;return {...rememberedInference,...(mode === 'providers'? providerDictationConfig(config, selection, activeMode): dictationModeConfig(config, mode)),+ ...(privateModeReturn || config?.privateModeReturn ? { privateModeReturn } : {}),};}return {diff --git a/openwhispr-mobile/src/lib/onboardingMode.ts b/openwhispr-mobile/src/lib/onboardingMode.tsindex 698994a2d..ce10fe860 100644--- a/openwhispr-mobile/src/lib/onboardingMode.ts+++ b/openwhispr-mobile/src/lib/onboardingMode.ts@@ -2,6 +2,7 @@ import { useAuthStore } from '@/store/useAuthStore';import { useConfigStore } from '@/store/useConfigStore';import { useOnboardingStore } from '@/store/useOnboardingStore';import { useProcessingModeStore } from '@/store/useProcessingModeStore';+import { hasRealAccountHistory } from '@/sync/syncIdentity';import type { UserConfig } from '@/types';import { dictationModeConfig } from './inferenceModes';import { OnboardingError } from './onboardingErrors';@@ -20,18 +21,25 @@ export async function chooseOnboardingMode(): Promise<void> {if (useOnboardingStore.getState().currentStep !== from) return;const auth = useAuthStore.getState();- // Guests can't open a session during setup. On the download step Cloud is their only way past a- // download that can't finish, so it's saved for after sign-in instead of refused.- if (mode === 'cloud' && !auth.user && !(auth.isGuest && from === 'private-download')) {- if (auth.isGuest)- throw new OnboardingError(- 'Cloud needs an account. Use Local for now, or sign in after setup.',- );- await auth.ensureAnonymousSession();- if (!useAuthStore.getState().user) {- throw new OnboardingError(- 'Cloud needs a connection to set up. Try again or use Local for now.',- );+ if (mode === 'cloud' && !auth.user) {+ // Guests declined an account, and a device that synced one must not get a new identity (its+ // first sync would read as an account switch and wipe that account's notes), so neither opens+ // a session during setup. On the download step Cloud is their only way past a download that+ // can't finish, so it's saved for after sign-in instead of refused.+ if (auth.isGuest || hasRealAccountHistory()) {+ if (from !== 'private-download')+ throw new OnboardingError(+ auth.isGuest+ ? 'Cloud needs an account. Use Local for now, or sign in after setup.'+ : 'Cloud needs you signed in. Use Local for now, or sign in after setup.',+ );+ } else {+ await auth.ensureAnonymousSession();+ if (!useAuthStore.getState().user) {+ throw new OnboardingError(+ 'Cloud needs a connection to set up. Try again or use Local for now.',+ );+ }}}if (useOnboardingStore.getState().currentStep !== from) return;diff --git a/openwhispr-mobile/src/lib/workflowModeSwitch.ts b/openwhispr-mobile/src/lib/workflowModeSwitch.tsindex d31e2aa09..0f7ad1883 100644--- a/openwhispr-mobile/src/lib/workflowModeSwitch.ts+++ b/openwhispr-mobile/src/lib/workflowModeSwitch.ts@@ -10,8 +10,15 @@ import {getLocalReasoningUnavailableMessage,} from '@/lib/localReasoning';import type { LocalModelKey } from '@/lib/localModelCatalog';-import type { InferenceSelection, MobileInferenceScope } from '@/lib/mobileProviders';+import type { UserConfig } from '@/types';+import {+ resolveMobileInferenceRoute,+ type InferenceSelection,+ type MobileInferenceScope,+} from '@/lib/mobileProviders';import { getPrivateModeReadiness, getPrivateModeUnavailableMessage } from '@/lib/privateMode';+import { getProviderCredentialStatus } from '@/services/providers/ProviderCredentials';+import { getProviderPolicy } from '@/services/providers/ProviderPolicy';type SpeechScope = 'dictation' | 'upload';@@ -33,7 +40,7 @@ async function transcriptionModelReady(): Promise<ModeSwitchResult | null> {return 'refused';}// Nothing to run yet: open the model list, where every on-device model can be- // downloaded, as the Home toggle does.+ // downloaded.if (readiness.status === 'missing') {router.push('/(account)/model-download');return 'needs-model';@@ -49,7 +56,7 @@ async function appleIntelligenceReady(): Promise<boolean> {}// Applies OpenWhispr Cloud or On-Device to a workflow as soon as it is tapped, after the same-// sign-in and model checks the Home toggle runs.+// sign-in and model checks Private mode runs.export async function switchWorkflowMode(scope: MobileInferenceScope,mode: 'openwhispr' | 'local',@@ -78,8 +85,51 @@ export async function switchWorkflowMode(return 'switched';}+// The provider turning Private mode off returns dictation to: the one dictation is saved to, or+// the last one used when Private mode was turned on from Bring Your Own Key.+function returnProvider(config: UserConfig | null): InferenceSelection | undefined {+ const saved = config?.inference?.dictation;+ if (saved?.mode === 'providers') return saved;+ if (!config?.privateModeReturn) return undefined;+ return Object.values(config.rememberedInference?.dictation ?? {}).find(+ (selection) => selection.mode === 'providers',+ );+}++// A provider whose key was removed, or that the organization no longer allows, can't take+// dictation back. A policy still loading doesn't count against it.+async function providerUsable(selection: InferenceSelection): Promise<boolean> {+ const resolved = resolveMobileInferenceRoute({+ scope: 'dictation',+ selection,+ policy: await getProviderPolicy(),+ });+ if (!resolved.ok) return resolved.code === 'POLICY_UNRESOLVED';+ if (!selection.credentialRef) return true;+ const status = await getProviderCredentialStatus(selection.credentialRef).catch(() => ({+ isConfigured: true,+ }));+ return status.isConfigured;+}++// The Private mode switch in AI Models. On keeps dictation and uploads on this phone; off hands+// dictation back to Cloud, or to Bring Your Own Key when that is where Private mode was turned on+// and the provider can still run.+export async function setPrivateMode(enabled: boolean): Promise<ModeSwitchResult> {+ if (enabled) return switchWorkflowMode('dictation', 'local');+ const { config, updateConfig } = useConfigStore.getState();+ const provider = returnProvider(config);+ if (provider && (await providerUsable(provider))) {+ const { activeMode, setActiveMode } = useProcessingModeStore.getState();+ setActiveMode('providers', true);+ await updateConfig(workflowSaveConfig(config, 'dictation', provider, activeMode));+ return 'switched';+ }+ return switchWorkflowMode('dictation', 'openwhispr');+}+// Saves the on-device model for a workflow; undefined means Automatic. The pick is also-// remembered so switching back to On-Device, from here or the Home toggle, restores it.+// remembered so switching back to On-Device, from here or Private mode, restores it.export async function pickLocalModel(scope: SpeechScope,model: LocalModelKey | undefined,diff --git a/openwhispr-mobile/src/screens/AIModelsScreen.tsx b/openwhispr-mobile/src/screens/AIModelsScreen.tsxindex f127e0d47..5ca868e8e 100644--- a/openwhispr-mobile/src/screens/AIModelsScreen.tsx+++ b/openwhispr-mobile/src/screens/AIModelsScreen.tsx@@ -6,13 +6,13 @@ import { SettingsRow, SettingsSection } from '@/components/ui/SettingsSection';import { SettingsScreen } from '@/components/ui/SettingsScreen';import { SettingsSwitch } from '@/components/ui/SettingsSwitch';import type { LucideIconName } from '@/components/ui/SystemIcon';-import { Text } from '@/components/ui/Text';import { Toast } from '@/components/ui/Toast';import { useConfigToggle } from '@/hooks/useConfigToggle';import { useToast } from '@/hooks/useToast';import { confirmDestructive } from '@/lib/alerts';import { WORKFLOW_LABELS, WORKFLOWS, workflowSummary } from '@/lib/aiWorkflows';import { getLocalReasoningReadiness } from '@/lib/localReasoning';+import { setPrivateMode } from '@/lib/workflowModeSwitch';import type { InferenceSelection, MobileInferenceScope } from '@/lib/mobileProviders';import {clearProviderCredentials,@@ -138,6 +138,25 @@ export default function AIModelsScreen(): React.JSX.Element {);}+ // The switch shows the requested state while the checks run, rather than snapping back to the+ // current mode until they finish; it settles on the real mode either way.+ const [requestedPrivateMode, setRequestedPrivateMode] = useState<boolean | null>(null);+ const privateMode = activeMode === 'private';++ async function togglePrivateMode(enabled: boolean): Promise<void> {+ if (busy) return;+ setBusy(true);+ setRequestedPrivateMode(enabled);+ try {+ if ((await setPrivateMode(enabled)) === 'switched') {+ showToast(enabled ? 'Private mode on.' : 'Private mode off.', 'success');+ }+ } finally {+ setRequestedPrivateMode(null);+ setBusy(false);+ }+ }+const onDeviceUnavailable =localReadiness && localReadiness.status !== 'ready'? localReasoningStatusLabel(localReadiness)@@ -146,9 +165,32 @@ export default function AIModelsScreen(): React.JSX.Element {return (<View className="flex-1 bg-systemBackground"><SettingsScreen>- <Text className="mb-4 px-8 text-[13px] text-secondaryLabel">- Each workflow picks its own mode.- </Text>+ {/* The one place Private mode is switched: with it on, the workflow pages lock the modes+ it never runs, so a choice there can't look saved and then be ignored. */}+ <SettingsSection>+ <SettingsRow+ iconStyle="line"+ icon="lock"+ mdIcon="Lock"+ title="Private Mode"+ description={+ privateMode+ ? 'Audio stays on this iPhone, notes ask before leaving it, and the voice assistant is off.'+ : 'Keep audio on this iPhone and ask before notes leave it.'+ }+ rightElement={+ <SettingsSwitch+ accessibilityLabel="Private Mode"+ value={requestedPrivateMode ?? privateMode}+ disabled={busy}+ onValueChange={(enabled) => {+ void togglePrivateMode(enabled);+ }}+ />+ }+ showChevron={false}+ />+ </SettingsSection><SettingsSection title="Workflows">{WORKFLOWS.map((scope) => (<SettingsRowdiff --git a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsxindex fed31440b..87fcc0f84 100644--- a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx+++ b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx@@ -41,7 +41,7 @@ export default function CleanupPromptScreen() {const inactiveNotice = !cleanupEnabled? 'Text Cleanup is off. Your prompt is saved and applies once you turn it on.': activeMode === 'private' && cleanupMode !== 'local' && cleanupMode !== 'providers'- ? 'On-Device mode skips cleanup unless it is set to On-Device or Bring Your Own Key. Your prompt is saved and applies when it runs.'+ ? 'Private mode skips cleanup unless it is set to On-Device or Bring Your Own Key. Your prompt is saved and applies when it runs.': activeMode === 'providers' && !cleanupMode? 'Bring Your Own Key skips cleanup until Text Cleanup has a selection. Your prompt is saved and applies once it does.': null;diff --git a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx b/openwhispr-mobile/src/screens/DictationAgentScreen.tsxindex 8f24dba5f..01654c974 100644--- a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx+++ b/openwhispr-mobile/src/screens/DictationAgentScreen.tsx@@ -7,7 +7,12 @@ import { SettingsSwitch } from '@/components/ui/SettingsSwitch';import { useConfigStore } from '@/store/useConfigStore';import { useConfigToggle } from '@/hooks/useConfigToggle';import { useProcessingModeStore } from '@/store/useProcessingModeStore';-import { getDictationAgentName, isDictationAgentEnabled } from '@/lib/dictationAgent';+import {+ getDictationAgentName,+ isDictationAgentEnabled,+ voiceAssistantToggleConfig,+} from '@/lib/dictationAgent';+import { PRIVATE_MODE_LOCKED_REASON } from '@/lib/aiWorkflows';import { safeHaptics } from '@/lib/utils';import { iosColor } from '@/config/colors';import { AppFont } from '@/lib/fonts';@@ -23,7 +28,7 @@ export function DictationAgentScreen(): React.JSX.Element {// Bring Your Own Key skips the assistant until it has a selection of its own.const unavailableNotice =activeMode === 'private'- ? 'Voice Assistant needs Cloud or Bring Your Own Key mode. Your settings are saved and apply once one is active.'+ ? `${PRIVATE_MODE_LOCKED_REASON} Your settings are saved and apply once Private mode is off.`: activeMode === 'providers' && !agentSelected? 'Bring Your Own Key skips the voice assistant until Chat & Voice Assistant has a selection. Your settings are saved and apply once it does.': null;@@ -34,7 +39,13 @@ export function DictationAgentScreen(): React.JSX.Element {const [nameValue, setNameValue] = useState(currentName);- const handleToggleEnabled = useConfigToggle('dictationAgentEnabled');+ const handleToggleEnabled = useCallback(+ (value: boolean): void => {+ safeHaptics('light');+ void updateConfig(voiceAssistantToggleConfig(config, value));+ },+ [config, updateConfig],+ );const handleToggleShareContext = useConfigToggle('dictationAgentShareContext');const commitName = useCallback((): void => {@@ -75,10 +86,11 @@ export function DictationAgentScreen(): React.JSX.Element {icon="person.wave.2"mdIcon="UserRoundCog"title="Enable Voice Assistant"- description="Say your assistant’s name while dictating to have OpenWhispr rewrite what you said. Also turns note chat on or off."+ description="Say your assistant’s name while dictating to have OpenWhispr rewrite what you said."rightElement={<SettingsSwitch- value={enabled}+ // Shows what runs: the voice assistant is off wherever it can't run.+ value={enabled && isAvailable}onValueChange={handleToggleEnabled}disabled={!isAvailable}/>diff --git a/openwhispr-mobile/src/screens/HomeScreen.tsx b/openwhispr-mobile/src/screens/HomeScreen.tsxindex adad94e0d..cdc1b37e4 100644--- a/openwhispr-mobile/src/screens/HomeScreen.tsx+++ b/openwhispr-mobile/src/screens/HomeScreen.tsx@@ -1,5 +1,4 @@import { getTranscriptionProvider } from '@/lib/inferenceRouting';-import { dictationModeConfig } from '@/lib/inferenceModes';import React, { useCallback, useEffect, useRef, useState } from 'react';import { View, Pressable, ScrollView, ActivityIndicator, Alert, StyleSheet } from 'react-native';import { Text } from '@/components/ui/Text';@@ -25,16 +24,11 @@ import { useTranscriptStore } from '@/store/useTranscriptStore';import { useProcessingModeStore } from '@/store/useProcessingModeStore';import { useModelDownloadStore } from '@/store/useModelDownloadStore';import { useUsageStore } from '@/store/useUsageStore';-import { useConfigStore } from '@/store/useConfigStore';import { useAuthStore } from '@/store/useAuthStore';import { useHandoffStore } from '@/store/useHandoffStore';import { useAppInit } from '@/hooks/useAppInit';import { TranscriptionService } from '@/services/transcription/TranscriptionService';-import {- getPrivateModeReadiness,- getPrivateModeUnavailableMessage,- promptLocalModelFallback,-} from '@/lib/privateMode';+import { getPrivateModeReadiness, promptLocalModelFallback } from '@/lib/privateMode';import { getPreferredTranscriptionLanguage } from '@/lib/transcriptionLanguage';import { accountRequiredForCloud, showAccountRequiredAlert } from '@/lib/accountAccess';import { isMicPermissionError, isNoSpeechError, showMicPermissionAlert } from '@/lib/permissions';@@ -51,7 +45,6 @@ import { returnToHost, selectHandoffView } from '@/lib/handoffReturn';import { HardwareKeyboardNudgeBanner } from '@/components/features/HardwareKeyboardNudgeBanner';import { SwipeableCard } from '@/components/ui/SwipeableCard';import { Glass } from '@/components/ui/Glass';-import { CloudIcon } from '@/components/ui/CloudIcon';import { SystemIcon, type LucideIconName } from '@/components/ui/SystemIcon';import { DictationModeControl } from '@/components/ui/DictationModeControl';import { UsageLimitBanner } from '@/components/ui/UsageMeter';@@ -136,8 +129,6 @@ export default function HomeScreen() {const deleteTranscript = useTranscriptStore((state) => state.deleteTranscript);const retryTranscript = useTranscriptStore((state) => state.retryTranscript);const activeMode = useProcessingModeStore((state) => state.activeMode);- const setActiveMode = useProcessingModeStore((state) => state.setActiveMode);- const updateConfig = useConfigStore((state) => state.updateConfig);const downloadCompletedCount = useModelDownloadStore((state) => state.completedCount);const user = useAuthStore((state) => state.user);const usage = useUsageStore((state) => state.usage);@@ -351,58 +342,6 @@ export default function HomeScreen() {}};- const handleTogglePrivateMode = () => {- safeHaptics('light');- if (isRecording) return;-- if (activeMode === 'providers') {- router.push({ pathname: '/(account)/ai-workflow', params: { scope: 'dictation' } });- return;- }- if (isPrivateMode) {- if (useConfigStore.getState().config?.inference?.dictation?.mode === 'providers') {- setActiveMode('providers', true);- updateConfig({ defaultMode: 'providers' });- return;- }- if (accountRequiredForCloud(user)) {- showAccountRequiredAlert('cloud transcription');- return;- }- setActiveMode('cloud', true);- updateConfig(dictationModeConfig(useConfigStore.getState().config, 'cloud'));- showModeToast({- name: 'cloud.fill',- mdName: 'Cloud',- color: 'brand',- text: 'Cloud on · higher-quality transcription on our servers',- });- return;- }-- if (localModelStatus === 'unavailable') {- Alert.alert('Private Mode Unavailable', getPrivateModeUnavailableMessage());- return;- }-- if (localModelStatus !== 'ready') {- // Model not downloaded yet — send the user to the download screen.- // We deliberately do NOT start the download automatically, and we leave- // the mode on Cloud until they've downloaded and toggle again.- router.push('/(account)/model-download');- return;- }-- setActiveMode('private', true);- updateConfig(dictationModeConfig(useConfigStore.getState().config, 'private'));- showModeToast({- name: 'cloud.slash.fill',- mdName: 'CloudOff',- color: 'tertiaryLabel',- text: 'Cloud off · transcribing privately on your device',- });- };-const handleDictationModeChange = (enabled: boolean) => {showModeToast({name: 'power',@@ -579,39 +518,21 @@ export default function HomeScreen() {<View className="px-4" style={{ paddingTop: insets.top + 8 }}><View className="min-h-[44px] flex-row items-center justify-between">- <Pressable- onPress={handleTogglePrivateMode}- disabled={isRecording}- {...(activeMode === 'providers'- ? {- accessibilityRole: 'button',- accessibilityState: { disabled: isRecording },- accessibilityLabel: 'Transcription: Bring Your Own Key',- accessibilityHint: 'Opens Dictation settings.',- }- : {- accessibilityRole: 'switch',- accessibilityState: { checked: !isPrivateMode, disabled: isRecording },- accessibilityLabel: 'Cloud transcription',- })}- className="h-9 flex-row items-center rounded-full px-1 active:opacity-80"- style={{- backgroundColor: isPrivateMode ? '#E3E0DE' : BRAND,- boxShadow: '0px 1px 3px rgba(0,0,0,0.18)',- }}- >- {!isPrivateMode && (- <Text className="ml-2 mr-1 text-xs font-bold text-white">- {activeMode === 'providers' ? 'Own key' : 'On'}- </Text>- )}- <View className="h-7 w-7 items-center justify-center rounded-full bg-white">- <CloudIcon size={16} color={isPrivateMode ? '#8E8E93' : BRAND} off={isPrivateMode} />- </View>- {isPrivateMode && (- <Text className="ml-1 mr-2 text-xs font-bold text-secondaryLabel">Off</Text>- )}- </Pressable>+ {/* Private mode is a setting, not a quick switch: Home only shows it's on. */}+ {isPrivateMode ? (+ <Pressable+ onPress={() => router.push('/(account)/ai-models')}+ accessibilityRole="button"+ accessibilityLabel="Private mode is on"+ accessibilityHint="Opens AI Models."+ className="h-9 flex-row items-center gap-1.5 rounded-full bg-tertiarySystemFill px-3 active:opacity-70"+ >+ <SystemIcon name="lock.fill" mdName="Lock" size={13} color="secondaryLabel" />+ <Text className="text-xs font-bold text-secondaryLabel">Private</Text>+ </Pressable>+ ) : (+ <View />+ )}<DictationModeControl onModeChange={handleDictationModeChange} /></View><KeyboardFullAccessBanner />diff --git a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx b/openwhispr-mobile/src/screens/NoteEditorScreen.tsxindex bb42273e0..da8a3e5b9 100644--- a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx+++ b/openwhispr-mobile/src/screens/NoteEditorScreen.tsx@@ -43,7 +43,7 @@ import { shouldOfferVoiceSetup, voiceSetupCandidates } from '@/lib/notes/voiceSeimport { SpeakerProfileOwnerAlreadyExistsError } from '@/data/local/notesRepository';import { VOICE_ALREADY_TAUGHT_ALERT } from '@/lib/voiceEnrollmentMessages';import { NoteChatSheet } from '@/components/notes/NoteChatSheet';-import { isDictationAgentEnabled } from '@/lib/dictationAgent';+import { isNoteChatEnabled } from '@/lib/dictationAgent';import { SpeakerTranscript } from '@/components/notes/SpeakerTranscript';import { TranscriptSheet } from '@/components/notes/TranscriptSheet';import { NoteMetaRow } from '@/components/notes/NoteMetaRow';@@ -176,8 +176,7 @@ export default function NoteEditorScreen() {const notesMode = useConfigStore((s) => s.config?.inference?.notes?.mode);const notesProviderId = useConfigStore((s) => s.config?.inference?.notes?.providerId);const chatMode = useConfigStore((s) => s.config?.inference?.agent?.mode);- // Note chat shares the Chat & Voice Assistant switch with the voice assistant.- const chatEnabled = useConfigStore((s) => (s.config ? isDictationAgentEnabled(s.config) : true));+ const chatEnabled = useConfigStore((s) => (s.config ? isNoteChatEnabled(s.config) : true));const providerNotes = notesMode === 'providers';// Only an unset or OpenWhispr chat route reaches Cloud, so only it needs an account and the paywall.const cloudChat = chatMode !== 'providers' && chatMode !== 'local';diff --git a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsxindex 6cb7cd2bf..6e7e668b2 100644--- a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx+++ b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx@@ -29,10 +29,12 @@ import {removeProviderCredential,setProviderCredential,} from '@/services/providers/ProviderCredentials';-import { workflowSaveConfig } from '@/lib/inferenceModes';+import { MODE_LABELS, workflowSaveConfig } from '@/lib/inferenceModes';import { InferenceModePicker } from '@/components/settings/InferenceModePicker';import {ON_DEVICE_MODE_NOTES,+ PRIVATE_MODE_LOCKED,+ PRIVATE_MODE_LOCKED_REASON,UNSET_ON_DEVICE_CLEANUP_NOTE,UNSET_UNSUPPORTED_CLEANUP_NOTE,UNSET_PROVIDER_NOTES,@@ -42,7 +44,13 @@ import {unsetSelection,} from '@/lib/aiWorkflows';import { isLocalModelKey } from '@/lib/localModelCatalog';-import { getDictationAgentName, isDictationAgentEnabled } from '@/lib/dictationAgent';+import {+ getDictationAgentName,+ isDictationAgentEnabled,+ isNoteChatEnabled,+ voiceAssistantToggleConfig,+} from '@/lib/dictationAgent';+import { safeHaptics } from '@/lib/utils';import { SystemIcon, type LucideIconName } from '@/components/ui/SystemIcon';import { switchWorkflowMode } from '@/lib/workflowModeSwitch';import { getPrivateModeReadiness } from '@/lib/privateMode';@@ -158,30 +166,73 @@ function CleanupSettings({ enabled }: { enabled: boolean }): React.JSX.Element {);}-function AssistantSettings({ enabled }: { enabled: boolean }): React.JSX.Element {- const toggleAssistant = useConfigToggle('dictationAgentEnabled');- const agentName = useConfigStore((state) =>- state.config ? getDictationAgentName(state.config) : undefined,- );+// Note chat and the voice assistant share this workflow's model but switch on and off apart, so+// Private mode can turn the voice assistant off while note chat keeps working.+function AssistantSettings(): React.JSX.Element {+ const config = useConfigStore((state) => state.config);+ const updateConfig = useConfigStore((state) => state.updateConfig);+ const privateMode = useProcessingModeStore((state) => state.activeMode === 'private');+ const toggleNoteChat = useConfigToggle('noteChatEnabled');+ const chatEnabled = config ? isNoteChatEnabled(config) : true;+ const voiceEnabled = config ? isDictationAgentEnabled(config) : true;+ const agentName = config ? getDictationAgentName(config) : undefined;return (- <WorkflowSwitchCard- title="Enable Chat & Voice Assistant"- description="Chat with your notes, and say your assistant’s name to give it commands."- icon="bubble.left.and.bubble.right"- mdIcon="MessagesSquare"- enabled={enabled}- onToggle={toggleAssistant}- offNote="Note chat and the voice assistant are off."- >- <SettingsRow- iconStyle="line"- icon="person.wave.2"- mdIcon="UserRoundCog"- title="Voice Assistant"- subtitle={agentName}- onPress={() => router.push('/(account)/dictation-agent')}- />- </WorkflowSwitchCard>+ <>+ <SettingsSection>+ <SettingsRow+ iconStyle="line"+ icon="bubble.left.and.bubble.right"+ mdIcon="MessagesSquare"+ title="Note Chat"+ description="Ask questions about your notes and get answers from them."+ rightElement={+ <SettingsSwitch+ accessibilityLabel="Note Chat"+ value={chatEnabled}+ onValueChange={toggleNoteChat}+ />+ }+ showChevron={false}+ />+ <SettingsRow+ iconStyle="line"+ icon="person.wave.2"+ mdIcon="UserRoundCog"+ title="Voice Assistant"+ description={+ privateMode+ ? PRIVATE_MODE_LOCKED_REASON+ : 'Say your assistant’s name while dictating to give it commands.'+ }+ disabled={privateMode}+ rightElement={+ <SettingsSwitch+ accessibilityLabel="Voice Assistant"+ value={voiceEnabled && !privateMode}+ disabled={privateMode}+ onValueChange={(enabled) => {+ safeHaptics('light');+ void updateConfig(voiceAssistantToggleConfig(config, enabled));+ }}+ />+ }+ showChevron={false}+ />+ {voiceEnabled && !privateMode ? (+ <SettingsRow+ iconStyle="line"+ icon="slider.horizontal.3"+ mdIcon="SlidersHorizontal"+ title="Voice Assistant Settings"+ subtitle={agentName}+ onPress={() => router.push('/(account)/dictation-agent')}+ />+ ) : null}+ </SettingsSection>+ {chatEnabled || voiceEnabled ? null : (+ <SectionFooter>Note chat and the voice assistant are off.</SectionFooter>+ )}+ </>);}@@ -240,8 +291,17 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXconst updateConfig = useConfigStore((state) => state.updateConfig);const setActiveMode = useProcessingModeStore((state) => state.setActiveMode);const activeMode = useProcessingModeStore((state) => state.activeMode);- const savedSelection = config?.inference?.[scope] ?? unsetSelection(scope, activeMode);- // On-Device mode skips an unsaved cleanup, so the On-Device default must not look picked.+ const storedSelection = config?.inference?.[scope] ?? unsetSelection(scope, activeMode);+ // Private mode runs dictation and uploads on this phone whatever is saved, so a saved mode it+ // locks shows as On-Device (Automatic), which is what runs, and stays saved for later.+ const lockedByPrivateMode =+ activeMode === 'private' &&+ (scope === 'dictation' || scope === 'upload') &&+ !!PRIVATE_MODE_LOCKED[scope]?.includes(storedSelection.mode);+ const savedSelection: InferenceSelection = lockedByPrivateMode+ ? { mode: 'local' }+ : storedSelection;+ // Private mode skips an unsaved cleanup, so the On-Device default must not look picked.const cleanupUnsaved =scope === 'cleanup' && activeMode === 'private' && !config?.inference?.cleanup;// Tracks the saved selection, except while a Bring Your Own Key draft is being set up.@@ -299,20 +359,38 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX? UNSET_UNSUPPORTED_CLEANUP_NOTE: UNSET_ON_DEVICE_CLEANUP_NOTE: undefined) ??+ (lockedByPrivateMode && ON_DEVICE_MODE_NOTES[scope]+ ? `${ON_DEVICE_MODE_NOTES[scope]} Your ${MODE_LABELS[storedSelection.mode]} choice applies again when Private mode is off.`+ : undefined) ??(activeMode === 'private' ? ON_DEVICE_MODE_NOTES[scope] : undefined) ??(activeMode === 'providers' && !config?.inference?.[scope]? UNSET_PROVIDER_NOTES[scope]: undefined) ??(selection.mode === 'providers' && savedSelection.mode !== 'providers'- ? 'Save to switch to Bring Your Own Key.'+ ? activeMode === 'private'+ ? 'Save to switch to Bring Your Own Key. This turns Private mode off.'+ : 'Save to switch to Bring Your Own Key.': undefined);+ // Private mode is switched in AI Models, so a mode it never runs here can't be picked.+ const modeUnavailable: Partial<Record<InferenceMode, string>> = {+ ...Object.fromEntries(+ (activeMode === 'private' ? (PRIVATE_MODE_LOCKED[scope] ?? []) : []).map((mode) => [+ mode,+ PRIVATE_MODE_LOCKED_REASON,+ ]),+ ),+ ...(onDeviceUnsupported ? { local: onDeviceUnsupported } : {}),+ };// Keys are stored per provider (per server for Custom), so every workflow on it shares one.const keyOwner =provider?.id === 'custom' ? 'this server' : providerDisplayName(provider?.id ?? '');- // Text Cleanup and Chat & Voice Assistant can be switched off; then they use no key.+ // Text Cleanup, and note chat with the voice assistant, can be switched off; then they use no key.const switchedOff = (workflow: MobileInferenceScope): boolean =>(workflow === 'cleanup' && !(config?.cleanupEnabled ?? true)) ||- (workflow === 'agent' && !!config && !isDictationAgentEnabled(config));+ (workflow === 'agent' &&+ !!config &&+ !isNoteChatEnabled(config) &&+ !isDictationAgentEnabled(config));const workflowOff = switchedOff(scope);const sharedWith = WORKFLOWS.filter((other) => {const saved = config?.inference?.[other];@@ -680,14 +758,14 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXkeyboardDismissMode="interactive">{scope === 'cleanup' ? <CleanupSettings enabled={!workflowOff} /> : null}- {scope === 'agent' ? <AssistantSettings enabled={!workflowOff} /> : null}+ {scope === 'agent' ? <AssistantSettings /> : null}{workflowOff ? null : (<><InferenceModePickerscope={speechScope ? 'speech' : 'text'}selectedMode={shownMode}onSelect={chooseMode}- unavailable={onDeviceUnsupported ? { local: onDeviceUnsupported } : undefined}+ unavailable={modeUnavailable}/>{modeNote ? <SectionFooter>{modeNote}</SectionFooter> : null}{selection.mode === 'local' && speechScope ? (@@ -696,6 +774,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXpicked={isLocalModelKey(savedSelection.modelId) ? savedSelection.modelId : undefined}+ lockedChoice={lockedByPrivateMode}/>) : null}{shownMode === 'local' && !speechScope ? (diff --git a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsxindex acf965da5..27ede6b30 100644--- a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx@@ -1,6 +1,6 @@import React from 'react';import { Alert, Platform } from 'react-native';-import { fireEvent, render, screen } from '@testing-library/react-native';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native';const mockPush = jest.fn();const mockClearCredentials = jest.fn().mockResolvedValue(undefined);@@ -42,6 +42,11 @@ jest.mock('@/services/providers/ProviderCredentials', () => ({},}));+const mockSetPrivateMode = jest.fn();+jest.mock('@/lib/workflowModeSwitch', () => ({+ setPrivateMode: (...args: unknown[]) => mockSetPrivateMode(...args),+}));+import AIModelsScreen from '../AIModelsScreen';const originalPlatform = Platform.OS;@@ -53,6 +58,7 @@ beforeEach(() => {Platform.OS = 'ios';mockCredentialStatus.mockResolvedValue({ isConfigured: true });mockReadiness.mockResolvedValue({ status: 'ready', tokenCounting: false });+ mockSetPrivateMode.mockResolvedValue('switched');});afterAll(() => {@@ -228,3 +234,66 @@ it.each([render(<AIModelsScreen />);expect(await screen.findByText(new RegExp(`Status: ${label}\\.`))).toBeTruthy();});++// AI Models is the one place Private mode is switched; Home only shows that it's on.+describe('Private Mode switch', () => {+ it('shows Private mode off, with what turning it on does', async () => {+ render(<AIModelsScreen />);+ expect(screen.getByLabelText('Private Mode').props.value).toBe(false);+ expect(+ screen.getByText('Keep audio on this iPhone and ask before notes leave it.'),+ ).toBeTruthy();+ await screen.findByText(/Status: Ready/);+ });++ it('shows Private mode on, and how to choose per workflow again', async () => {+ mockActiveMode = 'private';+ render(<AIModelsScreen />);+ expect(screen.getByLabelText('Private Mode').props.value).toBe(true);+ expect(+ screen.getByText(+ 'Audio stays on this iPhone, notes ask before leaving it, and the voice assistant is off.',+ ),+ ).toBeTruthy();+ await screen.findByText(/Status: Ready/);+ });++ it.each([+ [true, 'Private mode on.'],+ [false, 'Private mode off.'],+ ])('switches Private mode to %s', async (enabled, message) => {+ mockActiveMode = enabled ? 'cloud' : 'private';+ render(<AIModelsScreen />);+ fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', enabled);+ expect(await screen.findByTestId('toast-success')).toHaveTextContent(message);+ expect(mockSetPrivateMode).toHaveBeenCalledWith(enabled);+ });++ // The model list opened, or sign-in was asked for; nothing changed yet.+ it.each(['needs-model', 'refused'])('says nothing when the switch is %s', async (result) => {+ mockSetPrivateMode.mockResolvedValue(result);+ render(<AIModelsScreen />);+ fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', true);+ await waitFor(() => expect(mockSetPrivateMode).toHaveBeenCalledWith(true));+ expect(screen.queryByTestId('toast-success')).toBeNull();+ await screen.findByText(/Status: Ready/);+ });++ // Turning on waits for the model check; the switch must not bounce back off meanwhile, nor take a+ // second tap.+ it('holds the requested state while switching, then settles on the real mode', async () => {+ let finish: (result: string) => void = () => undefined;+ mockSetPrivateMode.mockReturnValue(new Promise((resolve) => (finish = resolve)));+ render(<AIModelsScreen />);+ fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', true);+ await waitFor(() => expect(screen.getByLabelText('Private Mode').props.disabled).toBe(true));+ expect(screen.getByLabelText('Private Mode').props.value).toBe(true);+ fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', false);+ expect(mockSetPrivateMode).toHaveBeenCalledTimes(1);++ await act(async () => finish('refused'));+ expect(screen.getByLabelText('Private Mode').props.value).toBe(false);+ expect(screen.getByLabelText('Private Mode').props.disabled).toBe(false);+ await screen.findByText(/Status: Ready/);+ });+});diff --git a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsxindex d9418214b..6a6249dc1 100644--- a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx@@ -97,7 +97,7 @@ describe('CleanupPromptScreen — guidance', () => {render(<CleanupPromptScreen />);expect(screen.getByText(- /On-Device mode skips cleanup unless it is set to On-Device or Bring Your Own Key/,+ /Private mode skips cleanup unless it is set to On-Device or Bring Your Own Key/,),).toBeTruthy();});diff --git a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsxindex bcd707182..a2452b938 100644--- a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx@@ -1,17 +1,18 @@import React from 'react';import { Switch } from 'react-native';-import { render, screen } from '@testing-library/react-native';+import { fireEvent, render, screen } from '@testing-library/react-native';import { DictationAgentScreen } from '../DictationAgentScreen';let mockActiveMode = 'providers';let mockConfig: Record<string, unknown> = { defaultMode: 'providers' };+const mockUpdateConfig = jest.fn();jest.mock('@/components/ui/Text', () => ({ Text: require('react-native').Text }));jest.mock('@/components/ui/SystemIcon', () => ({ SystemIcon: () => null }));jest.mock('@/hooks/useConfigToggle', () => ({ useConfigToggle: () => jest.fn() }));jest.mock('@/store/useConfigStore', () => ({useConfigStore: (selector: (state: unknown) => unknown) =>- selector({ config: mockConfig, updateConfig: jest.fn() }),+ selector({ config: mockConfig, updateConfig: mockUpdateConfig }),}));jest.mock('@/store/useProcessingModeStore', () => ({useProcessingModeStore: (selector: (state: unknown) => unknown) =>@@ -21,6 +22,7 @@ jest.mock('@/store/useProcessingModeStore', () => ({const NOTICE = /skips the voice assistant until Chat & Voice Assistant has a selection/;beforeEach(() => {+ jest.clearAllMocks();mockActiveMode = 'providers';mockConfig = { defaultMode: 'providers' };});@@ -41,8 +43,31 @@ it('is enabled once the voice assistant has a Bring Your Own Key selection', ()expect(screen.UNSAFE_getAllByType(Switch).some((toggle) => toggle.props.disabled)).toBe(false);});-it('asks for Cloud or Bring Your Own Key in On-Device mode', () => {+// Private mode turns the voice assistant off, so its switch must not read as on.+it('shows the voice assistant off in Private mode and says where to turn it back on', () => {mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };render(<DictationAgentScreen />);- expect(screen.getByText(/Voice Assistant needs Cloud or Bring Your Own Key mode/)).toBeTruthy();+ expect(+ screen.getByText(+ 'Off while Private mode is on. Turn it off in AI Models. Your settings are saved and apply once Private mode is off.',+ ),+ ).toBeTruthy();+ const [enable] = screen.UNSAFE_getAllByType(Switch);+ expect(enable.props.value).toBe(false);+ expect(enable.props.disabled).toBe(true);+});++it('switches only the voice assistant, keeping note chat as it was', () => {+ mockConfig = {+ defaultMode: 'providers',+ inference: { agent: { mode: 'providers', providerId: 'groq', modelId: 'llama' } },+ };+ render(<DictationAgentScreen />);+ expect(screen.queryByText(/Also turns note chat/)).toBeNull();+ fireEvent(screen.UNSAFE_getAllByType(Switch)[0], 'valueChange', false);+ expect(mockUpdateConfig).toHaveBeenCalledWith({+ dictationAgentEnabled: false,+ noteChatEnabled: true,+ });});diff --git a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsxindex 8591cd189..379632f9d 100644--- a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx@@ -150,7 +150,6 @@ jest.mock('@/components/ui/SwipeableCard', () => ({SwipeableCard: ({ children }: { children: React.ReactNode }) => children,}));jest.mock('@/components/ui/Glass', () => ({ Glass: () => null }));-jest.mock('@/components/ui/CloudIcon', () => ({ CloudIcon: () => null }));jest.mock('@/components/ui/SystemIcon', () => ({ SystemIcon: () => null }));jest.mock('@/components/ui/DictationModeControl', () => ({ DictationModeControl: () => null }));jest.mock('@/components/ui/UsageMeter', () => ({ UsageLimitBanner: () => null }));@@ -193,34 +192,26 @@ describe('HomeScreen Pro completion', () => {});});-describe('HomeScreen mode control', () => {+// Private mode is set in AI Models; Home only shows that it's on.+describe('HomeScreen Private mode badge', () => {afterEach(() => {mockProcessingModeStoreState.activeMode = 'cloud';});- it('is a button that opens the Dictation page in Bring Your Own Key mode', () => {- mockProcessingModeStoreState.activeMode = 'providers';+ it('opens AI Models from the badge while Private mode is on', () => {+ mockProcessingModeStoreState.activeMode = 'private';render(<HomeScreen />);- const control = screen.getByLabelText('Transcription: Bring Your Own Key');- expect(control.props.accessibilityRole).toBe('button');- expect(control.props.accessibilityState?.checked).toBeUndefined();- expect(control.props.accessibilityHint).toBe('Opens Dictation settings.');+ const badge = screen.getByLabelText('Private mode is on');+ expect(badge.props.accessibilityRole).toBe('button');+ fireEvent.press(badge);+ expect(require('expo-router').router.push).toHaveBeenCalledWith('/(account)/ai-models');});- it('is a Cloud switch otherwise', () => {+ it.each(['cloud', 'providers'])('shows no mode switch or badge in %s mode', (mode) => {+ mockProcessingModeStoreState.activeMode = mode;render(<HomeScreen />);- const control = screen.getByLabelText('Cloud transcription');- expect(control.props.accessibilityRole).toBe('switch');- expect(control.props.accessibilityState).toMatchObject({ checked: true });- });-- it('opens the Dictation page when dictation uses your own key', () => {- mockProcessingModeStoreState.activeMode = 'providers';- render(<HomeScreen />);- fireEvent.press(screen.getByLabelText('Transcription: Bring Your Own Key'));- expect(require('expo-router').router.push).toHaveBeenCalledWith({- pathname: '/(account)/ai-workflow',- params: { scope: 'dictation' },- });+ expect(screen.queryByLabelText('Private mode is on')).toBeNull();+ expect(screen.queryByLabelText('Cloud transcription')).toBeNull();+ expect(screen.queryByLabelText('Transcription: Bring Your Own Key')).toBeNull();});});diff --git a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsxindex 471d245d3..883c058f0 100644--- a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx@@ -528,6 +528,7 @@ beforeEach(() => {mockAuthState.user = { id: 'user-1', email: '[email protected]', emailVerified: true };mockConfigState.config.inference = undefined;mockConfigState.config.dictationAgentEnabled = undefined;+ mockConfigState.config.noteChatEnabled = undefined;mockProcessingModeState.activeMode = 'cloud';mockActions = [defaultAction()];mockActionsState.actions = mockActions;@@ -743,13 +744,22 @@ describe('NoteEditorScreen note chat', () => {expect(queryByTestId('chat-suggestion-Key decisions')).toBeNull();});- it('hides every Ask entry point when Chat & Voice Assistant is off', () => {- mockConfigState.config.dictationAgentEnabled = false;+ it.each([+ ['note chat is off', { noteChatEnabled: false }],+ ['the old shared switch was turned off', { dictationAgentEnabled: false }],+ ])('hides every Ask entry point when %s', (_label, settings) => {+ Object.assign(mockConfigState.config, settings);const { queryByText, queryByTestId } = render(<NoteEditorScreen />);expect(queryByText('Ask about this note')).toBeNull();expect(queryByTestId(PILL)).toBeNull();});+ it('keeps note chat when only the voice assistant is off', () => {+ Object.assign(mockConfigState.config, { dictationAgentEnabled: false, noteChatEnabled: true });+ const { getByTestId } = render(<NoteEditorScreen />);+ expect(getByTestId(PILL)).toBeTruthy();+ });+it('sends a meeting shortcut prompt immediately when its chip is tapped', async () => {(ReasoningService.chatOverNote as jest.Mock).mockResolvedValue({ text: 'Answer', model: 'x' });const { getByTestId } = render(<NoteEditorScreen />);diff --git a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsxindex 63ff258d8..1deba0ca1 100644--- a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx@@ -45,11 +45,24 @@ jest.mock('@/lib/workflowModeSwitch', () => ({switchWorkflowMode: (...args: unknown[]) => mockSwitchMode(...args),}));jest.mock('@/components/settings/OnDeviceModelSection', () => ({- OnDeviceModelSection: ({ scope, picked }: { scope: string; picked?: string }) => (- <MockText>{`On-device models for ${scope}, picked ${picked ?? 'Automatic'}`}</MockText>+ OnDeviceModelSection: ({+ scope,+ picked,+ lockedChoice,+ }: {+ scope: string;+ picked?: string;+ lockedChoice?: boolean;+ }) => (+ <MockText>+ {`On-device models for ${scope}, picked ${picked ?? 'Automatic'}${lockedChoice ? ', choice locked' : ''}`}+ </MockText>),}));-jest.mock('@/hooks/useConfigToggle', () => ({ useConfigToggle: () => jest.fn() }));+const mockToggle = jest.fn();+jest.mock('@/hooks/useConfigToggle', () => ({+ useConfigToggle: (key: string) => (value: unknown) => mockToggle(key, value),+}));jest.mock('@/store/useCustomPromptsStore', () => ({useCustomPromptsStore: (selector: (state: unknown) => unknown) =>selector({ customPrompts: { cleanup: mockStoredPrompt } }),@@ -108,6 +121,7 @@ jest.mock('@/services/providers/ProviderCredentials', () => ({}));import { WorkflowSettingsScreen } from '../WorkflowSettingsScreen';+import { PRIVATE_MODE_LOCKED_REASON } from '@/lib/aiWorkflows';function chooseProvider(provider: string): void {fireEvent.press(screen.getByText('Provider'));@@ -387,8 +401,9 @@ it('closes the keyboard when a key is pasted, but not while typing', () => {expect(dismiss).toHaveBeenCalledTimes(1);});-it('checks a provider from On-Device mode, since a check sends no user content', async () => {+it('checks a provider from Private mode, since a check sends no user content', async () => {mockActiveMode = 'private';+ mockScope = 'cleanup';render(<WorkflowSettingsScreen />);enableProviders();fireEvent.changeText(screen.getByLabelText('API key'), 'test-key');@@ -450,7 +465,7 @@ it('shows no cleanup mode for a private-mode user who has not saved one, since cexpect(selectedMode()).toBeUndefined();expect(screen.getByText(- 'Not saved yet. On-Device mode skips cleanup until you choose On-Device or Bring Your Own Key.',+ 'Not saved yet. Private mode skips cleanup until you choose On-Device or Bring Your Own Key.',),).toBeTruthy();expect(screen.queryByText('Runs on Apple Intelligence on this iPhone.')).toBeNull();@@ -477,12 +492,16 @@ it('keeps On-Device cleanup selected once a private-mode user has saved it', ()expect(mockSwitchMode).not.toHaveBeenCalled();});-it('keeps uploads on the previous mode when dictation switches to Bring Your Own Key', async () => {+// Needs no account, so it is also how a guest, who is kept in Private mode, uses their own key.+it('keeps uploads on this phone when dictation leaves Private mode for Bring Your Own Key', async () => {mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';mockCredentialStatus.mockResolvedValue({ isConfigured: true });render(<WorkflowSettingsScreen />);enableProviders();+ expect(+ screen.getByText('Save to switch to Bring Your Own Key. This turns Private mode off.'),+ ).toBeTruthy();fireEvent.press(screen.getByText('Save'));await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());const saved = mockUpdateConfig.mock.calls[0][0] as {@@ -490,9 +509,10 @@ it('keeps uploads on the previous mode when dictation switches to Bring Your Own};expect(saved.inference.dictation.mode).toBe('providers');expect(saved.inference.upload).toEqual({ mode: 'local' });+ expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);});-it('keeps notes and chat on this phone when dictation leaves On-Device for a provider', async () => {+it('keeps notes and chat on this phone when dictation leaves Private mode for a provider', async () => {mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';mockCredentialStatus.mockResolvedValue({ isConfigured: true });@@ -719,20 +739,56 @@ it('asks for a key when none is saved', async () => {await waitFor(() => expect(mockCredentialStatus).toHaveBeenCalled());});-it('turns Chat & Voice Assistant on and off from the top of its page', () => {- mockScope = 'agent';- const view = render(<WorkflowSettingsScreen />);- const page = JSON.stringify(view.toJSON());- expect(page.indexOf('Enable Chat & Voice Assistant')).toBeLessThan(- page.indexOf('OpenWhispr Cloud'),- );- fireEvent.press(screen.getByText('Voice Assistant'));- expect(mockPush).toHaveBeenCalledWith('/(account)/dictation-agent');- mockConfig = { defaultMode: 'cloud', dictationAgentEnabled: false };- view.rerender(<WorkflowSettingsScreen />);- expect(screen.queryByText('OpenWhispr Cloud')).toBeNull();- expect(screen.queryByText('Voice Assistant')).toBeNull();- expect(screen.getByText('Note chat and the voice assistant are off.')).toBeTruthy();+describe('note chat and the voice assistant', () => {+ beforeEach(() => {+ mockScope = 'agent';+ });++ it('switch apart at the top of their page', () => {+ const view = render(<WorkflowSettingsScreen />);+ const page = JSON.stringify(view.toJSON());+ expect(page.indexOf('Note Chat')).toBeLessThan(page.indexOf('OpenWhispr Cloud'));+ fireEvent(screen.getByLabelText('Note Chat'), 'valueChange', false);+ expect(mockToggle).toHaveBeenCalledWith('noteChatEnabled', false);+ // Note chat stops following the voice assistant's switch once that is changed.+ fireEvent(screen.getByLabelText('Voice Assistant'), 'valueChange', false);+ expect(mockUpdateConfig).toHaveBeenCalledWith({+ dictationAgentEnabled: false,+ noteChatEnabled: true,+ });+ fireEvent.press(screen.getByText('Voice Assistant Settings'));+ expect(mockPush).toHaveBeenCalledWith('/(account)/dictation-agent');+ });++ it('keep the model choice while note chat is on and the voice assistant off', () => {+ mockConfig = { defaultMode: 'cloud', dictationAgentEnabled: false, noteChatEnabled: true };+ render(<WorkflowSettingsScreen />);+ expect(screen.getByLabelText('Note Chat').props.value).toBe(true);+ expect(screen.getByLabelText('Voice Assistant').props.value).toBe(false);+ expect(screen.getByText('OpenWhispr Cloud')).toBeTruthy();+ expect(screen.queryByText('Voice Assistant Settings')).toBeNull();+ expect(screen.queryByText('Note chat and the voice assistant are off.')).toBeNull();+ });++ // The one switch both shared before is still what an existing user's choice is saved in.+ it('are both off, with no model choice, when the old shared switch was turned off', () => {+ mockConfig = { defaultMode: 'cloud', dictationAgentEnabled: false };+ render(<WorkflowSettingsScreen />);+ expect(screen.getByLabelText('Note Chat').props.value).toBe(false);+ expect(screen.queryByText('OpenWhispr Cloud')).toBeNull();+ expect(screen.getByText('Note chat and the voice assistant are off.')).toBeTruthy();+ });++ it('show the voice assistant off in Private mode, while note chat stays on', () => {+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };+ render(<WorkflowSettingsScreen />);+ expect(screen.getByLabelText('Note Chat').props.value).toBe(true);+ expect(screen.getByLabelText('Voice Assistant').props.value).toBe(false);+ expect(screen.getByLabelText('Voice Assistant').props.disabled).toBe(true);+ expect(screen.getAllByText(PRIVATE_MODE_LOCKED_REASON).length).toBeGreaterThan(0);+ expect(screen.queryByText('Voice Assistant Settings')).toBeNull();+ });});it('shows a default cleanup prompt as Default', () => {@@ -789,7 +845,7 @@ it('adds no pins when an existing user re-saves dictation with their own key', aexpect(saved.inference.notes).toBeUndefined();});-it('explains that On-Device mode skips a saved Cloud cleanup choice', () => {+it('explains that Private mode skips a saved Cloud cleanup choice', () => {mockConfig = { defaultMode: 'private', inference: { cleanup: { mode: 'openwhispr' } } };mockActiveMode = 'private';mockScope = 'cleanup';@@ -797,7 +853,7 @@ it('explains that On-Device mode skips a saved Cloud cleanup choice', () => {expect(selectedMode()).toBe('OpenWhispr Cloud');expect(screen.getByText(- 'In On-Device mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until dictation leaves On-Device.',+ 'In Private mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until Private mode is off.',),).toBeTruthy();});@@ -805,13 +861,13 @@ it('explains that On-Device mode skips a saved Cloud cleanup choice', () => {it.each([['agent',- 'In On-Device mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',+ 'In Private mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',],['notes',- 'On-Device mode formats notes on this iPhone and asks before sending one to your choice here.',+ 'Private mode formats notes on this iPhone and asks before sending one to your choice here.',],-])('explains what On-Device mode means for %s', (scope, note) => {+])('explains what Private mode means for %s', (scope, note) => {mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';mockScope = scope;@@ -819,33 +875,101 @@ it.each([expect(screen.getByText(note)).toBeTruthy();});-it('explains that On-Device mode keeps a workflow on this phone, and still saves a change', async () => {+// Private mode runs uploads on this phone, so a saved choice it locks isn't shown as picked, or+// offered for editing, but stays saved for when Private mode is off.+it('shows On-Device for an upload choice Private mode locks, and keeps that choice', () => {mockConfig = {defaultMode: 'private',inference: { upload: { mode: 'providers', providerId: 'openai', modelId: 'whisper-1' } },};mockActiveMode = 'private';mockScope = 'upload';- mockCredentialStatus.mockResolvedValue({ isConfigured: true });render(<WorkflowSettingsScreen />);+ expect(selectedMode()).toBe('On-Device');expect(screen.getByText(- 'On-Device mode keeps this on your iPhone. Your choice applies when dictation leaves On-Device.',+ 'Private mode keeps uploads on this iPhone. Your Bring Your Own Key choice applies again when Private mode is off.',),).toBeTruthy();- fireEvent.changeText(screen.getByLabelText('API key'), 'replacement-key');- fireEvent.press(screen.getByText('Save'));- await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());- expect(mockUpdateConfig.mock.calls[0][0].inference.upload).toMatchObject({- providerId: 'openai',- });+ expect(screen.queryByLabelText('API key')).toBeNull();+ // Tapping the Automatic row it shows must not replace the saved choice either.+ expect(+ screen.getByText('On-device models for upload, picked Automatic, choice locked'),+ ).toBeTruthy();+ fireEvent.press(screen.getByText('On-Device'));+ expect(mockSwitchMode).not.toHaveBeenCalled();+ expect(mockUpdateConfig).not.toHaveBeenCalled();+});++it('names a locked Cloud upload choice in the note', () => {+ mockConfig = { defaultMode: 'private', inference: { upload: { mode: 'openwhispr' } } };+ mockActiveMode = 'private';+ mockScope = 'upload';+ render(<WorkflowSettingsScreen />);+ expect(selectedMode()).toBe('On-Device');+ expect(+ screen.getByText(+ 'Private mode keeps uploads on this iPhone. Your OpenWhispr Cloud choice applies again when Private mode is off.',+ ),+ ).toBeTruthy();+});++it('shows On-Device for a guest whose saved Cloud dictation Private mode overrides', () => {+ mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };+ mockActiveMode = 'private';+ render(<WorkflowSettingsScreen />);+ expect(selectedMode()).toBe('On-Device');+ fireEvent.press(screen.getByText('On-Device'));+ expect(mockSwitchMode).not.toHaveBeenCalled();+ expect(mockUpdateConfig).not.toHaveBeenCalled();+});++it('keeps the plain upload note when uploads already run on this phone', () => {+ mockConfig = { defaultMode: 'private' };+ mockActiveMode = 'private';+ mockScope = 'upload';+ render(<WorkflowSettingsScreen />);+ expect(screen.getByText('Private mode keeps uploads on this iPhone.')).toBeTruthy();+});++function modeDisabled(title: string): boolean {+ let row = screen.getByText(title).parent;+ while (row && !row.props.accessibilityState) row = row.parent;+ return !!row?.props.accessibilityState.disabled;+}++// Private mode is switched in AI Models, so a page can't offer a mode it would ignore. Dictation+// keeps Bring Your Own Key: saving it leaves Private mode, with no account needed.+it.each([+ ['dictation', ['OpenWhispr Cloud'], ['On-Device', 'Bring Your Own Key']],+ ['upload', ['OpenWhispr Cloud', 'Bring Your Own Key'], ['On-Device']],+ ['cleanup', ['OpenWhispr Cloud'], ['On-Device', 'Bring Your Own Key']],+ ['notes', [], ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key']],+ ['agent', [], ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key']],+])('locks the modes Private mode never runs for %s', (scope, locked, open) => {+ mockConfig = { defaultMode: 'private' };+ mockActiveMode = 'private';+ mockScope = scope;+ render(<WorkflowSettingsScreen />);+ for (const title of locked) expect(modeDisabled(title)).toBe(true);+ for (const title of open) expect(modeDisabled(title)).toBe(false);+ // The agent page's Voice Assistant switch is off for the same reason.+ expect(+ screen.queryAllByText('Off while Private mode is on. Turn it off in AI Models.'),+ ).toHaveLength(locked.length + (scope === 'agent' ? 1 : 0));+});++it('locks no mode outside Private mode', () => {+ render(<WorkflowSettingsScreen />);+ for (const title of ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key'])+ expect(modeDisabled(title)).toBe(false);});-it('does not show the On-Device note on the Dictation page', () => {+it('does not show the Private mode note on the Dictation page', () => {mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';render(<WorkflowSettingsScreen />);- expect(screen.queryByText(/On-Device mode keeps this/)).not.toBeOnTheScreen();+ expect(screen.queryByText(/Private mode keeps/)).not.toBeOnTheScreen();});it('does not edit dictation settings from an unknown workflow link', () => {@@ -1098,7 +1222,7 @@ describe('an iPhone that cannot run Apple Intelligence', () => {expect(await screen.findByText(- "Not saved yet. This iPhone can't run On-Device cleanup, so On-Device mode skips it until you choose Bring Your Own Key.",+ "Not saved yet. This iPhone can't run On-Device cleanup, so Private mode skips it until you choose Bring Your Own Key.",),).toBeTruthy();});diff --git a/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx b/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsxindex e17000451..7f0fece3d 100644--- a/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx@@ -60,7 +60,7 @@ it('names the voice assistant throughout its settings screen', () => {render(<DictationAgentScreen />);expect(screen.getByText('Enable Voice Assistant')).toBeTruthy();expect(screen.getByText('Assistant Name')).toBeTruthy();- expect(screen.getByText(/Voice Assistant needs Cloud or Bring Your Own Key mode/)).toBeTruthy();+ expect(screen.getByText(/Off while Private mode is on/)).toBeTruthy();expect(screen.queryByText(/agent/i)).toBeNull();});diff --git a/openwhispr-mobile/src/screens/onboarding/steps/DictationEmailStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/DictationEmailStep.tsxindex 5f2bddbdc..7a7bb3e8d 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/DictationEmailStep.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/DictationEmailStep.tsx@@ -17,10 +17,14 @@ import { useOnboardingPracticeMode } from '@/hooks/useOnboardingPracticeMode';import { useOnboardingStep } from '@/hooks/useOnboardingStep';import { useAuthStore } from '@/store/useAuthStore';import { useHandoffStore } from '@/store/useHandoffStore';+import { hasRealAccountHistory } from '@/sync/syncIdentity';import { addKeyboardStatusChangedListener } from '../../../../modules/app-group-storage/src';const SAMPLE_EMAIL ='Hey Tim, excited to chat. Are you free next Friday at 3pm… actually, 4pm? Thanks, Chad';+// What the sample comes out as, shown when the live try can't run.+const EXAMPLE_EMAIL =+ 'Hey Tim,\n\nExcited to chat. Are you free next Friday at 4pm?\n\nThanks,\nChad';const GMAIL_ICON = require('../../../../assets/onboarding/app-icons/gmail.png');const MAIL_ICON = require('../../../../assets/onboarding/app-icons/mail.png');@@ -30,7 +34,13 @@ export function DictationEmailStep(): ReactElement {const { goNext, progress } = useOnboardingStep('dictation-email');const { localSelected } = useOnboardingPracticeMode();const user = useAuthStore((state) => state.user);+ const isGuest = useAuthStore((state) => state.isGuest);const ensureSession = useAuthStore((state) => state.ensureAnonymousSession);+ // A guest declined an account, and a device with account history must not get a new identity+ // (its first sync would read as an account switch and wipe that account's notes), so neither+ // can get a session here, and Retry would only ever fail.+ const [noHistory] = useState(() => !hasRealAccountHistory());+ const sessionPossible = !isGuest && noHistory;const isTranscribing = useHandoffStore((state) => state.isTranscribing);const input = useRef<TextInput>(null);const dismissOnInsert = useRef(false);@@ -38,6 +48,10 @@ export function DictationEmailStep(): ReactElement {const [status, setStatus] = useState('idle');const [error, setError] = useState<string | null>(null);const liveAvailable = !localSelected && !!user;+ // A practice error only means something while the field is shown; without it, Retry would offer+ // a session where none can be made.+ const shownError = liveAvailable ? error : null;+ const canRetry = liveAvailable ? !!error : !localSelected && sessionPossible;const busy =status === 'recording' || status === 'transcribing' || status === 'cleaning' || isTranscribing;@@ -72,13 +86,16 @@ export function DictationEmailStep(): ReactElement {setError(null);setStatus('idle');setValue('');+ // Refocuses a field already shown; one swapped in for the example focuses itself (autoFocus).input.current?.focus();}, [ensureSession]);const note = localSelected- ? 'Practice uses Cloud. Skip it to keep Local.'+ ? 'Practice uses Cloud. Here’s an example instead.': !user- ? 'Cloud practice needs a connection. Try again or skip for now.'+ ? sessionPossible+ ? 'Cloud practice needs a connection. Here’s an example instead.'+ : 'Cloud practice needs an account. Here’s an example instead.': status === 'recording'? 'Listening…': busy@@ -97,7 +114,7 @@ export function DictationEmailStep(): ReactElement {ctaLabel="Continue"ctaDisabled={busy}onCta={goNext}- secondaryCtaLabel={!localSelected && (error || !user) ? 'Retry' : undefined}+ secondaryCtaLabel={canRetry ? 'Retry' : undefined}onSecondaryCta={retry}><ScrollView keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>@@ -116,42 +133,62 @@ export function DictationEmailStep(): ReactElement {<Text className="w-16 text-[14px] text-tertiaryLabel">Subject</Text><Text className="text-[14px] font-medium text-label">Quick sync</Text></View>- <View className="px-4 pb-4 pt-3">- <Text className="mb-2 text-[11px] font-bold uppercase tracking-wider text-tertiaryLabel">- Read this aloud- </Text>- <TextInput- ref={input}- accessibilityLabel="Your dictated email"- value={value}- onChangeText={(text) => {- setValue(text);- // Native readiness precedes the keyboard consuming its pending transcript, and the- // status stays ready afterwards, so dismiss once per dictation, not on every edit.- if (dismissOnInsert.current && text.trim()) {- dismissOnInsert.current = false;- Keyboard.dismiss();- }- }}- editable={liveAvailable}- autoFocus={liveAvailable}- multiline- placeholder={SAMPLE_EMAIL}- placeholderTextColor="#9CA3AF"- style={styles.emailInput}- textAlignVertical="top"- autoCorrect={false}- scrollEnabled- />- </View>+ {/* Without a live try the field would be a dead box that looks tappable, so the card shows+ the sample and its result instead. */}+ {liveAvailable ? (+ <View className="px-4 pb-4 pt-3">+ <Text className="mb-2 text-[11px] font-bold uppercase tracking-wider text-tertiaryLabel">+ Read this aloud+ </Text>+ <TextInput+ ref={input}+ accessibilityLabel="Your dictated email"+ value={value}+ onChangeText={(text) => {+ setValue(text);+ // Native readiness precedes the keyboard consuming its pending transcript, and the+ // status stays ready afterwards, so dismiss once per dictation, not on every edit.+ if (dismissOnInsert.current && text.trim()) {+ dismissOnInsert.current = false;+ Keyboard.dismiss();+ }+ }}+ autoFocus+ multiline+ placeholder={SAMPLE_EMAIL}+ placeholderTextColor="#9CA3AF"+ style={styles.emailInput}+ textAlignVertical="top"+ autoCorrect={false}+ scrollEnabled+ />+ </View>+ ) : (+ <View className="gap-4 px-4 pb-4 pt-3">+ <View>+ <Text className="mb-2 text-[11px] font-bold uppercase tracking-wider text-tertiaryLabel">+ You say+ </Text>+ <Text className="text-[15px] leading-[21px] text-secondaryLabel">+ “{SAMPLE_EMAIL}”+ </Text>+ </View>+ <View>+ <Text className="mb-2 text-[11px] font-bold uppercase tracking-wider text-tertiaryLabel">+ OpenWhispr writes+ </Text>+ <Text className="text-[16px] leading-[22px] text-label">{EXAMPLE_EMAIL}</Text>+ </View>+ </View>+ )}</View><Text- accessibilityRole={error ? 'alert' : undefined}+ accessibilityRole={shownError ? 'alert' : undefined}accessibilityLiveRegion="polite"- className={`mt-3 text-[13px] ${error ? 'text-systemRed' : 'text-secondaryLabel'}`}+ className={`mt-3 text-[13px] ${shownError ? 'text-systemRed' : 'text-secondaryLabel'}`}>- {error ?? note}+ {shownError ?? note}</Text>{/* Reassurance — works anywhere */}diff --git a/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx b/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsxindex 7075ddaeb..a47cc4341 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx@@ -68,10 +68,10 @@ export function SlowDownloadSheet({<View className="mt-4 rounded-2xl border border-separator bg-secondarySystemGroupedBackground p-4"><View className="flex-row items-center gap-2">- <SystemIcon name="cloud.fill" mdName="Cloud" size={16} color="brand" />+ <SystemIcon name="lock.fill" mdName="Lock" size={16} color="brand" /><Text className="flex-1 text-[13px] leading-[18px] text-secondaryLabel">- Turn the Cloud toggle <Text className="font-semibold text-label">off</Text> on the- home screen to switch to Private once it's ready.+ Turn on <Text className="font-semibold text-label">Private Mode</Text> in Account+ → AI Models to switch once it's ready.</Text></View></View>diff --git a/openwhispr-mobile/src/screens/onboarding/steps/VoiceAgentStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/VoiceAgentStep.tsxindex 831b83e0d..613374080 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/VoiceAgentStep.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/VoiceAgentStep.tsx@@ -15,6 +15,7 @@ import { BRAND } from '@/config/colors';import { AppFont } from '@/lib/fonts';import { safeHaptics } from '@/lib/utils';import { useAuthStore } from '@/store/useAuthStore';+import { hasRealAccountHistory } from '@/sync/syncIdentity';import { addKeyboardStatusChangedListener } from '../../../../modules/app-group-storage/src';type Phase = 'start' | 'asking' | 'first-draft' | 'refined' | 'done';@@ -53,6 +54,9 @@ export function VoiceAgentStep(): ReactElement {const { goNext, goBack, progress } = useOnboardingStep('voice-agent');const { localSelected } = useOnboardingPracticeMode();const user = useAuthStore((state) => state.user);+ const isGuest = useAuthStore((state) => state.isGuest);+ // As on the dictation step: a guest, or a device with account history, never gets a session here.+ const [noHistory] = useState(() => !hasRealAccountHistory());const input = useRef<TextInput>(null);const draftsReady = useRef(0);const lastDraftAt = useRef<string | undefined>(undefined);@@ -118,7 +122,9 @@ export function VoiceAgentStep(): ReactElement {const fallbackNote = localSelected? 'The voice assistant uses Cloud. Here’s an example instead.': !user- ? 'The voice assistant needs a connection. Here’s an example instead.'+ ? !isGuest && noHistory+ ? 'The voice assistant needs a connection. Here’s an example instead.'+ : 'The voice assistant needs an account. Here’s an example instead.': errorNote;return (diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/DictationEmailStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/DictationEmailStep.test.tsxindex 7bbe4152e..8e50c7f14 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/DictationEmailStep.test.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/DictationEmailStep.test.tsx@@ -27,11 +27,17 @@ jest.mock('@/store/useProcessingModeStore', () => ({},}));let mockUser: { id: string } | null = { id: 'anon' };+let mockIsGuest = false;+let mockAccountHistory = false;const mockEnsureSession = jest.fn();jest.mock('@/store/useAuthStore', () => ({useAuthStore: Object.assign((selector: (s: unknown) => unknown) =>- selector({ user: mockUser, ensureAnonymousSession: mockEnsureSession }),+ selector({+ user: mockUser,+ isGuest: mockIsGuest,+ ensureAnonymousSession: mockEnsureSession,+ }),{ getState: () => ({ user: mockUser }) },),}));@@ -40,6 +46,9 @@ jest.mock('@/store/useConfigStore', () => ({useConfigStore: (selector: (s: unknown) => unknown) =>selector({ config: { defaultMode: mockSavedMode } }),}));+jest.mock('@/sync/syncIdentity', () => ({+ hasRealAccountHistory: () => mockAccountHistory,+}));jest.mock('@/store/useHandoffStore', () => ({useHandoffStore: (selector: (s: unknown) => unknown) => selector({ isTranscribing: false }),}));@@ -49,19 +58,37 @@ beforeEach(() => {mockMode = null;mockSavedMode = 'cloud';mockUser = { id: 'anon' };+ mockIsGuest = false;+ mockAccountHistory = false;mockNext.mockResolvedValue(undefined);mockEnsureSession.mockResolvedValue(undefined);});const SAMPLE_EMAIL ='Hey Tim, excited to chat. Are you free next Friday at 3pm… actually, 4pm? Thanks, Chad';+const EXAMPLE_EMAIL =+ 'Hey Tim,\n\nExcited to chat. Are you free next Friday at 4pm?\n\nThanks,\nChad';++// Without a live try there's no field to tap, only the sample and what OpenWhispr makes of it.+function expectExample(screen: ReturnType<typeof render>): void {+ expect(screen.queryByLabelText('Your dictated email')).toBeNull();+ expect(screen.queryByText('Read this aloud')).toBeNull();+ expect(screen.getByText('You say')).toBeTruthy();+ expect(screen.getByText(`“${SAMPLE_EMAIL}”`)).toBeTruthy();+ expect(screen.getByText('OpenWhispr writes')).toBeTruthy();+ expect(screen.getByText(EXAMPLE_EMAIL)).toBeTruthy();+}it('lays the practice out as an email to Tim with the sample as the placeholder', () => {const screen = render(<DictationEmailStep />);for (const text of ['To', 'Tim', 'Subject', 'Quick sync', 'Read this aloud']) {expect(screen.getByText(text)).toBeTruthy();}- expect(screen.getByLabelText('Your dictated email').props.placeholder).toBe(SAMPLE_EMAIL);+ const field = screen.getByLabelText('Your dictated email');+ expect(field.props.placeholder).toBe(SAMPLE_EMAIL);+ expect(field.props.autoFocus).toBe(true);+ expect(field.props.editable).not.toBe(false);+ expect(screen.queryByText('You say')).toBeNull();expect(screen.getByText('works in any email app')).toBeTruthy();});@@ -80,19 +107,21 @@ it('offers retry after a recording failure, without an example', async () => {const screen = render(<DictationEmailStep />);act(() => mockListener({ status: 'error', error: 'Network unavailable' }));expect(screen.getByText('Network unavailable')).toBeTruthy();- expect(screen.queryByText('Show an example')).toBeNull();- expect(screen.queryByText(/Example/)).toBeNull();+ expect(screen.queryByText('You say')).toBeNull();+ expect(screen.getByLabelText('Your dictated email')).toBeTruthy();fireEvent.press(screen.getByText('Retry'));- await waitFor(() => expect(mockEnsureSession).toHaveBeenCalledTimes(1));+ await waitFor(() => expect(screen.queryByText('Network unavailable')).not.toBeOnTheScreen());+ expect(mockEnsureSession).toHaveBeenCalledTimes(1);+ expect(screen.queryByText('Retry')).toBeNull();});it('keeps Local selected when revisiting practice', () => {mockMode = 'private';const screen = render(<DictationEmailStep />);expect(mockSetMode).not.toHaveBeenCalled();- expect(screen.getByLabelText('Your dictated email').props.editable).toBe(false);- expect(screen.getByText('Practice uses Cloud. Skip it to keep Local.')).toBeTruthy();- expect(screen.queryByText(/Example/)).toBeNull();+ expect(screen.getByText('Practice uses Cloud. Here’s an example instead.')).toBeTruthy();+ expectExample(screen);+ expect(screen.queryByText('Retry')).toBeNull();});it('keeps offline practice skippable', async () => {@@ -141,7 +170,77 @@ it('keeps a saved Local default when replaying onboarding', () => {mockSavedMode = 'private';const screen = render(<DictationEmailStep />);expect(mockSetMode).not.toHaveBeenCalled();- expect(screen.getByText('Practice uses Cloud. Skip it to keep Local.')).toBeTruthy();+ expect(screen.getByText('Practice uses Cloud. Here’s an example instead.')).toBeTruthy();+ expectExample(screen);+});++// First run offline: no session yet, and one can still be made.+it('shows the example with a retry when there is no session', () => {+ mockUser = null;+ const screen = render(<DictationEmailStep />);+ expect(+ screen.getByText('Cloud practice needs a connection. Here’s an example instead.'),+ ).toBeTruthy();+ expectExample(screen);+ expect(screen.getByText('Retry')).toBeTruthy();+});++// A guest declined an account, and a device that synced one must not get a new identity (it+// would wipe that account's notes), so a retry could only fail.+it.each([+ ['a guest', () => (mockIsGuest = true)],+ ['a device that synced an account', () => (mockAccountHistory = true)],+])('shows the example without a retry for %s', (_label, arrange) => {+ mockUser = null;+ arrange();+ const screen = render(<DictationEmailStep />);+ expect(+ screen.getByText('Cloud practice needs an account. Here’s an example instead.'),+ ).toBeTruthy();+ expectExample(screen);+ expect(screen.queryByText('Retry')).toBeNull();+});++// The keyboard can still report a failed dictation while the example is shown; a Retry then would+// make a session for an account that must not get one.+it.each([+ ['a guest', () => (mockIsGuest = true)],+ ['a device that synced an account', () => (mockAccountHistory = true)],+ ['Local', () => (mockSavedMode = 'private')],+])('ignores a keyboard failure while showing the example for %s', (_label, arrange) => {+ mockUser = null;+ arrange();+ const screen = render(<DictationEmailStep />);+ act(() => mockListener({ status: 'setup_required', error: 'Open OpenWhispr to finish setup.' }));+ expect(screen.queryByText('Open OpenWhispr to finish setup.')).toBeNull();+ expect(screen.queryByText('Retry')).toBeNull();+ expectExample(screen);+ expect(mockEnsureSession).not.toHaveBeenCalled();+});++// "Reset onboarding" while signed in: the account is already there, so practice runs.+it('lets a signed-in account with synced notes practice live', () => {+ mockAccountHistory = true;+ mockUser = { id: 'user-1' };+ const screen = render(<DictationEmailStep />);+ expect(screen.queryByText('You say')).toBeNull();+ expect(screen.getByLabelText('Your dictated email').props.autoFocus).toBe(true);+ expect(screen.queryByText('Retry')).toBeNull();+});++it('swaps the example for a focused field once a retry gets a session', async () => {+ mockUser = null;+ const screen = render(<DictationEmailStep />);+ mockEnsureSession.mockImplementation(async () => {+ mockUser = { id: 'anon' };+ });+ fireEvent.press(screen.getByText('Retry'));+ await waitFor(() => expect(mockEnsureSession).toHaveBeenCalledTimes(1));+ screen.rerender(<DictationEmailStep />);+ expect(screen.queryByText('You say')).toBeNull();+ expect(screen.getByLabelText('Your dictated email').props.autoFocus).toBe(true);+ expect(screen.queryByText('Retry')).toBeNull();+ expect(screen.queryByText(/Still no connection/)).toBeNull();});it('explains why Cloud practice could not be retried', async () => {diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/ToneStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/ToneStep.test.tsxindex a2d174ae4..a7c75889c 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/ToneStep.test.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/ToneStep.test.tsx@@ -2,6 +2,7 @@ import { fireEvent, render, waitFor } from '@testing-library/react-native';import { ToneStep } from '../ToneStep';jest.mock('@/lib/sentry', () => ({ Sentry: { captureException: jest.fn() } }));+jest.mock('@/sync/syncIdentity', () => ({ hasRealAccountHistory: () => false }));jest.mock('react-native-safe-area-context', () => ({ SafeAreaView: require('react-native').View }));jest.mock('@/components/ui/Text', () => ({ Text: require('react-native').Text }));jest.mock('@/components/ui/SystemIcon', () => ({ SystemIcon: () => null }));diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/VoiceAgentStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/VoiceAgentStep.test.tsxindex 85664ac2b..0c5e2d76f 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/VoiceAgentStep.test.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/VoiceAgentStep.test.tsx@@ -52,8 +52,14 @@ jest.mock('@/store/useConfigStore', () => ({selector({ config: { defaultMode: mockSavedMode } }),}));let mockUser: { id: string } | null = { id: 'anon' };+let mockIsGuest = false;+let mockAccountHistory = false;jest.mock('@/store/useAuthStore', () => ({- useAuthStore: (selector: (s: unknown) => unknown) => selector({ user: mockUser }),+ useAuthStore: (selector: (s: unknown) => unknown) =>+ selector({ user: mockUser, isGuest: mockIsGuest }),+}));+jest.mock('@/sync/syncIdentity', () => ({+ hasRealAccountHistory: () => mockAccountHistory,}));// The field is focused on arrival, and the glyph is the keyboard's own agent button.@@ -74,6 +80,8 @@ beforeEach(() => {mockMode = null;mockSavedMode = 'cloud';mockUser = { id: 'anon' };+ mockIsGuest = false;+ mockAccountHistory = false;mockNext.mockResolvedValue(undefined);mockBack.mockResolvedValue(undefined);});@@ -313,6 +321,19 @@ it('shows the example when there is no session to try the agent with', () => {expect(screen.getByText('Example request')).toBeTruthy();});+it.each([+ ['a guest', () => (mockIsGuest = true)],+ ['a device that synced an account', () => (mockAccountHistory = true)],+])('says the voice assistant needs an account for %s', (_label, arrange) => {+ mockUser = null;+ arrange();+ const screen = render(<VoiceAgentStep />);+ expect(+ screen.getByText('The voice assistant needs an account. Here’s an example instead.'),+ ).toBeTruthy();+ expect(screen.getByText('Example request')).toBeTruthy();+});+it.each(['Continue', 'Skip'])('leaves the voice-agent step using %s', async (action) => {const screen = render(<VoiceAgentStep />);await act(async () => {diff --git a/openwhispr-mobile/src/store/useTranscriptStore.ts b/openwhispr-mobile/src/store/useTranscriptStore.tsindex fa4c10dd1..9340a5c61 100644--- a/openwhispr-mobile/src/store/useTranscriptStore.ts+++ b/openwhispr-mobile/src/store/useTranscriptStore.ts@@ -369,7 +369,7 @@ export const useTranscriptStore = create<TranscriptState>((set, get) => {rerouted ?? (provider === current.provider ? current : snapshotTextInference(provider));if (provider !== 'local' && activeMode === 'private') {throw new Error(- 'This recording used a remote provider. Leave private mode to retry its original route.',+ 'This recording used a remote provider. Turn off Private Mode in Account → AI Models to retry its original route.',);}const retryCount = (current.retryCount ?? 0) + 1;diff --git a/openwhispr-mobile/src/types/index.ts b/openwhispr-mobile/src/types/index.tsindex e5b29c773..8281838be 100644--- a/openwhispr-mobile/src/types/index.ts+++ b/openwhispr-mobile/src/types/index.ts@@ -16,6 +16,10 @@ export interface UserConfig {// Workflows held on the previous mode when dictation moved to Bring Your Own Key,// as opposed to ones the user chose; only these are released when dictation leaves it.pinnedInference?: MobileInferenceScope[];+ // Set while Private mode is on after being turned on from Bring Your Own Key, so turning it+ // off goes back to the last provider rather than to Cloud, with the workflows it held+ // (pinnedInference) held on the same selections again.+ privateModeReturn?: { pinned: Partial<Record<MobileInferenceScope, InferenceSelection>> };defaultMode: ProcessingMode;cleanupEnabled?: boolean;autoGenerateNoteTitle?: boolean;@@ -39,6 +43,8 @@ export interface UserConfig {appleLocalIntelligenceEnabled?: boolean;// Dictation agent (cloud-only, default on)dictationAgentEnabled?: boolean;+ // Note chat, which once shared dictationAgentEnabled's switch and follows it until set.+ noteChatEnabled?: boolean;dictationAgentName?: string;dictationAgentShareContext?: boolean;}