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): explain language-blocked Apple Intelligence and keep Local Mode to dictation (#2805)
Chad Piha788db13e2af8
diff --git a/openwhispr-mobile/modules/apple-llm/ios/AppleLLMModule.swift b/openwhispr-mobile/modules/apple-llm/ios/AppleLLMModule.swiftindex 839a969a8..325c54df6 100644--- a/openwhispr-mobile/modules/apple-llm/ios/AppleLLMModule.swift+++ b/openwhispr-mobile/modules/apple-llm/ios/AppleLLMModule.swift@@ -201,9 +201,27 @@ public class AppleLLMModule: Module {payload["status"] = "unavailable"}+ // Apple Intelligence runs in only some of the languages an iPhone can be set to, and its+ // availability has no reason for that, so the iPhone's language is checked beside it. The name+ // is in English, like the app's own text. Siri's language can't be read without the Siri+ // entitlement (INPreferences throws), so a mismatch with it is left to the message.+ let language = Locale(identifier: Locale.preferredLanguages.first ?? Locale.current.identifier)+ payload["deviceLanguage"] = englishName(of: language)+ // The list is read from the model, so an empty one says nothing about the language. A region+ // the model doesn't list (English (India)) can still run, so the language alone decides.+ if !model.supportedLanguages.isEmpty {+ let languageOnly = language.language.languageCode.map { Locale(identifier: $0.identifier) }+ payload["localeSupported"] =+ model.supportsLocale(language) || languageOnly.map { model.supportsLocale($0) } ?? false+ }+return payload}+ private static func englishName(of locale: Locale) -> String {+ Locale(identifier: "en").localizedString(forIdentifier: locale.identifier) ?? locale.identifier+ }+@available(iOS 26.0, *)private static func ensureAvailable() throws {guard SystemLanguageModel.default.isAvailable else {@@ -265,7 +283,7 @@ public class AppleLLMModule: Module {case .rateLimited(_):promise.reject("APPLE_LLM_RATE_LIMITED", modelError.localizedDescription)case .unsupportedLanguageOrLocale(_):- promise.reject("APPLE_LLM_UNAVAILABLE", modelError.localizedDescription)+ promise.reject("APPLE_LLM_UNSUPPORTED_LANGUAGE", modelError.localizedDescription)default:promise.reject("APPLE_LLM_FAILED", modelError.localizedDescription)}@@ -295,8 +313,10 @@ public class AppleLLMModule: Module {promise.reject("APPLE_LLM_OUTPUT_LIMIT", generationError.localizedDescription)case .rateLimited(_), .concurrentRequests(_):promise.reject("APPLE_LLM_RATE_LIMITED", generationError.localizedDescription)- case .assetsUnavailable(_), .unsupportedLanguageOrLocale(_):+ case .assetsUnavailable(_):promise.reject("APPLE_LLM_UNAVAILABLE", generationError.localizedDescription)+ case .unsupportedLanguageOrLocale(_):+ promise.reject("APPLE_LLM_UNSUPPORTED_LANGUAGE", generationError.localizedDescription)default:promise.reject("APPLE_LLM_FAILED", generationError.localizedDescription)}diff --git a/openwhispr-mobile/modules/apple-llm/src/index.types.ts b/openwhispr-mobile/modules/apple-llm/src/index.types.tsindex 88f16b75c..8a6ddf00e 100644--- a/openwhispr-mobile/modules/apple-llm/src/index.types.ts+++ b/openwhispr-mobile/modules/apple-llm/src/index.types.ts@@ -10,6 +10,11 @@ export interface AppleLLMAvailability {status: AppleLLMAvailabilityStatus;contextSize?: number;tokenCounting?: boolean;+ // Whether Apple Intelligence supports the iPhone's language, and that language's English name.+ // Missing from binaries built before they shipped, and localeSupported also while the model+ // lists no languages.+ localeSupported?: boolean;+ deviceLanguage?: string;}export interface AppleLLMTokenCountRequest {diff --git a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swiftindex 005e19611..09f3f3d25 100644--- a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift+++ b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift@@ -3064,11 +3064,12 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDelet provider = KeyboardHandoffProvider.sharedguard provider.isAgentEnabled() else { return }- // Not applicable ⇒ Private mode is on. Point at it, swallow the tap.+ // Not applicable ⇒ the voice assistant can't run: it needs an account or its own provider key.+ // Point at it, swallow the tap.guard provider.isAgentApplicable() else {playKeyClick()showTransientRecordState(- title: "Off in Local Mode",+ title: "Sign in to use",systemImage: "lock.fill",background: Palette.issue,duration: 1.6@@ -4195,8 +4196,9 @@ private struct KeyboardHandoffProvider {UserDefaults(suiteName: appGroupId)?.string(forKey: agentEnabledKey) == "1"}- /// Applicable = usable in the current mode (Cloud on). Not applicable ⇒ the- /// entry button is dimmed and points the user at the app, mirroring tone.+ /// Applicable = the voice assistant can run: an account for Cloud, or its own+ /// provider. Not applicable ⇒ the entry button is dimmed and points the user at+ /// the app, mirroring tone.func isAgentApplicable() -> Bool {UserDefaults(suiteName: appGroupId)?.string(forKey: agentApplicableKey) == "1"}diff --git a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.tsindex cfd74f9b8..69f623a38 100644--- a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts@@ -2,6 +2,7 @@ import {cleanupRunsOnDevice,cloudCleanupNeedsAccount,unsetSelection,+ voiceAssistantCanRun,workflowSelection,workflowSummary,} from '@/lib/aiWorkflows';@@ -233,9 +234,9 @@ describe('workflowSelection in Local Mode for a Cloud hold', () => {});});- it('formats notes on this phone and keeps note chat on Cloud', () => {+ it('keeps note formatting and note chat on Cloud', () => {expect(workflowSelection(heldOnCloud('notes'), 'notes', 'private', 'account')).toEqual({- mode: 'local',+ mode: 'openwhispr',});expect(workflowSelection(heldOnCloud('noteChat'), 'noteChat', 'private', 'none')).toEqual({mode: 'openwhispr',@@ -266,8 +267,62 @@ describe('workflowSummary for switched-off workflows', () => {const saved = config({ defaultMode: 'cloud', dictationAgentEnabled: false });expect(workflowSummary(saved, 'noteChat', 'cloud')).toBe('OpenWhispr Cloud');});+});++// Local Mode keeps dictation on this iPhone; note formatting and the voice assistant run their own+// choices there.+describe('workflowSummary in Local Mode', () => {+ it('shows note formatting and the voice assistant on Cloud with nothing saved', () => {+ expect(workflowSummary(config({}), 'notes', 'private', { cloudAccess: 'account' })).toBe(+ 'OpenWhispr Cloud',+ );+ expect(workflowSummary(config({}), 'agent', 'private', { cloudAccess: 'account' })).toBe(+ 'OpenWhispr Cloud',+ );+ });++ it('shows the providers saved for them', () => {+ const groq = { mode: 'providers' as const, providerId: 'groq', modelId: 'llama' };+ const saved = config({ inference: { notes: groq, agent: groq } });+ expect(workflowSummary(saved, 'notes', 'private')).toBe('Groq');+ expect(workflowSummary(saved, 'agent', 'private')).toBe('Groq');+ });++ it('shows On-Device note formatting saved for it', () => {+ const saved = config({ inference: { notes: { mode: 'local' } } });+ expect(workflowSummary(saved, 'notes', 'private')).toBe('On-Device');+ });+});++describe('voiceAssistantCanRun', () => {+ const groq = { mode: 'providers' as const, providerId: 'groq', modelId: 'llama' };++ it.each(['cloud', 'private'] as const)(+ 'runs on OpenWhispr Cloud in %s mode for a signed-in account only',+ (mode) => {+ expect(voiceAssistantCanRun(config({}), mode, 'account')).toBe(true);+ expect(voiceAssistantCanRun(config({}), mode, 'session')).toBe(false);+ expect(voiceAssistantCanRun(config({}), mode, 'none')).toBe(false);+ },+ );++ it.each(['cloud', 'private', 'providers'] as const)(+ 'runs on its own provider in %s mode, signed out too',+ (mode) => {+ expect(voiceAssistantCanRun(config({ inference: { agent: groq } }), mode, 'none')).toBe(true);+ },+ );++ it('is skipped under Bring Your Own Key with nothing saved', () => {+ expect(voiceAssistantCanRun(config({}), 'providers', 'account')).toBe(false);+ });- it('says the Voice Assistant is Off in Local Mode, which turns it off', () => {- expect(workflowSummary(config({}), 'agent', 'private')).toBe('Off');+ it('never runs switched off or on the iPhone', () => {+ expect(voiceAssistantCanRun(config({ dictationAgentEnabled: false }), 'cloud', 'account')).toBe(+ false,+ );+ expect(+ voiceAssistantCanRun(config({ inference: { agent: { mode: 'local' } } }), 'cloud', 'account'),+ ).toBe(false);});});diff --git a/openwhispr-mobile/src/lib/__tests__/cleanupTranscript.onDevice.test.ts b/openwhispr-mobile/src/lib/__tests__/cleanupTranscript.onDevice.test.tsindex 08ddfdabf..fe6d9f1ea 100644--- a/openwhispr-mobile/src/lib/__tests__/cleanupTranscript.onDevice.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/cleanupTranscript.onDevice.test.ts@@ -128,6 +128,11 @@ describe('a long transcript', () => {it.each([['APPLE_LLM_RATE_LIMITED', 'Apple Intelligence was busy.'],+ [+ 'APPLE_LLM_UNSUPPORTED_LANGUAGE',+ "Apple Intelligence doesn't support this language. If it's your iPhone's, choose another in Settings → General → Language & Region.",+ ],+ ['APPLE_LLM_UNAVAILABLE', 'Cleanup failed.'],['APPLE_LLM_CONTEXT_LIMIT', 'This transcript is too long for On-Device cleanup.'],['APPLE_LLM_GUARDRAIL', 'Cleanup failed.'],['APPLE_LLM_FAILED', 'Cleanup failed.'],diff --git a/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts b/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.tsindex f68672243..0d874ed3f 100644--- a/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/dictationAgent.test.ts@@ -1,8 +1,4 @@-import {- getDictationAgentName,- isDictationAgentApplicable,- isNoteChatEnabled,-} from '@/lib/dictationAgent';+import { getDictationAgentName, isNoteChatEnabled } from '@/lib/dictationAgent';import type { UserConfig } from '@/types';const baseConfig: UserConfig = { defaultMode: 'cloud' };@@ -25,36 +21,6 @@ describe('getDictationAgentName', () => {});});-describe('isDictationAgentApplicable', () => {- it('returns true when cloud mode and agent enabled', () => {- expect(- isDictationAgentApplicable('cloud', { ...baseConfig, dictationAgentEnabled: true }),- ).toBe(true);- });-- it('returns false when cloud mode but agent disabled', () => {- expect(- isDictationAgentApplicable('cloud', { ...baseConfig, dictationAgentEnabled: false }),- ).toBe(false);- });-- it('returns true when cloud mode and agent not set (default on)', () => {- expect(isDictationAgentApplicable('cloud', baseConfig)).toBe(true);- });-- it('returns false when cloud mode but agent explicitly disabled', () => {- expect(- isDictationAgentApplicable('cloud', { ...baseConfig, dictationAgentEnabled: false }),- ).toBe(false);- });-- it('returns false when private mode even if agent enabled', () => {- expect(- isDictationAgentApplicable('private', { ...baseConfig, dictationAgentEnabled: true }),- ).toBe(false);- });-});-// Note chat's switch is its own; configs from before it was are saved apart at launch.describe('note chat', () => {it('is on by default', () => {@@ -66,7 +32,3 @@ describe('note chat', () => {expect(isNoteChatEnabled({ ...baseConfig, noteChatEnabled: false })).toBe(false);});});--it('supports Providers mode', () => {- expect(isDictationAgentApplicable('providers', { defaultMode: 'providers' })).toBe(true);-});diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.tsindex 2be53d785..111761aba 100644--- a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts@@ -128,7 +128,7 @@ describe('workflowSaveConfig', () => {inference: { dictation: { mode: 'openwhispr' }, ...allSaved },pinnedInference: ['upload', 'agent'],};- const next = workflowSaveConfig(config, 'dictation', dictation, from, 'account', true);+ const next = workflowSaveConfig(config, 'dictation', dictation, from, 'account');expect(next.defaultMode).toBe(to);expect(next.inference).toEqual({ ...allSaved, dictation });expect(next.pinnedInference).toEqual(['upload', 'agent']);@@ -170,18 +170,19 @@ describe('workflowSaveConfig', () => {describe('leaving Local Mode', () => {it.each(['cloud', 'providers'] as const)(- 'holds what ran on this phone without a session when going to %s',+ 'holds what ran in Local Mode without a session when going to %s',(to) => {const dictation = to === 'cloud' ? { mode: 'openwhispr' as const } : groqDictation;- const next = workflowSaveConfig(local, 'dictation', dictation, 'private', 'none', true);+ const next = workflowSaveConfig(local, 'dictation', dictation, 'private', 'none');expect(next.inference).toEqual({dictation,upload: { mode: 'local' },cleanup: { mode: 'local' },- notes: { mode: 'local' },+ notes: { mode: 'openwhispr' },noteChat: { mode: 'local' },+ agent: { mode: 'openwhispr' },});- expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat']);+ expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat', 'agent']);},);@@ -204,10 +205,11 @@ describe('workflowSaveConfig', () => {},);- // Saved On-Device notes never fall back to Cloud; Local Mode asked before using it instead.- it('holds notes on Cloud when Apple Intelligence cannot run them', () => {+ // Local Mode ran note formatting and the voice assistant on their own choices: Cloud unset.+ it('holds note formatting and the voice assistant on Cloud', () => {const next = workflowSaveConfig(local, 'dictation', { mode: 'openwhispr' }, 'private');expect(next.inference?.notes).toEqual({ mode: 'openwhispr' });+ expect(next.inference?.agent).toEqual({ mode: 'openwhispr' });});it('holds the on-device model picked for a workflow', () => {@@ -270,7 +272,9 @@ describe('workflowSaveConfig', () => {expect(next.rememberedInference?.cleanup?.openai).toEqual(openai);});- it('keeps the voice assistant skipped through a round trip in Local Mode', () => {+ // Bring Your Own Key skipped the voice assistant, so nothing was held for it; Local Mode then ran+ // it on Cloud, which leaving Local Mode holds.+ it('holds what Local Mode ran after a round trip from Bring Your Own Key', () => {const providers: UserConfig = {defaultMode: 'providers',inference: { dictation: groqDictation },@@ -288,6 +292,7 @@ describe('workflowSaveConfig', () => {cleanup: { mode: 'local' },notes: { mode: 'openwhispr' },noteChat: { mode: 'openwhispr' },+ agent: { mode: 'openwhispr' },});});@@ -307,30 +312,24 @@ describe('workflowSaveConfig', () => {...workflowSaveConfig(on, 'dictation', groqDictation, 'private', 'account'),};expect(off.inference?.cleanup).toEqual({ mode: 'openwhispr' });- expect(off.inference).not.toHaveProperty('agent');+ expect(off.inference?.agent).toEqual({ mode: 'openwhispr' });});- // Setup in Local Mode holds only uploads and cleanup; the voice assistant is off there, so a- // later switch to Bring Your Own Key leaves it skipped rather than sending it to Cloud.- it('leaves the voice assistant unsaved when Local setup is followed by Bring Your Own Key', () => {+ // Setup in Local Mode holds only uploads and cleanup; a later switch to Bring Your Own Key holds+ // the rest where Local Mode ran them.+ it('holds what Local setup ran when it is followed by Bring Your Own Key', () => {const setup = dictationModeConfig({ defaultMode: 'cloud' }, 'private');const localSetup: UserConfig = { ...setup, ...holdOnDeviceConfig(setup) };- const next = workflowSaveConfig(- localSetup,- 'dictation',- groqDictation,- 'private',- 'session',- true,- );+ const next = workflowSaveConfig(localSetup, 'dictation', groqDictation, 'private', 'session');expect(next.inference).toEqual({dictation: groqDictation,upload: { mode: 'local' },cleanup: { mode: 'local' },- notes: { mode: 'local' },+ notes: { mode: 'openwhispr' },noteChat: { mode: 'local' },+ agent: { mode: 'openwhispr' },});- expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat']);+ expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat', 'agent']);});// Cloud cleanup held for an anonymous session can't run in Local Mode, which cleans on this@@ -521,7 +520,6 @@ it('holds note chat on this iPhone when dictation leaves Local Mode for Bring Yo'private',);expect(next.inference?.noteChat).toEqual({ mode: 'local' });- // Local Mode turns the voice assistant off, so there is nothing to hold for it.- expect(next.inference?.agent).toBeUndefined();+ expect(next.inference?.agent).toEqual({ mode: 'openwhispr' });expect(next.pinnedInference).toContain('noteChat');});diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.tsindex 3d351f580..b29f02ef3 100644--- a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts@@ -225,7 +225,8 @@ const OPENAI_TEXT = {credentialRef: 'provider.openai',};-// Local Mode keeps dictation on this phone; cleanup runs what is saved for it.+// Local Mode keeps dictation on this phone; cleanup runs what is saved for it, and so does the voice+// assistant, which has no on-device version.it.each([['a provider', OPENAI_TEXT, { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' }],['OpenWhispr Cloud', { mode: 'openwhispr' }, { mode: 'openwhispr' }],@@ -237,7 +238,21 @@ it.each([const snapshot = snapshotTranscriptionJob('dictation', KEYBOARD_TEXT_SCOPES);expect(snapshot.provider).toBe('local');expect(snapshot.cleanupRoute).toMatchObject({ ...route, scope: 'cleanup' });- expect(snapshot.agentRoute).toEqual({ mode: 'local', scope: 'agent' });+ expect(snapshot.agentRoute).toMatchObject({+ mode: 'providers',+ providerId: 'openai',+ modelId: 'gpt-5-mini',+ scope: 'agent',+ });+});++it('runs a Local Mode voice assistant with nothing saved on OpenWhispr Cloud', () => {+ mockProcessing.activeMode = 'private';+ mockUser = { id: 'u', isAnonymous: false };+ mockState.config.inference = { dictation: { mode: 'local' } };+ const snapshot = snapshotTranscriptionJob('dictation', KEYBOARD_TEXT_SCOPES);+ expect(snapshot.provider).toBe('local');+ expect(snapshot.agentRoute).toEqual({ mode: 'openwhispr', scope: 'agent' });});// With nothing saved, Local Mode cleans on OpenWhispr Cloud only for a signed-in account.diff --git a/openwhispr-mobile/src/lib/__tests__/keyboardAgentSync.test.ts b/openwhispr-mobile/src/lib/__tests__/keyboardAgentSync.test.tsindex 482079345..b78108dba 100644--- a/openwhispr-mobile/src/lib/__tests__/keyboardAgentSync.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/keyboardAgentSync.test.ts@@ -64,9 +64,22 @@ jest.mock('@/lib/uuid', () => ({randomUUID: jest.fn(() => 'test-uuid-1234'),}));+jest.mock('@/store/useAuthStore', () => {+ const { create } = jest.requireActual('zustand');+ return { useAuthStore: create(() => ({ user: null })) };+});++const { useAuthStore: mockAuthStore } = jest.requireMock('@/store/useAuthStore') as {+ useAuthStore: {+ setState: (state: { user: { id: string; isAnonymous: boolean } | null }) => void;+ };+};+const ACCOUNT = { id: 'u', isAnonymous: false };+beforeEach(() => {for (const key of Object.keys(store)) delete store[key];jest.clearAllMocks();+ mockAuthStore.setState({ user: ACCOUNT });});// ─── Mirror keys ───────────────────────────────────────────────────────────────@@ -105,14 +118,34 @@ describe('startKeyboardAgentSync mirror keys', () => {stop();});- it('writes applicable=0 in private mode even when agent enabled', () => {+ // The voice assistant runs its own selection in every mode, Local Mode included.+ it('writes applicable=1 in Local Mode for a signed-in account', () => {useConfigStore.setState({- config: { defaultMode: 'cloud', dictationAgentEnabled: true } as any,+ config: { defaultMode: 'private', dictationAgentEnabled: true } as any,});useProcessingModeStore.setState({ activeMode: 'private' });+ const stop = startKeyboardAgentSync();+ expect(store.keyboard_agent_applicable).toBe('1');+ stop();+ });++ // Cloud refuses the voice assistant without an account; its own provider needs none.+ it('writes applicable=0 without an account unless the voice assistant has a provider', () => {+ mockAuthStore.setState({ user: { id: 'a', isAnonymous: true } });+ useConfigStore.setState({ config: { defaultMode: 'private' } as any });+ useProcessingModeStore.setState({ activeMode: 'private' });+const stop = startKeyboardAgentSync();expect(store.keyboard_agent_applicable).toBe('0');++ useConfigStore.setState({+ config: {+ defaultMode: 'private',+ inference: { agent: { mode: 'providers', providerId: 'groq', modelId: 'llama' } },+ } as any,+ });+ expect(store.keyboard_agent_applicable).toBe('1');stop();});@@ -171,7 +204,8 @@ describe('startKeyboardAgentSync mirror keys', () => {stop();});- it('updates applicable when mode changes', () => {+ it('updates applicable when the user signs in', () => {+ mockAuthStore.setState({ user: null });useConfigStore.setState({config: { defaultMode: 'cloud', dictationAgentEnabled: true } as any,});@@ -180,6 +214,20 @@ describe('startKeyboardAgentSync mirror keys', () => {const stop = startKeyboardAgentSync();expect(store.keyboard_agent_applicable).toBe('0');+ mockAuthStore.setState({ user: ACCOUNT });+ expect(store.keyboard_agent_applicable).toBe('1');+ stop();+ });++ it('updates applicable when the mode changes', () => {+ useConfigStore.setState({+ config: { defaultMode: 'cloud', dictationAgentEnabled: true } as any,+ });+ useProcessingModeStore.setState({ activeMode: 'providers' });++ const stop = startKeyboardAgentSync();+ expect(store.keyboard_agent_applicable).toBe('0');+useProcessingModeStore.getState().setActiveMode('cloud', true);expect(store.keyboard_agent_applicable).toBe('1');stop();diff --git a/openwhispr-mobile/src/lib/__tests__/keyboardInferenceRoute.test.ts b/openwhispr-mobile/src/lib/__tests__/keyboardInferenceRoute.test.tsindex d5174ba83..092c354fc 100644--- a/openwhispr-mobile/src/lib/__tests__/keyboardInferenceRoute.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/keyboardInferenceRoute.test.ts@@ -224,3 +224,15 @@ it('recovers a BYOK keyboard job with no text route as unavailable, never Cloud''The voice assistant is unavailable. Your raw transcript is saved.',);});++// The voice assistant has no on-device version, so a stored on-device job with no text route gives+// it OpenWhispr Cloud while cleanup stays on this iPhone.+it('recovers an on-device keyboard job with no text route, sending only cleanup to the iPhone', () => {+ mockStorage.set(+ 'keyboard_inference_route',+ JSON.stringify({ version: 1, jobId: 'local-job', route: { provider: 'local' } }),+ );+ const route = readKeyboardInferenceRoute('local-job');+ expect(route?.cleanupRoute).toEqual({ mode: 'local', scope: 'cleanup' });+ expect(route?.agentRoute).toEqual({ mode: 'openwhispr', scope: 'agent' });+});diff --git a/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts b/openwhispr-mobile/src/lib/__tests__/localReasoning.test.tsindex a63b9ade8..0e57950a8 100644--- a/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts@@ -59,11 +59,12 @@ describe('local reasoning readiness policy', () => {expect(mockAppleAvailability).not.toHaveBeenCalled();});- it('uses local reasoning in private mode when Apple Intelligence is ready', async () => {+ // Note formatting follows its own selection in Local Mode; a note made there is private.+ it('does not require local reasoning for a shared note in Local Mode', async () => {mockProcessingState.activeMode = 'private';- await expect(shouldUseLocalReasoning({ isPrivateNote: false })).resolves.toBe(true);- expect(mockAppleAvailability).toHaveBeenCalledTimes(1);+ await expect(shouldUseLocalReasoning({ isPrivateNote: false })).resolves.toBe(false);+ await expect(shouldUseLocalReasoning({ isPrivateNote: true })).resolves.toBe(true);});it('uses local reasoning for signed-out content when ready', async () => {@@ -125,18 +126,23 @@ it.each([},);-it.each(['ready', 'disabled', 'appleIntelligenceOff', 'modelNotReady', 'unavailable'] as const)(- 'does not treat %s as an unsupported iPhone, since it can change',- (status) => {- expect(isLocalReasoningUnsupported({ status, tokenCounting: false })).toBe(false);- },-);+it.each([+ 'ready',+ 'disabled',+ 'appleIntelligenceOff',+ 'modelNotReady',+ 'unavailable',+ 'unsupportedLanguage',+] as const)('does not treat %s as an unsupported iPhone, since it can change', (status) => {+ expect(isLocalReasoningUnsupported({ status, tokenCounting: false })).toBe(false);+});// Off in iOS Settings or still preparing its model, the iPhone still runs Apple Intelligence.it.each([['ready', true],['appleIntelligenceOff', true],['modelNotReady', true],+ ['unsupportedLanguage', true],['disabled', false],['unavailable', false],['unsupportedDevice', false],@@ -155,7 +161,118 @@ it.each([expect(getLocalReasoningUnavailableMessage({ status, tokenCounting: false })).toBe(message);});+// iOS reports Apple Intelligence as off when the language keeps it off, so the language explains it.+describe("an iPhone set to a language Apple Intelligence doesn't support", () => {+ it.each(['appleIntelligenceNotEnabled', 'unavailable'])(+ 'names the language when availability is %s',+ async (native) => {+ mockAppleAvailability.mockResolvedValue({+ status: native,+ tokenCounting: false,+ localeSupported: false,+ deviceLanguage: 'Polish (Poland)',+ });++ const readiness = await getLocalReasoningReadiness();++ expect(readiness).toEqual({+ status: 'unsupportedLanguage',+ deviceLanguage: 'Polish (Poland)',+ tokenCounting: false,+ });+ expect(getLocalReasoningUnavailableMessage(readiness)).toBe(+ "Apple Intelligence doesn't support Polish (Poland), your iPhone's language. Choose a supported one in Settings → General → Language & Region.",+ );+ },+ );++ // An ineligible iPhone can't be fixed in Settings, and a download means Apple Intelligence is on.+ it.each([+ ['deviceNotEligible', 'unsupportedDevice'],+ ['modelNotReady', 'modelNotReady'],+ ])('keeps the reason iOS gave for %s', async (native, status) => {+ mockAppleAvailability.mockResolvedValue({+ status: native,+ tokenCounting: false,+ localeSupported: false,+ deviceLanguage: 'Polish (Poland)',+ });++ await expect(getLocalReasoningReadiness()).resolves.toEqual(+ expect.objectContaining({ status }),+ );+ });++ it('never stops Apple Intelligence that iOS says is available', async () => {+ mockAppleAvailability.mockResolvedValue({+ status: 'available',+ contextSize: 4096,+ tokenCounting: true,+ localeSupported: false,+ deviceLanguage: 'English (South Africa)',+ });++ await expect(getLocalReasoningReadiness()).resolves.toMatchObject({ status: 'ready' });+ });++ // Binaries built before the check shipped send no language fields, and the model lists no+ // languages while it is off, so localeSupported is left out then.+ it.each([+ { status: 'appleIntelligenceNotEnabled', tokenCounting: false },+ {+ status: 'appleIntelligenceNotEnabled',+ tokenCounting: false,+ deviceLanguage: 'English (United States)',+ },+ ])('keeps the reason iOS gave when the language is not known to be wrong', async (payload) => {+ mockAppleAvailability.mockResolvedValue(payload);++ await expect(getLocalReasoningReadiness()).resolves.toMatchObject({+ status: 'appleIntelligenceOff',+ });+ });++ it("says the iPhone's language without a name", () => {+ expect(+ getLocalReasoningUnavailableMessage({ status: 'unsupportedLanguage', tokenCounting: false }),+ ).toBe(+ "Apple Intelligence doesn't support your iPhone's language. Choose a supported one in Settings → General → Language & Region.",+ );+ });+});++// The app can't read Siri's language, so the off message says what a Siri-only Settings page means.+it("says Apple Intelligence also needs Siri set to the iPhone's language", async () => {+ mockAppleAvailability.mockResolvedValue({+ status: 'appleIntelligenceNotEnabled',+ tokenCounting: false,+ localeSupported: true,+ deviceLanguage: 'English (South Africa)',+ });++ const readiness = await getLocalReasoningReadiness();++ expect(readiness).toMatchObject({ status: 'appleIntelligenceOff' });+ expect(getLocalReasoningUnavailableMessage(readiness)).toBe(+ "Apple Intelligence is turned off, so this can't run on-device. Turn it on in Settings → Apple Intelligence & Siri. If that page shows only Siri, set Siri to the same language as your iPhone.",+ );+});+describe('toLocalReasoningError', () => {+ it('explains an unsupported language rather than passing on the native text', () => {+ const error = toLocalReasoningError(+ Object.assign(new Error('UnsupportedLanguageOrLocale'), {+ code: 'APPLE_LLM_UNSUPPORTED_LANGUAGE',+ }),+ );+ expect(error).toMatchObject({+ code: 'APPLE_LLM_UNSUPPORTED_LANGUAGE',+ message:+ "Apple Intelligence doesn't support this language. If it's your iPhone's, choose another in Settings → General → Language & Region.",+ retryable: false,+ });+ });+it('reads an aborted request as cancelled', () => {const aborted = Object.assign(new Error('cancelled'), { name: 'AbortError' });expect(toLocalReasoningError(aborted)).toMatchObject({diff --git a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.tsindex 9114e82f8..e6c30182d 100644--- a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts@@ -232,7 +232,7 @@ it('keeps an On-Device transcript raw when cleanup is turned off', async () => {it.each([['appleIntelligenceOff',- "Apple Intelligence is turned off, so this can't run on-device. Turn it on in Settings → Apple Intelligence & Siri.",+ "Apple Intelligence is turned off, so this can't run on-device. Turn it on in Settings → Apple Intelligence & Siri. If that page shows only Siri, set Siri to the same language as your iPhone.",],['disabled', 'Local Apple Intelligence is turned off in AI Models.'],[diff --git a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.tsindex 2fd90dcd5..c1f87e605 100644--- a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts@@ -152,6 +152,17 @@ it.each(['appleIntelligenceOff', 'modelNotReady'])(},);+// Changing the iPhone's language restarts the app, so the page sends the user back instead.+it('asks to come back once the language is changed rather than waiting', async () => {+ mockLocalReasoningReadiness.mockResolvedValue({ status: 'unsupportedLanguage' });+ await expect(switchWorkflowMode('cleanup', 'local')).resolves.toBe('refused');+ expect(alert).toHaveBeenCalledWith(+ 'On-Device Unavailable',+ 'Apple Intelligence is turned off. Then come back and choose On-Device again.',+ );+ expect(mockUpdateConfig).not.toHaveBeenCalled();+});+// Nothing in iOS Settings makes these ready, so the page must not wait for them.it.each(['unsupportedDevice', 'disabled', 'unavailable'])('refuses a text workflow on-device when Apple Intelligence is %s',@@ -234,9 +245,9 @@ describe('switching dictation', () => {expect(mockUpdateConfig).toHaveBeenCalledWith(LOCAL_FROM_CLOUD);});- // Only dictation moves: note formatting stays on this phone, where Local Mode ran it, and with an- // account, uploads and cleanup stay on Cloud, where Local Mode ran them. Note chat, which Local- // Mode asked about before sending it to Cloud, stays on this phone.+ // Only dictation moves: with an account, uploads and cleanup stay on Cloud, where Local Mode ran+ // them, and so do note formatting and the voice assistant, which ran their own choices there.+ // Note chat, which Local Mode asked about before sending it to Cloud, stays on this phone.it('to OpenWhispr Cloud turns Local Mode off and leaves the other workflows where they ran', async () => {mockActiveMode = 'private';mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };@@ -248,52 +259,22 @@ describe('switching dictation', () => {dictation: { mode: 'openwhispr' },upload: { mode: 'openwhispr' },cleanup: { mode: 'openwhispr' },- notes: { mode: 'local' },+ notes: { mode: 'openwhispr' },noteChat: { mode: 'local' },+ agent: { mode: 'openwhispr' },},- pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat', 'agent'],});});- // Saved On-Device notes never fall back to Cloud, so without Apple Intelligence they stay on- // Cloud, which Local Mode asked before using.- it('to OpenWhispr Cloud holds notes on Cloud when Apple Intelligence cannot run them', async () => {- mockLocalReasoningReadiness.mockResolvedValue({ status: 'unavailable', tokenCounting: false });- mockActiveMode = 'private';- mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };- await expect(switchWorkflowMode('dictation', 'openwhispr')).resolves.toBe('switched');- expect(mockUpdateConfig.mock.calls[0][0].inference.notes).toEqual({ mode: 'openwhispr' });- });-- // The cached readiness outlives a change in iOS Settings, so leaving Local Mode asks again.- it('asks afresh whether Apple Intelligence can run only when leaving Local Mode', async () => {+ // Leaving Local Mode holds what ran there, which no longer depends on Apple Intelligence.+ it('does not check Apple Intelligence when dictation leaves Local Mode', async () => {mockActiveMode = 'private';mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };await switchWorkflowMode('dictation', 'openwhispr');- expect(mockLocalReasoningReadiness).toHaveBeenCalledWith({ refresh: true });-- mockLocalReasoningReadiness.mockClear();- mockActiveMode = 'cloud';- mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };- await switchWorkflowMode('dictation', 'local');expect(mockLocalReasoningReadiness).not.toHaveBeenCalled();});- // The readiness check is awaited before the config is read, so a save made meanwhile is kept.- it('builds the saved config from the config as it is after the readiness check', async () => {- mockActiveMode = 'private';- mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };- mockLocalReasoningReadiness.mockImplementation(async () => {- mockConfig = {- defaultMode: 'private',- inference: { dictation: { mode: 'local' }, agent: { mode: 'openwhispr' } },- };- return { status: 'ready', tokenCounting: false };- });- await switchWorkflowMode('dictation', 'openwhispr');- expect(mockUpdateConfig.mock.calls[0][0].inference.agent).toEqual({ mode: 'openwhispr' });- });-// Without an account Local Mode cleaned on this phone, while a session uploaded to Cloud.it('to OpenWhispr Cloud holds cleanup on this phone for an anonymous session', async () => {mockUser = { id: 'a', isAnonymous: true };@@ -306,10 +287,11 @@ describe('switching dictation', () => {dictation: { mode: 'openwhispr' },upload: { mode: 'openwhispr' },cleanup: { mode: 'local' },- notes: { mode: 'local' },+ notes: { mode: 'openwhispr' },noteChat: { mode: 'local' },+ agent: { mode: 'openwhispr' },},- pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat', 'agent'],});});@@ -332,3 +314,67 @@ describe('switching dictation', () => {expect(mockUpdateConfig.mock.calls[0][0].inference.cleanup).toEqual(cleanup);});});++// On-Device dictation moves only dictation, so turning it on offers to move note formatting too.+describe('offering On-Device note formatting', () => {+ const OFFER = 'Format notes on this iPhone too?';+ const flush = (): Promise<void> => new Promise((resolve) => setImmediate(resolve));++ function offer(): { onPress?: () => void }[] | undefined {+ return alert.mock.calls.find(([title]) => title === OFFER)?.[2];+ }++ it('offers it when dictation turns Local Mode on and Apple Intelligence is ready', async () => {+ await switchWorkflowMode('dictation', 'local');+ await flush();+ expect(alert).toHaveBeenCalledWith(+ OFFER,+ 'Dictation now stays on this iPhone. Note formatting and titles still use OpenWhispr Cloud.',+ expect.any(Array),+ );++ offer()?.[1].onPress?.();+ await flush();+ expect(mockUpdateConfig).toHaveBeenLastCalledWith(+ expect.objectContaining({+ inference: expect.objectContaining({ notes: { mode: 'local' } }),+ }),+ );+ });++ it('leaves note formatting alone on Not Now', async () => {+ await switchWorkflowMode('dictation', 'local');+ await flush();+ offer()?.[0].onPress?.();+ await flush();+ expect(mockUpdateConfig).toHaveBeenCalledTimes(1);+ });++ it('does not offer it when Apple Intelligence is not ready', async () => {+ mockLocalReasoningReadiness.mockResolvedValue({+ status: 'modelNotReady',+ tokenCounting: false,+ });+ await switchWorkflowMode('dictation', 'local');+ await flush();+ expect(offer()).toBeUndefined();+ });++ it('does not offer it when note formatting is already On-Device', async () => {+ mockConfig = {+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' }, notes: { mode: 'local' } },+ };+ await switchWorkflowMode('dictation', 'local');+ await flush();+ expect(offer()).toBeUndefined();+ });++ it('does not offer it for another workflow or when leaving Local Mode', async () => {+ await switchWorkflowMode('upload', 'local');+ mockActiveMode = 'private';+ await switchWorkflowMode('dictation', 'openwhispr');+ await flush();+ expect(offer()).toBeUndefined();+ });+});diff --git a/openwhispr-mobile/src/lib/aiWorkflows.ts b/openwhispr-mobile/src/lib/aiWorkflows.tsindex 01d835130..b424ec7bc 100644--- a/openwhispr-mobile/src/lib/aiWorkflows.ts+++ b/openwhispr-mobile/src/lib/aiWorkflows.ts@@ -27,22 +27,18 @@ export const UNSET_PROVIDER_NOTES: Partial<Record<MobileInferenceScope, string>>export const ON_DEVICE_CLEANUP_UNSUPPORTED_NOTE ="This iPhone can't run On-Device cleanup, so it's skipped. OpenWhispr Cloud can clean up your transcripts.";-// Dictation owns Local Mode: On-Device dictation turns it on, and the other modes turn it off.+// Dictation owns Local Mode: On-Device dictation turns it on, and the other modes turn it off. Note+// formatting and the voice assistant keep their own choices; notes made in Local Mode are private.export const LOCAL_MODE_DICTATION_NOTES = {- on: 'Local Mode is on: dictation stays on this iPhone and notes ask before leaving it. Choose OpenWhispr Cloud or Bring Your Own Key to turn it off.',- off: 'On-Device turns on Local Mode: dictation stays on this iPhone and notes ask before leaving it.',+ on: 'Local Mode is on: dictation stays on this iPhone, notes you make stay private, and note chat asks before leaving it. Choose OpenWhispr Cloud or Bring Your Own Key to turn it off.',+ off: 'On-Device turns on Local Mode: dictation stays on this iPhone, notes you make stay private, and note chat asks before leaving it.',};-// What Local Mode means for note formatting, note chat and the voice assistant.+// What Local Mode means for note chat.export const ON_DEVICE_MODE_NOTES: Partial<Record<MobileInferenceScope, string>> = {- notes: 'Local Mode formats notes on this iPhone and asks before sending one to your choice here.',noteChat: 'In Local Mode note chat asks before sending a note off this iPhone.',- agent: 'In Local Mode the voice assistant is off.',};-export const PRIVATE_MODE_LOCKED_REASON =- 'Off while Local Mode is on. Change Dictation in AI Models to turn it off.';-// Outside Cloud dictation, cleaning with OpenWhispr Cloud is a separate Cloud pass, which needs a// signed-in account.export const CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE =@@ -110,14 +106,28 @@ export function workflowSwitchedOff(return false;}+// The voice assistant runs on its own selection in every mode. It can run on a provider, or on+// OpenWhispr Cloud for a signed-in account, which an anonymous session can't use for it; it has no+// on-device version, and unset under Bring Your Own Key it is skipped.+export function voiceAssistantCanRun(+ config: UserConfig | null,+ activeMode: ProcessingMode,+ cloudAccess: CloudAccess,+): boolean {+ if (!config || workflowSwitchedOff(config, 'agent')) return false;+ const selection = workflowSelection(config, 'agent', activeMode, cloudAccess);+ if (selection.mode === 'providers') return !!selection.providerId;+ return selection.mode === 'openwhispr' && cloudAccess === 'account';+}+export function parseWorkflow(value: unknown): MobileInferenceScope | null {return WORKFLOWS.find((scope) => scope === value) ?? null;}-// What a workflow with no saved selection runs. Local Mode keeps dictation and note formatting on-// this iPhone, and uses OpenWhispr Cloud for uploads and cleanup when the account can, else this-// iPhone. Note chat uses OpenWhispr Cloud when unset in every mode, and Bring Your Own Key-// dictation waits for a provider before cleanup or the agent.+// What a workflow with no saved selection runs. Local Mode keeps dictation on this iPhone, and uses+// OpenWhispr Cloud for uploads and cleanup when the account can, else this iPhone. Note formatting,+// note chat and the voice assistant use OpenWhispr Cloud when unset in Cloud and Local Mode, and+// Bring Your Own Key dictation waits for a provider before cleanup or the voice assistant.export function unsetSelection(scope: MobileInferenceScope,activeMode: ProcessingMode,@@ -145,22 +155,20 @@ export function workflowSummary(} = {},): string {if (workflowSwitchedOff(config, scope)) return 'Off';- // Local Mode turns the voice assistant off.- if (activeMode === 'private' && scope === 'agent') return 'Off';if (scope === 'cleanup') {if (cleanupRunsOnDevice(config, activeMode, cloudAccess) && onDeviceUnavailable)return `Skipped · ${onDeviceUnavailable}`;if (cloudCleanupNeedsAccount(config, activeMode, cloudAccess)) return 'Skipped · Sign in';}const selection = workflowSelection(config, scope, activeMode, cloudAccess);- // Local Mode runs dictation, note formatting and provider note chat on this phone first, whatever- // is saved; note chat set to OpenWhispr, or not set, goes straight to Cloud. Uploads and cleanup- // run what is saved for them.+ // Local Mode runs dictation and provider note chat on this phone first, whatever is saved; note+ // chat set to OpenWhispr, or not set, goes straight to Cloud. The other workflows run what is+ // saved for them.if (activeMode === 'private' && scope === 'noteChat' && selection.mode === 'openwhispr')return MODE_LABELS.openwhispr;if (selection.mode === 'local' && isLocalModelKey(selection.modelId))return LOCAL_MODEL_TITLES[selection.modelId];- if (activeMode === 'private' && scope !== 'upload' && scope !== 'cleanup')+ if (activeMode === 'private' && (scope === 'dictation' || scope === 'noteChat'))return MODE_LABELS.local;if (selection.mode !== 'providers') return MODE_LABELS[selection.mode];if (!selection.providerId) return 'Not set';diff --git a/openwhispr-mobile/src/lib/cleanupTranscript.ts b/openwhispr-mobile/src/lib/cleanupTranscript.tsindex b609b1f93..df8ab43b7 100644--- a/openwhispr-mobile/src/lib/cleanupTranscript.ts+++ b/openwhispr-mobile/src/lib/cleanupTranscript.ts@@ -15,6 +15,7 @@ import {getLocalReasoningReadiness,getLocalReasoningUnavailableMessage,LocalReasoningError,+ UNSUPPORTED_LANGUAGE_MESSAGE,} from './localReasoning';import { withRetry, createApiRetryStrategy } from './retry';@@ -81,6 +82,7 @@ function cleanupFailureReason(error: unknown): string {if (error instanceof LocalReasoningError) {if (error.code === 'APPLE_LLM_CANCELLED') return 'Apple Intelligence took too long.';if (error.code === 'APPLE_LLM_RATE_LIMITED') return 'Apple Intelligence was busy.';+ if (error.code === 'APPLE_LLM_UNSUPPORTED_LANGUAGE') return UNSUPPORTED_LANGUAGE_MESSAGE;if (error.code === 'LOCAL_CONTEXT_LIMIT' || error.code === 'APPLE_LLM_CONTEXT_LIMIT') {return TOO_LONG_FOR_ON_DEVICE;}diff --git a/openwhispr-mobile/src/lib/dictationAgent.ts b/openwhispr-mobile/src/lib/dictationAgent.tsindex df8400bf5..432194c2e 100644--- a/openwhispr-mobile/src/lib/dictationAgent.ts+++ b/openwhispr-mobile/src/lib/dictationAgent.ts@@ -1,4 +1,4 @@-import type { ProcessingMode, UserConfig } from '@/types';+import type { UserConfig } from '@/types';const DEFAULT_AGENT_NAME = 'OpenWhispr';@@ -11,12 +11,6 @@ export function isDictationAgentEnabled(config: UserConfig): boolean {return config.dictationAgentEnabled ?? true;}-// The voice assistant is the keyboard's compose wand, which has no on-device version yet, so Local-// Mode keeps it off.-export function isDictationAgentApplicable(mode: ProcessingMode, config: UserConfig): boolean {- return (mode === 'cloud' || mode === 'providers') && isDictationAgentEnabled(config);-}-// Configs from before Note Chat had a switch of its own get it saved at launch (noteChatSplitConfig).export function isNoteChatEnabled(config: UserConfig): boolean {return config.noteChatEnabled ?? true;diff --git a/openwhispr-mobile/src/lib/inferenceModes.ts b/openwhispr-mobile/src/lib/inferenceModes.tsindex 8ea44f1ff..07e7ae794 100644--- a/openwhispr-mobile/src/lib/inferenceModes.ts+++ b/openwhispr-mobile/src/lib/inferenceModes.ts@@ -65,13 +65,15 @@ export const MODE_LABELS: Record<InferenceMode, string> = {// needs a signed-in account.export type CloudAccess = 'none' | 'session' | 'account';-// What Local Mode runs for a workflow with nothing saved: OpenWhispr Cloud for note chat, and for-// uploads and cleanup when the account can use it there; this iPhone otherwise.+// What Local Mode runs for a workflow with nothing saved: this iPhone for dictation; OpenWhispr+// Cloud for note formatting, note chat and the voice assistant, as in Cloud mode, and for uploads+// and cleanup when the account can use it there; this iPhone otherwise.export function localModeDefault(scope: MobileInferenceScope,cloudAccess: CloudAccess,): InferenceMode {const onCloud =+ scope === 'notes' ||scope === 'agent' ||scope === 'noteChat' ||(scope === 'upload' && cloudAccess !== 'none') ||@@ -95,24 +97,18 @@ export function localSelection(// What a workflow with nothing saved runs in `mode`, or undefined when there is nothing to hold:// cleanup and the voice assistant are skipped under Bring Your Own Key until a provider is saved-// for them, and Local Mode turns the voice assistant off. Note formatting saved as On-Device never-// falls back to Cloud, so Local Mode's is held on this iPhone only while Apple Intelligence can run-// it; otherwise Local Mode asks before using Cloud. Local Mode also asks before note chat leaves the-// phone, which no other mode does, so note chat is held On-Device rather than sent to Cloud unasked.+// for them. Local Mode asks before note chat leaves the phone, which no other mode does, so note+// chat is held On-Device rather than sent to Cloud unasked.function unsavedRunsIn(config: Pick<UserConfig, 'rememberedInference'> | null,scope: OtherWorkflow,mode: ProcessingMode,cloudAccess: CloudAccess,- localReasoningReady: boolean,): InferenceSelection | undefined {if (mode === 'providers' && (scope === 'cleanup' || scope === 'agent')) return undefined;- if (mode === 'private' && scope === 'agent') return undefined;const onDevice =mode === 'private' &&- (scope === 'noteChat' ||- (localModeDefault(scope, cloudAccess) === 'local' &&- (scope !== 'notes' || localReasoningReady)));+ (scope === 'noteChat' || localModeDefault(scope, cloudAccess) === 'local');return onDevice ? localSelection(config, scope) : { mode: 'openwhispr' };}@@ -148,14 +144,13 @@ function dictationSwitchConfig(mode: ProcessingMode,leavingMode: ProcessingMode,cloudAccess: CloudAccess,- localReasoningReady: boolean,): DictationModeConfig {const inference = { ...config?.inference, dictation };if (mode === leavingMode) return { defaultMode: mode, inference };const pinnedInference = [...(config?.pinnedInference ?? [])];for (const scope of OTHER_WORKFLOWS) {if (inference[scope]) continue;- const selection = unsavedRunsIn(config, scope, leavingMode, cloudAccess, localReasoningReady);+ const selection = unsavedRunsIn(config, scope, leavingMode, cloudAccess);if (!selection) continue;inference[scope] = selection;if (!pinnedInference.includes(scope)) pinnedInference.push(scope);@@ -168,15 +163,13 @@ function dictationSwitchConfig(}// The config a workflow page writes when the user saves `selection` for `scope`. `cloudAccess` is-// what the user has on OpenWhispr Cloud, and `localReasoningReady` whether Apple Intelligence can-// run here; together they decide what an unsaved workflow ran in Local Mode.+// what the user has on OpenWhispr Cloud, which decides what an unsaved workflow ran in Local Mode.export function workflowSaveConfig(config: UserConfig | null,scope: MobileInferenceScope,selection: InferenceSelection,activeMode: ProcessingMode,cloudAccess: CloudAccess = 'none',- localReasoningReady = false,): Partial<UserConfig> {const { providerId } = selection;const otherProviders = Object.fromEntries(@@ -202,14 +195,7 @@ export function workflowSaveConfig(: { mode: 'openwhispr' as const };return {...rememberedInference,- ...dictationSwitchConfig(- config,- dictation,- mode,- activeMode,- cloudAccess,- localReasoningReady,- ),+ ...dictationSwitchConfig(config, dictation, mode, activeMode, cloudAccess),};}return {@@ -267,3 +253,19 @@ export function noteChatSplitConfig(config: UserConfig): Partial<UserConfig> {: {}),};}++// Local Mode once formatted notes on this iPhone whatever was saved for them. A config from then+// that is in Local Mode, with nothing of the user's own saved for note formatting, holds it+// On-Device, so the update sends no note to Cloud that wasn't sent before.+export function notesLocalModeSplitConfig(config: UserConfig): Partial<UserConfig> {+ const saved = config.inference?.notes;+ const ownChoice = !!saved && !config.pinnedInference?.includes('notes');+ if (config.defaultMode !== 'private' || ownChoice) return { notesLocalModeSplit: true };+ return {+ notesLocalModeSplit: true,+ inference: { ...config.inference, notes: localSelection(config, 'notes') },+ pinnedInference: saved+ ? (config.pinnedInference ?? [])+ : [...(config.pinnedInference ?? []), 'notes'],+ };+}diff --git a/openwhispr-mobile/src/lib/inferenceRouting.ts b/openwhispr-mobile/src/lib/inferenceRouting.tsindex 54b4b00dc..9c42e746e 100644--- a/openwhispr-mobile/src/lib/inferenceRouting.ts+++ b/openwhispr-mobile/src/lib/inferenceRouting.ts@@ -130,11 +130,11 @@ export function snapshotTextInference(? unsetSelection('cleanup', activeMode, cloudAccess): selection;const cleanupMode = localCleanup?.mode ?? 'local';+ // The voice assistant runs its own selection, wherever the spoken instruction was transcribed.if (provider === 'local' &&- (scope === 'agent' ||- cleanupMode === 'local' ||- (cleanupMode === 'openwhispr' && cloudAccess !== 'account'))+ scope === 'cleanup' &&+ (cleanupMode === 'local' || (cleanupMode === 'openwhispr' && cloudAccess !== 'account'))) {result[routeKey] = { mode: 'local', scope };} else if (!selection && provider === 'byok') {diff --git a/openwhispr-mobile/src/lib/keyboardAgentSync.ts b/openwhispr-mobile/src/lib/keyboardAgentSync.tsindex c0763f88a..1997383a6 100644--- a/openwhispr-mobile/src/lib/keyboardAgentSync.ts+++ b/openwhispr-mobile/src/lib/keyboardAgentSync.ts@@ -1,11 +1,8 @@import { AppState } from 'react-native';import type { KeyboardTone } from '@/types';import { DEFAULT_KEYBOARD_TONE } from '@/lib/keyboardTone';-import {- getDictationAgentName,- isDictationAgentApplicable,- isDictationAgentEnabled,-} from '@/lib/dictationAgent';+import { cloudAccessFor, voiceAssistantCanRun } from '@/lib/aiWorkflows';+import { getDictationAgentName, isDictationAgentEnabled } from '@/lib/dictationAgent';import { useConfigStore } from '@/store/useConfigStore';import { useProcessingModeStore } from '@/store/useProcessingModeStore';import { randomUUID } from '@/lib/uuid';@@ -61,12 +58,22 @@ export interface KeyboardAgentResult extends KeyboardAgentResultInput {updatedAtMs: number;}+// Required lazily: the auth store imports the composer, which imports this module.+function authStore(): (typeof import('@/store/useAuthStore'))['useAuthStore'] {+ return (require('@/store/useAuthStore') as typeof import('@/store/useAuthStore')).useAuthStore;+}+function writeAgentMirrorKeys(): void {const config = useConfigStore.getState().config;const mode = useProcessingModeStore.getState().activeMode;const enabled = isDictationAgentEnabled(config ?? { defaultMode: 'cloud' });- const applicable = isDictationAgentApplicable(mode, config ?? { defaultMode: 'cloud' });+ // The keyboard dims the wand where it can't run, in any mode.+ const applicable = voiceAssistantCanRun(+ config,+ mode,+ cloudAccessFor(authStore().getState().user),+ );const name = getDictationAgentName(config ?? { defaultMode: 'cloud' });const shareContext = config?.dictationAgentShareContext ?? false;@@ -81,6 +88,7 @@ export function startKeyboardAgentSync(): () => void {const unsubConfig = useConfigStore.subscribe(writeAgentMirrorKeys);const unsubMode = useProcessingModeStore.subscribe(writeAgentMirrorKeys);+ const unsubAuth = authStore().subscribe(writeAgentMirrorKeys);const appStateSub = AppState.addEventListener('change', (state) => {if (state === 'active') {writeAgentMirrorKeys();@@ -90,6 +98,7 @@ export function startKeyboardAgentSync(): () => void {return () => {unsubConfig();unsubMode();+ unsubAuth();appStateSub.remove();};}diff --git a/openwhispr-mobile/src/lib/keyboardInferenceRoute.ts b/openwhispr-mobile/src/lib/keyboardInferenceRoute.tsindex c694d3743..34d3a3650 100644--- a/openwhispr-mobile/src/lib/keyboardInferenceRoute.ts+++ b/openwhispr-mobile/src/lib/keyboardInferenceRoute.ts@@ -92,7 +92,12 @@ function readRoute(jobId: string, storageKey: string): TranscriptionJobRoute | uif (route.provider === 'byok')route[unavailable] =`${scope === 'cleanup' ? 'Cleanup' : 'The voice assistant'} is unavailable. Your raw transcript is saved.`;- else route[field] = { mode: route.provider === 'local' ? 'local' : 'openwhispr', scope };+ // The voice assistant has no on-device version, so only cleanup defaults to this iPhone.+ else+ route[field] = {+ mode: route.provider === 'local' && scope === 'cleanup' ? 'local' : 'openwhispr',+ scope,+ };}}return route;diff --git a/openwhispr-mobile/src/lib/localReasoning.ts b/openwhispr-mobile/src/lib/localReasoning.tsindex c37a2d844..0c3ab97bf 100644--- a/openwhispr-mobile/src/lib/localReasoning.ts+++ b/openwhispr-mobile/src/lib/localReasoning.ts@@ -1,11 +1,10 @@-import { AppleLLM } from '@/lib/appleLLM';+import { AppleLLM, type AppleLLMAvailability } from '@/lib/appleLLM';import type {LocalReasoningErrorCode,LocalReasoningReadiness,ReasoningRoutingOptions,UserConfig,} from '@/types';-import type { ProcessingMode } from '@/types';export const LOCAL_CONTEXT_FALLBACK_SIZE = 4096;export const LOCAL_OUTPUT_TOKEN_RESERVE = 900;@@ -19,6 +18,11 @@ export const LOCAL_TOKEN_CHAR_RATIO = 3.5;// adds.export const LOCAL_CLEANUP_MAX_TRANSCRIPT_TOKENS = Math.floor(LOCAL_OUTPUT_TOKEN_RESERVE * 0.8);+const LANGUAGE_SETTINGS = 'Settings → General → Language & Region';++// A generation refused for its language: the text's, which can be in any language, or the iPhone's.+export const UNSUPPORTED_LANGUAGE_MESSAGE = `Apple Intelligence doesn't support this language. If it's your iPhone's, choose another in ${LANGUAGE_SETTINGS}.`;+let cachedReadiness: Promise<LocalReasoningReadiness> | null = null;export class LocalReasoningError extends Error {@@ -56,6 +60,8 @@ export async function getLocalReasoningReadiness(options?: {cachedReadiness = (async () => {try {const availability = await AppleLLM.getAvailability();+ const languageReadiness = languageReadinessFor(availability);+ if (languageReadiness) return languageReadiness;switch (availability.status) {case 'available':return {@@ -94,9 +100,29 @@ export async function getLocalReasoningReadiness(options?: {return cachedReadiness;}+// iOS has no availability reason for a language Apple Intelligence doesn't support; it reports+// Apple Intelligence as off. So the language explains only that. A model still downloading means+// Apple Intelligence is on, an ineligible iPhone stays one, and Apple Intelligence that runs is+// never stopped.+function languageReadinessFor(availability: AppleLLMAvailability): LocalReasoningReadiness | null {+ if (+ availability.status !== 'appleIntelligenceNotEnabled' &&+ availability.status !== 'unavailable'+ ) {+ return null;+ }+ if (availability.localeSupported !== false) return null;+ return {+ status: 'unsupportedLanguage',+ deviceLanguage: availability.deviceLanguage,+ tokenCounting: false,+ };+}++// A private note, or no account to reach Cloud with, keeps note formatting on this iPhone. Local+// Mode doesn't: note formatting follows its own selection, and notes made there are private.export function isLocalReasoningRequired(options: ReasoningRoutingOptions = {}): boolean {if (options.isPrivateNote) return true;- if (getActiveMode() === 'private') return true;return !getAuthUser();}@@ -104,16 +130,6 @@ export function isAppleLocalIntelligenceEnabled(config = getUserConfig()): boolereturn config?.appleLocalIntelligenceEnabled ?? true;}-function getActiveMode(): ProcessingMode {- try {- const { useProcessingModeStore } =- require('@/store/useProcessingModeStore') as typeof import('@/store/useProcessingModeStore');- return useProcessingModeStore.getState().activeMode;- } catch {- return 'cloud';- }-}-// Lazy require to break a module cycle (localReasoning ← useNotesStore ← … ←// useAuthStore). If the store can't be resolved, treat the caller as// signed-out — the privacy-safe default, since routing still gates on Apple@@ -197,13 +213,15 @@ export async function fitsLocalCleanupOutput(text: string): Promise<boolean> {return tokens <= LOCAL_CLEANUP_MAX_TRANSCRIPT_TOKENS;}-// This iPhone runs Apple Intelligence, even if it is turned off in Settings or still preparing-// its model. Disabled in AI Models or unavailable says nothing about the device either way.+// This iPhone runs Apple Intelligence, even if it is turned off in Settings, still preparing its+// model, or kept off by its language. Disabled in AI Models or unavailable says nothing about the+// device either way.export function canRunLocalReasoning(readiness?: LocalReasoningReadiness | null): boolean {return (readiness?.status === 'ready' ||readiness?.status === 'appleIntelligenceOff' ||- readiness?.status === 'modelNotReady'+ readiness?.status === 'modelNotReady' ||+ readiness?.status === 'unsupportedLanguage');}@@ -212,6 +230,13 @@ export function isLocalReasoningUnsupported(readiness?: LocalReasoningReadinessreturn readiness?.status === 'unsupportedDevice' || readiness?.status === 'unsupportedOS';}+// What keeps Apple Intelligence off when the language does, in one sentence.+export function getLocalReasoningLanguageNote(readiness: LocalReasoningReadiness): string {+ return readiness.deviceLanguage+ ? `Apple Intelligence doesn't support ${readiness.deviceLanguage}, your iPhone's language.`+ : "Apple Intelligence doesn't support your iPhone's language.";+}+export function getLocalReasoningUnavailableMessage(readiness?: LocalReasoningReadiness): string {switch (readiness?.status) {case 'unsupportedDevice':@@ -220,10 +245,14 @@ export function getLocalReasoningUnavailableMessage(readiness?: LocalReasoningRereturn 'On-Device AI needs iOS 26 or later on an iPhone with Apple Intelligence.';case 'disabled':return 'Local Apple Intelligence is turned off in AI Models.';+ // Apple Intelligence also needs Siri set to the iPhone's language, and iOS then offers only a+ // Siri page; the app can't read Siri's language to tell.case 'appleIntelligenceOff':- return "Apple Intelligence is turned off, so this can't run on-device. Turn it on in Settings → Apple Intelligence & Siri.";+ return "Apple Intelligence is turned off, so this can't run on-device. Turn it on in Settings → Apple Intelligence & Siri. If that page shows only Siri, set Siri to the same language as your iPhone.";case 'modelNotReady':return 'Apple Intelligence is still downloading its model. Check Settings → Apple Intelligence & Siri, and keep your iPhone on Wi-Fi and charging.';+ case 'unsupportedLanguage':+ return `${getLocalReasoningLanguageNote(readiness)} Choose a supported one in ${LANGUAGE_SETTINGS}.`;case 'unavailable':default:return 'Local Apple Intelligence is unavailable on this device.';@@ -242,6 +271,8 @@ export function toLocalReasoningError(error: unknown): LocalReasoningError {}switch (code) {+ case 'APPLE_LLM_UNSUPPORTED_LANGUAGE':+ return new LocalReasoningError(code, UNSUPPORTED_LANGUAGE_MESSAGE);case 'APPLE_LLM_GUARDRAIL':case 'APPLE_LLM_CONTEXT_LIMIT':case 'APPLE_LLM_OUTPUT_LIMIT':diff --git a/openwhispr-mobile/src/lib/workflowModeSwitch.ts b/openwhispr-mobile/src/lib/workflowModeSwitch.tsindex fa966b353..793d064ab 100644--- a/openwhispr-mobile/src/lib/workflowModeSwitch.ts+++ b/openwhispr-mobile/src/lib/workflowModeSwitch.ts@@ -8,7 +8,7 @@ import {requiresRealAccount,showAccountRequiredAlert,} from '@/lib/accountAccess';-import { cloudAccessFor } from '@/lib/aiWorkflows';+import { cloudAccessFor, workflowSelection, workflowSummary } from '@/lib/aiWorkflows';import { localSelection, workflowSaveConfig } from '@/lib/inferenceModes';import {canRunLocalReasoning,@@ -17,7 +17,6 @@ import {} from '@/lib/localReasoning';import type { LocalModelKey } from '@/lib/localModelCatalog';import { type InferenceSelection, type MobileInferenceScope } from '@/lib/mobileProviders';-import type { InferenceMode, ProcessingMode } from '@/types';import { getPrivateModeReadiness, getPrivateModeUnavailableMessage } from '@/lib/privateMode';type SpeechScope = 'dictation' | 'upload';@@ -57,6 +56,11 @@ async function appleIntelligenceReady(): Promise<ModeSwitchResult | null> {Alert.alert('On-Device Unavailable', message);return 'refused';}+ // Changing the iPhone's language restarts every app, so this page can't wait for it.+ if (readiness.status === 'unsupportedLanguage') {+ Alert.alert('On-Device Unavailable', `${message} Then come back and choose On-Device again.`);+ return 'refused';+ }Alert.alert('On-Device Unavailable',`${message} Keep this page open and On-Device turns on once Apple Intelligence is ready.`,@@ -64,16 +68,27 @@ async function appleIntelligenceReady(): Promise<ModeSwitchResult | null> {return 'not-ready';}-// Whether Apple Intelligence can run here, which decides where note formatting with nothing saved-// is held when dictation leaves Local Mode (workflowSaveConfig). Asked only then, and afresh, since-// the cached answer outlives a change in iOS Settings.-export async function leavingLocalModeWithLocalReasoning(- scope: MobileInferenceScope,- activeMode: ProcessingMode,- target: InferenceMode,-): Promise<boolean> {- if (scope !== 'dictation' || activeMode !== 'private' || target === 'local') return false;- return (await getLocalReasoningReadiness({ refresh: true })).status === 'ready';+// On-Device dictation keeps only dictation on this iPhone, so turning it on offers to move note+// formatting here too, while Apple Intelligence can run it.+async function offerOnDeviceNoteFormatting(): Promise<void> {+ const { config } = useConfigStore.getState();+ const cloudAccess = cloudAccessFor(useAuthStore.getState().user);+ if (workflowSelection(config, 'notes', 'private', cloudAccess).mode === 'local') return;+ if ((await getLocalReasoningReadiness()).status !== 'ready') return;+ const current = workflowSummary(config, 'notes', 'private', { cloudAccess });+ Alert.alert(+ 'Format notes on this iPhone too?',+ `Dictation now stays on this iPhone. Note formatting and titles still use ${current}.`,+ [+ { text: 'Not Now', style: 'cancel' },+ {+ text: 'Use On-Device',+ onPress: (): void => {+ switchWorkflowMode('notes', 'local').catch(() => undefined);+ },+ },+ ],+ );}// Applies OpenWhispr Cloud or On-Device to a workflow as soon as it is tapped, after its sign-in@@ -104,22 +119,16 @@ export async function switchWorkflowMode(if (blocked) return blocked;}- const { activeMode, setActiveMode } = useProcessingModeStore.getState();- const localReasoningReady = await leavingLocalModeWithLocalReasoning(scope, activeMode, mode);const { config, updateConfig } = useConfigStore.getState();+ const { activeMode, setActiveMode } = useProcessingModeStore.getState();if (scope === 'dictation') setActiveMode(mode === 'local' ? 'private' : 'cloud', true);const selection: InferenceSelection =mode === 'local' ? localSelection(config, scope) : { mode: 'openwhispr' };await updateConfig(- workflowSaveConfig(- config,- scope,- selection,- activeMode,- cloudAccessFor(user),- localReasoningReady,- ),+ workflowSaveConfig(config, scope, selection, activeMode, cloudAccessFor(user)),);+ if (scope === 'dictation' && mode === 'local' && activeMode !== 'private')+ offerOnDeviceNoteFormatting().catch(() => undefined);return 'switched';}diff --git a/openwhispr-mobile/src/screens/AIModelsScreen.tsx b/openwhispr-mobile/src/screens/AIModelsScreen.tsxindex 7af862c46..e69906a18 100644--- a/openwhispr-mobile/src/screens/AIModelsScreen.tsx+++ b/openwhispr-mobile/src/screens/AIModelsScreen.tsx@@ -43,6 +43,8 @@ function localReasoningStatusLabel(readiness: LocalReasoningReadiness | null): sreturn 'Apple Intelligence off';case 'modelNotReady':return 'Downloading model';+ case 'unsupportedLanguage':+ return 'Language not supported';case 'unavailable':return 'Not eligible';case 'unsupportedDevice':diff --git a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx b/openwhispr-mobile/src/screens/DictationAgentScreen.tsxindex 3cd375209..aabec2938 100644--- a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx+++ b/openwhispr-mobile/src/screens/DictationAgentScreen.tsx@@ -8,7 +8,6 @@ import { useConfigStore } from '@/store/useConfigStore';import { useConfigToggle } from '@/hooks/useConfigToggle';import { useProcessingModeStore } from '@/store/useProcessingModeStore';import { getDictationAgentName, isDictationAgentEnabled } 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,11 +22,9 @@ export function DictationAgentScreen(): React.JSX.Element {const agentSelected = !!config?.inference?.agent;// Bring Your Own Key skips the assistant until it has a selection of its own.const unavailableNotice =- activeMode === 'private'- ? `${PRIVATE_MODE_LOCKED_REASON} Your settings are saved and apply once Local Mode is off.`- : activeMode === 'providers' && !agentSelected- ? 'Bring Your Own Key skips the voice assistant until you choose a provider for it in AI Models. Your settings are saved and apply once you do.'- : null;+ activeMode === 'providers' && !agentSelected+ ? 'Bring Your Own Key skips the voice assistant until you choose a provider for it in AI Models. Your settings are saved and apply once you do.'+ : null;const isAvailable = !unavailableNotice;const enabled = config ? isDictationAgentEnabled(config) : true;const shareContext = config?.dictationAgentShareContext ?? false;@@ -61,8 +58,8 @@ export function DictationAgentScreen(): React.JSX.Element {<Text className="text-[13px] text-secondaryLabel">Tap the wand on the OpenWhispr keyboard and say what to write, like a reply or a rewriteof the selected text. Your assistant drafts it for you to insert, regenerate or change.- Saying its name while dictating gives no command. Requires Cloud or Bring Your Own Key- mode.+ Saying its name while dictating gives no command. It runs on the AI chosen for the Voice+ Assistant in AI Models, whatever Dictation uses.</Text></View>diff --git a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx b/openwhispr-mobile/src/screens/NoteEditorScreen.tsxindex e4a8aeab7..079121172 100644--- a/openwhispr-mobile/src/screens/NoteEditorScreen.tsx+++ b/openwhispr-mobile/src/screens/NoteEditorScreen.tsx@@ -480,7 +480,11 @@ export default function NoteEditorScreen() {}),[contentIsTranscript, hasEnhancedTab, transcriptPending, usesSegmentTranscript],);- const requiresCloudConfirmation = note?.isPrivate === 1 || activeMode === 'private';+ // A private note asks before any AI leaves this iPhone. Local Mode asks too for note chat; note+ // formatting follows its own selection there.+ const formattingRequiresCloudConfirmation = note?.isPrivate === 1;+ const chatRequiresCloudConfirmation =+ formattingRequiresCloudConfirmation || activeMode === 'private';const handleKeepMine = useCallback(() => {safeHaptics('selection');@@ -858,7 +862,7 @@ export default function NoteEditorScreen() {}const localRequired = providerNotes- ? requiresCloudConfirmation+ ? formattingRequiresCloudConfirmation: isLocalReasoningRequired(routing);if (localRequired) {@@ -899,7 +903,7 @@ export default function NoteEditorScreen() {}).catch(() => {});};- if (requiresCloudConfirmation) {+ if (formattingRequiresCloudConfirmation) {confirmCloudOnce(`${action.name} sends this note to cloud AI for this request. Your note privacy and sync settings will not change.`,() => gateAndRun({ ...routing, allowCloudFallback: true }),@@ -915,7 +919,7 @@ export default function NoteEditorScreen() {notesProviderId,providerNotes,registerSuperwallGate,- requiresCloudConfirmation,+ formattingRequiresCloudConfirmation,runSelectedAction,user,],@@ -1043,7 +1047,7 @@ export default function NoteEditorScreen() {}).catch(() => {});};- if (requiresCloudConfirmation && chatMode !== 'local') {+ if (chatRequiresCloudConfirmation && chatMode !== 'local') {confirmCloudOnce('Chat sends this note context to your selected AI service for this request. Your note privacy and sync settings will not change.',() => gateAndRun(true),@@ -1053,7 +1057,14 @@ export default function NoteEditorScreen() {gateAndRun();},- [chatMode, cloudChat, registerSuperwallGate, requiresCloudConfirmation, startChatRequest, user],+ [+ chatMode,+ chatRequiresCloudConfirmation,+ cloudChat,+ registerSuperwallGate,+ startChatRequest,+ user,+ ],);const handleAskNote = useCallback(() => {diff --git a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsxindex 9b3be26af..fb188cffb 100644--- a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx+++ b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx@@ -44,7 +44,6 @@ import {CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE,LOCAL_MODE_DICTATION_NOTES,ON_DEVICE_MODE_NOTES,- PRIVATE_MODE_LOCKED_REASON,ON_DEVICE_CLEANUP_UNSUPPORTED_NOTE,UNSET_PROVIDER_NOTES,WORKFLOW_LABELS,@@ -59,13 +58,10 @@ import { isLocalModelKey } from '@/lib/localModelCatalog';import { getDictationAgentName } from '@/lib/dictationAgent';import { safeHaptics } from '@/lib/utils';import { SystemIcon, type LucideIconName } from '@/components/ui/SystemIcon';-import {- leavingLocalModeWithLocalReasoning,- type ModeSwitchResult,- switchWorkflowMode,-} from '@/lib/workflowModeSwitch';+import { type ModeSwitchResult, switchWorkflowMode } from '@/lib/workflowModeSwitch';import { getPrivateModeReadiness } from '@/lib/privateMode';import {+ getLocalReasoningLanguageNote,getLocalReasoningReadiness,getLocalReasoningUnavailableMessage,isLocalReasoningUnsupported,@@ -118,7 +114,7 @@ function joinNames(names: string[]): string {}// A workflow that can be turned off: its switch sits above Mode, with the workflow's own-// settings row under it while it is on. A disabled switch shows why in its description.+// settings row under it while it is on.function WorkflowSwitchCard({title,label,@@ -126,7 +122,6 @@ function WorkflowSwitchCard({icon,mdIcon,enabled,- disabled = false,onToggle,offNote,children,@@ -137,7 +132,6 @@ function WorkflowSwitchCard({icon: string;mdIcon: LucideIconName;enabled: boolean;- disabled?: boolean;onToggle: (value: boolean) => void;offNote: string;children?: React.ReactNode;@@ -151,20 +145,14 @@ function WorkflowSwitchCard({mdIcon={mdIcon}title={title}description={description}- disabled={disabled}rightElement={- <SettingsSwitch- accessibilityLabel={label}- value={enabled}- disabled={disabled}- onValueChange={onToggle}- />+ <SettingsSwitch accessibilityLabel={label} value={enabled} onValueChange={onToggle} />}showChevron={false}/>{enabled ? children : null}</SettingsSection>- {enabled || disabled ? null : <SectionFooter>{offNote}</SectionFooter>}+ {enabled ? null : <SectionFooter>{offNote}</SectionFooter>}</>);}@@ -213,26 +201,19 @@ function NoteChatSettings({ enabled }: { enabled: boolean }): React.JSX.Element);}-// Local Mode turns the voice assistant off.function VoiceAssistantSettings({ enabled }: { enabled: boolean }): React.JSX.Element {const updateConfig = useConfigStore((state) => state.updateConfig);const agentName = useConfigStore((state) =>state.config ? getDictationAgentName(state.config) : undefined,);- const privateMode = useProcessingModeStore((state) => state.activeMode === 'private');return (<WorkflowSwitchCardtitle="Enable Voice Assistant"label="Voice Assistant"- description={- privateMode- ? PRIVATE_MODE_LOCKED_REASON- : 'Tap the wand on the OpenWhispr keyboard and say what to write.'- }+ description="Tap the wand on the OpenWhispr keyboard and say what to write."icon="person.wave.2"mdIcon="UserRoundCog"- enabled={enabled && !privateMode}- disabled={privateMode}+ enabled={enabled}onToggle={(value) => {safeHaptics('light');void updateConfig({ dictationAgentEnabled: value });@@ -369,7 +350,10 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXconst onDeviceUnsupported = isLocalReasoningUnsupported(appleIntelligence)? getLocalReasoningUnavailableMessage(appleIntelligence ?? undefined): null;- const onDeviceStatus = appleIntelligence && APPLE_INTELLIGENCE_STATUSES[appleIntelligence.status];+ const onDeviceStatus =+ appleIntelligence?.status === 'unsupportedLanguage'+ ? getLocalReasoningLanguageNote(appleIntelligence)+ : appleIntelligence && APPLE_INTELLIGENCE_STATUSES[appleIntelligence.status];// Nothing is shown as picked when the On-Device text workflow can never run on this iPhone.const pickedMode =!speechScope && onDeviceUnsupported && selection.mode === 'local' ? null : selection.mode;@@ -407,9 +391,9 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXconst keyOwner =provider?.id === 'custom' ? 'this server' : providerDisplayName(provider?.id ?? '');const workflowOff = workflowSwitchedOff(config, scope);- // A switched-off workflow uses no key, nor does the voice assistant in Local Mode.+ // A switched-off workflow uses no key.const usesKey = (workflow: MobileInferenceScope): boolean =>- !workflowSwitchedOff(config, workflow) && !(activeMode === 'private' && workflow === 'agent');+ !workflowSwitchedOff(config, workflow);const sharedWith = WORKFLOWS.filter((other) => {const saved = config?.inference?.[other];return (@@ -657,20 +641,8 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXtry {const saved = await prepareSelection();if (!saved) return;- const localReasoningReady = await leavingLocalModeWithLocalReasoning(- scope,- activeMode,- saved.mode,- );await updateConfig(- workflowSaveConfig(- useConfigStore.getState().config,- scope,- saved,- activeMode,- cloudAccess,- localReasoningReady,- ),+ workflowSaveConfig(useConfigStore.getState().config, scope, saved, activeMode, cloudAccess),);if (useConfigStore.getState().error) {showError('Unable to save your selection. Please try again.');diff --git a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsxindex b0f182d67..334d2173a 100644--- a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx@@ -146,8 +146,9 @@ it('shows what each workflow runs while Local Mode is on', async () => {// A picked model keeps its name; uploads and cleanup run what is saved for them.expect(screen.getByText('Whisper base')).toBeTruthy();expect(screen.getByText('OpenAI')).toBeTruthy();- // Cleanup and note chat, which is OpenWhispr Cloud when unset.- expect(screen.getAllByText('OpenWhispr Cloud')).toHaveLength(2);+ // Cleanup, plus note formatting, note chat and the voice assistant, which run their own choices+ // in Local Mode: OpenWhispr Cloud when unset.+ expect(screen.getAllByText('OpenWhispr Cloud')).toHaveLength(4);await screen.findByText(/Status: Ready/);});@@ -164,11 +165,11 @@ it('says a saved Cloud cleanup is skipped in Local Mode without an account', asy});// With nothing saved, Local Mode uploads to Cloud with any session and cleans there when signed in.-// Note chat is always one of the OpenWhispr Cloud rows.+// Note formatting, note chat and the voice assistant are always OpenWhispr Cloud rows.it.each([- ['no session', 1, null],- ['an anonymous session', 2, { id: 'a', isAnonymous: true }],- ['a signed-in account', 3, { id: 'u', isAnonymous: false }],+ ['no session', 3, null],+ ['an anonymous session', 4, { id: 'a', isAnonymous: true }],+ ['a signed-in account', 5, { id: 'u', isAnonymous: false }],])('with nothing saved in Local Mode for %s, shows %d Cloud rows', async (_label, count, user) => {mockUser = user;mockActiveMode = 'private';@@ -237,7 +238,6 @@ it('shows provider note chat as On-Device, which answers it on this iPhone first};render(<AIModelsScreen />);expect(screen.queryByText('Groq')).toBeNull();- expect(screen.queryByText('OpenWhispr Cloud')).toBeNull();await screen.findByText(/Status: Ready/);});@@ -272,6 +272,16 @@ it.each([expect(await screen.findByText(new RegExp(`Status: ${label}\\s`))).toBeTruthy();});+it('says when the iPhone is set to a language Apple Intelligence does not support', async () => {+ mockReadiness.mockResolvedValue({+ status: 'unsupportedLanguage',+ deviceLanguage: 'English (South Africa)',+ tokenCounting: false,+ });+ render(<AIModelsScreen />);+ expect(await screen.findByText(/Status: Language not supported\s/)).toBeTruthy();+});+// Dictation owns Local Mode, so AI Models has no switch of its own.it('has no Local Mode switch', async () => {render(<AIModelsScreen />);diff --git a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsxindex bbbc2451f..41a88d6e4 100644--- a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx@@ -43,19 +43,15 @@ 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);});-// Private mode turns the voice assistant off, so its switch must not read as on.-it('shows the voice assistant off in Local Mode and says where to turn it back on', () => {+// The voice assistant runs its own selection, so Local Mode leaves it on.+it('keeps the voice assistant on in Local Mode', () => {mockActiveMode = 'private';mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };render(<DictationAgentScreen />);- expect(- screen.getByText(- 'Off while Local Mode is on. Change Dictation in AI Models to turn it off. Your settings are saved and apply once Local Mode is off.',- ),- ).toBeTruthy();+ expect(screen.queryByText(/Local Mode/)).not.toBeOnTheScreen();const [enable] = screen.UNSAFE_getAllByType(Switch);- expect(enable.props.value).toBe(false);- expect(enable.props.disabled).toBe(true);+ expect(enable.props.value).toBe(true);+ expect(enable.props.disabled).toBe(false);});it('switches only the voice assistant, keeping note chat as it was', () => {diff --git a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsxindex 364eee6a8..a605751da 100644--- a/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/NoteEditorScreen.calendarContext.test.tsx@@ -605,6 +605,8 @@ describe('NoteEditorScreen generated meeting context', () => {it('offers enable local AI alongside cloud once when local intelligence is disabled', async () => {mockProcessingModeState.activeMode = 'private';+ mockNote = note({ isPrivate: 1 });+ mockNotesState.notes = [mockNote];mockConfigState.config.appleLocalIntelligenceEnabled = false;const alertSpy = jest.spyOn(Alert, 'alert').mockImplementation(() => undefined);@@ -963,6 +965,8 @@ describe('NoteEditorScreen On-Device and provider routes', () => {it('names the provider when it offers to send a private note there once', async () => {mockProcessingModeState.activeMode = 'private';+ mockNote = note({ isPrivate: 1 });+ mockNotesState.notes = [mockNote];mockAppleAvailability = 'deviceNotEligible';mockConfigState.config.inference = {notes: {@@ -987,6 +991,8 @@ describe('NoteEditorScreen On-Device and provider routes', () => {it('still offers to enable local AI when the fallback is a provider', async () => {mockProcessingModeState.activeMode = 'private';+ mockNote = note({ isPrivate: 1 });+ mockNotesState.notes = [mockNote];mockConfigState.config.appleLocalIntelligenceEnabled = false;mockConfigState.config.inference = {notes: {@@ -1005,6 +1011,26 @@ describe('NoteEditorScreen On-Device and provider routes', () => {expect(labels).toEqual(['Cancel', 'Enable Local AI', 'Use Groq Once']);});+ // Note formatting follows its own selection in Local Mode; only a private note stays here.+ it('sends a shared note to the provider saved for note formatting in Local Mode', async () => {+ mockProcessingModeState.activeMode = 'private';+ mockAppleAvailability = 'deviceNotEligible';+ mockConfigState.config.inference = {+ notes: {+ mode: 'providers',+ providerId: 'groq',+ modelId: 'llama',+ credentialRef: 'provider.groq',+ },+ };+ const { getByTestId } = render(<NoteEditorScreen />);+ await act(async () => {+ fireEvent.press(getByTestId('run-action-1'));+ });+ await waitFor(() => expect(ReasoningService.processText).toHaveBeenCalledTimes(1));+ expect(alertSpy).not.toHaveBeenCalled();+ });+it('lets a signed-out user chat with a note when chat is On-Device', async () => {mockAuthState.user = null;mockConfigState.config.inference = { noteChat: { mode: 'local' } };diff --git a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsxindex f9f0f2b30..242f023a6 100644--- a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx@@ -127,7 +127,7 @@ jest.mock('@/services/providers/ProviderCredentials', () => ({}));import { WorkflowSettingsScreen } from '../WorkflowSettingsScreen';-import { CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE, PRIVATE_MODE_LOCKED_REASON } from '@/lib/aiWorkflows';+import { CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE } from '@/lib/aiWorkflows';function chooseProvider(provider: string): void {fireEvent.press(screen.getByText('Provider'));@@ -520,9 +520,8 @@ it('says why a held Cloud cleanup is skipped under Bring Your Own Key without anexpect(screen.getByText(CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE)).toBeTruthy();});-// Local Mode formats notes on this phone first, so a Cloud hold shows what runs, as the AI Models-// row does.-it('shows note formatting held on Cloud as On-Device in Local Mode', () => {+// Note formatting runs its own selection in Local Mode, so a Cloud hold shows as Cloud.+it('shows note formatting held on Cloud as OpenWhispr Cloud in Local Mode', () => {mockConfig = {defaultMode: 'private',inference: { dictation: { mode: 'local' }, notes: { mode: 'openwhispr' } },@@ -531,7 +530,7 @@ it('shows note formatting held on Cloud as On-Device in Local Mode', () => {mockActiveMode = 'private';mockScope = 'notes';render(<WorkflowSettingsScreen />);- expect(selectedMode()).toBe('On-Device');+ expect(selectedMode()).toBe('OpenWhispr Cloud');});it('keeps On-Device cleanup selected once a private-mode user has saved it', () => {@@ -580,13 +579,13 @@ it('keeps uploads on Cloud when a user with a session leaves Local Mode for a prcleanup: { mode: 'local' },noteChat: { mode: 'local' },},- pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat', 'agent'],});});-// Local Mode formatted notes with Apple Intelligence. It turned the voice assistant off, so that-// stays unset and is skipped until a provider is saved for it.-it('keeps notes on this phone when dictation leaves Local Mode for a provider', async () => {+// Local Mode ran note formatting and the voice assistant on their own choices, Cloud when unset, and+// asked before sending note chat off the phone.+it('holds note formatting and the voice assistant on Cloud when dictation leaves Local Mode for a provider', async () => {mockLocalReasoningReady = true;mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';@@ -596,10 +595,13 @@ it('keeps notes on this phone when dictation leaves Local Mode for a provider',fireEvent.press(screen.getByText('Save'));await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({- inference: { notes: { mode: 'local' }, noteChat: { mode: 'local' } },- pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],+ inference: {+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'local' },+ agent: { mode: 'openwhispr' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat', 'agent'],});- expect(mockUpdateConfig.mock.calls[0][0].inference.agent).toBeUndefined();});it('switches dictation from Bring Your Own Key to Cloud on tap, without Save', async () => {@@ -996,14 +998,14 @@ describe('the Voice Assistant page', () => {expect(screen.getByText('The OpenWhispr keyboard shows no wand.')).toBeTruthy();});- it('shows the voice assistant off in Local Mode', () => {+ // The voice assistant runs its own selection, so Local Mode leaves it on.+ it('keeps the voice assistant on in Local Mode', () => {mockActiveMode = 'private';mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };render(<WorkflowSettingsScreen />);- 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();+ expect(screen.getByLabelText('Voice Assistant').props.value).toBe(true);+ expect(screen.getByLabelText('Voice Assistant').props.disabled).toBeFalsy();+ expect(screen.getByText('Voice Assistant Settings')).toBeTruthy();});});@@ -1026,17 +1028,15 @@ it('treats Note Chat as unused for keys once its switch is off', async () => {await waitFor(() => expect(mockCredentialStatus).toHaveBeenCalled());});-// Local Mode never runs the voice assistant on its saved provider.-it('treats the Voice Assistant as unused for keys in Local Mode', async () => {+// Local Mode runs the voice assistant on its saved provider too.+it('counts the Voice Assistant as using its key in Local Mode', async () => {mockCredentialStatus.mockResolvedValue({ isConfigured: true });mockActiveMode = 'private';mockScope = 'noteChat';const groq = { mode: 'providers', providerId: 'groq', modelId: 'openai/gpt-oss-20b' };mockConfig = { defaultMode: 'private', inference: { noteChat: groq, agent: groq } };render(<WorkflowSettingsScreen />);- expect(- screen.getByText('Stays on this iPhone. Every workflow set to Groq uses the same key.'),- ).toBeTruthy();+ expect(screen.getByText('Stays on this iPhone. Also used by Voice Assistant.')).toBeTruthy();await waitFor(() => expect(mockCredentialStatus).toHaveBeenCalled());});@@ -1132,19 +1132,23 @@ it.each([expect(selectedMode()).toBe(label);});-it.each([- ['agent', 'In Local Mode the voice assistant is off.'],- ['noteChat', 'In Local Mode note chat asks before sending a note off this iPhone.'],- [- 'notes',- 'Local Mode formats notes on this iPhone and asks before sending one to your choice here.',- ],-])('explains what Local Mode means for %s', (scope, note) => {+it('explains what Local Mode means for note chat', () => {+ mockConfig = { defaultMode: 'private' };+ mockActiveMode = 'private';+ mockScope = 'noteChat';+ render(<WorkflowSettingsScreen />);+ expect(+ screen.getByText('In Local Mode note chat asks before sending a note off this iPhone.'),+ ).toBeTruthy();+});++// Note formatting and the voice assistant run their own selections in Local Mode.+it.each(['notes', 'agent'])('says nothing about Local Mode on the %s page', (scope) => {mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';mockScope = scope;render(<WorkflowSettingsScreen />);- expect(screen.getByText(note)).toBeTruthy();+ expect(screen.queryByText(/Local Mode/)).not.toBeOnTheScreen();});it('shows On-Device for a guest whose saved Cloud dictation Local Mode overrides', () => {@@ -1190,16 +1194,6 @@ it.each([expect(screen.getByText(note)).toBeTruthy();});-it('turns the voice assistant off in Local Mode', () => {- mockConfig = { defaultMode: 'private' };- mockActiveMode = 'private';- mockScope = 'agent';- render(<WorkflowSettingsScreen />);- expect(- screen.getByText('Off while Local Mode is on. Change Dictation in AI Models to turn it off.'),- ).toBeTruthy();-});-it('turns Local Mode off when OpenWhispr Cloud is picked on the Dictation page', async () => {mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };mockActiveMode = 'private';@@ -1218,11 +1212,11 @@ it('locks no mode outside Local Mode', () => {it.each([['cloud',- 'On-Device turns on Local Mode: dictation stays on this iPhone and notes ask before leaving it.',+ 'On-Device turns on Local Mode: dictation stays on this iPhone, notes you make stay private, and note chat asks before leaving it.',],['private',- 'Local Mode is on: dictation stays on this iPhone and notes ask before leaving it. Choose OpenWhispr Cloud or Bring Your Own Key to turn it off.',+ 'Local Mode is on: dictation stays on this iPhone, notes you make stay private, and note chat asks before leaving it. Choose OpenWhispr Cloud or Bring Your Own Key to turn it off.',],])('explains Local Mode on the Dictation page in %s mode', (mode, note) => {mockConfig = { defaultMode: mode };@@ -1474,8 +1468,16 @@ describe('an iPhone that cannot run Apple Intelligence', () => {it.each([['appleIntelligenceOff', 'Apple Intelligence is turned off in iOS Settings.'],['modelNotReady', 'Apple Intelligence is downloading its model.'],+ [+ 'unsupportedLanguage',+ "Apple Intelligence doesn't support Polish (Poland), your iPhone's language.",+ ],])('keeps On-Device available and says why while it is %s', async (status, reason) => {- mockLocalReadiness.mockResolvedValue({ status, tokenCounting: false });+ mockLocalReadiness.mockResolvedValue({+ status,+ tokenCounting: false,+ deviceLanguage: 'Polish (Poland)',+ });mockScope = 'cleanup';render(<WorkflowSettingsScreen />);diff --git a/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx b/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsxindex 9dc621092..ca19ef563 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(/Off while Local Mode is on/)).toBeTruthy();+ expect(screen.getByText(/the AI chosen for the Voice Assistant in AI Models/)).toBeTruthy();expect(screen.queryByText(/agent/i)).toBeNull();});diff --git a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsxindex b7edb798b..af40f83b5 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx@@ -6,7 +6,11 @@ import { SystemIcon } from '@/components/ui/SystemIcon';import { OpenWhisprMark } from '@/components/ui/OpenWhisprMark';import { BRAND } from '@/config/colors';import { useOnboardingStep } from '@/hooks/useOnboardingStep';-import { canRunLocalReasoning, getLocalReasoningReadiness } from '@/lib/localReasoning';+import {+ canRunLocalReasoning,+ getLocalReasoningLanguageNote,+ getLocalReasoningReadiness,+} from '@/lib/localReasoning';import { chooseOnboardingMode } from '@/lib/onboardingMode';import { useConfigStore } from '@/store/useConfigStore';import { useModelDownloadStore } from '@/store/useModelDownloadStore';@@ -45,7 +49,9 @@ function privateCleanupLine(hint:readiness?.status === 'appleIntelligenceOff'? 'Starts once it’s on in Settings → Apple Intelligence & Siri.'- : undefined,+ : readiness?.status === 'unsupportedLanguage'+ ? `${getLocalReasoningLanguageNote(readiness)} Starts once that's changed in Settings.`+ : undefined,};}if (readiness?.status === 'unsupportedDevice') {diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsxindex 5816f90ef..dd40033ac 100644--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx@@ -19,7 +19,7 @@ let mockUser: { id: string; isAnonymous: boolean } | null = null;jest.mock('@/store/useAuthStore', () => ({useAuthStore: (selector: (state: unknown) => unknown) => selector({ user: mockUser }),}));-let mockReadiness: { status: string } = { status: 'ready' };+let mockReadiness: { status: string; deviceLanguage?: string } = { status: 'ready' };jest.mock('@/lib/localReasoning', () => ({...jest.requireActual('@/lib/localReasoning'),getLocalReasoningReadiness: async () => mockReadiness,@@ -104,6 +104,18 @@ describe('cleanup line', () => {).toBeTruthy();});+ it.each([+ [+ { status: 'unsupportedLanguage', deviceLanguage: 'Polish (Poland)' },+ "Apple Intelligence doesn't support Polish (Poland), your iPhone's language. Starts once that's changed in Settings.",+ ],+ ])('says cleanup starts once the language is changed (%o)', async (readiness, hint) => {+ mockReadiness = readiness;+ const screen = await renderStep();+ expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();+ expect(screen.getByText(hint)).toBeTruthy();+ });+it.each([['unsupportedDevice',diff --git a/openwhispr-mobile/src/services/agent/AgentComposerService.ts b/openwhispr-mobile/src/services/agent/AgentComposerService.tsindex 0b518d259..6c8fffaf2 100644--- a/openwhispr-mobile/src/services/agent/AgentComposerService.ts+++ b/openwhispr-mobile/src/services/agent/AgentComposerService.ts@@ -310,7 +310,8 @@ async function runGeneration(params: {if (session.inferenceRoute?.mode === 'providers') {const { resolveMobileProviderRoute } =require('@/lib/inferenceRouting') as typeof import('@/lib/inferenceRouting');- const route = await resolveMobileProviderRoute('agent', session.inferenceRoute);+ // The provider saved for the voice assistant is the user's choice, in Local Mode too.+ const route = await resolveMobileProviderRoute('agent', session.inferenceRoute, false, true);if (controller.signal.aborted) return;session.inferenceRoute = route;}diff --git a/openwhispr-mobile/src/services/agent/AgentStreamClient.ts b/openwhispr-mobile/src/services/agent/AgentStreamClient.tsindex 2992df484..9461d43ed 100644--- a/openwhispr-mobile/src/services/agent/AgentStreamClient.ts+++ b/openwhispr-mobile/src/services/agent/AgentStreamClient.ts@@ -170,7 +170,8 @@ export async function streamAgentText(options: StreamAgentTextOptions): Promise<'On-device keyboard composition is not available. Choose a provider or OpenWhispr Cloud.',);if (selection?.mode === 'providers') {- const route = await resolveMobileProviderRoute('agent', options.inferenceRoute);+ // The provider saved for the voice assistant is the user's choice, in Local Mode too.+ const route = await resolveMobileProviderRoute('agent', options.inferenceRoute, false, true);const { processProviderText } =require('@/services/providers/ProviderExecution') as typeof import('@/services/providers/ProviderExecution');const latest = messages.at(-1);diff --git a/openwhispr-mobile/src/services/agent/__tests__/AgentStreamClient.byok.test.ts b/openwhispr-mobile/src/services/agent/__tests__/AgentStreamClient.byok.test.tsindex c91bf1358..9d768762b 100644--- a/openwhispr-mobile/src/services/agent/__tests__/AgentStreamClient.byok.test.ts+++ b/openwhispr-mobile/src/services/agent/__tests__/AgentStreamClient.byok.test.ts@@ -68,7 +68,8 @@ it('uses the persisted provider route after provider settings change', async ()systemPrompt: 'Compose text.',inferenceRoute: route,});- expect(resolveMobileProviderRoute).toHaveBeenCalledWith('agent', route);+ // The provider saved for the voice assistant is the user's choice, so Local Mode doesn't refuse it.+ expect(resolveMobileProviderRoute).toHaveBeenCalledWith('agent', route, false, true);expect(fetch).not.toHaveBeenCalled();});diff --git a/openwhispr-mobile/src/services/reasoning/ReasoningService.ts b/openwhispr-mobile/src/services/reasoning/ReasoningService.tsindex 33aac3257..7124f8c26 100644--- a/openwhispr-mobile/src/services/reasoning/ReasoningService.ts+++ b/openwhispr-mobile/src/services/reasoning/ReasoningService.ts@@ -140,7 +140,9 @@ export class ReasoningService {const allowCloudFallback = routing?.allowCloudFallback === true;const chosenProvider = usesProviders && routing?.sendToChosenProvider === true;let privateContent = !chosenProvider && routing?.isPrivateNote === true;- if ((usesProviders && !chosenProvider) || localSelected) {+ // Local Mode keeps cleanup and note chat on this iPhone unless the user chose otherwise; note+ // formatting follows its own selection there.+ if (scope !== 'notes' && ((usesProviders && !chosenProvider) || localSelected)) {const { useProcessingModeStore } =require('@/store/useProcessingModeStore') as typeof import('@/store/useProcessingModeStore');privateContent ||= useProcessingModeStore.getState().activeMode === 'private';diff --git a/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts b/openwhispr-mobile/src/store/__tests__/useConfigStore.test.tsindex b03c54a70..bafd587a7 100644--- a/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts+++ b/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts@@ -35,12 +35,14 @@ it('upgrades a Local Mode config from before the Cloud defaults before anythinglocalModeUpgraded: true,noteChatSplit: true,noteChatEnabled: true,+ notesLocalModeSplit: true,inference: {dictation: { mode: 'local' },upload: { mode: 'local' },cleanup: { mode: 'local' },+ notes: { mode: 'local' },},- pinnedInference: ['upload', 'cleanup'],+ pinnedInference: ['upload', 'cleanup', 'notes'],};expect(useConfigStore.getState().config).toEqual(upgraded);expect(mockSaveConfig).toHaveBeenCalledWith(upgraded);@@ -54,13 +56,18 @@ it('still upgrades the loaded config when saving it fails', async () => {expect(useConfigStore.getState().config).toMatchObject({localModeUpgraded: true,- pinnedInference: ['upload', 'cleanup'],+ pinnedInference: ['upload', 'cleanup', 'notes'],});expect(useConfigStore.getState().error).toBeNull();});it('leaves an upgraded config alone', async () => {- const config = { defaultMode: 'private', localModeUpgraded: true, noteChatSplit: true };+ const config = {+ defaultMode: 'private',+ localModeUpgraded: true,+ noteChatSplit: true,+ notesLocalModeSplit: true,+ };mockGetConfig.mockResolvedValue(config);await useConfigStore.getState().loadConfig();@@ -77,6 +84,7 @@ it('starts a new install on the Cloud defaults', async () => {expect(useConfigStore.getState().config).toMatchObject({localModeUpgraded: true,noteChatSplit: true,+ notesLocalModeSplit: true,});expect(mockSaveConfig).not.toHaveBeenCalled();});@@ -102,8 +110,69 @@ it('splits note chat from the voice assistant before anything reads the config',localModeUpgraded: true,noteChatSplit: true,noteChatEnabled: true,+ notesLocalModeSplit: true,inference: { agent: groq, noteChat: groq },};expect(useConfigStore.getState().config).toEqual(split);expect(mockSaveConfig).toHaveBeenCalledWith(split);});++// Local Mode once formatted notes on this iPhone whatever was saved, so the update keeps a Local+// Mode config's note formatting there unless the user chose otherwise.+describe('note formatting leaving Local Mode', () => {+ const upgradedBefore = { localModeUpgraded: true, noteChatSplit: true };++ it('holds note formatting On-Device for a Local Mode config with nothing saved', async () => {+ mockGetConfig.mockResolvedValue({ ...upgradedBefore, defaultMode: 'private' });++ await useConfigStore.getState().loadConfig();++ expect(useConfigStore.getState().config).toMatchObject({+ notesLocalModeSplit: true,+ inference: { notes: { mode: 'local' } },+ pinnedInference: ['notes'],+ });+ });++ it('holds a note formatting Cloud hold On-Device too', async () => {+ mockGetConfig.mockResolvedValue({+ ...upgradedBefore,+ defaultMode: 'private',+ inference: { notes: { mode: 'openwhispr' } },+ pinnedInference: ['notes'],+ });++ await useConfigStore.getState().loadConfig();++ expect(useConfigStore.getState().config).toMatchObject({+ inference: { notes: { mode: 'local' } },+ pinnedInference: ['notes'],+ });+ });++ it("keeps the user's own note formatting choice", async () => {+ const groq = { mode: 'providers', providerId: 'groq', modelId: 'llama' };+ mockGetConfig.mockResolvedValue({+ ...upgradedBefore,+ defaultMode: 'private',+ inference: { notes: groq },+ });++ await useConfigStore.getState().loadConfig();++ expect(useConfigStore.getState().config?.inference?.notes).toEqual(groq);+ expect(useConfigStore.getState().config?.pinnedInference).toBeUndefined();+ });++ it('leaves a config outside Local Mode alone', async () => {+ mockGetConfig.mockResolvedValue({ ...upgradedBefore, defaultMode: 'cloud' });++ await useConfigStore.getState().loadConfig();++ expect(useConfigStore.getState().config).toEqual({+ ...upgradedBefore,+ defaultMode: 'cloud',+ notesLocalModeSplit: true,+ });+ });+});diff --git a/openwhispr-mobile/src/store/__tests__/useNotesStore.meeting.test.ts b/openwhispr-mobile/src/store/__tests__/useNotesStore.meeting.test.tsindex 5c8ddcc63..efde53b3f 100644--- a/openwhispr-mobile/src/store/__tests__/useNotesStore.meeting.test.ts+++ b/openwhispr-mobile/src/store/__tests__/useNotesStore.meeting.test.ts@@ -620,7 +620,9 @@ describe('runMeetingPipeline', () => {});});- it('derives the title locally in private mode and never sends transcript to the cloud', async () => {+ // Note formatting follows its own selection in Local Mode; only a private note stays here, and a+ // meeting recorded in Local Mode is private.+ it('titles a shared meeting note with its note formatting choice in Local Mode', async () => {mockAuthState.user = signedInUser;mockProcessingModeState.activeMode = 'private';mockConfigState.config.autoGenerateNoteTitle = true;@@ -635,12 +637,8 @@ describe('runMeetingPipeline', () => {await useNotesStore.getState().runMeetingPipeline(7, 'file://meeting.wav', 2);- expect(mockGenerateNoteTitle).not.toHaveBeenCalled();- expect(ReasoningService.processText).not.toHaveBeenCalled();- expect(mockDeriveLocalTitle).toHaveBeenCalledWith('Discuss launch risks.');- expect(notesRepository.updateNote).toHaveBeenCalledWith(7, {- title: 'Local fallback title',- });+ expect(mockGenerateNoteTitle).toHaveBeenCalled();+ expect(mockDeriveLocalTitle).not.toHaveBeenCalled();});it('derives the title locally for notes marked private even in cloud mode', async () => {@@ -878,7 +876,7 @@ describe('runMeetingPipeline', () => {title: 'Planning Sync',content: 'Customer launch risk came up twice. Prioritize onboarding.',noteType: 'meeting',- isPrivate: 0,+ isPrivate: 1,deletedAt: null,enhancedAtContentHash: null,});@@ -921,7 +919,7 @@ describe('runMeetingPipeline', () => {expect.objectContaining({routing: expect.objectContaining({allowCloudFallback: true,- isPrivateNote: false,+ isPrivateNote: true,}),}),);diff --git a/openwhispr-mobile/src/store/useConfigStore.ts b/openwhispr-mobile/src/store/useConfigStore.tsindex a990d939d..dabccbbbe 100644--- a/openwhispr-mobile/src/store/useConfigStore.ts+++ b/openwhispr-mobile/src/store/useConfigStore.ts@@ -1,7 +1,11 @@import { create } from 'zustand';import { UserConfig } from '../types';import { StorageService } from '../services/storage/StorageService';-import { localModeUpgradeConfig, noteChatSplitConfig } from '../lib/inferenceModes';+import {+ localModeUpgradeConfig,+ noteChatSplitConfig,+ notesLocalModeSplitConfig,+} from '../lib/inferenceModes';import { useProcessingModeStore } from './useProcessingModeStore';interface ConfigState {@@ -18,6 +22,7 @@ const defaultConfig: UserConfig = {appleLocalIntelligenceEnabled: true,localModeUpgraded: true,noteChatSplit: true,+ notesLocalModeSplit: true,};export const useConfigStore = create<ConfigState>((set, get) => ({@@ -30,17 +35,22 @@ export const useConfigStore = create<ConfigState>((set, get) => ({try {const config = await StorageService.getConfig();// A config from before Local Mode's Cloud defaults is upgraded before anything reads it, so- // its uploads and cleanup never reach Cloud, and one from before note chat had a selection of- // its own keeps the one it shared. A failed save upgrades it again next launch.+ // its uploads and cleanup never reach Cloud; one from before note chat had a selection of its+ // own keeps the one it shared; and one from before note formatting left Local Mode keeps its+ // notes on this iPhone. A failed save upgrades it again next launch.const localModeConfig =!config || config.localModeUpgraded? config: { ...config, ...localModeUpgradeConfig(config) };- const resolvedConfig = !localModeConfig- ? defaultConfig- : localModeConfig.noteChatSplit+ const noteChatConfig =+ !localModeConfig || localModeConfig.noteChatSplit? localModeConfig: { ...localModeConfig, ...noteChatSplitConfig(localModeConfig) };+ const resolvedConfig = !noteChatConfig+ ? defaultConfig+ : noteChatConfig.notesLocalModeSplit+ ? noteChatConfig+ : { ...noteChatConfig, ...notesLocalModeSplitConfig(noteChatConfig) };if (config && resolvedConfig !== config) {await StorageService.saveConfig(resolvedConfig).catch(() => undefined);}diff --git a/openwhispr-mobile/src/store/useNotesStore.ts b/openwhispr-mobile/src/store/useNotesStore.tsindex dcb79a7bb..07b14d482 100644--- a/openwhispr-mobile/src/store/useNotesStore.ts+++ b/openwhispr-mobile/src/store/useNotesStore.ts@@ -218,7 +218,7 @@ const canUseCloudForMeetingNote = (note: Note | null | undefined): note is NoteuseConfigStore.getState().config?.inference?.notes?.mode !== 'providers')return false;- if (useProcessingModeStore.getState().activeMode === 'private') return false;+ // Local Mode's meetings are private notes; note formatting follows its own selection otherwise.return !!note && !note.deletedAt && note.noteType === 'meeting' && note.isPrivate !== 1;};diff --git a/openwhispr-mobile/src/types/index.ts b/openwhispr-mobile/src/types/index.tsindex 57f4c5ce3..83149ae8b 100644--- a/openwhispr-mobile/src/types/index.ts+++ b/openwhispr-mobile/src/types/index.ts@@ -23,6 +23,9 @@ export interface UserConfig {// Set once note chat has its own selection, copied from the voice assistant's it used to share.// New installs start with it; older configs get it from noteChatSplitConfig at launch.noteChatSplit?: boolean;+ // Set once note formatting follows its own selection in Local Mode instead of running on this+ // iPhone. New installs start with it; older configs get it from notesLocalModeSplitConfig.+ notesLocalModeSplit?: boolean;defaultMode: ProcessingMode;cleanupEnabled?: boolean;autoGenerateNoteTitle?: boolean;@@ -146,12 +149,16 @@ export type LocalReasoningStatus =| 'unsupportedDevice'| 'unsupportedOS'| 'appleIntelligenceOff'- | 'modelNotReady';+ | 'modelNotReady'+ // Apple Intelligence doesn't support the iPhone's language, which Settings can change.+ | 'unsupportedLanguage';export interface LocalReasoningReadiness {status: LocalReasoningStatus;contextSize?: number;tokenCounting?: boolean;+ // The iPhone's language, named for unsupportedLanguage.+ deviceLanguage?: string;}export type LocalReasoningErrorCode =@@ -160,6 +167,7 @@ export type LocalReasoningErrorCode =| 'APPLE_LLM_OUTPUT_LIMIT'| 'APPLE_LLM_RATE_LIMITED'| 'APPLE_LLM_UNAVAILABLE'+ | 'APPLE_LLM_UNSUPPORTED_LANGUAGE'| 'APPLE_LLM_FAILED'| 'APPLE_LLM_CANCELLED'| 'LOCAL_CONTEXT_LIMIT'