Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(mobile): rename Private Mode to Local Mode and move cleanup with it (#2691)

Chad Piha98fc45459c91
diff --git a/openwhispr-mobile/README.md b/openwhispr-mobile/README.md
index ead9586db..907ad74fe 100644
--- a/openwhispr-mobile/README.md
+++ b/openwhispr-mobile/README.md
@@ -6,7 +6,7 @@ The mobile app lives in the main [`OpenWhispr/openwhispr`](https://github.com/Op
## Highlights
-- **Cloud, Private, or Bring Your Own Key** — choose hosted transcription, on-device inference, or your own provider key on iOS
+- **Cloud, Local Mode, or Bring Your Own Key** — choose hosted transcription, on-device inference, or your own provider key on iOS
- **iOS dictation keyboard** — dictate from any text field system-wide via a custom keyboard extension
- **Markdown notes** — folders, full-text search, AI-assisted cleanup
- **Note sharing** — web links, email invitations, organization domains, and viewer/editor access; Markdown and plain-text exports remain available offline
diff --git a/openwhispr-mobile/app/_layout.tsx b/openwhispr-mobile/app/_layout.tsx
index 44c1362b0..33e2ba1a4 100644
--- a/openwhispr-mobile/app/_layout.tsx
+++ b/openwhispr-mobile/app/_layout.tsx
@@ -35,7 +35,6 @@ import { PermissionAlertMount } from '@/components/ui/PermissionAlert';
import { startKeyboardToneSync } from '@/lib/keyboardToneSync';
import { startKeyboardAgentSync } from '@/lib/keyboardAgentSync';
import { startKeyboardFullAccessProbe } from '@/lib/keyboardFullAccessProbe';
-import { applyPendingOnDeviceCleanup } from '@/lib/onboardingMode';
import { OpenWhisprSuperwallProvider } from '@/components/superwall/OpenWhisprSuperwallProvider';
import { eraseProviderCredentialsFromPreviousInstall } from '@/services/providers/ProviderCredentials';
@@ -104,8 +103,6 @@ function RootLayout() {
stopTone = startKeyboardToneSync();
stopAgent = startKeyboardAgentSync();
stopFullAccessProbe = startKeyboardFullAccessProbe();
- // Launch is where an iOS update shows up, so cleanup setup couldn't save is saved here.
- applyPendingOnDeviceCleanup().catch(() => undefined);
}
};
diff --git a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift
index 6b6347479..005e19611 100644
--- a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift
+++ b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift
@@ -1801,7 +1801,7 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDe
// when locked. The header costs one row of the height-capped menu, so on
// shorter keyboards the last tone ("Excited") can fall into the scroll
// region instead of showing inline.
- let menuTitle = applicable ? "Dictation Tone" : "Turn off Private Mode to use tones"
+ let menuTitle = applicable ? "Dictation Tone" : "Tones are off in Local Mode"
toneButton.menu = UIMenu(title: menuTitle, children: actions)
toneButton.isUserInteractionEnabled = true
toneButton.alpha = applicable ? 1.0 : 0.4
@@ -3068,7 +3068,7 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDe
guard provider.isAgentApplicable() else {
playKeyClick()
showTransientRecordState(
- title: "Turn off Private Mode",
+ title: "Off in Local Mode",
systemImage: "lock.fill",
background: Palette.issue,
duration: 1.6
diff --git a/openwhispr-mobile/src/components/onboarding/__tests__/OnboardingShell.test.tsx b/openwhispr-mobile/src/components/onboarding/__tests__/OnboardingShell.test.tsx
index 6e6ea7767..12e3c1c34 100644
--- a/openwhispr-mobile/src/components/onboarding/__tests__/OnboardingShell.test.tsx
+++ b/openwhispr-mobile/src/components/onboarding/__tests__/OnboardingShell.test.tsx
@@ -70,7 +70,7 @@ it('reports an unexpected failure and shows the fallback instead of its text', a
});
it('shows a failure written for the user as is', async () => {
- const message = 'Cloud needs a connection to set up. Try again or use Private Mode for now.';
+ const message = 'Cloud needs a connection to set up. Try again or use Local Mode for now.';
render(
<OnboardingShell
title="Mode"
diff --git a/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts b/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts
index ffd25c552..46e9ca605 100644
--- a/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts
+++ b/openwhispr-mobile/src/hooks/__tests__/useUsageLimitRecovery.test.ts
@@ -50,7 +50,7 @@ jest.mock('@/components/ui/UsageMeter', () => ({
function expectQuotaGuidance(): void {
expect(Alert.alert).toHaveBeenCalledWith(
'Weekly Limit Reached',
- expect.stringContaining('Turn on Private Mode in Account → AI Models'),
+ expect.stringContaining('Set Dictation to On-Device in Account → AI Models'),
expect.arrayContaining([
expect.objectContaining({ text: 'View Usage', onPress: expect.any(Function) }),
expect.objectContaining({ text: 'Upgrade', onPress: expect.any(Function) }),
diff --git a/openwhispr-mobile/src/hooks/useFileUpload.ts b/openwhispr-mobile/src/hooks/useFileUpload.ts
index b5770e223..4f191ddd3 100644
--- a/openwhispr-mobile/src/hooks/useFileUpload.ts
+++ b/openwhispr-mobile/src/hooks/useFileUpload.ts
@@ -148,7 +148,7 @@ export function useFileUpload(options: UseFileUploadOptions = {}) {
// decodes Opus, so route private-mode Opus uploads there instead.
if (transcriptionProvider === 'local' && isOggOpus(file.name, file.mimeType, file.uri)) {
throw new Error(
- "Opus audio can't be transcribed on this iPhone yet. In Account → AI Models, turn off Private Mode or set Uploads to OpenWhispr Cloud, then try again.",
+ "Opus audio can't be transcribed on this iPhone yet. Set Uploads to OpenWhispr Cloud in Account → AI Models, then try again.",
);
}
diff --git a/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts b/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts
index 45360d619..42fec82a6 100644
--- a/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts
+++ b/openwhispr-mobile/src/hooks/useUsageLimitRecovery.ts
@@ -27,7 +27,7 @@ function showUsageLimitFallback(): void {
Alert.alert(
'Weekly Limit Reached',
- `You've used ${words} for this week.${resetLabel ? ` ${resetLabel}.` : ''} Turn on Private Mode in Account → AI Models for unlimited on-device dictation, or upgrade to Pro for unlimited cloud transcription.`,
+ `You've used ${words} for this week.${resetLabel ? ` ${resetLabel}.` : ''} Set Dictation to On-Device in Account → AI Models for unlimited on-device dictation, or upgrade to Pro for unlimited cloud transcription.`,
[
{ text: 'OK', style: 'cancel' },
{ text: 'View Usage', onPress: () => router.push('/(account)') },
diff --git a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts
index ed330e8dd..f8f99d8c8 100644
--- a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts
@@ -6,15 +6,46 @@ function config(overrides: Partial<UserConfig> = {}): UserConfig {
}
describe('workflowSummary for Text Cleanup', () => {
+ // With nothing saved, Local Mode cleans on OpenWhispr Cloud for a signed-in account and on this
+ // phone otherwise, since a separate Cloud pass needs a real account.
it.each([
- ['nothing saved', undefined],
- ['OpenWhispr Cloud', { mode: 'openwhispr' as const }],
- ])('is skipped in On-Device mode with %s saved', (_label, cleanup) => {
- const saved = config({ inference: cleanup ? { cleanup } : {} });
- expect(workflowSummary(saved, 'cleanup', 'private')).toBe('Skipped');
+ ['account', 'OpenWhispr Cloud'],
+ ['session', 'On-Device'],
+ ['none', 'On-Device'],
+ ] as const)('with nothing saved in Local Mode and %s access, runs %s', (cloudAccess, label) => {
+ expect(workflowSummary(config({}), 'cleanup', 'private', { cloudAccess })).toBe(label);
});
- it('names the provider saved for cleanup in On-Device mode, which cleans there', () => {
+ it('runs a saved OpenWhispr Cloud cleanup in Local Mode for a signed-in account', () => {
+ const saved = config({ inference: { cleanup: { mode: 'openwhispr' } } });
+ expect(workflowSummary(saved, 'cleanup', 'private', { cloudAccess: 'account' })).toBe(
+ 'OpenWhispr Cloud',
+ );
+ });
+
+ // Local Mode dictates on this phone, so Cloud cleanup is a separate pass that needs an account.
+ it.each(['session', 'none'] as const)(
+ 'skips a saved OpenWhispr Cloud cleanup in Local Mode with %s access',
+ (cloudAccess) => {
+ const saved = config({ inference: { cleanup: { mode: 'openwhispr' } } });
+ expect(workflowSummary(saved, 'cleanup', 'private', { cloudAccess })).toBe(
+ 'Skipped · Sign in',
+ );
+ expect(
+ workflowSummary({ ...saved, defaultMode: 'cloud' }, 'cleanup', 'cloud', { cloudAccess }),
+ ).toBe('OpenWhispr Cloud');
+ },
+ );
+
+ it('is skipped in Local Mode when Apple Intelligence cannot run', () => {
+ expect(
+ workflowSummary(config({}), 'cleanup', 'private', {
+ onDeviceUnavailable: 'Not supported on this iPhone',
+ }),
+ ).toBe('Skipped · Not supported on this iPhone');
+ });
+
+ it('names a cleanup provider saved in Local Mode', () => {
const saved = config({
inference: { cleanup: { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' } },
});
@@ -30,15 +61,26 @@ describe('workflowSummary for Text Cleanup', () => {
});
it.each(['private', 'cloud'] as const)(
- 'says why saved On-Device cleanup cannot run in %s mode',
+ 'says why saved On-Device cleanup is skipped in %s mode',
(mode) => {
const saved = config({ defaultMode: mode, inference: { cleanup: { mode: 'local' } } });
expect(
workflowSummary(saved, 'cleanup', mode, { onDeviceUnavailable: 'Apple Intelligence off' }),
- ).toBe('On-Device · Apple Intelligence off');
+ ).toBe('Skipped · Apple Intelligence off');
},
);
+ it('ignores On-Device availability for a cleanup provider saved in Local Mode', () => {
+ const saved = config({
+ inference: { cleanup: { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' } },
+ });
+ expect(
+ workflowSummary(saved, 'cleanup', 'private', {
+ onDeviceUnavailable: 'Apple Intelligence off',
+ }),
+ ).toBe('OpenAI');
+ });
+
it('ignores On-Device availability for a cleanup that does not run on the phone', () => {
const saved = config({ defaultMode: 'cloud', inference: { cleanup: { mode: 'openwhispr' } } });
expect(
@@ -70,3 +112,28 @@ describe('workflowSummary for Text Cleanup', () => {
);
});
});
+
+describe('workflowSummary for Uploads', () => {
+ // With nothing saved, Local Mode uploads to OpenWhispr Cloud whenever there is a session.
+ it.each([
+ ['account', 'OpenWhispr Cloud'],
+ ['session', 'OpenWhispr Cloud'],
+ ['none', 'On-Device'],
+ ] as const)('with nothing saved in Local Mode and %s access, runs %s', (cloudAccess, label) => {
+ expect(workflowSummary(config({}), 'upload', 'private', { cloudAccess })).toBe(label);
+ });
+
+ it('names an upload provider saved in Local Mode', () => {
+ const saved = config({
+ inference: { upload: { mode: 'providers', providerId: 'openai', modelId: 'whisper-1' } },
+ });
+ expect(workflowSummary(saved, 'upload', 'private')).toBe('OpenAI');
+ });
+
+ it('keeps dictation On-Device in Local Mode whatever is saved', () => {
+ const saved = config({ inference: { dictation: { mode: 'openwhispr' } } });
+ expect(workflowSummary(saved, 'dictation', 'private', { cloudAccess: 'account' })).toBe(
+ 'On-Device',
+ );
+ });
+});
diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts
index 410d04d7b..135997bd3 100644
--- a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts
@@ -1,9 +1,20 @@
jest.mock('react-native', () => ({ Platform: { OS: 'ios' } }));
import { Platform } from 'react-native';
-import { dictationModeConfig, getInferenceModes, workflowSaveConfig } from '../inferenceModes';
+import {
+ dictationModeConfig,
+ getInferenceModes,
+ localModeUpgradeConfig,
+ workflowSaveConfig,
+} from '../inferenceModes';
import type { UserConfig } from '@/types';
+const groqCleanup = {
+ mode: 'providers' as const,
+ providerId: 'groq',
+ modelId: 'llama-3.3-70b-versatile',
+ credentialRef: 'provider.groq',
+};
const groqDictation = {
mode: 'providers' as const,
providerId: 'groq',
@@ -27,6 +38,34 @@ it('releases only the automatic pins when dictation leaves Bring Your Own Key',
expect(next.pinnedInference).toBeUndefined();
});
+// Local Mode cleans On-Device whatever is saved for cleanup other than a provider, so switching
+// keeps the user's cleanup choice for when Local Mode is off again.
+it.each([
+ ['On-Device', { mode: 'local' as const }],
+ ['OpenWhispr Cloud', { mode: 'openwhispr' as const }],
+ ['provider', groqCleanup],
+])('keeps a saved %s cleanup when switching modes', (_label, cleanup) => {
+ for (const mode of ['cloud', 'private'] as const) {
+ const saved: UserConfig = {
+ defaultMode: mode === 'cloud' ? 'private' : 'cloud',
+ inference: { cleanup },
+ };
+ expect(dictationModeConfig(saved, mode).inference?.cleanup).toEqual(cleanup);
+ }
+});
+
+// Picking another on-device model, or replaying Local Mode in onboarding, is not a mode change.
+it('keeps the automatic pins when dictation is saved to the mode it is already in', () => {
+ const held: UserConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' }, upload: { mode: 'local' } },
+ pinnedInference: ['upload'],
+ };
+ const next = dictationModeConfig(held, 'private');
+ expect(next.inference?.upload).toEqual({ mode: 'local' });
+ expect(next).not.toHaveProperty('pinnedInference');
+});
+
it('keeps an explicit On-Device upload choice when dictation leaves Bring Your Own Key', () => {
const explicit: UserConfig = {
defaultMode: 'providers',
@@ -43,7 +82,7 @@ it('keeps an explicit upload choice when toggling between Cloud and On-Device',
expect(dictationModeConfig(explicit, 'private').inference?.upload).toEqual({ mode: 'local' });
});
-it('keeps the dictation selection in step with Private mode', () => {
+it('keeps the dictation selection in step with Local Mode', () => {
const config = {
defaultMode: 'private' as const,
inference: {
@@ -163,14 +202,14 @@ describe('workflowSaveConfig', () => {
});
});
- describe('where Private mode returns to', () => {
+ describe('where Local Mode returns to', () => {
const fromProviders: UserConfig = {
defaultMode: 'private',
privateModeReturn: { pinned: { upload: { mode: 'openwhispr' } } },
inference: { dictation: { mode: 'local' } },
};
- it('is Bring Your Own Key, with what it held, when Private mode is turned on from it', () => {
+ it('is Bring Your Own Key, with what it held, when Local Mode is turned on from it', () => {
const config: UserConfig = {
defaultMode: 'providers',
inference: {
@@ -186,7 +225,28 @@ describe('workflowSaveConfig', () => {
expect(next.inference).toEqual({ dictation: { mode: 'local' }, notes: { mode: 'local' } });
});
- it('is not set when Private mode is turned on from Cloud', () => {
+ it.each([
+ ['On-Device', { mode: 'local' as const }],
+ ['OpenWhispr Cloud', { mode: 'openwhispr' as const }],
+ ])(
+ 'keeps a %s cleanup when Local Mode is turned on from Bring Your Own Key and off again',
+ (_label, cleanup) => {
+ const providers: UserConfig = {
+ defaultMode: 'providers',
+ inference: { dictation: groqDictation, cleanup },
+ rememberedInference: { dictation: { groq: groqDictation } },
+ };
+ const on = {
+ ...providers,
+ ...workflowSaveConfig(providers, 'dictation', { mode: 'local' }, 'providers'),
+ };
+ const off = { ...on, ...workflowSaveConfig(on, 'dictation', groqDictation, 'private') };
+ expect(off.defaultMode).toBe('providers');
+ expect(off.inference?.cleanup).toEqual(cleanup);
+ },
+ );
+
+ it('is not set when Local Mode is turned on from Cloud', () => {
const config: UserConfig = { defaultMode: 'cloud' };
expect(
workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'cloud'),
@@ -206,7 +266,7 @@ describe('workflowSaveConfig', () => {
it.each([
['Cloud', { mode: 'openwhispr' as const }],
['Bring Your Own Key', groqDictation],
- ])('is cleared when dictation leaves Private mode for %s', (_label, selection) => {
+ ])('is cleared when dictation leaves Local Mode for %s', (_label, selection) => {
const next = workflowSaveConfig(fromProviders, 'dictation', selection, 'private');
expect(next).toHaveProperty('privateModeReturn', undefined);
});
@@ -217,7 +277,7 @@ describe('workflowSaveConfig', () => {
expect(next.pinnedInference).toEqual(['upload']);
});
- it('keeps a choice made in Private mode over what Bring Your Own Key held', () => {
+ it('keeps a choice made in Local Mode over what Bring Your Own Key held', () => {
const config: UserConfig = {
...fromProviders,
inference: {
@@ -230,7 +290,33 @@ describe('workflowSaveConfig', () => {
expect(next).not.toHaveProperty('pinnedInference');
});
- it('holds workflows on this phone when Private mode was not turned on from it', () => {
+ // Local Mode uploaded to OpenWhispr Cloud with nothing saved and a session, so that is held.
+ it.each([
+ ['session', 'openwhispr'],
+ ['account', 'openwhispr'],
+ ['none', 'local'],
+ ] as const)('holds uploads where Local Mode ran them with %s access', (cloudAccess, mode) => {
+ const config: UserConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' } },
+ };
+ const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private', cloudAccess);
+ expect(next.inference?.upload).toEqual({ mode });
+ expect(next.inference?.notes).toEqual({ mode: 'local' });
+ });
+
+ it('holds what Bring Your Own Key held over a workflow Local Mode held automatically', () => {
+ const config: UserConfig = {
+ ...fromProviders,
+ inference: { dictation: { mode: 'local' }, upload: { mode: 'local' } },
+ pinnedInference: ['upload'],
+ };
+ const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');
+ expect(next.inference?.upload).toEqual({ mode: 'openwhispr' });
+ expect(next.pinnedInference).toEqual(['upload']);
+ });
+
+ it('holds workflows on this phone when Local Mode was not turned on from it', () => {
const config: UserConfig = {
defaultMode: 'private',
inference: { dictation: { mode: 'local' } },
@@ -249,6 +335,54 @@ describe('workflowSaveConfig', () => {
});
});
+// Before Local Mode's Cloud defaults, it kept uploads and cleanup on this phone and ignored a Cloud
+// choice saved for them.
+describe('localModeUpgradeConfig', () => {
+ it('holds uploads and cleanup on this phone for a config in Local Mode', () => {
+ const config: UserConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'openwhispr' } },
+ rememberedInference: { upload: { local: { mode: 'local', modelId: 'whisper-base' } } },
+ };
+ expect(localModeUpgradeConfig(config)).toEqual({
+ localModeUpgraded: true,
+ inference: {
+ dictation: { mode: 'local' },
+ upload: { mode: 'local', modelId: 'whisper-base' },
+ cleanup: { mode: 'local' },
+ },
+ pinnedInference: ['upload', 'cleanup'],
+ });
+ });
+
+ it('keeps an On-Device or provider choice the user saved', () => {
+ const config: UserConfig = {
+ defaultMode: 'private',
+ inference: { upload: { mode: 'local', modelId: 'whisper-base' }, cleanup: groqCleanup },
+ };
+ expect(localModeUpgradeConfig(config)).toEqual({
+ localModeUpgraded: true,
+ inference: config.inference,
+ pinnedInference: [],
+ });
+ });
+
+ it.each(['cloud', 'providers'] as const)('only marks a config in %s mode', (defaultMode) => {
+ expect(localModeUpgradeConfig({ defaultMode })).toEqual({ localModeUpgraded: true });
+ });
+
+ it('is released when dictation leaves Local Mode, so Cloud runs them again', () => {
+ const config: UserConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' } },
+ };
+ const upgraded = { ...config, ...localModeUpgradeConfig(config) };
+ const next = dictationModeConfig(upgraded, 'cloud');
+ expect(next.inference).toEqual({ dictation: { mode: 'openwhispr' } });
+ expect(next.pinnedInference).toBeUndefined();
+ });
+});
+
describe('getInferenceModes', () => {
afterEach(() => {
Platform.OS = 'ios';
diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts
index 33a42412c..577169d38 100644
--- a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts
@@ -14,11 +14,16 @@ jest.mock('@/store/useConfigStore', () => ({ useConfigStore: { getState: () => m
jest.mock('@/store/useProcessingModeStore', () => ({
useProcessingModeStore: { getState: () => mockProcessing },
}));
+let mockUser: { id: string; isAnonymous: boolean } | null = null;
+jest.mock('@/store/useAuthStore', () => ({
+ useAuthStore: { getState: () => ({ user: mockUser }) },
+}));
describe('mobile inference routing', () => {
beforeEach(() => {
mockState.config = { defaultMode: 'cloud', inference: {} };
mockProcessing.activeMode = 'cloud';
+ mockUser = null;
});
it('does not opt existing configuration into providers', () => {
expect(getInferenceSelection('dictation')).toBeUndefined();
@@ -201,43 +206,80 @@ it('marks text stages unavailable, never Cloud, for BYOK dictation with no text
);
});
-it('keeps a saved provider cleanup for an On-Device recording; everything else stays local', () => {
+const OPENAI_TEXT = {
+ mode: 'providers' as const,
+ providerId: 'openai',
+ modelId: 'gpt-5-mini',
+ credentialRef: 'provider.openai',
+};
+
+// Local Mode keeps dictation on this phone; cleanup runs what is saved for it.
+it.each([
+ ['a provider', OPENAI_TEXT, { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' }],
+ ['OpenWhispr Cloud', { mode: 'openwhispr' }, { mode: 'openwhispr' }],
+ ['On-Device', { mode: 'local' }, { mode: 'local' }],
+])('cleans a Local Mode recording with %s saved for cleanup there', (_label, cleanup, route) => {
mockProcessing.activeMode = 'private';
- mockState.config.inference = {
- dictation: { mode: 'local' },
- cleanup: {
- mode: 'providers',
- providerId: 'openai',
- modelId: 'gpt-5-mini',
- credentialRef: 'provider.openai',
- },
- agent: {
- mode: 'providers',
- providerId: 'openai',
- modelId: 'gpt-5-mini',
- credentialRef: 'provider.openai',
- },
- };
+ mockUser = { id: 'u', isAnonymous: false };
+ mockState.config.inference = { dictation: { mode: 'local' }, cleanup, agent: OPENAI_TEXT };
const snapshot = snapshotTranscriptionJob('dictation');
expect(snapshot.provider).toBe('local');
- expect(snapshot.cleanupRoute).toMatchObject({
- mode: 'providers',
- scope: 'cleanup',
- providerId: 'openai',
- modelId: 'gpt-5-mini',
- });
+ expect(snapshot.cleanupRoute).toMatchObject({ ...route, scope: 'cleanup' });
expect(snapshot.agentRoute).toEqual({ mode: 'local', scope: 'agent' });
- expect(snapshot.cleanupUnavailable).toBeUndefined();
});
+// With nothing saved, Local Mode cleans on OpenWhispr Cloud only for a signed-in account.
+it.each([
+ ['a signed-in account', { id: 'u', isAnonymous: false }, 'openwhispr'],
+ ['an anonymous session', { id: 'a', isAnonymous: true }, 'local'],
+ ['no session', null, 'local'],
+])('cleans a Local Mode recording with nothing saved for %s', (_label, user, mode) => {
+ mockProcessing.activeMode = 'private';
+ mockUser = user;
+ mockState.config.inference = { dictation: { mode: 'local' } };
+ expect(snapshotTranscriptionJob('dictation').cleanupRoute).toEqual({ mode, scope: 'cleanup' });
+});
+
+// Cloud cleaning a transcript made on this phone needs a signed-in account, whatever the mode, so
+// without one it is pinned here and left raw (cleanupRunsOnDevice is false for a Cloud choice).
+it.each([
+ ['an anonymous session', { id: 'a', isAnonymous: true }],
+ ['no session', null],
+])('keeps a saved Cloud cleanup of an On-Device transcript here for %s', (_label, user) => {
+ mockUser = user;
+ for (const mode of ['private', 'cloud'] as const) {
+ mockProcessing.activeMode = mode;
+ mockState.config.inference = { upload: { mode: 'local' }, cleanup: { mode: 'openwhispr' } };
+ expect(snapshotTranscriptionJob('upload').cleanupRoute).toEqual({
+ mode: 'local',
+ scope: 'cleanup',
+ });
+ }
+});
+
+// Uploads in Local Mode run what is saved for them, or OpenWhispr Cloud when there is a session.
it.each([
- ['OpenWhispr Cloud', { mode: 'openwhispr' }],
- ['nothing', undefined],
-])('keeps cleanup On-Device for an On-Device recording with %s saved', (_label, cleanup) => {
+ ['nothing saved, with a session', undefined, { id: 'a', isAnonymous: true }, 'cloud'],
+ ['nothing saved, with no session', undefined, null, 'local'],
+ ['a provider saved', { mode: 'providers', providerId: 'groq' }, null, 'byok'],
+ ['On-Device saved', { mode: 'local' }, { id: 'u', isAnonymous: false }, 'local'],
+])('routes a Local Mode upload with %s', (_label, upload, user, provider) => {
mockProcessing.activeMode = 'private';
- mockState.config.inference = { dictation: { mode: 'local' }, ...(cleanup ? { cleanup } : {}) };
- expect(snapshotTranscriptionJob('dictation').cleanupRoute).toEqual({
- mode: 'local',
+ mockUser = user;
+ mockState.config.inference = upload ? { upload } : {};
+ expect(getTranscriptionProvider('upload')).toBe(provider);
+ expect(getTranscriptionProvider('dictation')).toBe('local');
+});
+
+it('sends an On-Device upload outside Local Mode to the provider saved for cleanup', () => {
+ mockProcessing.activeMode = 'cloud';
+ mockState.config.inference = { upload: { mode: 'local' }, cleanup: OPENAI_TEXT };
+ const snapshot = snapshotTranscriptionJob('upload');
+ expect(snapshot.provider).toBe('local');
+ expect(snapshot.cleanupRoute).toMatchObject({
+ mode: 'providers',
scope: 'cleanup',
+ providerId: 'openai',
+ modelId: 'gpt-5-mini',
});
});
diff --git a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
index dcf1e5844..912bb2579 100644
--- a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
@@ -1,5 +1,4 @@
-import { Platform } from 'react-native';
-import { applyPendingOnDeviceCleanup, chooseOnboardingMode } from '../onboardingMode';
+import { chooseOnboardingMode } from '../onboardingMode';
import { OnboardingError } from '../onboardingErrors';
jest.mock('@/lib/sentry', () => ({ Sentry: { captureException: jest.fn() } }));
@@ -11,8 +10,6 @@ let mockError: string | null = null;
let mockUser: { id: string; isAnonymous: boolean } | null = null;
let mockGuest = false;
let mockCurrentStep = 'privacy-mode';
-let mockSelectedMode: string | null = null;
-let mockReadiness: { status: string } = { status: 'ready' };
let mockConfig: Record<string, unknown> = { defaultMode: 'private' };
jest.mock('@/store/useConfigStore', () => ({
useConfigStore: {
@@ -28,18 +25,9 @@ jest.mock('@/store/useProcessingModeStore', () => ({
}));
jest.mock('@/store/useOnboardingStore', () => ({
useOnboardingStore: {
- getState: () => ({
- currentStep: mockCurrentStep,
- selectedMode: mockSelectedMode,
- chooseMode: mockChooseMode,
- }),
+ getState: () => ({ currentStep: mockCurrentStep, chooseMode: mockChooseMode }),
},
}));
-const mockGetReadiness = jest.fn();
-jest.mock('@/lib/localReasoning', () => ({
- ...jest.requireActual('@/lib/localReasoning'),
- getLocalReasoningReadiness: (...args: unknown[]) => mockGetReadiness(...args),
-}));
let mockAccountHistory = false;
jest.mock('@/sync/syncIdentity', () => ({
hasRealAccountHistory: () => mockAccountHistory,
@@ -61,10 +49,6 @@ beforeEach(() => {
mockGuest = false;
mockAccountHistory = false;
mockCurrentStep = 'privacy-mode';
- mockSelectedMode = null;
- mockReadiness = { status: 'ready' };
- mockGetReadiness.mockImplementation(async () => mockReadiness);
- Platform.OS = 'ios';
mockConfig = { defaultMode: 'private' };
mockUpdateConfig.mockResolvedValue(undefined);
mockChooseMode.mockResolvedValue(undefined);
@@ -148,7 +132,7 @@ it('moves the dictation route with the chosen mode and restores both on failure'
);
expect(mockUpdateConfig).toHaveBeenNthCalledWith(1, {
defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
+ inference: { dictation: { mode: 'local' } },
pinnedInference: undefined,
});
expect(mockUpdateConfig).toHaveBeenLastCalledWith({
@@ -158,6 +142,17 @@ it('moves the dictation route with the chosen mode and restores both on failure'
});
});
+// Local Mode cleans On-Device with nothing saved, so setup leaves a cleanup choice as it is.
+it.each([
+ ['cloud', { mode: 'local' }],
+ ['private', { mode: 'openwhispr' }],
+] as const)('keeps a saved cleanup when a replay picks %s', async (mode, cleanup) => {
+ mockUser = { id: 'u', isAnonymous: false };
+ mockConfig = { defaultMode: mode, inference: { dictation: { mode: 'openwhispr' }, cleanup } };
+ await chooseOnboardingMode(mode, 'privacy-mode');
+ expect(mockUpdateConfig.mock.calls[0][0].inference.cleanup).toEqual(cleanup);
+});
+
// A new identity there would read as an account switch and wipe the synced account's notes.
describe('on a device that synced an account, signed out', () => {
beforeEach(() => {
@@ -178,236 +173,3 @@ describe('on a device that synced an account, signed out', () => {
expect(mockChooseMode).toHaveBeenCalledWith('cloud', 'private-download');
});
});
-
-// Private mode skips cleanup with no selection of its own, which nobody choosing it in setup
-// would know to go save.
-describe('cleanup', () => {
- it.each(['ready', 'appleIntelligenceOff', 'modelNotReady'])(
- 'saves On-Device cleanup with Private mode (Apple Intelligence %s)',
- async (status) => {
- mockReadiness = { status };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
- });
- },
- );
-
- it('saves it from the download step too', async () => {
- mockCurrentStep = 'private-download';
- await chooseOnboardingMode('private', 'private-download');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
- });
- });
-
- it('leaves cleanup unset on an iPhone that can never run Apple Intelligence', async () => {
- mockReadiness = { status: 'unsupportedDevice' };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' } },
- });
- });
-
- // An iOS update may make it run, and readiness that can't be read says nothing either way.
- it.each(['unsupportedOS', 'disabled', 'unavailable'])(
- 'marks On-Device cleanup pending when readiness is %s',
- async (status) => {
- mockReadiness = { status };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' } },
- onDeviceCleanupPending: true,
- });
- },
- );
-
- it('marks nothing pending on Android', async () => {
- Platform.OS = 'android';
- mockReadiness = { status: 'unsupportedOS' };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' } },
- });
- });
-
- it('clears a pending cleanup when Cloud is chosen', async () => {
- mockUser = { id: 'anon', isAnonymous: true };
- mockSelectedMode = 'private';
- mockConfig = { defaultMode: 'private', onDeviceCleanupPending: true };
- await chooseOnboardingMode('cloud', 'privacy-mode');
- const saved = mockUpdateConfig.mock.calls[0][0];
- expect(saved).toHaveProperty('onDeviceCleanupPending', undefined);
- expect(saved.inference).toEqual({ dictation: { mode: 'openwhispr' } });
- expect(mockGetReadiness).not.toHaveBeenCalled();
- });
-
- it('restores a pending cleanup if progress cannot be saved', async () => {
- mockReadiness = { status: 'unsupportedOS' };
- mockConfig = { defaultMode: 'cloud' };
- mockChooseMode.mockRejectedValueOnce(new Error('Keychain unavailable'));
- await expect(chooseOnboardingMode('private', 'privacy-mode')).rejects.toThrow('Keychain');
- expect(mockUpdateConfig.mock.calls.at(-1)?.[0]).toHaveProperty(
- 'onDeviceCleanupPending',
- undefined,
- );
- });
-
- it('keeps a pending cleanup marked if progress cannot be saved', async () => {
- mockConfig = { defaultMode: 'private', onDeviceCleanupPending: true };
- mockChooseMode.mockRejectedValueOnce(new Error('Keychain unavailable'));
- await expect(chooseOnboardingMode('private', 'privacy-mode')).rejects.toThrow('Keychain');
- expect(mockUpdateConfig.mock.calls[0][0]).toHaveProperty('onDeviceCleanupPending', undefined);
- expect(mockUpdateConfig.mock.calls.at(-1)?.[0]).toHaveProperty('onDeviceCleanupPending', true);
- });
-
- // Private mode never runs Cloud cleanup, so a saved one gives way as if nothing were saved.
- it('saves On-Device cleanup over a saved Cloud cleanup', async () => {
- mockConfig = { defaultMode: 'cloud', inference: { cleanup: { mode: 'openwhispr' } } };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
- });
- });
-
- it.each(['unsupportedDevice', 'unsupportedOS'])(
- 'keeps a saved Cloud cleanup, with nothing pending, when readiness is %s',
- async (status) => {
- mockReadiness = { status };
- mockConfig = { defaultMode: 'cloud', inference: { cleanup: { mode: 'openwhispr' } } };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'openwhispr' } },
- });
- },
- );
-
- it('keeps a cleanup selection already saved', async () => {
- const provider = { mode: 'providers', providerId: 'groq', modelId: 'llama' };
- mockConfig = { defaultMode: 'cloud', inference: { cleanup: provider } };
- await chooseOnboardingMode('private', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: provider },
- });
- });
-
- it('drops the On-Device cleanup an earlier Private choice saved when Cloud is chosen', async () => {
- mockUser = { id: 'anon', isAnonymous: true };
- mockSelectedMode = 'private';
- mockConfig = {
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
- };
- await chooseOnboardingMode('cloud', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'cloud',
- inference: { dictation: { mode: 'openwhispr' } },
- });
- });
-
- it.each([
- ['On-Device saved before this setup', null, { mode: 'local' }],
- ['a picked On-Device model', 'private', { mode: 'local', modelId: 'apple' }],
- ['a provider', 'private', { mode: 'providers', providerId: 'groq' }],
- ])('keeps %s when Cloud is chosen', async (_label, selectedMode, cleanup) => {
- mockUser = { id: 'anon', isAnonymous: true };
- mockSelectedMode = selectedMode;
- mockConfig = { defaultMode: 'private', inference: { cleanup } };
- await chooseOnboardingMode('cloud', 'privacy-mode');
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- defaultMode: 'cloud',
- inference: { dictation: { mode: 'openwhispr' }, cleanup },
- });
- });
-});
-
-// Setup couldn't save On-Device cleanup on an older iOS; a later launch saves it once it can.
-describe('applyPendingOnDeviceCleanup', () => {
- beforeEach(() => {
- mockConfig = {
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, notes: { mode: 'openwhispr' } },
- onDeviceCleanupPending: true,
- };
- });
-
- it('saves On-Device cleanup once Apple Intelligence can run', async () => {
- await applyPendingOnDeviceCleanup();
- expect(mockGetReadiness).toHaveBeenCalledWith({ refresh: true });
- expect(mockUpdateConfig).toHaveBeenCalledWith({
- onDeviceCleanupPending: undefined,
- inference: {
- dictation: { mode: 'local' },
- notes: { mode: 'openwhispr' },
- cleanup: { mode: 'local' },
- },
- });
- });
-
- it.each(['unsupportedOS', 'disabled', 'unavailable'])(
- 'keeps waiting while readiness is %s',
- async (status) => {
- mockReadiness = { status };
- await applyPendingOnDeviceCleanup();
- expect(mockUpdateConfig).not.toHaveBeenCalled();
- },
- );
-
- // An older iOS can't tell an iPhone that will never run Apple Intelligence; once updated it can.
- it('stops waiting once this iPhone turns out never to run Apple Intelligence', async () => {
- mockReadiness = { status: 'unsupportedDevice' };
- await applyPendingOnDeviceCleanup();
- expect(mockUpdateConfig).toHaveBeenCalledTimes(1);
- expect(mockUpdateConfig).toHaveBeenCalledWith({ onDeviceCleanupPending: undefined });
- });
-
- it('does nothing without a pending cleanup', async () => {
- mockConfig = { defaultMode: 'private' };
- await applyPendingOnDeviceCleanup();
- expect(mockGetReadiness).not.toHaveBeenCalled();
- expect(mockUpdateConfig).not.toHaveBeenCalled();
- });
-
- // Unset cleanup outside Private mode runs on Cloud; coming back to Private mode applies it.
- it('waits while Private mode is off', async () => {
- mockConfig = { ...mockConfig, defaultMode: 'cloud' };
- await applyPendingOnDeviceCleanup();
- expect(mockGetReadiness).not.toHaveBeenCalled();
- expect(mockUpdateConfig).not.toHaveBeenCalled();
- });
-
- it('only clears the flag once cleanup was set some other way', async () => {
- const provider = { mode: 'providers', providerId: 'groq' };
- mockConfig = { ...mockConfig, inference: { cleanup: provider } };
- await applyPendingOnDeviceCleanup();
- expect(mockGetReadiness).not.toHaveBeenCalled();
- expect(mockUpdateConfig).toHaveBeenCalledWith({ onDeviceCleanupPending: undefined });
- });
-
- it('keeps a cleanup choice saved while readiness was being read', async () => {
- const provider = { mode: 'providers', providerId: 'groq' };
- mockGetReadiness.mockImplementationOnce(async () => {
- mockConfig = { ...mockConfig, inference: { cleanup: provider } };
- return { status: 'ready' };
- });
- await applyPendingOnDeviceCleanup();
- expect(mockUpdateConfig).toHaveBeenCalledWith({ onDeviceCleanupPending: undefined });
- });
-
- it('saves nothing if Private mode was turned off while readiness was being read', async () => {
- mockGetReadiness.mockImplementationOnce(async () => {
- mockConfig = { ...mockConfig, defaultMode: 'cloud' };
- return { status: 'ready' };
- });
- await applyPendingOnDeviceCleanup();
- expect(mockUpdateConfig).not.toHaveBeenCalled();
- });
-});
diff --git a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts
index bdc74ba39..eb3dea242 100644
--- a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts
@@ -1,7 +1,8 @@
/**
- * A transcript made on this phone is cleaned by Apple Intelligence when the user chose
- * On-Device cleanup, or by the provider they saved for cleanup with their own key. Cloud
- * or no choice would send it off the device unasked, so the raw transcript is kept.
+ * A transcript made on this phone is cleaned by Apple Intelligence in Local Mode, or wherever
+ * the user chose On-Device cleanup, or by the provider they saved for cleanup with their own
+ * key. Outside Local Mode, Cloud or no choice would send it off the device unasked, so the raw
+ * transcript is kept.
*/
import { TranscriptionService } from '@/services/transcription/TranscriptionService';
import { transcribeAndCleanup } from '@/lib/transcribeAndCleanup';
@@ -39,8 +40,9 @@ jest.mock('@/lib/localReasoning', () => ({
jest.mock('@/lib/permissions', () => ({
isNoSpeechError: jest.fn(() => false),
}));
+let mockUser: { id: string; isAnonymous: boolean } | null = { id: 'u', isAnonymous: false };
jest.mock('@/store/useAuthStore', () => ({
- useAuthStore: { getState: () => ({ user: { id: 'u', isAnonymous: false } }) },
+ useAuthStore: { getState: () => ({ user: mockUser }) },
}));
jest.mock('@/store/useConfigStore', () => ({
useConfigStore: { getState: () => ({ config: mockConfig }) },
@@ -79,6 +81,7 @@ function transcribeOnDevice(
beforeEach(() => {
jest.clearAllMocks();
mockActiveMode = 'private';
+ mockUser = { id: 'u', isAnonymous: false };
mockConfig = {
cleanupEnabled: true,
defaultMode: 'private',
@@ -124,22 +127,26 @@ it('cleans an On-Device upload on this phone outside On-Device mode too', async
expect(result.text).toBe('cleaned:um hello there');
});
-it('cleans an On-Device transcript with the provider saved for cleanup', async () => {
+const OPENAI_CLEANUP = {
+ mode: 'providers',
+ providerId: 'openai',
+ modelId: 'gpt-5-mini',
+ credentialRef: 'provider.openai',
+};
+
+it('sends an On-Device upload outside Local Mode to the provider saved for cleanup', async () => {
+ mockActiveMode = 'cloud';
mockConfig = {
cleanupEnabled: true,
- defaultMode: 'private',
- inference: {
- dictation: { mode: 'local' },
- cleanup: {
- mode: 'providers',
- providerId: 'openai',
- modelId: 'gpt-5-mini',
- credentialRef: 'provider.openai',
- },
- },
+ defaultMode: 'cloud',
+ inference: { upload: { mode: 'local' }, cleanup: OPENAI_CLEANUP },
};
- const result = await transcribeOnDevice();
+ const result = await transcribeAndCleanup({
+ audioUri: 'file://a.wav',
+ provider: 'local',
+ requestContext: 'file',
+ });
expect(mockReason).toHaveBeenCalledTimes(1);
const req = mockReason.mock.calls[0][0] as Record<string, unknown>;
@@ -155,10 +162,12 @@ it('cleans an On-Device transcript with the provider saved for cleanup', async (
expect(result.cleanupApplied).toBe(true);
});
+// Local Mode keeps dictation on this phone; cleanup runs what is saved for it.
it.each([
- ['OpenWhispr Cloud', { mode: 'openwhispr' }],
- ['nothing saved', undefined],
-])('keeps an On-Device transcript raw when cleanup is set to %s', async (_label, cleanup) => {
+ ['OpenWhispr Cloud', { mode: 'openwhispr' }, { mode: 'openwhispr', scope: 'cleanup' }],
+ ['a provider', OPENAI_CLEANUP, { mode: 'providers', scope: 'cleanup', providerId: 'openai' }],
+ ['nothing, signed in', undefined, { mode: 'openwhispr', scope: 'cleanup' }],
+])('cleans a Local Mode dictation with %s saved for cleanup', async (_label, cleanup, route) => {
mockConfig = {
cleanupEnabled: true,
defaultMode: 'private',
@@ -167,10 +176,48 @@ it.each([
const result = await transcribeOnDevice();
+ expect(mockReason).toHaveBeenCalledTimes(1);
+ expect((mockReason.mock.calls[0][0] as Record<string, unknown>).inferenceRoute).toMatchObject(
+ route,
+ );
+ expect(result.text).toBe('cleaned:um hello there');
+});
+
+// A separate Cloud pass needs a signed-in account, so an anonymous session cleans on this phone.
+it('cleans a Local Mode dictation on this phone with nothing saved and no account', async () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = {
+ cleanupEnabled: true,
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' } },
+ };
+
+ const result = await transcribeOnDevice();
+
+ expect((mockReason.mock.calls[0][0] as Record<string, unknown>).inferenceRoute).toEqual({
+ mode: 'local',
+ scope: 'cleanup',
+ });
+ expect(result.text).toBe('cleaned:um hello there');
+});
+
+it('keeps an On-Device upload raw outside Local Mode with nothing saved for cleanup', async () => {
+ mockActiveMode = 'cloud';
+ mockConfig = {
+ cleanupEnabled: true,
+ defaultMode: 'cloud',
+ inference: { upload: { mode: 'local' } },
+ };
+
+ const result = await transcribeAndCleanup({
+ audioUri: 'file://a.wav',
+ provider: 'local',
+ requestContext: 'file',
+ });
+
expect(mockReason).not.toHaveBeenCalled();
expect(result.text).toBe('um hello there');
expect(result.cleanupApplied).toBe(false);
- expect(result.transcription.cleanupWarning).toBeUndefined();
});
it('keeps an On-Device transcript raw when cleanup is turned off', async () => {
@@ -200,6 +247,77 @@ it.each([
expect(result.transcription.cleanupWarning).toBe(`${reason} Your raw transcript is saved.`);
});
+// Nobody chose On-Device cleanup here, and AI Models already says it is skipped.
+describe('in Local Mode with nothing of its own saved for cleanup', () => {
+ beforeEach(() => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = {
+ cleanupEnabled: true,
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' } },
+ };
+ });
+
+ it.each(['unsupportedDevice', 'unsupportedOS', 'disabled', 'appleIntelligenceOff'])(
+ 'skips cleanup quietly when readiness is %s',
+ async (status) => {
+ mockReadiness.mockResolvedValue({ status, tokenCounting: false });
+ const onStage = jest.fn();
+
+ const result = await transcribeOnDevice({ onStage });
+
+ expect(mockReason).not.toHaveBeenCalled();
+ expect(onStage).not.toHaveBeenCalledWith('cleaning', expect.anything());
+ expect(result.text).toBe('um hello there');
+ expect(result.transcription.cleanupWarning).toBeUndefined();
+ },
+ );
+
+ // The launch upgrade holds cleanup On-Device for a config from before Local Mode's Cloud
+ // defaults (localModeUpgradeConfig); the user still never chose it.
+ it('skips quietly when Local Mode holds cleanup On-Device automatically', async () => {
+ mockConfig = {
+ ...mockConfig,
+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
+ pinnedInference: ['cleanup'],
+ };
+ mockReadiness.mockResolvedValue({ status: 'unsupportedDevice', tokenCounting: false });
+
+ const result = await transcribeOnDevice();
+
+ expect(mockReason).not.toHaveBeenCalled();
+ expect(result.transcription.cleanupWarning).toBeUndefined();
+ });
+
+ it('cleans once a fresh readiness check finds Apple Intelligence ready', async () => {
+ mockReadiness
+ .mockResolvedValueOnce({ status: 'appleIntelligenceOff', tokenCounting: false })
+ .mockResolvedValue({ status: 'ready', tokenCounting: true });
+
+ const result = await transcribeOnDevice();
+
+ expect(mockReadiness).toHaveBeenCalledWith({ refresh: true });
+ expect(result.text).toBe('cleaned:um hello there');
+ });
+});
+
+// Cleaning a dictation made on this phone with Cloud is a separate pass that refuses anonymous
+// sessions, so it is never attempted, and AI Models says why (workflowSummary).
+it('keeps a Local Mode dictation raw, without a warning, for Cloud cleanup and no account', async () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = {
+ cleanupEnabled: true,
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'openwhispr' } },
+ };
+
+ const result = await transcribeOnDevice();
+
+ expect(mockReason).not.toHaveBeenCalled();
+ expect(result.text).toBe('um hello there');
+ expect(result.transcription.cleanupWarning).toBeUndefined();
+});
+
it('checks readiness again before refusing, so a fix in iOS Settings takes effect', async () => {
mockReadiness
.mockResolvedValueOnce({ status: 'appleIntelligenceOff', tokenCounting: false })
diff --git a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
index 8d2eab2c7..961964f6a 100644
--- a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
@@ -184,14 +184,14 @@ describe('transcribeAndCleanup tone', () => {
// Tones are a Cloud cleanup option, so a tone picked before Private mode never reaches its
// cleanup, and On-Device cleanup never gets one.
it.each([
- ['a cleanup provider in Private mode', 'private', PROVIDER_ROUTE],
+ ['a cleanup provider in Local Mode', 'private', PROVIDER_ROUTE],
[
- 'On-Device cleanup in Private mode',
+ 'On-Device cleanup in Local Mode',
'private',
{ mode: 'local' as const, scope: 'cleanup' as const },
],
[
- 'On-Device cleanup outside Private mode',
+ 'On-Device cleanup outside Local Mode',
'cloud',
{ mode: 'local' as const, scope: 'cleanup' as const },
],
@@ -214,7 +214,7 @@ describe('transcribeAndCleanup tone', () => {
);
});
- it('passes the tone to a cleanup provider outside Private mode', async () => {
+ it('passes the tone to a cleanup provider outside Local Mode', async () => {
mockActiveMode = 'providers';
await transcribeAndCleanup({
diff --git a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts
index 8f57f2eaf..726c1dcaa 100644
--- a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts
@@ -8,8 +8,6 @@ const mockLocalReasoningReadiness = jest.fn();
let mockConfig: Record<string, unknown> | null = null;
let mockUser: Record<string, unknown> | null = { id: 'user-1' };
let mockActiveMode = 'cloud';
-const mockPolicy = jest.fn();
-const mockKeyStatus = jest.fn();
jest.mock('expo-router', () => ({ router: { push: (...args: unknown[]) => mockPush(...args) } }));
jest.mock('@/store/useConfigStore', () => ({
@@ -33,14 +31,8 @@ jest.mock('@/lib/localReasoning', () => ({
getLocalReasoningReadiness: () => mockLocalReasoningReadiness(),
getLocalReasoningUnavailableMessage: () => 'Apple Intelligence is turned off.',
}));
-jest.mock('@/services/providers/ProviderPolicy', () => ({
- getProviderPolicy: () => mockPolicy(),
-}));
-jest.mock('@/services/providers/ProviderCredentials', () => ({
- getProviderCredentialStatus: (reference: string) => mockKeyStatus(reference),
-}));
-import { pickLocalModel, setPrivateMode, switchWorkflowMode } from '../workflowModeSwitch';
+import { pickLocalModel, switchWorkflowMode } from '../workflowModeSwitch';
let alert: jest.SpyInstance;
@@ -52,38 +44,40 @@ beforeEach(() => {
mockPrivateReadiness.mockResolvedValue({ status: 'ready', modelName: 'Parakeet v2' });
mockLocalReasoningReadiness.mockResolvedValue({ status: 'ready', tokenCounting: false });
alert = jest.spyOn(Alert, 'alert').mockImplementation(() => undefined);
- mockPolicy.mockResolvedValue({ status: 'unmanaged' });
- mockKeyStatus.mockImplementation(async (reference: string) => ({
- reference,
- isConfigured: true,
- }));
});
-const OPENAI = {
- mode: 'providers',
- providerId: 'openai',
- modelId: 'gpt-4o-transcribe',
- credentialRef: 'provider.openai',
-} as const;
-const GROQ = {
- mode: 'providers',
- providerId: 'groq',
- modelId: 'whisper-large-v3',
- credentialRef: 'provider.groq',
-} as const;
-
it('asks a signed-out user to sign in before switching to Cloud', async () => {
mockUser = null;
mockConfig = { defaultMode: 'private' };
await expect(switchWorkflowMode('cleanup', 'openwhispr')).resolves.toBe('refused');
expect(alert).toHaveBeenCalledWith(
'Sign in required',
- 'Sign in to use cloud AI with cloud processing, or turn on Private Mode in Account → AI Models.',
+ 'Sign in to use cloud AI with cloud processing, or set Dictation to On-Device in Account → AI Models.',
expect.any(Array),
);
expect(mockUpdateConfig).not.toHaveBeenCalled();
});
+// Local Mode dictates on this phone, so Cloud cleanup is a separate pass that needs an account.
+it('asks an anonymous user to create an account before Cloud cleanup in Local Mode', async () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockActiveMode = 'private';
+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
+ await expect(switchWorkflowMode('cleanup', 'openwhispr')).resolves.toBe('refused');
+ expect(alert).toHaveBeenCalledWith(
+ 'Create an account',
+ 'Create an account to use cloud cleanup with cloud processing.',
+ expect.any(Array),
+ );
+ expect(mockUpdateConfig).not.toHaveBeenCalled();
+});
+
+it('lets an anonymous user pick Cloud cleanup outside Local Mode, where Cloud dictates', async () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ await expect(switchWorkflowMode('cleanup', 'openwhispr')).resolves.toBe('switched');
+ expect(alert).not.toHaveBeenCalled();
+});
+
it('switches dictation to On-Device along with the app mode', async () => {
await expect(switchWorkflowMode('dictation', 'local')).resolves.toBe('switched');
expect(mockSetActiveMode).toHaveBeenCalledWith('private', true);
@@ -185,9 +179,10 @@ describe('a workflow held on its old mode when dictation moved to your own key',
});
});
-describe('setPrivateMode', () => {
- it('turns on by switching dictation, and with it the app, to On-Device', async () => {
- await expect(setPrivateMode(true)).resolves.toBe('switched');
+// Dictation owns the app mode: On-Device turns Local Mode on, OpenWhispr Cloud turns it off.
+describe('switching dictation', () => {
+ it('to On-Device turns Local Mode on', async () => {
+ await expect(switchWorkflowMode('dictation', 'local')).resolves.toBe('switched');
expect(mockSetActiveMode).toHaveBeenCalledWith('private', true);
expect(mockUpdateConfig).toHaveBeenCalledWith({
defaultMode: 'private',
@@ -195,16 +190,10 @@ describe('setPrivateMode', () => {
});
});
- it('opens the model list instead of turning on when no model is downloaded', async () => {
- mockPrivateReadiness.mockResolvedValue({ status: 'missing', modelName: 'Parakeet v2' });
- await expect(setPrivateMode(true)).resolves.toBe('needs-model');
- expect(mockPush).toHaveBeenCalledWith('/(account)/model-download');
- expect(mockSetActiveMode).not.toHaveBeenCalled();
- });
-
- it('turns off by switching dictation back to Cloud', async () => {
+ it('to OpenWhispr Cloud turns Local Mode off', async () => {
+ mockActiveMode = 'private';
mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
- await expect(setPrivateMode(false)).resolves.toBe('switched');
+ await expect(switchWorkflowMode('dictation', 'openwhispr')).resolves.toBe('switched');
expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);
expect(mockUpdateConfig).toHaveBeenCalledWith({
defaultMode: 'cloud',
@@ -212,160 +201,22 @@ describe('setPrivateMode', () => {
});
});
- it('remembers Bring Your Own Key, and what it held, when turned on from it', async () => {
- mockActiveMode = 'providers';
- mockConfig = {
- defaultMode: 'providers',
- inference: { dictation: OPENAI, upload: { mode: 'openwhispr' } },
- pinnedInference: ['upload'],
- };
- await expect(setPrivateMode(true)).resolves.toBe('switched');
- expect(mockUpdateConfig).toHaveBeenCalledWith(
- expect.objectContaining({
- defaultMode: 'private',
- privateModeReturn: { pinned: { upload: { mode: 'openwhispr' } } },
- }),
- );
- });
-
- // Turning it off must not send audio to Cloud for someone who was using their own key.
- it('turns off into the last provider used when it was turned on from Bring Your Own Key', async () => {
- mockActiveMode = 'private';
- mockConfig = {
- defaultMode: 'private',
- privateModeReturn: {
- pinned: { upload: { mode: 'openwhispr' }, notes: { mode: 'openwhispr' } },
- },
- inference: { dictation: { mode: 'local' } },
- rememberedInference: {
- dictation: {
- local: { mode: 'local', modelId: 'whisper-base' },
- groq: GROQ,
- openai: OPENAI,
- },
- },
- };
- await expect(setPrivateMode(false)).resolves.toBe('switched');
- expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);
- const update = mockUpdateConfig.mock.calls[0][0];
- expect(update).toMatchObject({
- defaultMode: 'providers',
- // The provider held these on Cloud before Private mode was turned on, and does again.
- inference: { dictation: GROQ, upload: { mode: 'openwhispr' }, notes: { mode: 'openwhispr' } },
- pinnedInference: ['upload', 'notes'],
- });
- expect(update.inference).not.toHaveProperty('agent');
- expect(update).toHaveProperty('privateModeReturn', undefined);
- });
-
- it('ends a round trip from Bring Your Own Key where it started', async () => {
- const start = {
- defaultMode: 'providers',
- inference: {
- dictation: OPENAI,
- upload: { mode: 'openwhispr' },
- notes: { mode: 'openwhispr' },
- },
- rememberedInference: { dictation: { openai: OPENAI } },
- pinnedInference: ['upload', 'notes'],
- };
- mockActiveMode = 'providers';
- mockConfig = start;
- await setPrivateMode(true);
- const on = { ...start, ...mockUpdateConfig.mock.calls[0][0] };
- expect(on.inference).toEqual({ dictation: { mode: 'local' } });
-
- mockActiveMode = 'private';
- mockConfig = on;
- await setPrivateMode(false);
- const off = { ...on, ...mockUpdateConfig.mock.calls[1][0] };
- expect(off).toMatchObject({
- defaultMode: 'providers',
- inference: start.inference,
- pinnedInference: start.pinnedInference,
- });
- expect(off.privateModeReturn).toBeUndefined();
- });
-
+ // Local Mode cleans On-Device whatever is saved for cleanup, so switching leaves the user's
+ // cleanup choice as it is.
it.each([
- ['its key was removed', () => mockKeyStatus.mockResolvedValue({ isConfigured: false })],
- [
- 'the organization no longer allows it',
- () =>
- mockPolicy.mockResolvedValue({
- status: 'managed',
- transcription: { allowedModes: ['openwhispr', 'local'], allowedByokProviders: [] },
- llm: { allowedModes: ['openwhispr', 'local'], allowedByokProviders: [] },
- }),
- ],
- ])('turns off into Cloud when the provider can no longer run because %s', async (_, setUp) => {
- setUp();
- mockActiveMode = 'private';
+ ['local', { mode: 'local' }],
+ ['local', { mode: 'openwhispr' }],
+ ['local', { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' }],
+ ['openwhispr', { mode: 'local' }],
+ ['openwhispr', { mode: 'openwhispr' }],
+ ] as const)('to %s keeps a saved %j cleanup', async (mode, cleanup) => {
+ const from = mode === 'local' ? 'cloud' : 'private';
+ mockActiveMode = from;
mockConfig = {
- defaultMode: 'private',
- privateModeReturn: { pinned: {} },
- inference: { dictation: { mode: 'local' } },
- rememberedInference: { dictation: { openai: OPENAI } },
+ defaultMode: from,
+ inference: { dictation: { mode: mode === 'local' ? 'openwhispr' : 'local' }, cleanup },
};
- await expect(setPrivateMode(false)).resolves.toBe('switched');
- expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);
- expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({
- defaultMode: 'cloud',
- inference: { dictation: { mode: 'openwhispr' } },
- });
- });
-
- it('still returns to the provider while the organization policy is loading', async () => {
- mockPolicy.mockResolvedValue({ status: 'pending' });
- mockActiveMode = 'private';
- mockConfig = {
- defaultMode: 'private',
- privateModeReturn: { pinned: {} },
- inference: { dictation: { mode: 'local' } },
- rememberedInference: { dictation: { openai: OPENAI } },
- };
- await expect(setPrivateMode(false)).resolves.toBe('switched');
- expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);
- });
-
- // Needs no account, so a guest kept in Private mode can still leave it this way.
- it('turns off into the provider dictation is saved to without signing in', async () => {
- mockUser = null;
- mockActiveMode = 'private';
- mockConfig = { defaultMode: 'providers', inference: { dictation: OPENAI } };
- await expect(setPrivateMode(false)).resolves.toBe('switched');
- expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);
- expect(mockUpdateConfig).toHaveBeenCalledWith(
- expect.objectContaining({
- defaultMode: 'providers',
- inference: expect.objectContaining({ dictation: OPENAI }),
- }),
- );
- expect(alert).not.toHaveBeenCalled();
- });
-
- it('turns off into Cloud, not an old provider, when it was turned on from Cloud', async () => {
- mockActiveMode = 'private';
- mockConfig = {
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' } },
- rememberedInference: { dictation: { openai: OPENAI } },
- };
- await expect(setPrivateMode(false)).resolves.toBe('switched');
- expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);
- });
-
- it('stays on when a signed-out user would need Cloud', async () => {
- mockUser = null;
- mockActiveMode = 'private';
- mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
- await expect(setPrivateMode(false)).resolves.toBe('refused');
- // Private mode is already on, so the sign-in prompt doesn't offer it as the alternative.
- expect(alert).toHaveBeenCalledWith(
- 'Sign in required',
- 'Sign in to use cloud transcription with cloud processing.',
- expect.any(Array),
- );
- expect(mockSetActiveMode).not.toHaveBeenCalled();
+ await expect(switchWorkflowMode('dictation', mode)).resolves.toBe('switched');
+ expect(mockUpdateConfig.mock.calls[0][0].inference.cleanup).toEqual(cleanup);
});
});
diff --git a/openwhispr-mobile/src/lib/accountAccess.ts b/openwhispr-mobile/src/lib/accountAccess.ts
index 88759543e..df6a9cb02 100644
--- a/openwhispr-mobile/src/lib/accountAccess.ts
+++ b/openwhispr-mobile/src/lib/accountAccess.ts
@@ -39,13 +39,13 @@ export function getCloudAccountRequiredMessage(feature: string, anonymous = fals
// Already in Private Mode, which is what turning it off asks Cloud for, so don't offer it back.
return useProcessingModeStore.getState().activeMode === 'private'
? `${action}.`
- : `${action}, or turn on Private Mode in Account → AI Models.`;
+ : `${action}, or set Dictation to On-Device in Account → AI Models.`;
}
// For features with no local model (AI actions, AI chat): Private Mode is not
// an alternative, so don't suggest it as one.
export function getCloudOnlyAccountRequiredMessage(feature: string, anonymous = false): string {
- return `${anonymous ? 'Create an account' : 'Sign in'} to use ${feature}. This feature always uses cloud AI, even in Private Mode.`;
+ return `${anonymous ? 'Create an account' : 'Sign in'} to use ${feature}. This feature always uses cloud AI, even in Local Mode.`;
}
export function showAccountRequiredAlert(feature: string, options?: { cloudOnly?: boolean }): void {
diff --git a/openwhispr-mobile/src/lib/aiWorkflows.ts b/openwhispr-mobile/src/lib/aiWorkflows.ts
index 2205a5af2..de15f1803 100644
--- a/openwhispr-mobile/src/lib/aiWorkflows.ts
+++ b/openwhispr-mobile/src/lib/aiWorkflows.ts
@@ -1,8 +1,9 @@
+import type { AuthUser } from '@/lib/authClient';
import type { InferenceSelection } from '@/lib/mobileProviders';
-import { MODE_LABELS } from '@/lib/inferenceModes';
+import { localModeDefault, MODE_LABELS, type CloudAccess } from '@/lib/inferenceModes';
import { isLocalModelKey, LOCAL_MODEL_TITLES } from '@/lib/localModelCatalog';
import { providerDisplayName, type MobileInferenceScope } from '@/lib/mobileProviders';
-import type { InferenceMode, ProcessingMode, UserConfig } from '@/types';
+import type { ProcessingMode, UserConfig } from '@/types';
export const WORKFLOW_LABELS: Record<MobileInferenceScope, string> = {
dictation: 'Dictation',
@@ -21,62 +22,77 @@ export const UNSET_PROVIDER_NOTES: Partial<Record<MobileInferenceScope, string>>
'Not saved yet. The voice assistant is skipped until you save a selection; note chat uses OpenWhispr Cloud.',
};
-// Private mode skips cleanup until On-Device or a provider is saved for it, so the unset
-// page picks nothing.
-export const UNSET_ON_DEVICE_CLEANUP_NOTE =
- 'Not saved yet. Private Mode skips cleanup until you choose On-Device or Bring Your Own Key.';
+// On-Device cleanup on an iPhone that can never run Apple Intelligence.
+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.";
-// The same, on an iPhone that can never run On-Device cleanup.
-export const UNSET_UNSUPPORTED_CLEANUP_NOTE =
- "Not saved yet. This iPhone can't run On-Device cleanup, so Private Mode skips it until you choose Bring Your Own Key.";
+// Dictation owns Local Mode: On-Device dictation turns it on, and the other modes turn it off.
+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.',
+};
-// What Private mode means for each workflow other than dictation.
+// What Local Mode means for note formatting and chat, which run on this iPhone first.
export const ON_DEVICE_MODE_NOTES: Partial<Record<MobileInferenceScope, string>> = {
- upload: 'Private Mode keeps uploads on this iPhone.',
- notes:
- 'Private Mode formats notes on this iPhone and asks before sending one to your choice here.',
- cleanup:
- 'In Private Mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until Private Mode is off.',
+ notes: 'Local Mode formats notes on this iPhone and asks before sending one to your choice here.',
agent:
- 'In Private Mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
+ 'In Local Mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
};
-// Modes Private mode never runs for a workflow, so its page can't offer them as if they would.
-// Dictation keeps Bring Your Own Key, since saving it leaves Private mode (no account needed).
-// Notes and chat keep every mode: Private mode asks before sending a note to the one chosen.
-export const PRIVATE_MODE_LOCKED: Partial<Record<MobileInferenceScope, InferenceMode[]>> = {
- dictation: ['openwhispr'],
- upload: ['openwhispr', 'providers'],
- cleanup: ['openwhispr'],
-};
+export const PRIVATE_MODE_LOCKED_REASON =
+ 'Off while Local Mode is on. Change Dictation in AI Models to turn it off.';
-export const PRIVATE_MODE_LOCKED_REASON = 'Off while Private Mode is on. Turn it off in AI Models.';
+// Local Mode dictates on this iPhone, so cleaning with OpenWhispr Cloud is a separate Cloud pass,
+// which needs a signed-in account.
+export const CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE =
+ 'In Local Mode, OpenWhispr Cloud cleans transcripts only for a signed-in account, so cleanup is skipped until you sign in.';
-// A local transcript is cleaned on the phone when cleanup is saved as On-Device.
-export function cleanupSavedOnDevice(config: UserConfig | null): boolean {
- return config?.inference?.cleanup?.mode === 'local';
+export function cloudAccessFor(user: AuthUser | null): CloudAccess {
+ if (!user) return 'none';
+ return user.isAnonymous ? 'session' : 'account';
}
-// A local transcript is also cleaned by a provider saved for cleanup, which is the user's
-// consent to send it the text; unset or Cloud would take it off the phone unasked.
-export function cleansLocalTranscripts(config: UserConfig | null): boolean {
- const mode = config?.inference?.cleanup?.mode;
- return mode === 'local' || mode === 'providers';
+// OpenWhispr Cloud is saved for cleanup in Local Mode without an account to run it, so it is skipped
+// (snapshotTextInference). Unset cleanup only defaults to Cloud with an account (unsetSelection).
+export function cloudCleanupNeedsAccount(
+ config: UserConfig | null,
+ activeMode: ProcessingMode,
+ cloudAccess: CloudAccess,
+): boolean {
+ return (
+ activeMode === 'private' &&
+ config?.inference?.cleanup?.mode === 'openwhispr' &&
+ cloudAccess !== 'account'
+ );
+}
+
+// Cleanup runs On-Device when it is saved as On-Device, or in Local Mode when nothing is saved and
+// OpenWhispr Cloud can't clean (unsetSelection).
+export function cleanupRunsOnDevice(
+ config: UserConfig | null,
+ activeMode: ProcessingMode,
+ cloudAccess: CloudAccess = 'none',
+): boolean {
+ return (
+ (config?.inference?.cleanup ?? unsetSelection('cleanup', activeMode, cloudAccess)).mode ===
+ 'local'
+ );
}
export function parseWorkflow(value: unknown): MobileInferenceScope | null {
return WORKFLOWS.find((scope) => scope === value) ?? null;
}
-// What a workflow with no saved selection runs: On-Device mode keeps everything
-// local except note chat, which 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 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.
export function unsetSelection(
scope: MobileInferenceScope,
activeMode: ProcessingMode,
+ cloudAccess: CloudAccess = 'none',
): InferenceSelection {
- if (activeMode === 'private')
- return scope === 'agent' ? { mode: 'openwhispr' } : { mode: 'local' };
+ if (activeMode === 'private') return { mode: localModeDefault(scope, cloudAccess) };
if (activeMode === 'providers' && (scope === 'dictation' || UNSET_PROVIDER_NOTES[scope]))
return { mode: 'providers' };
return { mode: 'openwhispr' };
@@ -89,29 +105,29 @@ export function workflowSummary(
{
keyMissing = false,
onDeviceUnavailable,
+ cloudAccess = 'none',
}: {
keyMissing?: boolean;
// Why Apple Intelligence can't run right now, when it can't.
onDeviceUnavailable?: string;
+ cloudAccess?: CloudAccess;
} = {},
): string {
if (scope === 'cleanup') {
if (!(config?.cleanupEnabled ?? true)) return 'Off';
- if (cleanupSavedOnDevice(config) && onDeviceUnavailable)
- return `${MODE_LABELS.local} · ${onDeviceUnavailable}`;
- }
- // On-Device mode runs everything on this phone first, whatever is saved. Cleanup runs
- // only when set to On-Device or a provider, and only note chat set to OpenWhispr, or
- // not set, goes straight to Cloud.
- if (activeMode === 'private') {
- if (scope === 'cleanup' && !cleansLocalTranscripts(config)) return 'Skipped';
- const chatOnCloud = (config?.inference?.agent?.mode ?? 'openwhispr') === 'openwhispr';
- if (scope === 'agent' && chatOnCloud) return MODE_LABELS.openwhispr;
+ if (cleanupRunsOnDevice(config, activeMode, cloudAccess) && onDeviceUnavailable)
+ return `Skipped · ${onDeviceUnavailable}`;
+ if (cloudCleanupNeedsAccount(config, activeMode, cloudAccess)) return 'Skipped · Sign in';
}
- const selection = config?.inference?.[scope] ?? unsetSelection(scope, activeMode);
+ const selection = config?.inference?.[scope] ?? unsetSelection(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.
+ if (activeMode === 'private' && scope === 'agent' && selection.mode === 'openwhispr')
+ return MODE_LABELS.openwhispr;
if (selection.mode === 'local' && isLocalModelKey(selection.modelId))
return LOCAL_MODEL_TITLES[selection.modelId];
- if (activeMode === 'private' && !(scope === 'cleanup' && selection.mode === 'providers'))
+ if (activeMode === 'private' && scope !== 'upload' && scope !== 'cleanup')
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/inferenceModes.ts b/openwhispr-mobile/src/lib/inferenceModes.ts
index c0dc8621b..5ff33c72a 100644
--- a/openwhispr-mobile/src/lib/inferenceModes.ts
+++ b/openwhispr-mobile/src/lib/inferenceModes.ts
@@ -60,6 +60,24 @@ export const MODE_LABELS: Record<InferenceMode, string> = {
local: 'On-Device',
};
+// What a user can do on OpenWhispr Cloud, by the rules in accountAccess: any session transcribes
+// there, but a separate Cloud pass over text, such as cleaning a transcript made on this iPhone,
+// 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.
+export function localModeDefault(
+ scope: MobileInferenceScope,
+ cloudAccess: CloudAccess,
+): InferenceMode {
+ const onCloud =
+ scope === 'agent' ||
+ (scope === 'upload' && cloudAccess !== 'none') ||
+ (scope === 'cleanup' && cloudAccess === 'account');
+ return onCloud ? 'openwhispr' : 'local';
+}
+
type DictationModeConfig = Pick<
UserConfig,
'defaultMode' | 'inference' | 'pinnedInference' | 'privateModeReturn'
@@ -73,15 +91,17 @@ function scopesToPin(leavingMode: ProcessingMode): MobileInferenceScope[] {
return leavingMode === 'private' ? ['upload', 'notes', 'agent'] : ['upload', 'notes'];
}
-// The Private Mode switch and the Dictation page both own the dictation mode;
+// The Dictation page and onboarding own the dictation mode;
// writing the scope selection alongside defaultMode keeps routing and UI in step.
export function dictationModeConfig(
config: UserConfig | null,
mode: 'cloud' | 'private',
): DictationModeConfig {
- // Leaving Bring Your Own Key releases the automatic pins, so those workflows follow the
- // Cloud/On-Device choice again; selections the user saved themselves stay.
- const pinned = config?.pinnedInference ?? [];
+ // Changing the mode releases the automatic pins, so those workflows follow the Cloud/On-Device
+ // choice again; selections the user saved themselves stay. Picking another on-device model, or
+ // replaying the same choice in onboarding, keeps them.
+ const modeChanged = config?.defaultMode !== mode;
+ const pinned = modeChanged ? (config?.pinnedInference ?? []) : [];
const inference = Object.fromEntries(
Object.entries(config?.inference ?? {}).filter(
([scope]) => !pinned.includes(scope as MobileInferenceScope),
@@ -97,7 +117,7 @@ export function dictationModeConfig(
? (config?.rememberedInference?.dictation?.local ?? { mode: 'local' })
: { mode: 'openwhispr' },
},
- ...(config?.pinnedInference ? { pinnedInference: undefined } : {}),
+ ...(modeChanged && config?.pinnedInference ? { pinnedInference: undefined } : {}),
// Only a switch from Bring Your Own Key sets where Private mode returns to (workflowSaveConfig).
...(config?.privateModeReturn ? { privateModeReturn: undefined } : {}),
};
@@ -107,27 +127,37 @@ function providerDictationConfig(
config: UserConfig | null,
dictation: InferenceSelection,
leavingMode: ProcessingMode,
+ cloudAccess: CloudAccess,
): DictationModeConfig {
const inference = { ...config?.inference, dictation };
const pinnedInference = [...(config?.pinnedInference ?? [])];
// Leaving Private mode for the provider it was turned on from holds what that provider held,
- // so the round trip ends where it started.
+ // so the round trip ends where it started, even over a workflow Local Mode held automatically.
+ const returning = leavingMode === 'private' && !!config?.privateModeReturn;
const pins: [MobileInferenceScope, InferenceSelection][] =
leavingMode === 'providers'
? []
- : leavingMode === 'private' && config?.privateModeReturn
- ? (Object.entries(config.privateModeReturn.pinned) as [
+ : returning
+ ? (Object.entries(config?.privateModeReturn?.pinned ?? {}) as [
MobileInferenceScope,
InferenceSelection,
][])
: scopesToPin(leavingMode).map((scope) => [
scope,
- { mode: processingToInferenceMode(leavingMode) },
+ {
+ // Each holds what ran in the mode being left: uploads in Local Mode ran on
+ // OpenWhispr Cloud when there was a session.
+ mode:
+ leavingMode === 'private' && scope === 'upload'
+ ? localModeDefault(scope, cloudAccess)
+ : processingToInferenceMode(leavingMode),
+ },
]);
for (const [scope, selection] of pins) {
- if (inference[scope]) continue;
+ const heldAutomatically = pinnedInference.includes(scope);
+ if (inference[scope] && !(returning && heldAutomatically)) continue;
inference[scope] = selection;
- pinnedInference.push(scope);
+ if (!heldAutomatically) pinnedInference.push(scope);
}
return {
defaultMode: 'providers',
@@ -148,12 +178,14 @@ function pinnedSelections(
);
}
-// The config a workflow page writes when the user saves `selection` for `scope`.
+// The config a workflow page writes when the user saves `selection` for `scope`. `cloudAccess` is
+// what the user has on OpenWhispr Cloud, which decides what ran for uploads in Local Mode.
export function workflowSaveConfig(
config: UserConfig | null,
scope: MobileInferenceScope,
selection: InferenceSelection,
activeMode: ProcessingMode,
+ cloudAccess: CloudAccess = 'none',
): Partial<UserConfig> {
const { providerId } = selection;
const otherProviders = Object.fromEntries(
@@ -182,7 +214,7 @@ export function workflowSaveConfig(
return {
...rememberedInference,
...(mode === 'providers'
- ? providerDictationConfig(config, selection, activeMode)
+ ? providerDictationConfig(config, selection, activeMode, cloudAccess)
: dictationModeConfig(config, mode)),
...(privateModeReturn || config?.privateModeReturn ? { privateModeReturn } : {}),
};
@@ -195,3 +227,20 @@ export function workflowSaveConfig(
: {}),
};
}
+
+// Before Local Mode used OpenWhispr Cloud for uploads and cleanup with nothing saved, it kept both
+// on this iPhone and ignored a Cloud choice saved for them. A config from then that is in Local
+// Mode holds both there as automatic pins, released like any other when the mode changes, so the
+// upgrade sends nothing to Cloud that was never sent before. An On-Device or provider choice stays.
+export function localModeUpgradeConfig(config: UserConfig): Partial<UserConfig> {
+ if (config.defaultMode !== 'private') return { localModeUpgraded: true };
+ const inference = { ...config.inference };
+ const pinnedInference = [...(config.pinnedInference ?? [])];
+ for (const scope of ['upload', 'cleanup'] as const) {
+ const saved = inference[scope];
+ if (saved && saved.mode !== 'openwhispr') continue;
+ inference[scope] = config.rememberedInference?.[scope]?.local ?? { mode: 'local' };
+ if (!pinnedInference.includes(scope)) pinnedInference.push(scope);
+ }
+ return { localModeUpgraded: true, inference, pinnedInference };
+}
diff --git a/openwhispr-mobile/src/lib/inferenceRouting.ts b/openwhispr-mobile/src/lib/inferenceRouting.ts
index 3033f0d5b..ea5061b57 100644
--- a/openwhispr-mobile/src/lib/inferenceRouting.ts
+++ b/openwhispr-mobile/src/lib/inferenceRouting.ts
@@ -9,6 +9,8 @@ import {
} from '@/lib/mobileProviders';
import type { TranscriptionProvider, TranscriptionRequest, TextInferenceSnapshot } from '@/types';
import { isLocalModelKey, type LocalModelKey } from '@/lib/localModelCatalog';
+import { cloudAccessFor, unsetSelection } from '@/lib/aiWorkflows';
+import type { CloudAccess } from '@/lib/inferenceModes';
export type ProviderRoute = Extract<InferenceRoute, { mode: 'providers' }>;
@@ -24,20 +26,28 @@ export function getPickedLocalModel(scope: 'dictation' | 'upload'): LocalModelKe
: undefined;
}
+// Required lazily: the auth store loads the auth client, which routing doesn't otherwise need.
+function currentCloudAccess(): CloudAccess {
+ const { useAuthStore } = require('@/store/useAuthStore') as typeof import('@/store/useAuthStore');
+ return cloudAccessFor(useAuthStore.getState().user);
+}
+
export function getTranscriptionProvider(scope: InferenceScope): TranscriptionProvider {
- if (useProcessingModeStore.getState().activeMode === 'private') return 'local';
- const selection = getInferenceSelection(scope);
+ const { activeMode } = useProcessingModeStore.getState();
+ // Local Mode keeps dictation on this iPhone. Uploads run what is saved for them, or with nothing
+ // saved, OpenWhispr Cloud when there is a session (unsetSelection).
+ if (activeMode === 'private' && scope !== 'upload') return 'local';
+ const selection =
+ getInferenceSelection(scope) ??
+ (activeMode === 'private'
+ ? unsetSelection('upload', activeMode, currentCloudAccess())
+ : undefined);
if (selection?.mode === 'providers') return 'byok';
if (selection?.mode === 'local') return 'local';
// Bring Your Own Key mode without a dictation choice must refuse (see
// snapshotTranscriptionJob), never quietly send the audio to Cloud. Uploads
// without their own choice still follow Cloud.
- if (
- !selection &&
- scope === 'dictation' &&
- useProcessingModeStore.getState().activeMode === 'providers'
- )
- return 'byok';
+ if (!selection && scope === 'dictation' && activeMode === 'providers') return 'byok';
return 'cloud';
}
@@ -94,12 +104,27 @@ export type TranscriptionJobRoute = Pick<TranscriptionRequest, 'provider' | 'inf
export function snapshotTextInference(provider: TranscriptionProvider): TextInferenceSnapshot {
const result: TextInferenceSnapshot = {};
+ const { activeMode } = useProcessingModeStore.getState();
+ const cloudAccess = provider === 'local' ? currentCloudAccess() : 'none';
for (const scope of ['cleanup', 'agent'] as const) {
const routeKey = scope === 'cleanup' ? 'cleanupRoute' : 'agentRoute';
const errorKey = scope === 'cleanup' ? 'cleanupUnavailable' : 'agentUnavailable';
const selection = getInferenceSelection(scope);
- // A local transcript leaves the phone only for a cleanup provider the user saved.
- if (provider === 'local' && !(scope === 'cleanup' && selection?.mode === 'providers')) {
+ // A transcript made on this iPhone leaves it for cleanup only for the mode saved for cleanup,
+ // or in Local Mode with nothing saved, for OpenWhispr Cloud when the account can
+ // (unsetSelection). Cloud cleaning it is a separate pass that needs a signed-in account, so
+ // without one it stays here (cloudCleanupNeedsAccount).
+ const localCleanup =
+ scope === 'cleanup' && !selection && activeMode === 'private'
+ ? unsetSelection('cleanup', activeMode, cloudAccess)
+ : selection;
+ const cleanupMode = localCleanup?.mode ?? 'local';
+ if (
+ provider === 'local' &&
+ (scope === 'agent' ||
+ cleanupMode === 'local' ||
+ (cleanupMode === 'openwhispr' && cloudAccess !== 'account'))
+ ) {
result[routeKey] = { mode: 'local', scope };
} else if (!selection && provider === 'byok') {
result[errorKey] =
diff --git a/openwhispr-mobile/src/lib/onboardingMode.ts b/openwhispr-mobile/src/lib/onboardingMode.ts
index a127562a5..87b13b1a9 100644
--- a/openwhispr-mobile/src/lib/onboardingMode.ts
+++ b/openwhispr-mobile/src/lib/onboardingMode.ts
@@ -1,14 +1,10 @@
-import { Platform } from 'react-native';
import { useAuthStore } from '@/store/useAuthStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useOnboardingStore } from '@/store/useOnboardingStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
import { hasRealAccountHistory } from '@/sync/syncIdentity';
-import type { LocalReasoningReadiness, UserConfig } from '@/types';
-import type { InferenceSelection } from './mobileProviders';
-import { PRIVATE_MODE_LOCKED } from './aiWorkflows';
+import type { UserConfig } from '@/types';
import { dictationModeConfig } from './inferenceModes';
-import { canRunLocalReasoning, getLocalReasoningReadiness } from './localReasoning';
import { OnboardingError } from './onboardingErrors';
// updateConfig reports persistence errors in its store instead of rejecting.
@@ -19,67 +15,6 @@ export async function saveOnboardingConfig(updates: Partial<UserConfig>): Promis
if (error) throw new Error(error);
}
-// Private mode skips cleanup until it has a selection of its own, and nobody choosing Private mode
-// in setup would know to go save one. So setup saves On-Device cleanup on an iPhone that runs
-// Apple Intelligence, even while it's off or still preparing. Where it can't tell yet (an older
-// iOS, which an update may fix, Apple Intelligence turned off in AI Models, or readiness it can't
-// read), it marks cleanup pending for applyPendingOnDeviceCleanup. An iPhone that can never run
-// it, or Android, keeps cleanup unset (skipped). A selection already saved is left alone, unless
-// it is Cloud, which Private mode never runs.
-function onboardingCleanup(
- config: UserConfig | null,
- mode: 'cloud' | 'private',
- readiness: LocalReasoningReadiness | null,
-): { cleanup?: InferenceSelection; pending: boolean } {
- const saved = config?.inference?.cleanup;
- if (mode === 'private') {
- if (saved && !PRIVATE_MODE_LOCKED.cleanup?.includes(saved.mode)) {
- return { cleanup: saved, pending: false };
- }
- if (canRunLocalReasoning(readiness)) return { cleanup: { mode: 'local' }, pending: false };
- return {
- cleanup: saved,
- pending: !saved && Platform.OS === 'ios' && readiness?.status !== 'unsupportedDevice',
- };
- }
- // Back to Cloud after choosing Private mode earlier in setup drops the On-Device cleanup that
- // choice saved, so Cloud dictation gets Cloud cleanup.
- const savedBySetup =
- useOnboardingStore.getState().selectedMode === 'private' &&
- saved?.mode === 'local' &&
- Object.keys(saved).length === 1;
- return { cleanup: savedBySetup ? undefined : saved, pending: false };
-}
-
-// Saves the On-Device cleanup setup couldn't (onDeviceCleanupPending) once a launch finds Apple
-// Intelligence can run, while Private mode is still on and cleanup was never set. Outside Private
-// mode it waits, since unset cleanup there runs on Cloud.
-export async function applyPendingOnDeviceCleanup(): Promise<void> {
- const { config, updateConfig } = useConfigStore.getState();
- if (!config?.onDeviceCleanupPending) return;
- if (config.inference?.cleanup) {
- await updateConfig({ onDeviceCleanupPending: undefined });
- return;
- }
- if (config.defaultMode !== 'private') return;
- // A fresh read: the last one may predate an iOS update.
- const readiness = await getLocalReasoningReadiness({ refresh: true });
- // Updated, and it turns out this iPhone can never run it: nothing is left to wait for.
- if (readiness.status === 'unsupportedDevice') {
- await updateConfig({ onDeviceCleanupPending: undefined });
- return;
- }
- if (!canRunLocalReasoning(readiness)) return;
- const latest = useConfigStore.getState().config;
- if (!latest?.onDeviceCleanupPending || latest.defaultMode !== 'private') return;
- await updateConfig({
- onDeviceCleanupPending: undefined,
- ...(latest.inference?.cleanup
- ? {}
- : { inference: { ...latest.inference, cleanup: { mode: 'local' } } }),
- });
-}
-
export async function chooseOnboardingMode(
mode: 'cloud' | 'private',
from: 'privacy-mode' | 'private-download',
@@ -95,42 +30,27 @@ export async function chooseOnboardingMode(
if (from !== 'private-download')
throw new OnboardingError(
auth.isGuest
- ? 'Cloud needs an account. Use Private Mode for now, or sign in after setup.'
- : 'Cloud needs you signed in. Use Private Mode for now, or sign in after setup.',
+ ? 'Cloud needs an account. Use Local Mode for now, or sign in after setup.'
+ : 'Cloud needs you signed in. Use Local Mode for now, or sign in after setup.',
);
} else {
await auth.ensureAnonymousSession();
if (!useAuthStore.getState().user) {
throw new OnboardingError(
- 'Cloud needs a connection to set up. Try again or use Private Mode for now.',
+ 'Cloud needs a connection to set up. Try again or use Local Mode for now.',
);
}
}
}
- const readiness = mode === 'private' ? await getLocalReasoningReadiness() : null;
if (useOnboardingStore.getState().currentStep !== from) return;
const config = useConfigStore.getState().config ?? null;
const previous = {
defaultMode: config?.defaultMode ?? 'cloud',
inference: config?.inference,
pinnedInference: config?.pinnedInference,
- onDeviceCleanupPending: config?.onDeviceCleanupPending,
};
// The dictation route moves with the mode, so a replayed pick also leaves a Providers route.
- const next = dictationModeConfig(config, mode);
- const inference = { ...next.inference };
- const { cleanup, pending } = onboardingCleanup(config, mode, readiness);
- if (cleanup) inference.cleanup = cleanup;
- else delete inference.cleanup;
- await saveOnboardingConfig({
- ...next,
- inference,
- ...(pending
- ? { onDeviceCleanupPending: true }
- : config?.onDeviceCleanupPending
- ? { onDeviceCleanupPending: undefined }
- : {}),
- });
+ await saveOnboardingConfig(dictationModeConfig(config, mode));
useProcessingModeStore.getState().resetToDefault(mode);
try {
await useOnboardingStore.getState().chooseMode(mode, from);
diff --git a/openwhispr-mobile/src/lib/transcribeAndCleanup.ts b/openwhispr-mobile/src/lib/transcribeAndCleanup.ts
index 8e6b5a393..6743a0563 100644
--- a/openwhispr-mobile/src/lib/transcribeAndCleanup.ts
+++ b/openwhispr-mobile/src/lib/transcribeAndCleanup.ts
@@ -11,7 +11,7 @@ import { getActiveCustomCleanupPrompt } from '@/store/useCustomPromptsStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
import { useSnippetsStore } from '@/store/useSnippetsStore';
import { requiresRealAccount } from './accountAccess';
-import { cleanupSavedOnDevice } from './aiWorkflows';
+import { cleanupRunsOnDevice } from './aiWorkflows';
import { cleanupTranscript, AGENT_ACTION_TIMEOUT_MS } from './cleanupTranscript';
import {
getDictationAgentName,
@@ -20,6 +20,7 @@ import {
} from './dictationAgent';
import { isDictationContext } from './dictationHints';
import { isToneApplicable } from './keyboardTone';
+import { getLocalReasoningReadiness } from './localReasoning';
import { isNoSpeechError } from './permissions';
import { withRetry, type RetryOptions } from './retry';
import { expandSnippets } from './snippets';
@@ -62,16 +63,32 @@ function rawTranscriptResult(transcription: TranscriptionResponse): DictationPro
};
}
-// The pinned route decides where cleanup runs. A local job pins a local one unless the
-// user saved a cleanup provider, which is only pinned from that saved choice; whether
-// On-Device cleanup runs is read live, like cleanupEnabled.
+// The pinned route decides where cleanup runs: a local job pins a local one unless the mode saved
+// for cleanup, or Local Mode's Cloud default, sends it off this iPhone (snapshotTextInference).
+// Whether a pinned On-Device cleanup still runs is read live, like cleanupEnabled.
function cleansLocalTranscript(request: TranscriptionRequest): boolean {
- if (request.cleanupRoute?.mode === 'providers') return true;
- return (
- request.cleanupRoute?.mode === 'local' && cleanupSavedOnDevice(useConfigStore.getState().config)
+ if (!request.cleanupRoute) return false;
+ if (request.cleanupRoute.mode !== 'local') return true;
+ return cleanupRunsOnDevice(
+ useConfigStore.getState().config,
+ useProcessingModeStore.getState().activeMode,
);
}
+// Local Mode cleans On-Device with nothing of its own saved for cleanup: unset, or held there
+// automatically (pinnedInference). When Apple Intelligence can't run, AI Models already says that
+// cleanup is skipped, so it is skipped quietly rather than warning on every transcript the user
+// never asked to clean. The cached readiness outlives a fix in iOS Settings, so it is checked again
+// before skipping.
+async function skipsLocalModeCleanup(request: TranscriptionRequest): Promise<boolean> {
+ if (request.cleanupRoute?.mode !== 'local') return false;
+ const config = useConfigStore.getState().config;
+ if (config?.inference?.cleanup?.mode === 'local' && !config.pinnedInference?.includes('cleanup'))
+ return false;
+ if ((await getLocalReasoningReadiness()).status === 'ready') return false;
+ return (await getLocalReasoningReadiness({ refresh: true })).status !== 'ready';
+}
+
// Tones are a Cloud cleanup option: On-Device cleanup never takes one, and in Private mode the
// keyboard offers none (isToneApplicable), so a tone picked earlier can't rewrite its dictations.
function cleanupToneForRequest(request: TranscriptionRequest): KeyboardTone | undefined {
@@ -195,8 +212,8 @@ async function runSerialTranscribeAndCleanup(
const originalText = transcription.text;
lifecycle.onRawTranscript?.(originalText, transcription);
- // Local/private transcripts leave the device only for the cleanup provider the
- // user saved; otherwise they are cleaned by On-Device cleanup or not at all.
+ // A transcript made on this iPhone leaves it only for the cleanup route pinned for it;
+ // otherwise it is cleaned by On-Device cleanup or not at all.
if (transcription.provider === 'local' && !cleansLocalTranscript(request)) {
return rawTranscriptResult(transcription);
}
@@ -206,6 +223,7 @@ async function runSerialTranscribeAndCleanup(
if (lifecycle.shouldCancel?.()) {
return rawTranscriptResult(transcription);
}
+ if (await skipsLocalModeCleanup(request)) return rawTranscriptResult(transcription);
let cleanupWarning: string | undefined;
lifecycle.onStage?.('cleaning', { fusedCleanup: false });
diff --git a/openwhispr-mobile/src/lib/workflowModeSwitch.ts b/openwhispr-mobile/src/lib/workflowModeSwitch.ts
index 0f7ad1883..7b09aa8fd 100644
--- a/openwhispr-mobile/src/lib/workflowModeSwitch.ts
+++ b/openwhispr-mobile/src/lib/workflowModeSwitch.ts
@@ -3,22 +3,19 @@ import { router } from 'expo-router';
import { useAuthStore } from '@/store/useAuthStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
-import { accountRequiredForCloud, showAccountRequiredAlert } from '@/lib/accountAccess';
+import {
+ accountRequiredForCloud,
+ requiresRealAccount,
+ showAccountRequiredAlert,
+} from '@/lib/accountAccess';
import { workflowSaveConfig } from '@/lib/inferenceModes';
import {
getLocalReasoningReadiness,
getLocalReasoningUnavailableMessage,
} from '@/lib/localReasoning';
import type { LocalModelKey } from '@/lib/localModelCatalog';
-import type { UserConfig } from '@/types';
-import {
- resolveMobileInferenceRoute,
- type InferenceSelection,
- type MobileInferenceScope,
-} from '@/lib/mobileProviders';
+import { type InferenceSelection, type MobileInferenceScope } from '@/lib/mobileProviders';
import { getPrivateModeReadiness, getPrivateModeUnavailableMessage } from '@/lib/privateMode';
-import { getProviderCredentialStatus } from '@/services/providers/ProviderCredentials';
-import { getProviderPolicy } from '@/services/providers/ProviderPolicy';
type SpeechScope = 'dictation' | 'upload';
@@ -55,16 +52,27 @@ async function appleIntelligenceReady(): Promise<boolean> {
return false;
}
-// Applies OpenWhispr Cloud or On-Device to a workflow as soon as it is tapped, after the same
-// sign-in and model checks Private mode runs.
+// Applies OpenWhispr Cloud or On-Device to a workflow as soon as it is tapped, after its sign-in
+// and model checks. Dictation carries the app mode with it: On-Device turns Local Mode on.
export async function switchWorkflowMode(
scope: MobileInferenceScope,
mode: 'openwhispr' | 'local',
): Promise<ModeSwitchResult> {
- if (mode === 'openwhispr' && accountRequiredForCloud(useAuthStore.getState().user)) {
+ const { user } = useAuthStore.getState();
+ if (mode === 'openwhispr' && accountRequiredForCloud(user)) {
showAccountRequiredAlert(isSpeechScope(scope) ? 'cloud transcription' : 'cloud AI');
return 'refused';
}
+ // Local Mode dictates on this iPhone, so Cloud cleanup is a separate pass that needs an account.
+ if (
+ mode === 'openwhispr' &&
+ scope === 'cleanup' &&
+ useProcessingModeStore.getState().activeMode === 'private' &&
+ requiresRealAccount(user)
+ ) {
+ showAccountRequiredAlert('cloud cleanup');
+ return 'refused';
+ }
if (mode === 'local') {
const blocked = isSpeechScope(scope)
? await transcriptionModelReady()
@@ -85,51 +93,8 @@ export async function switchWorkflowMode(
return 'switched';
}
-// The provider turning Private mode off returns dictation to: the one dictation is saved to, or
-// the last one used when Private mode was turned on from Bring Your Own Key.
-function returnProvider(config: UserConfig | null): InferenceSelection | undefined {
- const saved = config?.inference?.dictation;
- if (saved?.mode === 'providers') return saved;
- if (!config?.privateModeReturn) return undefined;
- return Object.values(config.rememberedInference?.dictation ?? {}).find(
- (selection) => selection.mode === 'providers',
- );
-}
-
-// A provider whose key was removed, or that the organization no longer allows, can't take
-// dictation back. A policy still loading doesn't count against it.
-async function providerUsable(selection: InferenceSelection): Promise<boolean> {
- const resolved = resolveMobileInferenceRoute({
- scope: 'dictation',
- selection,
- policy: await getProviderPolicy(),
- });
- if (!resolved.ok) return resolved.code === 'POLICY_UNRESOLVED';
- if (!selection.credentialRef) return true;
- const status = await getProviderCredentialStatus(selection.credentialRef).catch(() => ({
- isConfigured: true,
- }));
- return status.isConfigured;
-}
-
-// The Private mode switch in AI Models. On keeps dictation and uploads on this phone; off hands
-// dictation back to Cloud, or to Bring Your Own Key when that is where Private mode was turned on
-// and the provider can still run.
-export async function setPrivateMode(enabled: boolean): Promise<ModeSwitchResult> {
- if (enabled) return switchWorkflowMode('dictation', 'local');
- const { config, updateConfig } = useConfigStore.getState();
- const provider = returnProvider(config);
- if (provider && (await providerUsable(provider))) {
- const { activeMode, setActiveMode } = useProcessingModeStore.getState();
- setActiveMode('providers', true);
- await updateConfig(workflowSaveConfig(config, 'dictation', provider, activeMode));
- return 'switched';
- }
- return switchWorkflowMode('dictation', 'openwhispr');
-}
-
// Saves the on-device model for a workflow; undefined means Automatic. The pick is also
-// remembered so switching back to On-Device, from here or Private mode, restores it.
+// remembered so switching back to On-Device restores it.
export async function pickLocalModel(
scope: SpeechScope,
model: LocalModelKey | undefined,
diff --git a/openwhispr-mobile/src/screens/AIModelsScreen.tsx b/openwhispr-mobile/src/screens/AIModelsScreen.tsx
index cbe936b3e..9864ace91 100644
--- a/openwhispr-mobile/src/screens/AIModelsScreen.tsx
+++ b/openwhispr-mobile/src/screens/AIModelsScreen.tsx
@@ -10,9 +10,8 @@ import { Toast } from '@/components/ui/Toast';
import { useConfigToggle } from '@/hooks/useConfigToggle';
import { useToast } from '@/hooks/useToast';
import { confirmDestructive } from '@/lib/alerts';
-import { WORKFLOW_LABELS, WORKFLOWS, workflowSummary } from '@/lib/aiWorkflows';
+import { WORKFLOW_LABELS, WORKFLOWS, cloudAccessFor, workflowSummary } from '@/lib/aiWorkflows';
import { getLocalReasoningReadiness } from '@/lib/localReasoning';
-import { setPrivateMode } from '@/lib/workflowModeSwitch';
import type { InferenceSelection, MobileInferenceScope } from '@/lib/mobileProviders';
import {
clearProviderCredentials,
@@ -20,6 +19,7 @@ import {
getProviderCredentialStatus,
subscribeProviderCredentialChanges,
} from '@/services/providers/ProviderCredentials';
+import { useAuthStore } from '@/store/useAuthStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
import type { LocalReasoningReadiness } from '@/types';
@@ -75,6 +75,7 @@ async function isKeyMissing(selection: InferenceSelection | undefined): Promise<
export default function AIModelsScreen(): React.JSX.Element {
const config = useConfigStore((state) => state.config);
const activeMode = useProcessingModeStore((state) => state.activeMode);
+ const cloudAccess = useAuthStore((state) => cloudAccessFor(state.user));
const [localReadiness, setLocalReadiness] = useState<LocalReasoningReadiness | null>(null);
const localIntelligenceEnabled = config?.appleLocalIntelligenceEnabled ?? true;
const handleToggleLocalIntelligence = useConfigToggle('appleLocalIntelligenceEnabled');
@@ -138,25 +139,6 @@ export default function AIModelsScreen(): React.JSX.Element {
);
}
- // The switch shows the requested state while the checks run, rather than snapping back to the
- // current mode until they finish; it settles on the real mode either way.
- const [requestedPrivateMode, setRequestedPrivateMode] = useState<boolean | null>(null);
- const privateMode = activeMode === 'private';
-
- async function togglePrivateMode(enabled: boolean): Promise<void> {
- if (busy) return;
- setBusy(true);
- setRequestedPrivateMode(enabled);
- try {
- if ((await setPrivateMode(enabled)) === 'switched') {
- showToast(enabled ? 'Private Mode on.' : 'Private Mode off.', 'success');
- }
- } finally {
- setRequestedPrivateMode(null);
- setBusy(false);
- }
- }
-
const onDeviceUnavailable =
localReadiness && localReadiness.status !== 'ready'
? localReasoningStatusLabel(localReadiness)
@@ -165,32 +147,6 @@ export default function AIModelsScreen(): React.JSX.Element {
return (
<View className="flex-1 bg-systemBackground">
<SettingsScreen>
- {/* The one place Private mode is switched: with it on, the workflow pages lock the modes
- it never runs, so a choice there can't look saved and then be ignored. */}
- <SettingsSection>
- <SettingsRow
- iconStyle="line"
- icon="lock"
- mdIcon="Lock"
- title="Private Mode"
- description={
- privateMode
- ? 'Audio stays on this iPhone, notes ask before leaving it, and the voice assistant is off.'
- : 'Keep audio on this iPhone and ask before notes leave it.'
- }
- rightElement={
- <SettingsSwitch
- accessibilityLabel="Private Mode"
- value={requestedPrivateMode ?? privateMode}
- disabled={busy}
- onValueChange={(enabled) => {
- void togglePrivateMode(enabled);
- }}
- />
- }
- showChevron={false}
- />
- </SettingsSection>
<SettingsSection title="Workflows">
{WORKFLOWS.map((scope) => (
<SettingsRow
@@ -201,6 +157,7 @@ export default function AIModelsScreen(): React.JSX.Element {
subtitle={workflowSummary(config, scope, activeMode, {
keyMissing: missingKeys.includes(scope),
onDeviceUnavailable,
+ cloudAccess,
})}
onPress={() => router.push({ pathname: '/(account)/ai-workflow', params: { scope } })}
/>
@@ -212,7 +169,7 @@ export default function AIModelsScreen(): React.JSX.Element {
icon="sparkles"
mdIcon="Sparkles"
title="Local Apple Intelligence"
- description={`Status: ${localReasoningStatusLabel(localReadiness)}. Runs On-Device text workflows, and private and signed-out note generation.`}
+ description={`Status: ${localReasoningStatusLabel(localReadiness)}\nRuns On-Device text workflows, and private and signed-out note generation.`}
rightElement={
<SettingsSwitch
value={localIntelligenceEnabled}
diff --git a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
index 4825deceb..0e67eb238 100644
--- a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
+++ b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
@@ -36,15 +36,12 @@ export default function CleanupPromptScreen() {
const baseline = override ?? DEFAULT_CLEANUP_PROMPT;
const [draft, setDraft] = useState(baseline);
- // On-Device transcripts are cleaned only by On-Device cleanup or a saved provider, and
// Bring Your Own Key skips cleanup until it has a selection.
const inactiveNotice = !cleanupEnabled
? 'Text Cleanup is off. Your prompt is saved and applies once you turn it on.'
- : activeMode === 'private' && cleanupMode !== 'local' && cleanupMode !== 'providers'
- ? 'Private Mode skips cleanup unless it is set to On-Device or Bring Your Own Key. Your prompt is saved and applies when it runs.'
- : activeMode === 'providers' && !cleanupMode
- ? 'Bring Your Own Key skips cleanup until Text Cleanup has a selection. Your prompt is saved and applies once it does.'
- : null;
+ : activeMode === 'providers' && !cleanupMode
+ ? 'Bring Your Own Key skips cleanup until Text Cleanup has a selection. Your prompt is saved and applies once it does.'
+ : null;
const isDirty = draft !== baseline;
const missingPlaceholder = !hasAgentNamePlaceholder(draft);
diff --git a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx b/openwhispr-mobile/src/screens/DictationAgentScreen.tsx
index b8b9cf099..55a2bc7ce 100644
--- a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx
+++ b/openwhispr-mobile/src/screens/DictationAgentScreen.tsx
@@ -28,7 +28,7 @@ export function DictationAgentScreen(): React.JSX.Element {
// Bring Your Own Key skips the assistant until it has a selection of its own.
const unavailableNotice =
activeMode === 'private'
- ? `${PRIVATE_MODE_LOCKED_REASON} Your settings are saved and apply once Private Mode is off.`
+ ? `${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 Chat & Voice Assistant has a selection. Your settings are saved and apply once it does.'
: null;
diff --git a/openwhispr-mobile/src/screens/HomeScreen.tsx b/openwhispr-mobile/src/screens/HomeScreen.tsx
index 7fb2af7e5..a6e43f048 100644
--- a/openwhispr-mobile/src/screens/HomeScreen.tsx
+++ b/openwhispr-mobile/src/screens/HomeScreen.tsx
@@ -523,12 +523,12 @@ export default function HomeScreen() {
<Pressable
onPress={() => router.push('/(account)/ai-models')}
accessibilityRole="button"
- accessibilityLabel="Private Mode is on"
+ accessibilityLabel="Local Mode is on"
accessibilityHint="Opens AI Models."
className="h-9 flex-row items-center gap-1.5 rounded-full bg-tertiarySystemFill px-3 active:opacity-70"
>
<SystemIcon name="lock.fill" mdName="Lock" size={13} color="secondaryLabel" />
- <Text className="text-xs font-bold text-secondaryLabel">Private</Text>
+ <Text className="text-xs font-bold text-secondaryLabel">Local</Text>
</Pressable>
) : (
<View />
diff --git a/openwhispr-mobile/src/screens/ModelDownloadScreen.tsx b/openwhispr-mobile/src/screens/ModelDownloadScreen.tsx
index c294f9950..14ce44cae 100644
--- a/openwhispr-mobile/src/screens/ModelDownloadScreen.tsx
+++ b/openwhispr-mobile/src/screens/ModelDownloadScreen.tsx
@@ -296,7 +296,7 @@ export default function ModelDownloadScreen() {
>
<Text className="mb-1.5 text-sm font-semibold text-label">Which model do I need?</Text>
<Text className="text-xs text-secondaryLabel leading-[18px]">
- One model is enough — private mode picks the right engine from your dictation language.
+ One model is enough — Local Mode picks the right engine from your dictation language.
Parakeet is the fastest and most accurate for English (v2) and 25 European languages (v3).
Whisper base covers everything else, including auto-detect. Downloads stay on your device.
</Text>
diff --git a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
index c7bb15926..7ba9ae4ff 100644
--- a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
+++ b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
@@ -18,6 +18,7 @@ import { OnDeviceModelSection } from '@/components/settings/OnDeviceModelSection
import { useConfigToggle } from '@/hooks/useConfigToggle';
import { useCustomPromptsStore } from '@/store/useCustomPromptsStore';
import { resolveCustomPrompt } from '@/config/prompts/registry';
+import { useAuthStore } from '@/store/useAuthStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
import type { UserConfig } from '@/types';
@@ -29,17 +30,19 @@ import {
removeProviderCredential,
setProviderCredential,
} from '@/services/providers/ProviderCredentials';
-import { MODE_LABELS, workflowSaveConfig } from '@/lib/inferenceModes';
+import { workflowSaveConfig } from '@/lib/inferenceModes';
import { InferenceModePicker } from '@/components/settings/InferenceModePicker';
import {
+ CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE,
+ LOCAL_MODE_DICTATION_NOTES,
ON_DEVICE_MODE_NOTES,
- PRIVATE_MODE_LOCKED,
PRIVATE_MODE_LOCKED_REASON,
- UNSET_ON_DEVICE_CLEANUP_NOTE,
- UNSET_UNSUPPORTED_CLEANUP_NOTE,
+ ON_DEVICE_CLEANUP_UNSUPPORTED_NOTE,
UNSET_PROVIDER_NOTES,
WORKFLOW_LABELS,
WORKFLOWS,
+ cloudAccessFor,
+ cloudCleanupNeedsAccount,
parseWorkflow,
unsetSelection,
} from '@/lib/aiWorkflows';
@@ -291,19 +294,16 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
const updateConfig = useConfigStore((state) => state.updateConfig);
const setActiveMode = useProcessingModeStore((state) => state.setActiveMode);
const activeMode = useProcessingModeStore((state) => state.activeMode);
- const storedSelection = config?.inference?.[scope] ?? unsetSelection(scope, activeMode);
- // Private mode runs dictation and uploads on this phone whatever is saved, so a saved mode it
- // locks shows as On-Device (Automatic), which is what runs, and stays saved for later.
+ const cloudAccess = useAuthStore((state) => cloudAccessFor(state.user));
+ const storedSelection =
+ config?.inference?.[scope] ?? unsetSelection(scope, activeMode, cloudAccess);
+ // Local Mode runs dictation on this phone whatever is saved, so a saved Cloud dictation (a guest
+ // held in Local Mode) shows as On-Device (Automatic), which is what runs.
const lockedByPrivateMode =
- activeMode === 'private' &&
- (scope === 'dictation' || scope === 'upload') &&
- !!PRIVATE_MODE_LOCKED[scope]?.includes(storedSelection.mode);
+ activeMode === 'private' && scope === 'dictation' && storedSelection.mode === 'openwhispr';
const savedSelection: InferenceSelection = lockedByPrivateMode
? { mode: 'local' }
: storedSelection;
- // Private mode skips an unsaved cleanup, so the On-Device default must not look picked.
- const cleanupUnsaved =
- scope === 'cleanup' && activeMode === 'private' && !config?.inference?.cleanup;
// Tracks the saved selection, except while a Bring Your Own Key draft is being set up.
const [selection, setSelection] = useState<InferenceSelection>(savedSelection);
const remembered = useRef<Record<string, InferenceSelection>>({});
@@ -331,8 +331,6 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
const modelId = selection.modelId ?? defaultModelId(provider);
const providerId = provider?.id;
const models = provider?.models.length ? provider.models : discoveredModels;
- const shownMode =
- cleanupUnsaved && selection.mode === savedSelection.mode ? null : selection.mode;
const speechScope = scope === 'dictation' || scope === 'upload' ? scope : null;
// On-Device text workflows run on Apple Intelligence, which some iPhones can never run.
const [onDeviceUnsupported, setOnDeviceUnsupported] = useState<string | null>(null);
@@ -353,34 +351,33 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
cancelled = true;
};
}, [speechScope]);
+ // 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;
const modeNote =
- (shownMode === null
- ? onDeviceUnsupported
- ? UNSET_UNSUPPORTED_CLEANUP_NOTE
- : UNSET_ON_DEVICE_CLEANUP_NOTE
+ (scope === 'cleanup' && selection.mode === 'local' && onDeviceUnsupported
+ ? ON_DEVICE_CLEANUP_UNSUPPORTED_NOTE
: undefined) ??
- (lockedByPrivateMode && ON_DEVICE_MODE_NOTES[scope]
- ? `${ON_DEVICE_MODE_NOTES[scope]} Your ${MODE_LABELS[storedSelection.mode]} choice applies again when Private Mode is off.`
+ (scope === 'cleanup' &&
+ selection.mode === 'openwhispr' &&
+ cloudCleanupNeedsAccount(config, activeMode, cloudAccess)
+ ? CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE
: undefined) ??
(activeMode === 'private' ? ON_DEVICE_MODE_NOTES[scope] : undefined) ??
(activeMode === 'providers' && !config?.inference?.[scope]
? UNSET_PROVIDER_NOTES[scope]
: undefined) ??
(selection.mode === 'providers' && savedSelection.mode !== 'providers'
- ? activeMode === 'private'
- ? 'Save to switch to Bring Your Own Key. This turns Private Mode off.'
+ ? activeMode === 'private' && scope === 'dictation'
+ ? 'Save to switch to Bring Your Own Key. This turns Local Mode off.'
: 'Save to switch to Bring Your Own Key.'
+ : undefined) ??
+ (scope === 'dictation'
+ ? LOCAL_MODE_DICTATION_NOTES[activeMode === 'private' ? 'on' : 'off']
: undefined);
- // Private mode is switched in AI Models, so a mode it never runs here can't be picked.
- const modeUnavailable: Partial<Record<InferenceMode, string>> = {
- ...Object.fromEntries(
- (activeMode === 'private' ? (PRIVATE_MODE_LOCKED[scope] ?? []) : []).map((mode) => [
- mode,
- PRIVATE_MODE_LOCKED_REASON,
- ]),
- ),
- ...(onDeviceUnsupported ? { local: onDeviceUnsupported } : {}),
- };
+ const modeUnavailable: Partial<Record<InferenceMode, string>> = onDeviceUnsupported
+ ? { local: onDeviceUnsupported }
+ : {};
// Keys are stored per provider (per server for Custom), so every workflow on it shares one.
const keyOwner =
provider?.id === 'custom' ? 'this server' : providerDisplayName(provider?.id ?? '');
@@ -490,7 +487,10 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
);
return;
}
- if (mode === savedSelection.mode && !cleanupUnsaved) {
+ // Tapping the shown mode saves it when nothing of the user's own is saved, since an unsaved
+ // default follows the mode and the account (unsetSelection), and a pin is released with them.
+ const ownChoice = !!config?.inference?.[scope] && !config.pinnedInference?.includes(scope);
+ if (mode === savedSelection.mode && ownChoice) {
setSelection(savedSelection);
return;
}
@@ -604,7 +604,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
const saved = await prepareSelection();
if (!saved) return;
await updateConfig(
- workflowSaveConfig(useConfigStore.getState().config, scope, saved, activeMode),
+ workflowSaveConfig(useConfigStore.getState().config, scope, saved, activeMode, cloudAccess),
);
if (useConfigStore.getState().error) {
showError('Unable to save your selection. Please try again.');
@@ -763,7 +763,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
<>
<InferenceModePicker
scope={speechScope ? 'speech' : 'text'}
- selectedMode={shownMode}
+ selectedMode={pickedMode}
onSelect={chooseMode}
unavailable={modeUnavailable}
/>
@@ -777,7 +777,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
lockedChoice={lockedByPrivateMode}
/>
) : null}
- {shownMode === 'local' && !speechScope ? (
+ {selection.mode === 'local' && !speechScope && !onDeviceUnsupported ? (
<SectionFooter>Runs on Apple Intelligence on this iPhone.</SectionFooter>
) : null}
{selection.mode === 'providers' && provider ? (
diff --git a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
index 4a35977a2..a15974137 100644
--- a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
@@ -1,11 +1,15 @@
import React from 'react';
import { Alert, Platform } from 'react-native';
-import { act, fireEvent, render, screen, waitFor } from '@testing-library/react-native';
+import { fireEvent, render, screen } from '@testing-library/react-native';
const mockPush = jest.fn();
const mockClearCredentials = jest.fn().mockResolvedValue(undefined);
let mockActiveMode = 'cloud';
let mockConfig: Record<string, unknown> | null = null;
+let mockUser: { id: string; isAnonymous: boolean } | null = null;
+jest.mock('@/store/useAuthStore', () => ({
+ useAuthStore: (selector: (state: unknown) => unknown) => selector({ user: mockUser }),
+}));
const mockCredentialStatus = jest.fn();
let mockCredentialListener: (() => void) | null = null;
const MockText = require('react-native').Text;
@@ -42,11 +46,6 @@ jest.mock('@/services/providers/ProviderCredentials', () => ({
},
}));
-const mockSetPrivateMode = jest.fn();
-jest.mock('@/lib/workflowModeSwitch', () => ({
- setPrivateMode: (...args: unknown[]) => mockSetPrivateMode(...args),
-}));
-
import AIModelsScreen from '../AIModelsScreen';
const originalPlatform = Platform.OS;
@@ -55,10 +54,10 @@ beforeEach(() => {
jest.clearAllMocks();
mockActiveMode = 'cloud';
mockConfig = null;
+ mockUser = null;
Platform.OS = 'ios';
mockCredentialStatus.mockResolvedValue({ isConfigured: true });
mockReadiness.mockResolvedValue({ status: 'ready', tokenCounting: false });
- mockSetPrivateMode.mockResolvedValue('switched');
});
afterAll(() => {
@@ -125,8 +124,9 @@ it('has no provider keys to remove on Android', async () => {
await screen.findByText(/Status: Ready/);
});
-it('shows what each workflow really does while On-Device mode is on', async () => {
+it('shows what each workflow runs while Local Mode is on', async () => {
mockActiveMode = 'private';
+ mockUser = { id: 'u', isAnonymous: false };
mockConfig = {
defaultMode: 'private',
inference: {
@@ -136,25 +136,42 @@ it('shows what each workflow really does while On-Device mode is on', async () =
},
};
render(<AIModelsScreen />);
- // A picked model keeps its name; uploads stay on the phone whatever is saved.
+ // A picked model keeps its name; uploads and cleanup run what is saved for them.
expect(screen.getByText('Whisper base')).toBeTruthy();
- expect(screen.queryByText('OpenAI')).toBeNull();
- // Cleanup set to anything but On-Device would leave the phone, so it is skipped.
- expect(screen.getByText('Skipped')).toBeTruthy();
- // Note chat keeps its own selection, which is OpenWhispr Cloud when unset.
- expect(screen.getByText('OpenWhispr Cloud')).toBeTruthy();
+ expect(screen.getByText('OpenAI')).toBeTruthy();
+ // Cleanup and note chat, which is OpenWhispr Cloud when unset.
+ expect(screen.getAllByText('OpenWhispr Cloud')).toHaveLength(2);
await screen.findByText(/Status: Ready/);
});
-it('shows cleanup as skipped in On-Device mode with nothing saved', async () => {
+it('says a saved Cloud cleanup is skipped in Local Mode without an account', async () => {
+ mockActiveMode = 'private';
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'openwhispr' } },
+ };
+ render(<AIModelsScreen />);
+ expect(screen.getByText('Skipped · Sign in')).toBeTruthy();
+ await screen.findByText(/Status: Ready/);
+});
+
+// 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.
+it.each([
+ ['no session', 1, null],
+ ['an anonymous session', 2, { id: 'a', isAnonymous: true }],
+ ['a signed-in account', 3, { id: 'u', isAnonymous: false }],
+])('with nothing saved in Local Mode for %s, shows %d Cloud rows', async (_label, count, user) => {
+ mockUser = user;
mockActiveMode = 'private';
mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
render(<AIModelsScreen />);
- expect(screen.getByText('Skipped')).toBeTruthy();
+ expect(screen.getAllByText('OpenWhispr Cloud')).toHaveLength(count);
await screen.findByText(/Status: Ready/);
});
-it('names the cleanup provider in On-Device mode, which cleans On-Device transcripts', async () => {
+it('names a cleanup provider saved in Local Mode', async () => {
mockActiveMode = 'private';
mockConfig = {
defaultMode: 'private',
@@ -164,7 +181,6 @@ it('names the cleanup provider in On-Device mode, which cleans On-Device transcr
},
};
render(<AIModelsScreen />);
- expect(screen.queryByText('Skipped')).toBeNull();
expect(screen.getByText('OpenAI')).toBeTruthy();
await screen.findByText(/Status: Ready/);
});
@@ -180,15 +196,12 @@ it('shows On-Device cleanup as running in On-Device mode', async () => {
await screen.findByText(/Status: Ready/);
});
-it('says why On-Device cleanup cannot run while Apple Intelligence is off', async () => {
+it('says cleanup is skipped, and why, while Apple Intelligence is off', async () => {
mockReadiness.mockResolvedValue({ status: 'appleIntelligenceOff', tokenCounting: false });
mockActiveMode = 'private';
- mockConfig = {
- defaultMode: 'private',
- inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
- };
+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
render(<AIModelsScreen />);
- expect(await screen.findByText('On-Device · Apple Intelligence off')).toBeTruthy();
+ expect(await screen.findByText('Skipped · Apple Intelligence off')).toBeTruthy();
});
it('shows provider note chat as On-Device, which answers it on this iPhone first', async () => {
@@ -232,68 +245,19 @@ it.each([
])('says when this iPhone cannot run Apple Intelligence (%s)', async (status, label) => {
mockReadiness.mockResolvedValue({ status, tokenCounting: false });
render(<AIModelsScreen />);
- expect(await screen.findByText(new RegExp(`Status: ${label}\\.`))).toBeTruthy();
+ expect(await screen.findByText(new RegExp(`Status: ${label}\\s`))).toBeTruthy();
});
-// AI Models is the one place Private mode is switched; Home only shows that it's on.
-describe('Private Mode switch', () => {
- it('shows Private mode off, with what turning it on does', async () => {
- render(<AIModelsScreen />);
- expect(screen.getByLabelText('Private Mode').props.value).toBe(false);
- expect(
- screen.getByText('Keep audio on this iPhone and ask before notes leave it.'),
- ).toBeTruthy();
- await screen.findByText(/Status: Ready/);
- });
-
- it('shows Private mode on, and how to choose per workflow again', async () => {
- mockActiveMode = 'private';
- render(<AIModelsScreen />);
- expect(screen.getByLabelText('Private Mode').props.value).toBe(true);
- expect(
- screen.getByText(
- 'Audio stays on this iPhone, notes ask before leaving it, and the voice assistant is off.',
- ),
- ).toBeTruthy();
- await screen.findByText(/Status: Ready/);
- });
-
- it.each([
- [true, 'Private Mode on.'],
- [false, 'Private Mode off.'],
- ])('switches Private mode to %s', async (enabled, message) => {
- mockActiveMode = enabled ? 'cloud' : 'private';
- render(<AIModelsScreen />);
- fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', enabled);
- expect(await screen.findByTestId('toast-success')).toHaveTextContent(message);
- expect(mockSetPrivateMode).toHaveBeenCalledWith(enabled);
- });
-
- // The model list opened, or sign-in was asked for; nothing changed yet.
- it.each(['needs-model', 'refused'])('says nothing when the switch is %s', async (result) => {
- mockSetPrivateMode.mockResolvedValue(result);
- render(<AIModelsScreen />);
- fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', true);
- await waitFor(() => expect(mockSetPrivateMode).toHaveBeenCalledWith(true));
- expect(screen.queryByTestId('toast-success')).toBeNull();
- await screen.findByText(/Status: Ready/);
- });
-
- // Turning on waits for the model check; the switch must not bounce back off meanwhile, nor take a
- // second tap.
- it('holds the requested state while switching, then settles on the real mode', async () => {
- let finish: (result: string) => void = () => undefined;
- mockSetPrivateMode.mockReturnValue(new Promise((resolve) => (finish = resolve)));
- render(<AIModelsScreen />);
- fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', true);
- await waitFor(() => expect(screen.getByLabelText('Private Mode').props.disabled).toBe(true));
- expect(screen.getByLabelText('Private Mode').props.value).toBe(true);
- fireEvent(screen.getByLabelText('Private Mode'), 'valueChange', false);
- expect(mockSetPrivateMode).toHaveBeenCalledTimes(1);
+// Dictation owns Local Mode, so AI Models has no switch of its own.
+it('has no Local Mode switch', async () => {
+ render(<AIModelsScreen />);
+ expect(screen.queryByLabelText('Local Mode')).toBeNull();
+ await screen.findByText(/Status: Ready/);
+});
- await act(async () => finish('refused'));
- expect(screen.getByLabelText('Private Mode').props.value).toBe(false);
- expect(screen.getByLabelText('Private Mode').props.disabled).toBe(false);
- await screen.findByText(/Status: Ready/);
- });
+it('puts the Apple Intelligence status on its own line', async () => {
+ render(<AIModelsScreen />);
+ expect((await screen.findByText(/Status: Ready/)).props.children).toBe(
+ 'Status: Ready\nRuns On-Device text workflows, and private and signed-out note generation.',
+ );
});
diff --git a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
index 58fce0422..914a7e299 100644
--- a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
@@ -92,14 +92,11 @@ describe('CleanupPromptScreen — guidance', () => {
expect(screen.queryByText(/requires Cloud mode/)).not.toBeOnTheScreen();
});
- it('says the prompt has no effect while On-Device mode skips cleanup', () => {
+ // Local Mode cleans on this phone, so the prompt applies with nothing saved.
+ it('treats unsaved cleanup in Local Mode as using the prompt', () => {
mockActiveMode = 'private';
render(<CleanupPromptScreen />);
- expect(
- screen.getByText(
- /Private Mode skips cleanup unless it is set to On-Device or Bring Your Own Key/,
- ),
- ).toBeTruthy();
+ expect(screen.queryByText(/Your prompt is saved and applies/)).toBeNull();
});
it('treats provider cleanup in On-Device mode as using the prompt', () => {
diff --git a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
index 2100437fe..1c8ab429b 100644
--- a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
@@ -44,13 +44,13 @@ it('is enabled once the voice assistant has a Bring Your Own Key selection', ()
});
// Private mode turns the voice assistant off, so its switch must not read as on.
-it('shows the voice assistant off in Private mode and says where to turn it back on', () => {
+it('shows the voice assistant off in Local Mode and says where to turn it back on', () => {
mockActiveMode = 'private';
mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };
render(<DictationAgentScreen />);
expect(
screen.getByText(
- 'Off while Private Mode is on. Turn it off in AI Models. Your settings are saved and apply once Private Mode is off.',
+ '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();
const [enable] = screen.UNSAFE_getAllByType(Switch);
diff --git a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
index 2c828a73d..976b256bb 100644
--- a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
@@ -193,15 +193,15 @@ describe('HomeScreen Pro completion', () => {
});
// Private mode is set in AI Models; Home only shows that it's on.
-describe('HomeScreen Private mode badge', () => {
+describe('HomeScreen Local Mode badge', () => {
afterEach(() => {
mockProcessingModeStoreState.activeMode = 'cloud';
});
- it('opens AI Models from the badge while Private mode is on', () => {
+ it('opens AI Models from the badge while Local Mode is on', () => {
mockProcessingModeStoreState.activeMode = 'private';
render(<HomeScreen />);
- const badge = screen.getByLabelText('Private Mode is on');
+ const badge = screen.getByLabelText('Local Mode is on');
expect(badge.props.accessibilityRole).toBe('button');
fireEvent.press(badge);
expect(require('expo-router').router.push).toHaveBeenCalledWith('/(account)/ai-models');
@@ -210,7 +210,7 @@ describe('HomeScreen Private mode badge', () => {
it.each(['cloud', 'providers'])('shows no mode switch or badge in %s mode', (mode) => {
mockProcessingModeStoreState.activeMode = mode;
render(<HomeScreen />);
- expect(screen.queryByLabelText('Private Mode is on')).toBeNull();
+ expect(screen.queryByLabelText('Local Mode is on')).toBeNull();
expect(screen.queryByLabelText('Cloud transcription')).toBeNull();
expect(screen.queryByLabelText('Transcription: Bring Your Own Key')).toBeNull();
});
diff --git a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
index 8ce4d02b8..0f8245de9 100644
--- a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
@@ -13,6 +13,10 @@ let mockActiveMode = 'cloud';
const mockCredentialStatus = jest.fn().mockResolvedValue({ isConfigured: false });
let mockConfig: Record<string, unknown> | null = null;
let mockScope: string | undefined;
+let mockUser: { id: string; isAnonymous: boolean } | null = null;
+jest.mock('@/store/useAuthStore', () => ({
+ useAuthStore: (selector: (state: unknown) => unknown) => selector({ user: mockUser }),
+}));
const mockPreventRemove = jest.fn();
const mockDispatch = jest.fn();
let mockStoredPrompt = '';
@@ -144,6 +148,7 @@ beforeEach(() => {
jest.clearAllMocks();
mockConfig = null;
mockScope = 'dictation';
+ mockUser = null;
mockStoredPrompt = '';
// A successful switch saves the mode, as the real helper does through the config store.
mockSwitchMode.mockImplementation(async (scope: string, mode: string) => {
@@ -401,9 +406,8 @@ it('closes the keyboard when a key is pasted, but not while typing', () => {
expect(dismiss).toHaveBeenCalledTimes(1);
});
-it('checks a provider from Private mode, since a check sends no user content', async () => {
+it('checks a provider from Local Mode, since a check sends no user content', async () => {
mockActiveMode = 'private';
- mockScope = 'cleanup';
render(<WorkflowSettingsScreen />);
enableProviders();
fireEvent.changeText(screen.getByLabelText('API key'), 'test-key');
@@ -457,29 +461,45 @@ it('defaults an unselected workflow to On-Device for a private-mode user', () =>
expect(selectedMode()).toBe('On-Device');
});
-it('shows no cleanup mode for a private-mode user who has not saved one, since cleanup is skipped', () => {
+// Local Mode cleans on this phone with nothing saved, so On-Device is what runs. Tapping it saves
+// it, since an unsaved default would move to Cloud once the user signs in.
+it('saves the On-Device cleanup a Local Mode user sees but has not saved', () => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
mockScope = 'cleanup';
render(<WorkflowSettingsScreen />);
- expect(selectedMode()).toBeUndefined();
- expect(
- screen.getByText(
- 'Not saved yet. Private Mode skips cleanup until you choose On-Device or Bring Your Own Key.',
- ),
- ).toBeTruthy();
- expect(screen.queryByText('Runs on Apple Intelligence on this iPhone.')).toBeNull();
+ expect(selectedMode()).toBe('On-Device');
+ expect(screen.getByText('Runs on Apple Intelligence on this iPhone.')).toBeTruthy();
+ fireEvent.press(screen.getByText('On-Device'));
+ expect(mockSwitchMode).toHaveBeenCalledWith('cleanup', 'local');
});
-it('saves On-Device cleanup when a private-mode user taps it with nothing saved', async () => {
- mockConfig = { defaultMode: 'private' };
+it('saves an upload Local Mode holds on this phone automatically when it is tapped', () => {
+ mockConfig = {
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' }, upload: { mode: 'local' } },
+ pinnedInference: ['upload'],
+ };
mockActiveMode = 'private';
- mockScope = 'cleanup';
+ mockScope = 'upload';
render(<WorkflowSettingsScreen />);
+ expect(selectedMode()).toBe('On-Device');
fireEvent.press(screen.getByText('On-Device'));
- await waitFor(() => expect(mockSwitchMode).toHaveBeenCalledWith('cleanup', 'local'));
- await waitFor(() => expect(selectedMode()).toBe('On-Device'));
- expect(screen.getByText('Runs on Apple Intelligence on this iPhone.')).toBeTruthy();
+ expect(mockSwitchMode).toHaveBeenCalledWith('upload', 'local');
+});
+
+it('says why a saved Cloud cleanup is skipped in Local Mode without an account', () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = { defaultMode: 'private', inference: { cleanup: { mode: 'openwhispr' } } };
+ mockActiveMode = 'private';
+ mockScope = 'cleanup';
+ render(<WorkflowSettingsScreen />);
+ expect(selectedMode()).toBe('OpenWhispr Cloud');
+ expect(
+ screen.getByText(
+ 'In Local Mode, OpenWhispr Cloud cleans transcripts only for a signed-in account, so cleanup is skipped until you sign in.',
+ ),
+ ).toBeTruthy();
});
it('keeps On-Device cleanup selected once a private-mode user has saved it', () => {
@@ -493,14 +513,14 @@ it('keeps On-Device cleanup selected once a private-mode user has saved it', ()
});
// Needs no account, so it is also how a guest, who is kept in Private mode, uses their own key.
-it('keeps uploads on this phone when dictation leaves Private mode for Bring Your Own Key', async () => {
+it('keeps uploads on this phone when dictation leaves Local Mode for Bring Your Own Key', async () => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
mockCredentialStatus.mockResolvedValue({ isConfigured: true });
render(<WorkflowSettingsScreen />);
enableProviders();
expect(
- screen.getByText('Save to switch to Bring Your Own Key. This turns Private Mode off.'),
+ screen.getByText('Save to switch to Bring Your Own Key. This turns Local Mode off.'),
).toBeTruthy();
fireEvent.press(screen.getByText('Save'));
await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());
@@ -512,7 +532,23 @@ it('keeps uploads on this phone when dictation leaves Private mode for Bring You
expect(mockSetActiveMode).toHaveBeenCalledWith('providers', true);
});
-it('keeps notes and chat on this phone when dictation leaves Private mode for a provider', async () => {
+// Local Mode uploaded to OpenWhispr Cloud with nothing saved and a session, so that is held.
+it('keeps uploads on Cloud when a user with a session leaves Local Mode for a provider', async () => {
+ mockUser = { id: 'a', isAnonymous: true };
+ mockConfig = { defaultMode: 'private' };
+ mockActiveMode = 'private';
+ mockCredentialStatus.mockResolvedValue({ isConfigured: true });
+ render(<WorkflowSettingsScreen />);
+ enableProviders();
+ fireEvent.press(screen.getByText('Save'));
+ await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());
+ expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({
+ inference: { upload: { mode: 'openwhispr' } },
+ pinnedInference: ['upload', 'notes', 'agent'],
+ });
+});
+
+it('keeps notes and chat on this phone when dictation leaves Local Mode for a provider', async () => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
mockCredentialStatus.mockResolvedValue({ isConfigured: true });
@@ -779,7 +815,7 @@ describe('note chat and the voice assistant', () => {
expect(screen.getByText('Note chat and the voice assistant are off.')).toBeTruthy();
});
- it('show the voice assistant off in Private mode, while note chat stays on', () => {
+ it('show the voice assistant off in Local Mode, while note chat stays on', () => {
mockActiveMode = 'private';
mockConfig = { defaultMode: 'private', dictationAgentEnabled: true };
render(<WorkflowSettingsScreen />);
@@ -845,76 +881,62 @@ it('adds no pins when an existing user re-saves dictation with their own key', a
expect(saved.inference.notes).toBeUndefined();
});
-it('explains that Private mode skips a saved Cloud cleanup choice', () => {
- mockConfig = { defaultMode: 'private', inference: { cleanup: { mode: 'openwhispr' } } };
- mockActiveMode = 'private';
- mockScope = 'cleanup';
- render(<WorkflowSettingsScreen />);
- expect(selectedMode()).toBe('OpenWhispr Cloud');
- expect(
- screen.getByText(
- 'In Private Mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until Private Mode is off.',
- ),
- ).toBeTruthy();
-});
-
+// Local Mode keeps dictation on this phone; uploads and cleanup run what is saved for them.
it.each([
+ ['cleanup', { mode: 'openwhispr' }, 'OpenWhispr Cloud'],
[
- 'agent',
- 'In Private Mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
+ 'cleanup',
+ { mode: 'providers', providerId: 'openai', modelId: 'gpt-5-mini' },
+ 'Bring Your Own Key',
],
+ ['upload', { mode: 'openwhispr' }, 'OpenWhispr Cloud'],
[
- 'notes',
- 'Private Mode formats notes on this iPhone and asks before sending one to your choice here.',
+ 'upload',
+ { mode: 'providers', providerId: 'openai', modelId: 'whisper-1' },
+ 'Bring Your Own Key',
],
-])('explains what Private mode means for %s', (scope, note) => {
- mockConfig = { defaultMode: 'private' };
+])('shows the %s choice saved in Local Mode', (scope, selection, label) => {
+ mockConfig = { defaultMode: 'private', inference: { [scope]: selection } };
mockActiveMode = 'private';
mockScope = scope;
render(<WorkflowSettingsScreen />);
- expect(screen.getByText(note)).toBeTruthy();
+ expect(selectedMode()).toBe(label);
});
-// Private mode runs uploads on this phone, so a saved choice it locks isn't shown as picked, or
-// offered for editing, but stays saved for when Private mode is off.
-it('shows On-Device for an upload choice Private mode locks, and keeps that choice', () => {
- mockConfig = {
- defaultMode: 'private',
- inference: { upload: { mode: 'providers', providerId: 'openai', modelId: 'whisper-1' } },
- };
+// With nothing saved, Local Mode uploads to OpenWhispr Cloud with any session, and cleans there
+// only for a signed-in account.
+it.each([
+ ['upload', null, 'On-Device'],
+ ['upload', { id: 'a', isAnonymous: true }, 'OpenWhispr Cloud'],
+ ['cleanup', { id: 'a', isAnonymous: true }, 'On-Device'],
+ ['cleanup', { id: 'u', isAnonymous: false }, 'OpenWhispr Cloud'],
+])('shows %s with nothing saved in Local Mode for %j as %s', (scope, user, label) => {
+ mockUser = user;
+ mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
- mockScope = 'upload';
+ mockScope = scope;
render(<WorkflowSettingsScreen />);
- expect(selectedMode()).toBe('On-Device');
- expect(
- screen.getByText(
- 'Private Mode keeps uploads on this iPhone. Your Bring Your Own Key choice applies again when Private Mode is off.',
- ),
- ).toBeTruthy();
- expect(screen.queryByLabelText('API key')).toBeNull();
- // Tapping the Automatic row it shows must not replace the saved choice either.
- expect(
- screen.getByText('On-device models for upload, picked Automatic, choice locked'),
- ).toBeTruthy();
- fireEvent.press(screen.getByText('On-Device'));
- expect(mockSwitchMode).not.toHaveBeenCalled();
- expect(mockUpdateConfig).not.toHaveBeenCalled();
+ expect(selectedMode()).toBe(label);
});
-it('names a locked Cloud upload choice in the note', () => {
- mockConfig = { defaultMode: 'private', inference: { upload: { mode: 'openwhispr' } } };
+it.each([
+ [
+ 'agent',
+ 'In Local Mode the voice assistant is off, and 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) => {
+ mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
- mockScope = 'upload';
+ mockScope = scope;
render(<WorkflowSettingsScreen />);
- expect(selectedMode()).toBe('On-Device');
- expect(
- screen.getByText(
- 'Private Mode keeps uploads on this iPhone. Your OpenWhispr Cloud choice applies again when Private Mode is off.',
- ),
- ).toBeTruthy();
+ expect(screen.getByText(note)).toBeTruthy();
});
-it('shows On-Device for a guest whose saved Cloud dictation Private mode overrides', () => {
+it('shows On-Device for a guest whose saved Cloud dictation Local Mode overrides', () => {
mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };
mockActiveMode = 'private';
render(<WorkflowSettingsScreen />);
@@ -924,52 +946,85 @@ it('shows On-Device for a guest whose saved Cloud dictation Private mode overrid
expect(mockUpdateConfig).not.toHaveBeenCalled();
});
-it('keeps the plain upload note when uploads already run on this phone', () => {
- mockConfig = { defaultMode: 'private' };
- mockActiveMode = 'private';
- mockScope = 'upload';
- render(<WorkflowSettingsScreen />);
- expect(screen.getByText('Private Mode keeps uploads on this iPhone.')).toBeTruthy();
-});
-
function modeDisabled(title: string): boolean {
let row = screen.getByText(title).parent;
while (row && !row.props.accessibilityState) row = row.parent;
return !!row?.props.accessibilityState.disabled;
}
-// Private mode is switched in AI Models, so a page can't offer a mode it would ignore. Dictation
-// keeps Bring Your Own Key: saving it leaves Private mode, with no account needed.
+// Every page offers every mode in Local Mode; on Dictation's, picking OpenWhispr Cloud or Bring Your
+// Own Key is how Local Mode is turned off.
+it.each(['dictation', 'upload', 'cleanup', 'notes', 'agent'])(
+ 'locks no mode for %s in Local Mode',
+ (scope) => {
+ mockConfig = { defaultMode: 'private' };
+ mockActiveMode = 'private';
+ mockScope = scope;
+ render(<WorkflowSettingsScreen />);
+ for (const title of ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key'])
+ expect(modeDisabled(title)).toBe(false);
+ },
+);
+
+// Only Dictation's mode turns Local Mode off; saving a provider for uploads leaves it on.
it.each([
- ['dictation', ['OpenWhispr Cloud'], ['On-Device', 'Bring Your Own Key']],
- ['upload', ['OpenWhispr Cloud', 'Bring Your Own Key'], ['On-Device']],
- ['cleanup', ['OpenWhispr Cloud'], ['On-Device', 'Bring Your Own Key']],
- ['notes', [], ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key']],
- ['agent', [], ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key']],
-])('locks the modes Private mode never runs for %s', (scope, locked, open) => {
+ ['dictation', 'Save to switch to Bring Your Own Key. This turns Local Mode off.'],
+ ['upload', 'Save to switch to Bring Your Own Key.'],
+])('says what saving Bring Your Own Key does for %s in Local Mode', (scope, note) => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
mockScope = scope;
render(<WorkflowSettingsScreen />);
- for (const title of locked) expect(modeDisabled(title)).toBe(true);
- for (const title of open) expect(modeDisabled(title)).toBe(false);
- // The agent page's Voice Assistant switch is off for the same reason.
+ enableProviders();
+ 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.queryAllByText('Off while Private Mode is on. Turn it off in AI Models.'),
- ).toHaveLength(locked.length + (scope === 'agent' ? 1 : 0));
+ screen.getByText('Off while Local Mode is on. Change Dictation in AI Models to turn it off.'),
+ ).toBeTruthy();
});
-it('locks no mode outside Private mode', () => {
+it('turns Local Mode off when OpenWhispr Cloud is picked on the Dictation page', async () => {
+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };
+ mockActiveMode = 'private';
+ render(<WorkflowSettingsScreen />);
+ fireEvent.press(screen.getByText('OpenWhispr Cloud'));
+ await waitFor(() => expect(mockSwitchMode).toHaveBeenCalledWith('dictation', 'openwhispr'));
+});
+
+it('locks no mode outside Local Mode', () => {
render(<WorkflowSettingsScreen />);
for (const title of ['OpenWhispr Cloud', 'On-Device', 'Bring Your Own Key'])
expect(modeDisabled(title)).toBe(false);
});
-it('does not show the Private mode note on the Dictation page', () => {
+// Dictation owns Local Mode, so its page says what On-Device does and how to leave it.
+it.each([
+ [
+ 'cloud',
+ 'On-Device turns on Local Mode: dictation stays on this iPhone and notes ask 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.',
+ ],
+])('explains Local Mode on the Dictation page in %s mode', (mode, note) => {
+ mockConfig = { defaultMode: mode };
+ mockActiveMode = mode;
+ render(<WorkflowSettingsScreen />);
+ expect(screen.getByText(note)).toBeTruthy();
+});
+
+it('does not show the Local Mode note on the Dictation page', () => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
render(<WorkflowSettingsScreen />);
- expect(screen.queryByText(/Private Mode keeps/)).not.toBeOnTheScreen();
+ expect(screen.queryByText(/Local Mode keeps/)).not.toBeOnTheScreen();
});
it('does not edit dictation settings from an unknown workflow link', () => {
@@ -1214,7 +1269,7 @@ describe('an iPhone that cannot run Apple Intelligence', () => {
expect(modeRow('On-Device').props.accessibilityState?.disabled).toBeFalsy();
});
- it('points an unsaved On-Device-mode cleanup at Bring Your Own Key', async () => {
+ it('says Local Mode cleanup is skipped, shows nothing picked and points at Cloud', async () => {
mockActiveMode = 'private';
mockConfig = { defaultMode: 'private', inference: {} };
mockScope = 'cleanup';
@@ -1222,8 +1277,10 @@ describe('an iPhone that cannot run Apple Intelligence', () => {
expect(
await screen.findByText(
- "Not saved yet. This iPhone can't run On-Device cleanup, so Private Mode skips it until you choose Bring Your Own Key.",
+ "This iPhone can't run On-Device cleanup, so it's skipped. OpenWhispr Cloud can clean up your transcripts.",
),
).toBeTruthy();
+ expect(selectedMode()).toBeUndefined();
+ expect(screen.queryByText('Runs on Apple Intelligence on this iPhone.')).not.toBeOnTheScreen();
});
});
diff --git a/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx b/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx
index 6f074b5e4..fbdc629da 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 Private Mode is on/)).toBeTruthy();
+ expect(screen.getByText(/Off while Local Mode is on/)).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.tsx
index d1067c443..7249c7a60 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
@@ -6,8 +6,10 @@ import { SystemIcon } from '@/components/ui/SystemIcon';
import { OpenWhisprMark } from '@/components/ui/OpenWhisprMark';
import { BRAND } from '@/config/colors';
import { useOnboardingStep } from '@/hooks/useOnboardingStep';
+import { cloudAccessFor, unsetSelection } from '@/lib/aiWorkflows';
import { canRunLocalReasoning, getLocalReasoningReadiness } from '@/lib/localReasoning';
import { chooseOnboardingMode } from '@/lib/onboardingMode';
+import { useAuthStore } from '@/store/useAuthStore';
import { useConfigStore } from '@/store/useConfigStore';
import { useModelDownloadStore } from '@/store/useModelDownloadStore';
import { useOnboardingStore } from '@/store/useOnboardingStore';
@@ -17,20 +19,21 @@ type ModeChoice = 'cloud' | 'private';
type CleanupLine = { included: boolean; text: string; hint?: string };
-// What Private Mode's cleanup does on this phone, matching what choosing it saves
-// (chooseOnboardingMode): a cleanup provider saved earlier keeps cleaning, and otherwise it's
-// Apple Intelligence or nothing. On an iPhone nothing is shown until the check answers.
+// What cleanup does in Local Mode: the mode saved for cleanup, or with nothing saved, OpenWhispr
+// Cloud for a signed-in account and Apple Intelligence or nothing otherwise (unsetSelection). On an
+// iPhone the On-Device line waits for the readiness check.
function privateCleanupLine(
readiness: LocalReasoningReadiness | null,
- savedCleanup: InferenceMode | undefined,
+ cleanup: InferenceMode,
): CleanupLine | null {
- if (savedCleanup === 'providers') {
+ if (cleanup === 'providers') {
return {
included: true,
text: 'Cleanup with your saved provider',
hint: 'Your transcription is sent to the provider you chose in AI Models.',
};
}
+ if (cleanup === 'openwhispr') return { included: true, text: 'Cleanup with OpenWhispr Cloud' };
if (Platform.OS !== 'ios') {
return {
included: false,
@@ -83,8 +86,12 @@ export function PrivacyModeStep(): ReactElement {
cancelled = true;
};
}, []);
- const savedCleanup = useConfigStore((state) => state.config?.inference?.cleanup?.mode);
- const cleanupLine = privateCleanupLine(readiness, savedCleanup);
+ const cloudAccess = useAuthStore((state) => cloudAccessFor(state.user));
+ const savedCleanup = useConfigStore((state) => state.config?.inference?.cleanup);
+ const cleanupLine = privateCleanupLine(
+ readiness,
+ (savedCleanup ?? unsetSelection('cleanup', 'private', cloudAccess)).mode,
+ );
const handleContinue = async (): Promise<void> => {
if (choice === 'private') {
@@ -124,15 +131,15 @@ export function PrivacyModeStep(): ReactElement {
<Bullet text="Automatic cleanup & formatting" />
</ModeCard>
<ModeCard
- title="Private Mode"
+ title="Local Mode"
icon={<SystemIcon name="lock.fill" mdName="Lock" size={18} color="brand" />}
selected={choice === 'private'}
onSelect={() => setChoice('private')}
>
<Text className="mt-1 text-[14px] leading-[19px] text-secondaryLabel">
- Everything runs on your device. Nothing is ever uploaded.
+ Dictation runs on your device and never leaves it.
</Text>
- <Bullet text="Works fully offline" />
+ <Bullet text="Dictation works offline" />
{cleanupLine ? <Bullet {...cleanupLine} /> : null}
<Text className="mt-2 text-[12px] text-tertiaryLabel">
One-time ~140–461 MB download, depending on language
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx
index b548e43c3..013f687c1 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx
@@ -121,7 +121,7 @@ export function PrivateDownloadStep() {
<OnboardingShell
progress={stepProgress}
onBack={goBack}
- title="Private Mode needs the full app"
+ title="Local Mode needs the full app"
subtitle={getPrivateModeUnavailableMessage()}
ctaLabel="Use Cloud instead"
onCta={switchToCloud}
@@ -140,7 +140,7 @@ export function PrivateDownloadStep() {
<OnboardingShell
progress={stepProgress}
onBack={goBack}
- title="Private Mode setup needs another try"
+ title="Local Mode setup needs another try"
subtitle={discoveryError}
ctaLabel="Retry model selection"
onCta={() => setDiscoveryAttempt((attempt) => attempt + 1)}
@@ -161,15 +161,15 @@ export function PrivateDownloadStep() {
<OnboardingShell
progress={stepProgress}
onBack={goBack}
- title="Set up Private Mode"
- titleAccent="Private"
- subtitle={`Private runs entirely on your device. It needs a one-time ${
+ title="Set up Local Mode"
+ titleAccent="Local"
+ subtitle={`Local Mode transcribes on your device. It needs a one-time ${
modelSize || 'model'
} download, matched to your languages.`}
- ctaLabel={done ? 'Continue with Private' : 'Continue · available when ready'}
+ ctaLabel={done ? 'Continue with Local Mode' : 'Continue · available when ready'}
ctaDisabled={!done}
onCta={() => chooseOnboardingMode('private', 'private-download')}
- secondaryCtaLabel={done ? 'Use Cloud instead' : "Don't use Private — switch to Cloud"}
+ secondaryCtaLabel={done ? 'Use Cloud instead' : "Don't use Local Mode — switch to Cloud"}
onSecondaryCta={switchToCloudStop}
>
<View className="flex-1 pt-2">
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx b/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx
index a47cc4341..f802926a0 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/SlowDownloadSheet.tsx
@@ -62,16 +62,16 @@ export function SlowDownloadSheet({
Download taking a while?
</Text>
<Text className="mt-1.5 text-[15px] leading-[20px] text-secondaryLabel">
- No need to wait. Continue setup on Cloud now — we&apos;ll finish your Private download
- in the background.
+ No need to wait. Continue setup on Cloud now — we&apos;ll finish your Local Mode
+ download in the background.
</Text>
<View className="mt-4 rounded-2xl border border-separator bg-secondarySystemGroupedBackground p-4">
<View className="flex-row items-center gap-2">
<SystemIcon name="lock.fill" mdName="Lock" size={16} color="brand" />
<Text className="flex-1 text-[13px] leading-[18px] text-secondaryLabel">
- Turn on <Text className="font-semibold text-label">Private Mode</Text> in Account
- → AI Models to switch once it&apos;s ready.
+ Set <Text className="font-semibold text-label">Dictation</Text> to On-Device in
+ Account → AI Models to switch once it&apos;s ready.
</Text>
</View>
</View>
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
index 706f0f696..c0cf7869c 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
@@ -15,6 +15,10 @@ jest.mock('@/store/useConfigStore', () => ({
useConfigStore: (selector: (state: unknown) => unknown) =>
selector({ config: { inference: { cleanup: mockSavedCleanup } } }),
}));
+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' };
jest.mock('@/lib/localReasoning', () => ({
...jest.requireActual('@/lib/localReasoning'),
@@ -48,6 +52,7 @@ beforeEach(() => {
mockSelectedMode = null;
mockReadiness = { status: 'ready' };
mockSavedCleanup = undefined;
+ mockUser = null;
jest.mocked(chooseOnboardingMode).mockResolvedValue(undefined);
mockCancelActiveDownloads.mockResolvedValue(undefined);
});
@@ -58,14 +63,14 @@ async function renderStep(): Promise<ReturnType<typeof render>> {
return screen;
}
const CLOUD = 'OpenWhispr Cloud';
-const LOCAL = 'Private Mode';
+const LOCAL = 'Local Mode';
it('describes each mode in a few short lines', async () => {
const screen = await renderStep();
for (const text of [
'Zero setup',
- 'Everything runs on your device. Nothing is ever uploaded.',
- 'Works fully offline',
+ 'Dictation runs on your device and never leaves it.',
+ 'Dictation works offline',
'Faster transcription',
'Higher quality',
'Automatic cleanup & formatting',
@@ -128,24 +133,25 @@ describe('cleanup line', () => {
expect(screen.queryByText(/Apple Intelligence|iPhone/)).toBeNull();
});
- // A provider saved for cleanup keeps cleaning in Private mode, on any phone.
- it.each(['ios', 'android'] as const)('names a saved cleanup provider (%s)', async (os) => {
- Platform.OS = os;
- mockReadiness = { status: 'unsupportedDevice' };
- mockSavedCleanup = { mode: 'providers' };
+ // Local Mode runs the cleanup saved for it, so a saved choice names where cleanup goes.
+ it.each([
+ ['openwhispr', 'Cleanup with OpenWhispr Cloud'],
+ ['providers', 'Cleanup with your saved provider'],
+ ])('names a saved %s cleanup', async (mode, line) => {
+ mockSavedCleanup = { mode };
const screen = await renderStep();
- expect(screen.getByText('Cleanup with your saved provider')).toBeTruthy();
- expect(
- screen.getByText('Your transcription is sent to the provider you chose in AI Models.'),
- ).toBeTruthy();
- expect(screen.queryByText(/Apple Intelligence|raw transcription/)).toBeNull();
+ expect(screen.getByText(line)).toBeTruthy();
+ expect(screen.queryByText(/Apple Intelligence/)).toBeNull();
});
- // Private mode never runs it, so the line is the one for this phone.
- it('ignores a saved Cloud cleanup', async () => {
- mockSavedCleanup = { mode: 'openwhispr' };
+ // With nothing saved, Local Mode cleans on OpenWhispr Cloud for a signed-in account only.
+ it.each([
+ [{ id: 'u', isAnonymous: false }, 'Cleanup with OpenWhispr Cloud'],
+ [{ id: 'a', isAnonymous: true }, 'Cleanup with Apple Intelligence'],
+ ])('with nothing saved, cleans for %j with the line %s', async (user, line) => {
+ mockUser = user;
const screen = await renderStep();
- expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();
+ expect(screen.getByText(line)).toBeTruthy();
});
// Neither says whether this iPhone can run it, so the card makes no claim.
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivateDownloadStep.test.tsx b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivateDownloadStep.test.tsx
index 84971ad5c..79f1a79d2 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivateDownloadStep.test.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivateDownloadStep.test.tsx
@@ -177,7 +177,7 @@ it('uses the same Cloud choice when model discovery fails', async () => {
it('reasserts Local before continuing with a completed model', async () => {
setDownload('parakeet-v2', { status: 'completed', progress: 1 });
render(<PrivateDownloadStep />);
- fireEvent.press(await screen.findByText('Continue with Private'));
+ fireEvent.press(await screen.findByText('Continue with Local Mode'));
await waitFor(() => expect(mockChooseMode).toHaveBeenCalledWith('private', 'private-download'));
});
@@ -189,7 +189,7 @@ describe('PrivateDownloadStep — switching to Cloud', () => {
render(<PrivateDownloadStep />);
await screen.findByText('Parakeet v2');
- fireEvent.press(screen.getByText("Don't use Private — switch to Cloud"));
+ fireEvent.press(screen.getByText("Don't use Local Mode — switch to Cloud"));
await waitFor(() => expect(mockCancelDownload).toHaveBeenCalledWith('parakeet-v2'));
expect(mockChooseMode).toHaveBeenCalledWith('cloud', 'private-download');
@@ -268,7 +268,7 @@ it('stops a stale download even when the new recommendation is already installed
render(<PrivateDownloadStep />);
- await screen.findByText('Continue with Private');
+ await screen.findByText('Continue with Local Mode');
await waitFor(() =>
expect(useModelDownloadStore.getState().downloads['parakeet-v2'].status).toBe('idle'),
);
diff --git a/openwhispr-mobile/src/services/transcription/TranscriptionService.ts b/openwhispr-mobile/src/services/transcription/TranscriptionService.ts
index 340a191d9..53632b82c 100644
--- a/openwhispr-mobile/src/services/transcription/TranscriptionService.ts
+++ b/openwhispr-mobile/src/services/transcription/TranscriptionService.ts
@@ -968,7 +968,14 @@ export class TranscriptionService {
const { transcribeWithProvider } =
require('@/services/providers/ProviderExecution') as typeof import('@/services/providers/ProviderExecution');
const scope = request.requestContext === 'file' ? 'upload' : 'dictation';
- const route = await resolveMobileProviderRoute(scope, request.inferenceRoute);
+ // Local Mode keeps dictation on this iPhone, but an upload goes to the provider saved for
+ // uploads.
+ const route = await resolveMobileProviderRoute(
+ scope,
+ request.inferenceRoute,
+ false,
+ scope === 'upload',
+ );
const recoveryJobId = request.jobId ?? request.clientTranscriptionId;
const routeSnapshot = recoveryJobId
? JSON.stringify({
diff --git a/openwhispr-mobile/src/services/transcription/__tests__/TranscriptionService.byok.test.ts b/openwhispr-mobile/src/services/transcription/__tests__/TranscriptionService.byok.test.ts
index 504cd7b56..37941e6c4 100644
--- a/openwhispr-mobile/src/services/transcription/__tests__/TranscriptionService.byok.test.ts
+++ b/openwhispr-mobile/src/services/transcription/__tests__/TranscriptionService.byok.test.ts
@@ -1,5 +1,6 @@
import * as FileSystem from 'expo-file-system/legacy';
import { BackgroundUploader } from '../../../../modules/background-uploader/src';
+import { resolveMobileProviderRoute } from '@/lib/inferenceRouting';
import { transcribeWithProvider } from '@/services/providers/ProviderExecution';
import { TranscriptionService } from '../TranscriptionService';
import type { TranscriptionRequest } from '../../../types';
@@ -104,6 +105,28 @@ test('BYOK returns provider metadata without an OpenWhispr session or upload', a
expect(FileSystem.uploadAsync).not.toHaveBeenCalled();
});
+// Local Mode keeps dictation on this iPhone, but an upload goes to the provider saved for uploads.
+test.each([
+ ['file', 'upload', true],
+ ['recording', 'dictation', false],
+] as const)(
+ 'lets a %s go to its saved provider only when it is an upload',
+ async (requestContext, scope, allowRemoteContent): Promise<void> => {
+ await TranscriptionService.transcribe({
+ audioUri: 'file:///clip.wav',
+ provider: 'byok',
+ requestContext,
+ inferenceRoute: mockProviderRoute,
+ });
+ expect(resolveMobileProviderRoute).toHaveBeenCalledWith(
+ scope,
+ mockProviderRoute,
+ false,
+ allowRemoteContent,
+ );
+ },
+);
+
test('BYOK recovery snapshot preserves the pinned text stages and client job ID', async (): Promise<void> => {
await TranscriptionService.transcribe({
audioUri: 'file:///recording.wav',
diff --git a/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts b/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts
new file mode 100644
index 000000000..6d318ee55
--- /dev/null
+++ b/openwhispr-mobile/src/store/__tests__/useConfigStore.test.ts
@@ -0,0 +1,77 @@
+const mockGetConfig = jest.fn();
+const mockSaveConfig = jest.fn();
+
+jest.mock('react-native', () => ({ Platform: { OS: 'ios' } }));
+jest.mock('@/services/storage/StorageService', () => ({
+ StorageService: {
+ getConfig: () => mockGetConfig(),
+ saveConfig: (config: unknown) => mockSaveConfig(config),
+ clearConfig: jest.fn(),
+ },
+}));
+jest.mock('@/store/useProcessingModeStore', () => ({
+ useProcessingModeStore: { getState: () => ({ resetToDefault: jest.fn() }) },
+}));
+
+import { useConfigStore } from '../useConfigStore';
+
+beforeEach(() => {
+ jest.clearAllMocks();
+ mockSaveConfig.mockResolvedValue(undefined);
+ useConfigStore.setState({ config: null, isLoading: false, error: null });
+});
+
+// A config from before Local Mode's Cloud defaults must never reach Cloud with them.
+it('upgrades a Local Mode config from before the Cloud defaults before anything reads it', async () => {
+ mockGetConfig.mockResolvedValue({
+ defaultMode: 'private',
+ inference: { dictation: { mode: 'local' } },
+ });
+
+ await useConfigStore.getState().loadConfig();
+
+ const upgraded = {
+ defaultMode: 'private',
+ localModeUpgraded: true,
+ inference: {
+ dictation: { mode: 'local' },
+ upload: { mode: 'local' },
+ cleanup: { mode: 'local' },
+ },
+ pinnedInference: ['upload', 'cleanup'],
+ };
+ expect(useConfigStore.getState().config).toEqual(upgraded);
+ expect(mockSaveConfig).toHaveBeenCalledWith(upgraded);
+});
+
+it('still upgrades the loaded config when saving it fails', async () => {
+ mockGetConfig.mockResolvedValue({ defaultMode: 'private' });
+ mockSaveConfig.mockRejectedValue(new Error('disk full'));
+
+ await useConfigStore.getState().loadConfig();
+
+ expect(useConfigStore.getState().config).toMatchObject({
+ localModeUpgraded: true,
+ pinnedInference: ['upload', 'cleanup'],
+ });
+ expect(useConfigStore.getState().error).toBeNull();
+});
+
+it('leaves an upgraded config alone', async () => {
+ const config = { defaultMode: 'private', localModeUpgraded: true };
+ mockGetConfig.mockResolvedValue(config);
+
+ await useConfigStore.getState().loadConfig();
+
+ expect(useConfigStore.getState().config).toBe(config);
+ expect(mockSaveConfig).not.toHaveBeenCalled();
+});
+
+it('starts a new install on the Cloud defaults', async () => {
+ mockGetConfig.mockResolvedValue(null);
+
+ await useConfigStore.getState().loadConfig();
+
+ expect(useConfigStore.getState().config).toMatchObject({ localModeUpgraded: true });
+ expect(mockSaveConfig).not.toHaveBeenCalled();
+});
diff --git a/openwhispr-mobile/src/store/__tests__/useTranscriptStore.retry.test.ts b/openwhispr-mobile/src/store/__tests__/useTranscriptStore.retry.test.ts
index d6795ad5a..276c4c33c 100644
--- a/openwhispr-mobile/src/store/__tests__/useTranscriptStore.retry.test.ts
+++ b/openwhispr-mobile/src/store/__tests__/useTranscriptStore.retry.test.ts
@@ -62,6 +62,10 @@ jest.mock('@/store/useProcessingModeStore', () => ({
},
}));
+jest.mock('@/store/useAuthStore', () => ({
+ useAuthStore: { getState: () => ({ user: null }) },
+}));
+
jest.mock('@/lib/appsflyer', () => ({
logTranscriptionCompleted: mockLogTranscriptionCompleted,
}));
@@ -489,6 +493,23 @@ it('retries a Cloud recording on-device after switching to private mode', async
);
});
+// Local Mode keeps dictation on this phone, but an upload follows what is chosen for uploads.
+it('retries an upload in Local Mode on the route chosen for uploads', async () => {
+ mockProcessingModeState.activeMode = 'private';
+ mockSnapshotTranscriptionJob.mockReturnValueOnce({
+ provider: 'cloud',
+ cleanupRoute: { mode: 'openwhispr', scope: 'cleanup' },
+ });
+ useTranscriptStore.setState({
+ transcripts: [failedTranscript({ provider: 'local', requestContext: 'file' })],
+ });
+ await useTranscriptStore.getState().retryTranscript('t1');
+ expect(mockSnapshotTranscriptionJob).toHaveBeenCalledWith('upload');
+ expect(mockTranscribeAndCleanup).toHaveBeenCalledWith(
+ expect.objectContaining({ provider: 'cloud' }),
+ );
+});
+
it('retries an On-Device recording on Cloud after switching to Cloud', async () => {
useTranscriptStore.setState({
transcripts: [
diff --git a/openwhispr-mobile/src/store/useConfigStore.ts b/openwhispr-mobile/src/store/useConfigStore.ts
index 8035318dd..4279e24c4 100644
--- a/openwhispr-mobile/src/store/useConfigStore.ts
+++ b/openwhispr-mobile/src/store/useConfigStore.ts
@@ -1,6 +1,7 @@
import { create } from 'zustand';
import { UserConfig } from '../types';
import { StorageService } from '../services/storage/StorageService';
+import { localModeUpgradeConfig } from '../lib/inferenceModes';
import { useProcessingModeStore } from './useProcessingModeStore';
interface ConfigState {
@@ -15,6 +16,7 @@ interface ConfigState {
const defaultConfig: UserConfig = {
defaultMode: 'cloud',
appleLocalIntelligenceEnabled: true,
+ localModeUpgraded: true,
};
export const useConfigStore = create<ConfigState>((set, get) => ({
@@ -26,7 +28,16 @@ export const useConfigStore = create<ConfigState>((set, get) => ({
set({ isLoading: true, error: null });
try {
const config = await StorageService.getConfig();
- const resolvedConfig = config || defaultConfig;
+ // A config from before Local Mode's Cloud defaults is upgraded before anything reads it, so
+ // its uploads and cleanup never reach Cloud. A failed save upgrades it again next launch.
+ const resolvedConfig = !config
+ ? defaultConfig
+ : config.localModeUpgraded
+ ? config
+ : { ...config, ...localModeUpgradeConfig(config) };
+ if (config && resolvedConfig !== config) {
+ await StorageService.saveConfig(resolvedConfig).catch(() => undefined);
+ }
useProcessingModeStore.getState().resetToDefault(resolvedConfig.defaultMode);
set({ config: resolvedConfig, isLoading: false });
} catch (error) {
diff --git a/openwhispr-mobile/src/store/useModelDownloadStore.ts b/openwhispr-mobile/src/store/useModelDownloadStore.ts
index e302201b7..d0de107e5 100644
--- a/openwhispr-mobile/src/store/useModelDownloadStore.ts
+++ b/openwhispr-mobile/src/store/useModelDownloadStore.ts
@@ -94,7 +94,7 @@ export const useModelDownloadStore = create<ModelDownloadState>((set, get) => {
{
status: 'error',
error:
- 'Local Whisper is not available. Build the app with `npx expo run:ios` to enable Private Mode.',
+ 'Local Whisper is not available. Build the app with `npx expo run:ios` to enable Local Mode.',
},
requestId,
);
diff --git a/openwhispr-mobile/src/store/useTranscriptStore.ts b/openwhispr-mobile/src/store/useTranscriptStore.ts
index 9340a5c61..6dfdfaccf 100644
--- a/openwhispr-mobile/src/store/useTranscriptStore.ts
+++ b/openwhispr-mobile/src/store/useTranscriptStore.ts
@@ -355,11 +355,14 @@ export const useTranscriptStore = create<TranscriptState>((set, get) => {
throw new Error('The original provider route is unavailable. Start a new transcription.');
}
const { activeMode } = useProcessingModeStore.getState();
+ const scope = current.requestContext === 'file' ? 'upload' : 'dictation';
// Provider recordings keep their original route. Cloud and On-Device
- // recordings follow the current mode, including the provider it now selects.
+ // recordings follow the current mode, including the provider it now selects;
+ // in Local Mode, uploads follow what is chosen for them.
const rerouted =
- current.provider !== 'byok' && activeMode === 'providers'
- ? snapshotTranscriptionJob(current.requestContext === 'file' ? 'upload' : 'dictation')
+ current.provider !== 'byok' &&
+ (activeMode === 'providers' || (activeMode === 'private' && scope === 'upload'))
+ ? snapshotTranscriptionJob(scope)
: undefined;
const provider =
rerouted?.provider ??
@@ -367,9 +370,9 @@ export const useTranscriptStore = create<TranscriptState>((set, get) => {
const inferenceRoute = rerouted ? rerouted.inferenceRoute : current.inferenceRoute;
const textRoutes =
rerouted ?? (provider === current.provider ? current : snapshotTextInference(provider));
- if (provider !== 'local' && activeMode === 'private') {
+ if (provider !== 'local' && activeMode === 'private' && scope === 'dictation') {
throw new Error(
- 'This recording used a remote provider. Turn off Private Mode in Account → AI Models to retry its original route.',
+ 'This recording used a remote provider. Change Dictation from On-Device in Account → AI Models to retry its original route.',
);
}
const retryCount = (current.retryCount ?? 0) + 1;
diff --git a/openwhispr-mobile/src/types/index.ts b/openwhispr-mobile/src/types/index.ts
index 6a21050d6..244cfbc2b 100644
--- a/openwhispr-mobile/src/types/index.ts
+++ b/openwhispr-mobile/src/types/index.ts
@@ -20,12 +20,11 @@ export interface UserConfig {
// off goes back to the last provider rather than to Cloud, with the workflows it held
// (pinnedInference) held on the same selections again.
privateModeReturn?: { pinned: Partial<Record<MobileInferenceScope, InferenceSelection>> };
+ // Set once a config follows Local Mode's OpenWhispr Cloud defaults for uploads and cleanup. New
+ // installs start with it; older configs get it from localModeUpgradeConfig at launch.
+ localModeUpgraded?: boolean;
defaultMode: ProcessingMode;
cleanupEnabled?: boolean;
- // Private mode was chosen in setup before this iPhone could run Apple Intelligence (an older
- // iOS, or it was off in AI Models or unreadable), so On-Device cleanup is saved the first time a
- // launch finds it can.
- onDeviceCleanupPending?: boolean;
autoGenerateNoteTitle?: boolean;
autoLearnCorrections?: boolean;
preferredLanguage?: string;