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): turn on cleanup when Private Mode is chosen in onboarding (#2687)

Chad Piha5ce7521e8123
diff --git a/openwhispr-mobile/app/_layout.tsx b/openwhispr-mobile/app/_layout.tsx
index 33e2ba1a4..44c1362b0 100644
--- a/openwhispr-mobile/app/_layout.tsx
+++ b/openwhispr-mobile/app/_layout.tsx
@@ -35,6 +35,7 @@ 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';
@@ -103,6 +104,8 @@ 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 98c3d0475..2f94780a3 100644
--- a/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift
+++ b/openwhispr-mobile/plugins/keyboard-extension/ios/KeyboardViewController.swift
@@ -1796,7 +1796,7 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDe
// when locked. The header costs one row of the height-capped menu, so on
// shorter keyboards the last tone ("Excited") can fall into the scroll
// region instead of showing inline.
- let menuTitle = applicable ? "Dictation Tone" : "Turn off Private mode to use tones"
+ let menuTitle = applicable ? "Dictation Tone" : "Turn off Private Mode to use tones"
toneButton.menu = UIMenu(title: menuTitle, children: actions)
toneButton.isUserInteractionEnabled = true
toneButton.alpha = applicable ? 1.0 : 0.4
@@ -3063,7 +3063,7 @@ final class KeyboardViewController: UIInputViewController, UIGestureRecognizerDe
guard provider.isAgentApplicable() else {
playKeyClick()
showTransientRecordState(
- title: "Turn off Private mode",
+ title: "Turn off Private 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 86b9a07df..6e6ea7767 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 Local for now.';
+ const message = 'Cloud needs a connection to set up. Try again or use Private Mode for now.';
render(
<OnboardingShell
title="Mode"
diff --git a/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts b/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts
index a9d0f47cc..741953aad 100644
--- a/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/localReasoning.test.ts
@@ -24,6 +24,7 @@ jest.mock('@/store/useConfigStore', () => ({
}));
import {
+ canRunLocalReasoning,
clearLocalReasoningReadinessCache,
getLocalReasoningReadiness,
getLocalReasoningUnavailableMessage,
@@ -126,6 +127,19 @@ it.each(['ready', 'disabled', 'appleIntelligenceOff', 'modelNotReady', 'unavaila
},
);
+// Off in iOS Settings or still preparing its model, the iPhone still runs Apple Intelligence.
+it.each([
+ ['ready', true],
+ ['appleIntelligenceOff', true],
+ ['modelNotReady', true],
+ ['disabled', false],
+ ['unavailable', false],
+ ['unsupportedDevice', false],
+ ['unsupportedOS', false],
+] as const)('reports whether this iPhone runs Apple Intelligence when %s', (status, runs) => {
+ expect(canRunLocalReasoning({ status, tokenCounting: false })).toBe(runs);
+});
+
it.each([
[
'unsupportedDevice',
diff --git a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
index 2aef10a3a..dcf1e5844 100644
--- a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
@@ -1,4 +1,5 @@
-import { chooseOnboardingMode } from '../onboardingMode';
+import { Platform } from 'react-native';
+import { applyPendingOnDeviceCleanup, chooseOnboardingMode } from '../onboardingMode';
import { OnboardingError } from '../onboardingErrors';
jest.mock('@/lib/sentry', () => ({ Sentry: { captureException: jest.fn() } }));
@@ -10,6 +11,8 @@ 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: {
@@ -25,9 +28,18 @@ jest.mock('@/store/useProcessingModeStore', () => ({
}));
jest.mock('@/store/useOnboardingStore', () => ({
useOnboardingStore: {
- getState: () => ({ currentStep: mockCurrentStep, chooseMode: mockChooseMode }),
+ getState: () => ({
+ currentStep: mockCurrentStep,
+ selectedMode: mockSelectedMode,
+ 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,
@@ -49,6 +61,10 @@ 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);
@@ -132,7 +148,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' } },
+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'local' } },
pinnedInference: undefined,
});
expect(mockUpdateConfig).toHaveBeenLastCalledWith({
@@ -162,3 +178,236 @@ 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.tone.test.ts b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
index df0700d5a..8d2eab2c7 100644
--- a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.tone.test.ts
@@ -23,8 +23,9 @@ jest.mock('@/lib/permissions', () => ({
isNoSpeechError: jest.fn(() => false),
}));
+let mockConfig: Record<string, unknown> = { cleanupEnabled: true };
jest.mock('@/store/useConfigStore', () => ({
- useConfigStore: { getState: () => ({ config: { cleanupEnabled: true } }) },
+ useConfigStore: { getState: () => ({ config: mockConfig }) },
}));
// Snippets merged into this pipeline: transcribeAndCleanup now reads the snippet
@@ -55,10 +56,19 @@ jest.mock('@/services/reasoning/ReasoningService', () => ({
},
}));
+let mockActiveMode = 'cloud';
jest.mock('@/store/useProcessingModeStore', () => ({
- useProcessingModeStore: { getState: () => ({ activeMode: 'cloud' }) },
+ useProcessingModeStore: { getState: () => ({ activeMode: mockActiveMode }) },
}));
+const PROVIDER_ROUTE = {
+ mode: 'providers' as const,
+ scope: 'cleanup' as const,
+ providerId: 'groq',
+ modelId: 'llama',
+ endpoint: 'https://api.groq.com/openai/v1',
+};
+
const mockTranscribe = TranscriptionService.transcribe as jest.Mock;
const mockFused = TranscriptionService.transcribeWithCloudCleanup as jest.Mock;
const mockCleanup = cleanupTranscript as jest.Mock;
@@ -66,6 +76,8 @@ const mockCleanup = cleanupTranscript as jest.Mock;
beforeEach(() => {
jest.clearAllMocks();
mockUser = { id: 'u', isAnonymous: false };
+ mockActiveMode = 'cloud';
+ mockConfig = { cleanupEnabled: true };
mockTranscribe.mockResolvedValue({ text: 'hello world', provider: 'cloud', duration: 1 });
});
@@ -168,4 +180,54 @@ 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],
+ [
+ 'On-Device cleanup in Private mode',
+ 'private',
+ { mode: 'local' as const, scope: 'cleanup' as const },
+ ],
+ [
+ 'On-Device cleanup outside Private mode',
+ 'cloud',
+ { mode: 'local' as const, scope: 'cleanup' as const },
+ ],
+ ])('passes no tone to %s', async (_label, activeMode, cleanupRoute) => {
+ mockActiveMode = activeMode;
+ mockConfig = { cleanupEnabled: true, inference: { cleanup: { mode: cleanupRoute.mode } } };
+ mockTranscribe.mockResolvedValue({ text: 'hello world', provider: 'local', duration: 1 });
+
+ await transcribeAndCleanup({
+ audioUri: 'file://a.wav',
+ provider: 'local',
+ requestContext: 'keyboard',
+ keyboardTone: 'formal',
+ cleanupRoute,
+ });
+
+ expect(mockCleanup).toHaveBeenCalledWith(
+ 'hello world',
+ expect.objectContaining({ tone: undefined, inferenceRoute: cleanupRoute }),
+ );
+ });
+
+ it('passes the tone to a cleanup provider outside Private mode', async () => {
+ mockActiveMode = 'providers';
+
+ await transcribeAndCleanup({
+ audioUri: 'file://a.wav',
+ provider: 'cloud',
+ requestContext: 'keyboard',
+ keyboardTone: 'formal',
+ cleanupRoute: PROVIDER_ROUTE,
+ });
+
+ expect(mockCleanup).toHaveBeenCalledWith(
+ 'hello world',
+ expect.objectContaining({ tone: 'formal', inferenceRoute: PROVIDER_ROUTE }),
+ );
+ });
});
diff --git a/openwhispr-mobile/src/lib/aiWorkflows.ts b/openwhispr-mobile/src/lib/aiWorkflows.ts
index 811edd318..2205a5af2 100644
--- a/openwhispr-mobile/src/lib/aiWorkflows.ts
+++ b/openwhispr-mobile/src/lib/aiWorkflows.ts
@@ -24,21 +24,21 @@ export const UNSET_PROVIDER_NOTES: Partial<Record<MobileInferenceScope, string>>
// 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.';
+ 'Not saved yet. Private Mode skips cleanup until you choose On-Device or Bring Your Own Key.';
// The same, on an iPhone that can never run On-Device cleanup.
export const UNSET_UNSUPPORTED_CLEANUP_NOTE =
- "Not saved yet. This iPhone can't run On-Device cleanup, so Private mode skips it until you choose Bring Your Own Key.";
+ "Not saved yet. This iPhone can't run On-Device cleanup, so Private Mode skips it until you choose Bring Your Own Key.";
// What Private mode means for each workflow other than dictation.
export const ON_DEVICE_MODE_NOTES: Partial<Record<MobileInferenceScope, string>> = {
- upload: 'Private mode keeps uploads on this iPhone.',
+ 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.',
+ '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.',
+ 'In Private Mode, cleanup runs on this iPhone, or sends only the transcript text to your provider with Bring Your Own Key. OpenWhispr Cloud cleanup is skipped until Private Mode is off.',
agent:
- 'In Private mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
+ 'In Private Mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
};
// Modes Private mode never runs for a workflow, so its page can't offer them as if they would.
@@ -50,7 +50,7 @@ export const PRIVATE_MODE_LOCKED: Partial<Record<MobileInferenceScope, Inference
cleanup: ['openwhispr'],
};
-export const PRIVATE_MODE_LOCKED_REASON = 'Off while Private mode is on. Turn it off in AI Models.';
+export const PRIVATE_MODE_LOCKED_REASON = 'Off while Private Mode is on. Turn it off in AI Models.';
// A local transcript is cleaned on the phone when cleanup is saved as On-Device.
export function cleanupSavedOnDevice(config: UserConfig | null): boolean {
diff --git a/openwhispr-mobile/src/lib/keyboardTone.ts b/openwhispr-mobile/src/lib/keyboardTone.ts
index 8558b4e81..e8223d292 100644
--- a/openwhispr-mobile/src/lib/keyboardTone.ts
+++ b/openwhispr-mobile/src/lib/keyboardTone.ts
@@ -10,8 +10,8 @@ export const KEYBOARD_TONES: { value: KeyboardTone; label: string; description:
export const DEFAULT_KEYBOARD_TONE: KeyboardTone = 'default';
-// Tone applies when remote cleanup runs. Private mode never
-// sends text to an LLM, and cleanup-off skips the rewrite entirely.
+// Tone is a Cloud cleanup option: Private mode's On-Device cleanup takes none, and
+// cleanup-off skips the rewrite entirely.
export function isToneApplicable(
mode: ProcessingMode,
cleanupEnabled: boolean | undefined,
diff --git a/openwhispr-mobile/src/lib/localReasoning.ts b/openwhispr-mobile/src/lib/localReasoning.ts
index d5117e481..ff5dbf075 100644
--- a/openwhispr-mobile/src/lib/localReasoning.ts
+++ b/openwhispr-mobile/src/lib/localReasoning.ts
@@ -175,6 +175,16 @@ export async function fitsLocalReasoningBudget(input: {
return count < budget;
}
+// This iPhone runs Apple Intelligence, even if it is turned off in Settings or still preparing
+// its model. Disabled in AI Models or unavailable says nothing about the device either way.
+export function canRunLocalReasoning(readiness?: LocalReasoningReadiness | null): boolean {
+ return (
+ readiness?.status === 'ready' ||
+ readiness?.status === 'appleIntelligenceOff' ||
+ readiness?.status === 'modelNotReady'
+ );
+}
+
// Unlike Apple Intelligence being off or still downloading, nothing in Settings fixes these.
export function isLocalReasoningUnsupported(readiness?: LocalReasoningReadiness | null): boolean {
return readiness?.status === 'unsupportedDevice' || readiness?.status === 'unsupportedOS';
diff --git a/openwhispr-mobile/src/lib/onboardingMode.ts b/openwhispr-mobile/src/lib/onboardingMode.ts
index ce10fe860..a127562a5 100644
--- a/openwhispr-mobile/src/lib/onboardingMode.ts
+++ b/openwhispr-mobile/src/lib/onboardingMode.ts
@@ -1,10 +1,14 @@
+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 { UserConfig } from '@/types';
+import type { LocalReasoningReadiness, UserConfig } from '@/types';
+import type { InferenceSelection } from './mobileProviders';
+import { PRIVATE_MODE_LOCKED } from './aiWorkflows';
import { dictationModeConfig } from './inferenceModes';
+import { canRunLocalReasoning, getLocalReasoningReadiness } from './localReasoning';
import { OnboardingError } from './onboardingErrors';
// updateConfig reports persistence errors in its store instead of rejecting.
@@ -15,6 +19,67 @@ 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',
@@ -30,27 +95,42 @@ export async function chooseOnboardingMode(
if (from !== 'private-download')
throw new OnboardingError(
auth.isGuest
- ? 'Cloud needs an account. Use Local for now, or sign in after setup.'
- : 'Cloud needs you signed in. Use Local for now, or sign in after setup.',
+ ? '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.',
);
} else {
await auth.ensureAnonymousSession();
if (!useAuthStore.getState().user) {
throw new OnboardingError(
- 'Cloud needs a connection to set up. Try again or use Local for now.',
+ 'Cloud needs a connection to set up. Try again or use Private 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.
- await saveOnboardingConfig(dictationModeConfig(config, mode));
+ 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 }
+ : {}),
+ });
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 1a4f89af0..8e6b5a393 100644
--- a/openwhispr-mobile/src/lib/transcribeAndCleanup.ts
+++ b/openwhispr-mobile/src/lib/transcribeAndCleanup.ts
@@ -19,6 +19,7 @@ import {
detectAgentMention,
} from './dictationAgent';
import { isDictationContext } from './dictationHints';
+import { isToneApplicable } from './keyboardTone';
import { isNoSpeechError } from './permissions';
import { withRetry, type RetryOptions } from './retry';
import { expandSnippets } from './snippets';
@@ -71,9 +72,16 @@ function cleansLocalTranscript(request: TranscriptionRequest): boolean {
);
}
+// 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 {
if (request.requestContext !== 'keyboard') return undefined;
if (!request.keyboardTone || request.keyboardTone === 'default') return undefined;
+ if (request.cleanupRoute?.mode === 'local') return undefined;
+ const { activeMode } = useProcessingModeStore.getState();
+ if (!isToneApplicable(activeMode, useConfigStore.getState().config?.cleanupEnabled)) {
+ return undefined;
+ }
return request.keyboardTone;
}
diff --git a/openwhispr-mobile/src/screens/AIModelsScreen.tsx b/openwhispr-mobile/src/screens/AIModelsScreen.tsx
index 5ca868e8e..cbe936b3e 100644
--- a/openwhispr-mobile/src/screens/AIModelsScreen.tsx
+++ b/openwhispr-mobile/src/screens/AIModelsScreen.tsx
@@ -149,7 +149,7 @@ export default function AIModelsScreen(): React.JSX.Element {
setRequestedPrivateMode(enabled);
try {
if ((await setPrivateMode(enabled)) === 'switched') {
- showToast(enabled ? 'Private mode on.' : 'Private mode off.', 'success');
+ showToast(enabled ? 'Private Mode on.' : 'Private Mode off.', 'success');
}
} finally {
setRequestedPrivateMode(null);
diff --git a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
index 87fcc0f84..4825deceb 100644
--- a/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
+++ b/openwhispr-mobile/src/screens/CleanupPromptScreen.tsx
@@ -41,7 +41,7 @@ export default function CleanupPromptScreen() {
const inactiveNotice = !cleanupEnabled
? 'Text Cleanup is off. Your prompt is saved and applies once you turn it on.'
: activeMode === 'private' && cleanupMode !== 'local' && cleanupMode !== 'providers'
- ? '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.'
+ ? 'Private Mode skips cleanup unless it is set to On-Device or Bring Your Own Key. Your prompt is saved and applies when it runs.'
: activeMode === 'providers' && !cleanupMode
? 'Bring Your Own Key skips cleanup until Text Cleanup has a selection. Your prompt is saved and applies once it does.'
: null;
diff --git a/openwhispr-mobile/src/screens/DictationAgentScreen.tsx b/openwhispr-mobile/src/screens/DictationAgentScreen.tsx
index 01654c974..b8b9cf099 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 Private Mode is off.`
: activeMode === 'providers' && !agentSelected
? 'Bring Your Own Key skips the voice assistant until Chat & Voice Assistant has a selection. Your settings are saved and apply once it does.'
: null;
diff --git a/openwhispr-mobile/src/screens/HomeScreen.tsx b/openwhispr-mobile/src/screens/HomeScreen.tsx
index cdc1b37e4..7fb2af7e5 100644
--- a/openwhispr-mobile/src/screens/HomeScreen.tsx
+++ b/openwhispr-mobile/src/screens/HomeScreen.tsx
@@ -523,7 +523,7 @@ export default function HomeScreen() {
<Pressable
onPress={() => router.push('/(account)/ai-models')}
accessibilityRole="button"
- accessibilityLabel="Private mode is on"
+ accessibilityLabel="Private Mode is on"
accessibilityHint="Opens AI Models."
className="h-9 flex-row items-center gap-1.5 rounded-full bg-tertiarySystemFill px-3 active:opacity-70"
>
diff --git a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
index 6e7e668b2..c7bb15926 100644
--- a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
+++ b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx
@@ -360,7 +360,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
: UNSET_ON_DEVICE_CLEANUP_NOTE
: undefined) ??
(lockedByPrivateMode && ON_DEVICE_MODE_NOTES[scope]
- ? `${ON_DEVICE_MODE_NOTES[scope]} Your ${MODE_LABELS[storedSelection.mode]} choice applies again when Private mode is off.`
+ ? `${ON_DEVICE_MODE_NOTES[scope]} Your ${MODE_LABELS[storedSelection.mode]} choice applies again when Private Mode is off.`
: undefined) ??
(activeMode === 'private' ? ON_DEVICE_MODE_NOTES[scope] : undefined) ??
(activeMode === 'providers' && !config?.inference?.[scope]
@@ -368,7 +368,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX
: undefined) ??
(selection.mode === 'providers' && savedSelection.mode !== 'providers'
? activeMode === 'private'
- ? 'Save to switch to Bring Your Own Key. This turns Private mode off.'
+ ? 'Save to switch to Bring Your Own Key. This turns Private Mode off.'
: 'Save to switch to Bring Your Own Key.'
: undefined);
// Private mode is switched in AI Models, so a mode it never runs here can't be picked.
diff --git a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
index 27ede6b30..4a35977a2 100644
--- a/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/AIModelsScreen.test.tsx
@@ -259,8 +259,8 @@ describe('Private Mode switch', () => {
});
it.each([
- [true, 'Private mode on.'],
- [false, 'Private mode off.'],
+ [true, 'Private Mode on.'],
+ [false, 'Private Mode off.'],
])('switches Private mode to %s', async (enabled, message) => {
mockActiveMode = enabled ? 'cloud' : 'private';
render(<AIModelsScreen />);
diff --git a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
index 6a6249dc1..58fce0422 100644
--- a/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/CleanupPromptScreen.test.tsx
@@ -97,7 +97,7 @@ describe('CleanupPromptScreen — guidance', () => {
render(<CleanupPromptScreen />);
expect(
screen.getByText(
- /Private mode skips cleanup unless it is set to On-Device or Bring Your Own Key/,
+ /Private Mode skips cleanup unless it is set to On-Device or Bring Your Own Key/,
),
).toBeTruthy();
});
diff --git a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
index a2452b938..2100437fe 100644
--- a/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/DictationAgentScreen.test.tsx
@@ -50,7 +50,7 @@ it('shows the voice assistant off in Private mode and says where to turn it back
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 Private Mode is on. Turn it off in AI Models. Your settings are saved and apply once Private Mode is off.',
),
).toBeTruthy();
const [enable] = screen.UNSAFE_getAllByType(Switch);
diff --git a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
index 379632f9d..2c828a73d 100644
--- a/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/HomeScreen.proCompletion.test.tsx
@@ -201,7 +201,7 @@ describe('HomeScreen Private mode badge', () => {
it('opens AI Models from the badge while Private mode is on', () => {
mockProcessingModeStoreState.activeMode = 'private';
render(<HomeScreen />);
- const badge = screen.getByLabelText('Private mode is on');
+ const badge = screen.getByLabelText('Private Mode is on');
expect(badge.props.accessibilityRole).toBe('button');
fireEvent.press(badge);
expect(require('expo-router').router.push).toHaveBeenCalledWith('/(account)/ai-models');
@@ -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('Private Mode is on')).toBeNull();
expect(screen.queryByLabelText('Cloud transcription')).toBeNull();
expect(screen.queryByLabelText('Transcription: Bring Your Own Key')).toBeNull();
});
diff --git a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
index 1deba0ca1..8ce4d02b8 100644
--- a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
+++ b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx
@@ -465,7 +465,7 @@ it('shows no cleanup mode for a private-mode user who has not saved one, since c
expect(selectedMode()).toBeUndefined();
expect(
screen.getByText(
- 'Not saved yet. Private mode skips cleanup until you choose On-Device or Bring Your Own Key.',
+ 'Not saved yet. Private Mode skips cleanup until you choose On-Device or Bring Your Own Key.',
),
).toBeTruthy();
expect(screen.queryByText('Runs on Apple Intelligence on this iPhone.')).toBeNull();
@@ -500,7 +500,7 @@ it('keeps uploads on this phone when dictation leaves Private mode for Bring You
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 Private Mode off.'),
).toBeTruthy();
fireEvent.press(screen.getByText('Save'));
await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());
@@ -853,7 +853,7 @@ it('explains that Private mode skips a saved Cloud cleanup choice', () => {
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.',
+ '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();
});
@@ -861,11 +861,11 @@ it('explains that Private mode skips a saved Cloud cleanup choice', () => {
it.each([
[
'agent',
- 'In Private mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
+ 'In Private Mode the voice assistant is off, and note chat asks before sending a note off this iPhone.',
],
[
'notes',
- 'Private mode formats notes on this iPhone and asks before sending one to your choice here.',
+ 'Private Mode formats notes on this iPhone and asks before sending one to your choice here.',
],
])('explains what Private mode means for %s', (scope, note) => {
mockConfig = { defaultMode: 'private' };
@@ -888,7 +888,7 @@ it('shows On-Device for an upload choice Private mode locks, and keeps that choi
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.',
+ '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();
@@ -909,7 +909,7 @@ it('names a locked Cloud upload choice in the note', () => {
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.',
+ 'Private Mode keeps uploads on this iPhone. Your OpenWhispr Cloud choice applies again when Private Mode is off.',
),
).toBeTruthy();
});
@@ -929,7 +929,7 @@ it('keeps the plain upload note when uploads already run on this phone', () => {
mockActiveMode = 'private';
mockScope = 'upload';
render(<WorkflowSettingsScreen />);
- expect(screen.getByText('Private mode keeps uploads on this iPhone.')).toBeTruthy();
+ expect(screen.getByText('Private Mode keeps uploads on this iPhone.')).toBeTruthy();
});
function modeDisabled(title: string): boolean {
@@ -955,7 +955,7 @@ it.each([
for (const title of open) expect(modeDisabled(title)).toBe(false);
// The agent page's Voice Assistant switch is off for the same reason.
expect(
- screen.queryAllByText('Off while Private mode is on. Turn it off in AI Models.'),
+ screen.queryAllByText('Off while Private Mode is on. Turn it off in AI Models.'),
).toHaveLength(locked.length + (scope === 'agent' ? 1 : 0));
});
@@ -969,7 +969,7 @@ it('does not show the Private mode note on the Dictation page', () => {
mockConfig = { defaultMode: 'private' };
mockActiveMode = 'private';
render(<WorkflowSettingsScreen />);
- expect(screen.queryByText(/Private mode keeps/)).not.toBeOnTheScreen();
+ expect(screen.queryByText(/Private Mode keeps/)).not.toBeOnTheScreen();
});
it('does not edit dictation settings from an unknown workflow link', () => {
@@ -1222,7 +1222,7 @@ describe('an iPhone that cannot run Apple Intelligence', () => {
expect(
await screen.findByText(
- "Not saved yet. This iPhone can't run On-Device cleanup, so Private mode skips it until you choose Bring Your Own Key.",
+ "Not saved yet. This iPhone can't run On-Device cleanup, so Private Mode skips it until you choose Bring Your Own Key.",
),
).toBeTruthy();
});
diff --git a/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx b/openwhispr-mobile/src/screens/__tests__/voiceAssistantNaming.test.tsx
index 7f0fece3d..6f074b5e4 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 Private 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 b77815cc9..d1067c443 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
@@ -1,17 +1,70 @@
-import { useState, type ReactElement, type ReactNode } from 'react';
-import { Pressable, ScrollView, View } from 'react-native';
+import { useEffect, useState, type ReactElement, type ReactNode } from 'react';
+import { Platform, Pressable, ScrollView, View } from 'react-native';
import { Text } from '@/components/ui/Text';
import { OnboardingShell } from '@/components/onboarding/OnboardingShell';
import { SystemIcon } from '@/components/ui/SystemIcon';
import { OpenWhisprMark } from '@/components/ui/OpenWhisprMark';
import { BRAND } from '@/config/colors';
import { useOnboardingStep } from '@/hooks/useOnboardingStep';
+import { canRunLocalReasoning, getLocalReasoningReadiness } from '@/lib/localReasoning';
import { chooseOnboardingMode } from '@/lib/onboardingMode';
+import { useConfigStore } from '@/store/useConfigStore';
import { useModelDownloadStore } from '@/store/useModelDownloadStore';
import { useOnboardingStore } from '@/store/useOnboardingStore';
+import type { InferenceMode, LocalReasoningReadiness } from '@/types';
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.
+function privateCleanupLine(
+ readiness: LocalReasoningReadiness | null,
+ savedCleanup: InferenceMode | undefined,
+): CleanupLine | null {
+ if (savedCleanup === 'providers') {
+ return {
+ included: true,
+ text: 'Cleanup with your saved provider',
+ hint: 'Your transcription is sent to the provider you chose in AI Models.',
+ };
+ }
+ if (Platform.OS !== 'ios') {
+ return {
+ included: false,
+ text: 'No automatic cleanup',
+ hint: 'You’ll get the raw transcription.',
+ };
+ }
+ if (canRunLocalReasoning(readiness)) {
+ return {
+ included: true,
+ text: 'Cleanup with Apple Intelligence',
+ hint:
+ readiness?.status === 'appleIntelligenceOff'
+ ? 'Starts once it’s on in Settings → Apple Intelligence & Siri.'
+ : undefined,
+ };
+ }
+ if (readiness?.status === 'unsupportedDevice') {
+ return {
+ included: false,
+ text: 'No cleanup on this iPhone',
+ hint: 'Needs Apple Intelligence (iPhone 15 Pro or later). You’ll get the raw transcription.',
+ };
+ }
+ if (readiness?.status === 'unsupportedOS') {
+ return {
+ included: false,
+ text: 'No cleanup on this iPhone yet',
+ hint: 'Needs iOS 26 on an iPhone with Apple Intelligence. Until then, you’ll get the raw transcription.',
+ };
+ }
+ return null;
+}
+
export function PrivacyModeStep(): ReactElement {
const { goBack, progress } = useOnboardingStep('privacy-mode');
const selectedMode = useOnboardingStore((state) => state.selectedMode);
@@ -20,6 +73,18 @@ export function PrivacyModeStep(): ReactElement {
const [choice, setChoice] = useState<ModeChoice>(
selectedMode === 'private' ? 'private' : 'cloud',
);
+ const [readiness, setReadiness] = useState<LocalReasoningReadiness | null>(null);
+ useEffect(() => {
+ let cancelled = false;
+ getLocalReasoningReadiness().then((result) => {
+ if (!cancelled) setReadiness(result);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+ const savedCleanup = useConfigStore((state) => state.config?.inference?.cleanup?.mode);
+ const cleanupLine = privateCleanupLine(readiness, savedCleanup);
const handleContinue = async (): Promise<void> => {
if (choice === 'private') {
@@ -59,7 +124,7 @@ export function PrivacyModeStep(): ReactElement {
<Bullet text="Automatic cleanup & formatting" />
</ModeCard>
<ModeCard
- title="Local · Private mode"
+ title="Private Mode"
icon={<SystemIcon name="lock.fill" mdName="Lock" size={18} color="brand" />}
selected={choice === 'private'}
onSelect={() => setChoice('private')}
@@ -68,14 +133,7 @@ export function PrivacyModeStep(): ReactElement {
Everything runs on your device. Nothing is ever uploaded.
</Text>
<Bullet text="Works fully offline" />
- <View className="mt-2 flex-row items-start gap-1.5">
- <View className="mt-px">
- <SystemIcon name="info.circle" mdName="Info" size={13} color="secondaryLabel" />
- </View>
- <Text className="flex-1 text-[13px] leading-[18px] text-secondaryLabel">
- No automatic cleanup or formatting — you get the raw transcription.
- </Text>
- </View>
+ {cleanupLine ? <Bullet {...cleanupLine} /> : null}
<Text className="mt-2 text-[12px] text-tertiaryLabel">
One-time ~140–461 MB download, depending on language
</Text>
@@ -85,11 +143,32 @@ export function PrivacyModeStep(): ReactElement {
);
}
-function Bullet({ text }: { text: string }): ReactElement {
+// A check for what the mode includes, a dash for what it doesn't, with an optional reason below.
+function Bullet({
+ text,
+ included = true,
+ hint,
+}: {
+ text: string;
+ included?: boolean;
+ hint?: string;
+}): ReactElement {
return (
- <View className="mt-1.5 flex-row items-center gap-1.5">
- <SystemIcon name="checkmark" mdName="Check" size={13} color="systemGreen" />
- <Text className="flex-1 text-[13px] leading-[18px] text-secondaryLabel">{text}</Text>
+ <View className="mt-1.5">
+ <View className="flex-row items-center gap-1.5">
+ <SystemIcon
+ name={included ? 'checkmark' : 'minus'}
+ mdName={included ? 'Check' : 'Minus'}
+ size={13}
+ color={included ? 'systemGreen' : 'tertiaryLabel'}
+ />
+ <Text className="flex-1 text-[13px] leading-[18px] text-secondaryLabel">{text}</Text>
+ </View>
+ {hint ? (
+ <Text className="ml-[19px] mt-0.5 text-[12px] leading-[16px] text-tertiaryLabel">
+ {hint}
+ </Text>
+ ) : null}
</View>
);
}
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/PrivateDownloadStep.tsx
index 52f01caa5..b548e43c3 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="Private 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="Local setup needs another try"
+ title="Private Mode setup needs another try"
subtitle={discoveryError}
ctaLabel="Retry model selection"
onCta={() => setDiscoveryAttempt((attempt) => attempt + 1)}
@@ -161,7 +161,7 @@ export function PrivateDownloadStep() {
<OnboardingShell
progress={stepProgress}
onBack={goBack}
- title="Set up Private mode"
+ title="Set up Private Mode"
titleAccent="Private"
subtitle={`Private runs entirely on your device. It needs a one-time ${
modelSize || 'model'
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 759728c7f..706f0f696 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
@@ -1,4 +1,5 @@
-import { fireEvent, render, waitFor } from '@testing-library/react-native';
+import { Platform } from 'react-native';
+import { act, fireEvent, render, waitFor } from '@testing-library/react-native';
import { PrivacyModeStep } from '../PrivacyModeStep';
import { chooseOnboardingMode } from '@/lib/onboardingMode';
import { OnboardingError } from '@/lib/onboardingErrors';
@@ -9,6 +10,16 @@ jest.mock('@/store/useOnboardingStore', () => ({
selector({ selectedMode: mockSelectedMode }),
}));
jest.mock('@/lib/onboardingMode', () => ({ chooseOnboardingMode: jest.fn() }));
+let mockSavedCleanup: { mode: string } | undefined;
+jest.mock('@/store/useConfigStore', () => ({
+ useConfigStore: (selector: (state: unknown) => unknown) =>
+ selector({ config: { inference: { cleanup: mockSavedCleanup } } }),
+}));
+let mockReadiness: { status: string } = { status: 'ready' };
+jest.mock('@/lib/localReasoning', () => ({
+ ...jest.requireActual('@/lib/localReasoning'),
+ getLocalReasoningReadiness: async () => mockReadiness,
+}));
const mockCancelActiveDownloads = jest.fn();
jest.mock('@/store/useModelDownloadStore', () => ({
useModelDownloadStore: (selector: (state: unknown) => unknown) =>
@@ -19,20 +30,38 @@ jest.mock('@/hooks/useOnboardingStep', () => ({
}));
jest.mock('react-native-safe-area-context', () => ({ SafeAreaView: require('react-native').View }));
jest.mock('@/components/ui/Text', () => ({ Text: require('react-native').Text }));
-jest.mock('@/components/ui/SystemIcon', () => ({ SystemIcon: () => null }));
+jest.mock('@/components/ui/SystemIcon', () => ({
+ SystemIcon: ({ mdName }: { mdName: string }) => {
+ const { View } = require('react-native');
+ return <View testID={`icon-${mdName}`} />;
+ },
+}));
jest.mock('@/components/ui/OpenWhisprMark', () => ({ OpenWhisprMark: () => null }));
+const originalPlatform = Platform.OS;
+afterEach(() => {
+ Platform.OS = originalPlatform;
+});
beforeEach(() => {
+ Platform.OS = 'ios';
jest.clearAllMocks();
mockSelectedMode = null;
+ mockReadiness = { status: 'ready' };
+ mockSavedCleanup = undefined;
jest.mocked(chooseOnboardingMode).mockResolvedValue(undefined);
mockCancelActiveDownloads.mockResolvedValue(undefined);
});
+// The Private Mode card's cleanup line waits on Apple Intelligence readiness.
+async function renderStep(): Promise<ReturnType<typeof render>> {
+ const screen = render(<PrivacyModeStep />);
+ await act(async () => {});
+ return screen;
+}
const CLOUD = 'OpenWhispr Cloud';
-const LOCAL = 'Local · Private mode';
+const LOCAL = 'Private Mode';
-it('describes each mode in a few short lines', () => {
- const screen = render(<PrivacyModeStep />);
+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.',
@@ -47,8 +76,90 @@ it('describes each mode in a few short lines', () => {
expect(screen.queryByText(/voice agent/i)).toBeNull();
expect(screen.queryByText(/Pro offer/i)).toBeNull();
});
-it('lists Cloud first and selects it by default', () => {
- const screen = render(<PrivacyModeStep />);
+
+// The Private Mode card's cleanup line matches what choosing it saves on this phone.
+describe('cleanup line', () => {
+ it.each(['ready', 'modelNotReady'])(
+ 'includes cleanup when Apple Intelligence is %s',
+ async (status) => {
+ mockReadiness = { status };
+ const screen = await renderStep();
+ expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();
+ expect(screen.queryByText(/Settings/)).toBeNull();
+ expect(screen.queryByTestId('icon-Minus')).toBeNull();
+ },
+ );
+
+ it('says cleanup starts once Apple Intelligence is turned on', async () => {
+ mockReadiness = { status: 'appleIntelligenceOff' };
+ const screen = await renderStep();
+ expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();
+ expect(
+ screen.getByText('Starts once it’s on in Settings → Apple Intelligence & Siri.'),
+ ).toBeTruthy();
+ });
+
+ it.each([
+ [
+ 'unsupportedDevice',
+ 'No cleanup on this iPhone',
+ 'Needs Apple Intelligence (iPhone 15 Pro or later). You’ll get the raw transcription.',
+ ],
+ [
+ 'unsupportedOS',
+ 'No cleanup on this iPhone yet',
+ 'Needs iOS 26 on an iPhone with Apple Intelligence. Until then, you’ll get the raw transcription.',
+ ],
+ ])('marks cleanup as not included when %s', async (status, text, hint) => {
+ mockReadiness = { status };
+ const screen = await renderStep();
+ expect(screen.getByText(text)).toBeTruthy();
+ expect(screen.getByText(hint)).toBeTruthy();
+ expect(screen.getAllByTestId('icon-Minus')).toHaveLength(1);
+ expect(screen.queryByText(/Cleanup with Apple Intelligence/)).toBeNull();
+ });
+
+ it('names no Apple Intelligence on Android', async () => {
+ Platform.OS = 'android';
+ mockReadiness = { status: 'unsupportedOS' };
+ const screen = await renderStep();
+ expect(screen.getByText('No automatic cleanup')).toBeTruthy();
+ expect(screen.getByText('You’ll get the raw transcription.')).toBeTruthy();
+ 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' };
+ 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();
+ });
+
+ // Private mode never runs it, so the line is the one for this phone.
+ it('ignores a saved Cloud cleanup', async () => {
+ mockSavedCleanup = { mode: 'openwhispr' };
+ const screen = await renderStep();
+ expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();
+ });
+
+ // Neither says whether this iPhone can run it, so the card makes no claim.
+ it.each(['disabled', 'unavailable'])(
+ 'shows no cleanup line when readiness is %s',
+ async (status) => {
+ mockReadiness = { status };
+ const screen = await renderStep();
+ expect(screen.queryByText(/cleanup on this|Cleanup with|raw transcription/)).toBeNull();
+ },
+ );
+});
+it('lists Cloud first and selects it by default', async () => {
+ const screen = await renderStep();
const [first, second] = screen.getAllByRole('radio');
expect(first.props.accessibilityLabel).toBe(CLOUD);
expect(second.props.accessibilityLabel).toBe(LOCAL);
@@ -57,16 +168,16 @@ it('lists Cloud first and selects it by default', () => {
expect(screen.queryByText('Use Cloud')).toBeNull();
expect(screen.queryByText('Use Local')).toBeNull();
});
-it('keeps the earlier Local choice when revisiting the step', () => {
+it('keeps the earlier Local choice when revisiting the step', async () => {
mockSelectedMode = 'private';
- const screen = render(<PrivacyModeStep />);
+ const screen = await renderStep();
expect(screen.getByLabelText(LOCAL).props.accessibilityState).toEqual({ selected: true });
});
it.each([
[CLOUD, 'cloud'],
[LOCAL, 'private'],
] as const)('commits %s on Continue', async (label, mode) => {
- const screen = render(<PrivacyModeStep />);
+ const screen = await renderStep();
fireEvent.press(screen.getByLabelText(label));
expect(chooseOnboardingMode).not.toHaveBeenCalled();
fireEvent.press(screen.getByText('Continue'));
@@ -76,7 +187,7 @@ it('keeps the choices available after a failed Cloud attempt', async () => {
jest
.mocked(chooseOnboardingMode)
.mockRejectedValueOnce(new OnboardingError('Cloud is unavailable'));
- const screen = render(<PrivacyModeStep />);
+ const screen = await renderStep();
fireEvent.press(screen.getByText('Continue'));
expect(await screen.findByText('Cloud is unavailable')).toBeTruthy();
fireEvent.press(screen.getByLabelText(LOCAL));
@@ -87,14 +198,14 @@ it('keeps the choices available after a failed Cloud attempt', async () => {
// Back from the download step leaves its model transferring; Cloud has no use for it.
it('stops a Local download left running once Cloud is chosen', async () => {
mockSelectedMode = 'private';
- const screen = render(<PrivacyModeStep />);
+ const screen = await renderStep();
fireEvent.press(screen.getByLabelText(CLOUD));
fireEvent.press(screen.getByText('Continue'));
await waitFor(() => expect(mockCancelActiveDownloads).toHaveBeenCalledTimes(1));
});
// Reset onboarding shows setup straight away, so a model downloading from Settings is not ours.
it('leaves other downloads alone when Local was not chosen in this setup', async () => {
- const screen = render(<PrivacyModeStep />);
+ const screen = await renderStep();
fireEvent.press(screen.getByText('Continue'));
await waitFor(() => expect(chooseOnboardingMode).toHaveBeenCalledWith('cloud', 'privacy-mode'));
expect(mockCancelActiveDownloads).not.toHaveBeenCalled();
diff --git a/openwhispr-mobile/src/store/useModelDownloadStore.ts b/openwhispr-mobile/src/store/useModelDownloadStore.ts
index 6d739bdcb..e302201b7 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 Private Mode.',
},
requestId,
);
diff --git a/openwhispr-mobile/src/types/index.ts b/openwhispr-mobile/src/types/index.ts
index 8281838be..3d4a404d3 100644
--- a/openwhispr-mobile/src/types/index.ts
+++ b/openwhispr-mobile/src/types/index.ts
@@ -22,6 +22,10 @@ export interface UserConfig {
privateModeReturn?: { pinned: Partial<Record<MobileInferenceScope, InferenceSelection>> };
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;