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): keep uploads and cleanup on device when onboarding picks Local Mode (#2715)

Chad Piha7ba797cbb648
diff --git a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
index 912bb2579..96c8081d4 100644
--- a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
+++ b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts
@@ -132,8 +132,12 @@ it('moves the dictation route with the chosen mode and restores both on failure'
);
expect(mockUpdateConfig).toHaveBeenNthCalledWith(1, {
defaultMode: 'private',
- inference: { dictation: { mode: 'local' } },
- pinnedInference: undefined,
+ inference: {
+ dictation: { mode: 'local' },
+ upload: { mode: 'local' },
+ cleanup: { mode: 'local' },
+ },
+ pinnedInference: ['upload', 'cleanup'],
});
expect(mockUpdateConfig).toHaveBeenLastCalledWith({
defaultMode: 'providers',
@@ -142,14 +146,64 @@ 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.
+// Choosing Local in setup keeps uploads and cleanup on this iPhone, even for a signed-in account,
+// whose Local Mode defaults would send them to Cloud. They are automatic pins, not the user's own.
+it('keeps uploads and cleanup on this iPhone when setup picks Local', async () => {
+ mockUser = { id: 'u', isAnonymous: false };
+ mockConfig = {
+ defaultMode: 'cloud',
+ inference: { dictation: { mode: 'openwhispr' }, cleanup: { mode: 'openwhispr' } },
+ rememberedInference: { upload: { local: { mode: 'local', modelId: 'whisper-base' } } },
+ };
+ await chooseOnboardingMode('private', 'privacy-mode');
+ expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({
+ defaultMode: 'private',
+ inference: {
+ dictation: { mode: 'local' },
+ upload: { mode: 'local', modelId: 'whisper-base' },
+ cleanup: { mode: 'local' },
+ },
+ pinnedInference: ['upload', 'cleanup'],
+ });
+});
+
it.each([
- ['cloud', { mode: 'local' }],
- ['private', { mode: 'openwhispr' }],
-] as const)('keeps a saved cleanup when a replay picks %s', async (mode, cleanup) => {
+ ['On-Device', { mode: 'local', modelId: 'parakeet-v2' }],
+ ['provider', { mode: 'providers', providerId: 'groq', modelId: 'llama-3.3-70b-versatile' }],
+])('keeps a saved %s choice when setup picks Local', async (_label, saved) => {
+ mockConfig = { defaultMode: 'cloud', inference: { upload: saved, cleanup: saved } };
+ await chooseOnboardingMode('private', 'privacy-mode');
+ const { inference, pinnedInference } = mockUpdateConfig.mock.calls[0][0];
+ expect(inference.upload).toEqual(saved);
+ expect(inference.cleanup).toEqual(saved);
+ expect(pinnedInference).toEqual([]);
+});
+
+// Going back to Cloud in setup changes the mode, which releases what Local held.
+it('releases them when setup goes back to Cloud', async () => {
mockUser = { id: 'u', isAnonymous: false };
- mockConfig = { defaultMode: mode, inference: { dictation: { mode: 'openwhispr' }, cleanup } };
- await chooseOnboardingMode(mode, 'privacy-mode');
+ mockConfig = {
+ defaultMode: 'private',
+ inference: {
+ dictation: { mode: 'local' },
+ upload: { mode: 'local' },
+ cleanup: { mode: 'local' },
+ },
+ pinnedInference: ['upload', 'cleanup'],
+ };
+ await chooseOnboardingMode('cloud', 'privacy-mode');
+ expect(mockUpdateConfig.mock.calls[0][0]).toEqual({
+ defaultMode: 'cloud',
+ inference: { dictation: { mode: 'openwhispr' } },
+ pinnedInference: undefined,
+ });
+});
+
+it('keeps a cleanup the user saved when setup picks Cloud', async () => {
+ mockUser = { id: 'u', isAnonymous: false };
+ const cleanup = { mode: 'local' };
+ mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' }, cleanup } };
+ await chooseOnboardingMode('cloud', 'privacy-mode');
expect(mockUpdateConfig.mock.calls[0][0].inference.cleanup).toEqual(cleanup);
});
diff --git a/openwhispr-mobile/src/lib/inferenceModes.ts b/openwhispr-mobile/src/lib/inferenceModes.ts
index 5ff33c72a..4d2fa8bff 100644
--- a/openwhispr-mobile/src/lib/inferenceModes.ts
+++ b/openwhispr-mobile/src/lib/inferenceModes.ts
@@ -228,12 +228,12 @@ 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 };
+// Holds uploads and cleanup on this iPhone unless the user saved On-Device or a provider for them.
+// They are automatic pins, so changing the mode releases them to its defaults, and a pinned
+// cleanup Apple Intelligence can't run yet is skipped quietly (skipsLocalModeCleanup).
+export function holdOnDeviceConfig(
+ config: Pick<UserConfig, 'inference' | 'pinnedInference' | 'rememberedInference'>,
+): Pick<UserConfig, 'inference' | 'pinnedInference'> {
const inference = { ...config.inference };
const pinnedInference = [...(config.pinnedInference ?? [])];
for (const scope of ['upload', 'cleanup'] as const) {
@@ -242,5 +242,13 @@ export function localModeUpgradeConfig(config: UserConfig): Partial<UserConfig>
inference[scope] = config.rememberedInference?.[scope]?.local ?? { mode: 'local' };
if (!pinnedInference.includes(scope)) pinnedInference.push(scope);
}
- return { localModeUpgraded: true, inference, pinnedInference };
+ return { inference, pinnedInference };
+}
+
+// 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, so a config from then that is in Local
+// Mode keeps them there: the upgrade sends nothing to Cloud that was never sent before.
+export function localModeUpgradeConfig(config: UserConfig): Partial<UserConfig> {
+ if (config.defaultMode !== 'private') return { localModeUpgraded: true };
+ return { localModeUpgraded: true, ...holdOnDeviceConfig(config) };
}
diff --git a/openwhispr-mobile/src/lib/onboardingMode.ts b/openwhispr-mobile/src/lib/onboardingMode.ts
index 87b13b1a9..d706b056a 100644
--- a/openwhispr-mobile/src/lib/onboardingMode.ts
+++ b/openwhispr-mobile/src/lib/onboardingMode.ts
@@ -4,7 +4,7 @@ import { useOnboardingStore } from '@/store/useOnboardingStore';
import { useProcessingModeStore } from '@/store/useProcessingModeStore';
import { hasRealAccountHistory } from '@/sync/syncIdentity';
import type { UserConfig } from '@/types';
-import { dictationModeConfig } from './inferenceModes';
+import { dictationModeConfig, holdOnDeviceConfig } from './inferenceModes';
import { OnboardingError } from './onboardingErrors';
// updateConfig reports persistence errors in its store instead of rejecting.
@@ -50,7 +50,12 @@ export async function chooseOnboardingMode(
pinnedInference: config?.pinnedInference,
};
// The dictation route moves with the mode, so a replayed pick also leaves a Providers route.
- await saveOnboardingConfig(dictationModeConfig(config, mode));
+ // Choosing Local in setup also keeps uploads and cleanup on this iPhone; going back to Cloud
+ // releases them, since the mode changes.
+ const next = dictationModeConfig(config, mode);
+ await saveOnboardingConfig(
+ mode === 'private' ? { ...next, ...holdOnDeviceConfig({ ...config, ...next }) } : next,
+ );
useProcessingModeStore.getState().resetToDefault(mode);
try {
await useOnboardingStore.getState().chooseMode(mode, from);
diff --git a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
index 7249c7a60..b7edb798b 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/PrivacyModeStep.tsx
@@ -6,10 +6,8 @@ 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';
@@ -19,12 +17,12 @@ type ModeChoice = 'cloud' | 'private';
type CleanupLine = { included: boolean; text: string; hint?: string };
-// 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.
+// What cleanup does once Local Mode is chosen here: a provider saved for it keeps cleaning, and
+// otherwise it runs on Apple Intelligence or not at all (holdOnDeviceConfig). On an iPhone the
+// On-Device line waits for the readiness check.
function privateCleanupLine(
readiness: LocalReasoningReadiness | null,
- cleanup: InferenceMode,
+ cleanup: InferenceMode | undefined,
): CleanupLine | null {
if (cleanup === 'providers') {
return {
@@ -33,7 +31,6 @@ function privateCleanupLine(
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,
@@ -86,12 +83,8 @@ export function PrivacyModeStep(): ReactElement {
cancelled = true;
};
}, []);
- 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 savedCleanup = useConfigStore((state) => state.config?.inference?.cleanup?.mode);
+ const cleanupLine = privateCleanupLine(readiness, savedCleanup);
const handleContinue = async (): Promise<void> => {
if (choice === 'private') {
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 c0cf7869c..5816f90ef 100644
--- a/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
+++ b/openwhispr-mobile/src/screens/onboarding/steps/__tests__/PrivacyModeStep.test.tsx
@@ -133,25 +133,26 @@ describe('cleanup line', () => {
expect(screen.queryByText(/Apple Intelligence|iPhone/)).toBeNull();
});
- // 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 };
+ // A provider saved for cleanup keeps cleaning in Local Mode.
+ it('names a saved cleanup provider', async () => {
+ mockSavedCleanup = { mode: 'providers' };
const screen = await renderStep();
- expect(screen.getByText(line)).toBeTruthy();
+ expect(screen.getByText('Cleanup with your saved provider')).toBeTruthy();
expect(screen.queryByText(/Apple Intelligence/)).toBeNull();
});
- // With nothing saved, Local Mode cleans on OpenWhispr Cloud for a signed-in account only.
+ // Choosing Local here keeps cleanup on this iPhone (holdOnDeviceConfig), whatever the account
+ // and even over a saved Cloud cleanup.
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) => {
+ ['a signed-in account', { id: 'u', isAnonymous: false }, undefined],
+ ['an anonymous session', { id: 'a', isAnonymous: true }, undefined],
+ ['a saved Cloud cleanup', { id: 'u', isAnonymous: false }, { mode: 'openwhispr' }],
+ ])('cleans with Apple Intelligence for %s', async (_label, user, saved) => {
mockUser = user;
+ mockSavedCleanup = saved;
const screen = await renderStep();
- expect(screen.getByText(line)).toBeTruthy();
+ expect(screen.getByText('Cleanup with Apple Intelligence')).toBeTruthy();
+ expect(screen.queryByText(/OpenWhispr Cloud cleanup|Cleanup with OpenWhispr Cloud/)).toBeNull();
});
// Neither says whether this iPhone can run it, so the card makes no claim.