Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(mobile): keep other workflows in place when dictation moves to Cloud (#2774)
Chad Pihae35b5ff7be01
diff --git a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.tsindex dfa90c927..cfd74f9b8 100644--- a/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/aiWorkflows.test.ts@@ -1,4 +1,10 @@-import { unsetSelection, workflowSummary } from '@/lib/aiWorkflows';+import {+ cleanupRunsOnDevice,+ cloudCleanupNeedsAccount,+ unsetSelection,+ workflowSelection,+ workflowSummary,+} from '@/lib/aiWorkflows';import type { UserConfig } from '@/types';function config(overrides: Partial<UserConfig> = {}): UserConfig {@@ -54,6 +60,59 @@ describe('workflowSummary for Text Cleanup', () => {},);+ // A Cloud cleanup held automatically when dictation left Cloud isn't the user's own choice, so+ // where Local Mode can't run it there, it cleans on this phone like an unsaved one.+ it.each(['session', 'none'] as const)(+ 'cleans on this phone for a Cloud cleanup held automatically, with %s access',+ (cloudAccess) => {+ const held = config({+ inference: { cleanup: { mode: 'openwhispr' } },+ pinnedInference: ['cleanup'],+ });+ expect(workflowSummary(held, 'cleanup', 'private', { cloudAccess })).toBe('On-Device');+ expect(cleanupRunsOnDevice(held, 'private', cloudAccess)).toBe(true);+ expect(cloudCleanupNeedsAccount(held, 'private', cloudAccess)).toBe(false);+ expect(workflowSelection(held, 'cleanup', 'cloud', cloudAccess)).toEqual({+ mode: 'openwhispr',+ });+ },+ );++ it('keeps a Cloud cleanup held automatically on Cloud for a signed-in account', () => {+ const held = config({+ inference: { cleanup: { mode: 'openwhispr' } },+ pinnedInference: ['cleanup'],+ });+ expect(workflowSummary(held, 'cleanup', 'private', { cloudAccess: 'account' })).toBe(+ 'OpenWhispr Cloud',+ );+ expect(cleanupRunsOnDevice(held, 'private', 'account')).toBe(false);+ });++ // Bring Your Own Key dictation also needs the separate Cloud pass, whether the user saved Cloud+ // or a dictation change held it there.+ it.each([+ ['saved', []],+ ['held automatically', ['cleanup']],+ ] as const)(+ 'skips a %s Cloud cleanup under Bring Your Own Key without an account',+ (_label, pins) => {+ const byok = config({+ defaultMode: 'providers',+ inference: { cleanup: { mode: 'openwhispr' } },+ pinnedInference: [...pins],+ });+ for (const cloudAccess of ['session', 'none'] as const) {+ expect(workflowSummary(byok, 'cleanup', 'providers', { cloudAccess })).toBe(+ 'Skipped · Sign in',+ );+ }+ expect(workflowSummary(byok, 'cleanup', 'providers', { cloudAccess: 'account' })).toBe(+ 'OpenWhispr Cloud',+ );+ },+ );+it('is skipped in Local Mode when Apple Intelligence cannot run', () => {expect(workflowSummary(config({}), 'cleanup', 'private', {@@ -155,6 +214,40 @@ describe('workflowSummary for Uploads', () => {});});+// A Cloud selection held when dictation left another mode runs as if unsaved in Local Mode, where+// the default already uses Cloud wherever the user's access lets it.+describe('workflowSelection in Local Mode for a Cloud hold', () => {+ const heldOnCloud = (scope: 'upload' | 'notes' | 'noteChat'): UserConfig =>+ config({ inference: { [scope]: { mode: 'openwhispr' } }, pinnedInference: [scope] });++ it.each([+ ['none', 'local'],+ ['session', 'openwhispr'],+ ['account', 'openwhispr'],+ ] as const)('runs an upload with %s access on %s', (cloudAccess, mode) => {+ expect(workflowSelection(heldOnCloud('upload'), 'upload', 'private', cloudAccess)).toEqual({+ mode,+ });+ expect(workflowSelection(heldOnCloud('upload'), 'upload', 'cloud', cloudAccess)).toEqual({+ mode: 'openwhispr',+ });+ });++ it('formats notes on this phone and keeps note chat on Cloud', () => {+ expect(workflowSelection(heldOnCloud('notes'), 'notes', 'private', 'account')).toEqual({+ mode: 'local',+ });+ expect(workflowSelection(heldOnCloud('noteChat'), 'noteChat', 'private', 'none')).toEqual({+ mode: 'openwhispr',+ });+ });++ it('keeps a Cloud upload the user saved', () => {+ const saved = config({ inference: { upload: { mode: 'openwhispr' } } });+ expect(workflowSelection(saved, 'upload', 'private', 'none')).toEqual({ mode: 'openwhispr' });+ });+});+describe('workflowSummary for switched-off workflows', () => {const groq = { mode: 'providers' as const, providerId: 'groq', modelId: 'llama' };diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.tsindex e5d7f9e57..2be53d785 100644--- a/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/inferenceModes.test.ts@@ -4,6 +4,7 @@ import { Platform } from 'react-native';import {dictationModeConfig,getInferenceModes,+ holdOnDeviceConfig,localModeUpgradeConfig,noteChatSplitConfig,workflowSaveConfig,@@ -23,7 +24,7 @@ const groqDictation = {credentialRef: 'provider.groq',};-it('releases only the automatic pins when dictation leaves Bring Your Own Key', () => {+it('releases only the automatic pins when onboarding picks another mode', () => {const pinned: UserConfig = {defaultMode: 'providers',inference: {@@ -55,16 +56,16 @@ it.each([}});-// 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', () => {+// A Dictation change in AI Models may have held workflows in the mode onboarding picks again.+it('releases the automatic pins when onboarding replays the mode it is in', () => {const held: UserConfig = {- defaultMode: 'private',- inference: { dictation: { mode: 'local' }, upload: { mode: 'local' } },+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' }, upload: { mode: 'local' } },pinnedInference: ['upload'],};- const next = dictationModeConfig(held, 'private');- expect(next.inference?.upload).toEqual({ mode: 'local' });- expect(next).not.toHaveProperty('pinnedInference');+ const next = dictationModeConfig(held, 'cloud');+ expect(next.inference).toEqual({ dictation: { mode: 'openwhispr' } });+ expect(next.pinnedInference).toBeUndefined();});it('keeps an explicit On-Device upload choice when dictation leaves Bring Your Own Key', () => {@@ -102,63 +103,141 @@ it('keeps the dictation selection in step with Local Mode', () => {});describe('workflowSaveConfig', () => {- it('keeps unsaved workflows on this phone when dictation moves from On-Device to a provider', () => {- const config: UserConfig = {- defaultMode: 'private',- inference: { dictation: { mode: 'local' } },- };- const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');- expect(next.defaultMode).toBe('providers');+ const local: UserConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ const allSaved: UserConfig['inference'] = {+ upload: { mode: 'local' },+ cleanup: groqCleanup,+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'local' },+ agent: { mode: 'local' },+ };++ // Changing Dictation changes only dictation, from and to every mode.+ it.each([+ ['cloud', 'private', { mode: 'local' as const }],+ ['cloud', 'providers', groqDictation],+ ['private', 'cloud', { mode: 'openwhispr' as const }],+ ['private', 'providers', groqDictation],+ ['providers', 'cloud', { mode: 'openwhispr' as const }],+ ['providers', 'private', { mode: 'local' as const }],+ ] as const)(+ 'leaves saved workflows alone when dictation moves from %s to %s',+ (from, to, dictation) => {+ const config: UserConfig = {+ defaultMode: from,+ inference: { dictation: { mode: 'openwhispr' }, ...allSaved },+ pinnedInference: ['upload', 'agent'],+ };+ const next = workflowSaveConfig(config, 'dictation', dictation, from, 'account', true);+ expect(next.defaultMode).toBe(to);+ expect(next.inference).toEqual({ ...allSaved, dictation });+ expect(next.pinnedInference).toEqual(['upload', 'agent']);+ },+ );++ it('holds unsaved workflows on Cloud when dictation leaves Cloud', () => {+ const next = workflowSaveConfig({ defaultMode: 'cloud' }, 'dictation', groqDictation, 'cloud');expect(next.inference).toEqual({dictation: groqDictation,- upload: { mode: 'local' },- notes: { mode: 'local' },- agent: { mode: 'local' },- noteChat: { mode: 'local' },+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'openwhispr' },+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'openwhispr' },+ agent: { mode: 'openwhispr' },});- expect(next.pinnedInference).toEqual(['upload', 'notes', 'agent', 'noteChat']);+ expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat', 'agent']);});- it('keeps uploads and notes on Cloud when dictation moves from Cloud to a provider', () => {- const next = workflowSaveConfig({ defaultMode: 'cloud' }, 'dictation', groqDictation, 'cloud');- expect(next.inference).toMatchObject({- upload: { mode: 'openwhispr' },- notes: { mode: 'openwhispr' },+ // Unsaved cleanup and voice assistant were skipped under Bring Your Own Key, so there is nothing+ // to hold; uploads, notes and note chat ran on Cloud.+ it('holds only what ran when dictation leaves Bring Your Own Key', () => {+ const config: UserConfig = {+ defaultMode: 'providers',+ inference: { dictation: groqDictation },+ };+ const next = workflowSaveConfig(config, 'dictation', { mode: 'openwhispr' }, 'providers');+ expect(next).toEqual({+ defaultMode: 'cloud',+ inference: {+ dictation: { mode: 'openwhispr' },+ upload: { mode: 'openwhispr' },+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'openwhispr' },+ },+ pinnedInference: ['upload', 'notes', 'noteChat'],});- expect(next.pinnedInference).toEqual(['upload', 'notes']);});- it('leaves the voice assistant unset when leaving Cloud, so it is skipped, not sent to Cloud', () => {- const next = workflowSaveConfig({ defaultMode: 'cloud' }, 'dictation', groqDictation, 'cloud');- expect(next.inference?.agent).toBeUndefined();+ describe('leaving Local Mode', () => {+ it.each(['cloud', 'providers'] as const)(+ 'holds what ran on this phone without a session when going to %s',+ (to) => {+ const dictation = to === 'cloud' ? { mode: 'openwhispr' as const } : groqDictation;+ const next = workflowSaveConfig(local, 'dictation', dictation, 'private', 'none', true);+ expect(next.inference).toEqual({+ dictation,+ upload: { mode: 'local' },+ cleanup: { mode: 'local' },+ notes: { mode: 'local' },+ noteChat: { mode: 'local' },+ });+ expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat']);+ },+ );++ // Local Mode used OpenWhispr Cloud for uploads with a session, and for cleanup with an account.+ it.each([+ ['session', 'openwhispr', 'local'],+ ['account', 'openwhispr', 'openwhispr'],+ ] as const)(+ 'holds uploads and cleanup where they ran with %s access',+ (access, upload, cleanup) => {+ const next = workflowSaveConfig(+ local,+ 'dictation',+ { mode: 'openwhispr' },+ 'private',+ access,+ );+ expect(next.inference?.upload).toEqual({ mode: upload });+ expect(next.inference?.cleanup).toEqual({ mode: cleanup });+ },+ );++ // Saved On-Device notes never fall back to Cloud; Local Mode asked before using it instead.+ it('holds notes on Cloud when Apple Intelligence cannot run them', () => {+ const next = workflowSaveConfig(local, 'dictation', { mode: 'openwhispr' }, 'private');+ expect(next.inference?.notes).toEqual({ mode: 'openwhispr' });+ });++ it('holds the on-device model picked for a workflow', () => {+ const whisper = { mode: 'local' as const, modelId: 'whisper-base' };+ const config: UserConfig = { ...local, rememberedInference: { upload: { local: whisper } } };+ const next = workflowSaveConfig(config, 'dictation', { mode: 'openwhispr' }, 'private');+ expect(next.inference?.upload).toEqual(whisper);+ });});- it('never pins cleanup or a workflow the user already chose', () => {+ it('turns Local Mode on with the model picked on the Dictation page', () => {+ const whisper = { mode: 'local' as const, modelId: 'whisper-base' };const config: UserConfig = {- defaultMode: 'private',- inference: { notes: { mode: 'openwhispr' } },+ defaultMode: 'cloud',+ rememberedInference: { dictation: { local: whisper } },};- const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');- expect(next.inference?.cleanup).toBeUndefined();- expect(next.inference?.notes).toEqual({ mode: 'openwhispr' });- expect(next.pinnedInference).toEqual(['upload', 'agent', 'noteChat']);+ const next = workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'cloud');+ expect(next.inference?.dictation).toEqual(whisper);});- it('adds no pins when a Bring Your Own Key user re-saves dictation', () => {+ it('holds nothing when dictation is saved to the mode it is already in', () => {const config: UserConfig = {defaultMode: 'providers',inference: { dictation: groqDictation, upload: { mode: 'local' } },pinnedInference: ['upload'],};- const next = workflowSaveConfig(- config,- 'dictation',- { ...groqDictation, providerId: 'openai', modelId: 'whisper-1' },- 'providers',- );- expect(next.inference?.notes).toBeUndefined();- expect(next.inference?.agent).toBeUndefined();- expect(next.pinnedInference).toEqual(['upload']);+ const openai = { ...groqDictation, providerId: 'openai', modelId: 'whisper-1' };+ const next = workflowSaveConfig(config, 'dictation', openai, 'providers');+ expect(next.inference).toEqual({ dictation: openai, upload: { mode: 'local' } });+ expect(next).not.toHaveProperty('pinnedInference');});it('makes a pinned workflow explicit once the user saves it', () => {@@ -191,148 +270,93 @@ describe('workflowSaveConfig', () => {expect(next.rememberedInference?.cleanup?.openai).toEqual(openai);});- it('switches dictation back to Cloud and releases the pins', () => {- const config: UserConfig = {+ it('keeps the voice assistant skipped through a round trip in Local Mode', () => {+ const providers: UserConfig = {defaultMode: 'providers',- inference: { dictation: groqDictation, upload: { mode: 'local' } },- pinnedInference: ['upload'],+ inference: { dictation: groqDictation },};- const next = workflowSaveConfig(config, 'dictation', { mode: 'openwhispr' }, 'providers');- expect(next).toEqual({- defaultMode: 'cloud',- inference: { dictation: { mode: 'openwhispr' } },+ const on = {+ ...providers,+ ...workflowSaveConfig(providers, 'dictation', { mode: 'local' }, 'providers'),+ };+ const off = { ...on, ...workflowSaveConfig(on, 'dictation', groqDictation, 'private') };+ expect(off.defaultMode).toBe('providers');+ // Skipped cleanup has no selection to hold, so it keeps the on-device cleanup Local Mode ran.+ expect(off.inference).toEqual({+ dictation: groqDictation,+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'local' },+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'openwhispr' },});});- describe('where Local Mode returns to', () => {- const fromProviders: UserConfig = {- defaultMode: 'private',- privateModeReturn: { pinned: { upload: { mode: 'openwhispr' } } },- inference: { dictation: { mode: 'local' } },+ // Local Mode cleaned on Cloud for an account, so that is what leaving it holds, even for a+ // cleanup Bring Your Own Key skipped before Local Mode was turned on.+ it('holds cleanup on Cloud when an account leaves Local Mode for Bring Your Own Key', () => {+ const providers: UserConfig = {+ defaultMode: 'providers',+ inference: { dictation: groqDictation },};+ const on = {+ ...providers,+ ...workflowSaveConfig(providers, 'dictation', { mode: 'local' }, 'providers', 'account'),+ };+ const off = {+ ...on,+ ...workflowSaveConfig(on, 'dictation', groqDictation, 'private', 'account'),+ };+ expect(off.inference?.cleanup).toEqual({ mode: 'openwhispr' });+ expect(off.inference).not.toHaveProperty('agent');+ });- it('is Bring Your Own Key, with what it held, when Local Mode is turned on from it', () => {- const config: UserConfig = {- defaultMode: 'providers',- inference: {- dictation: groqDictation,- upload: { mode: 'openwhispr' },- notes: { mode: 'local' },- },- pinnedInference: ['upload'],- };- const next = workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'providers');- // Notes is the user's own choice, so only the held upload is recorded.- expect(next.privateModeReturn).toEqual({ pinned: { upload: { mode: 'openwhispr' } } });- expect(next.inference).toEqual({ dictation: { mode: 'local' }, notes: { mode: 'local' } });- });-- it.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);- },+ // Setup in Local Mode holds only uploads and cleanup; the voice assistant is off there, so a+ // later switch to Bring Your Own Key leaves it skipped rather than sending it to Cloud.+ it('leaves the voice assistant unsaved when Local setup is followed by Bring Your Own Key', () => {+ const setup = dictationModeConfig({ defaultMode: 'cloud' }, 'private');+ const localSetup: UserConfig = { ...setup, ...holdOnDeviceConfig(setup) };+ const next = workflowSaveConfig(+ localSetup,+ 'dictation',+ groqDictation,+ 'private',+ 'session',+ true,);-- it('is not set when Local Mode is turned on from Cloud', () => {- const config: UserConfig = { defaultMode: 'cloud' };- expect(- workflowSaveConfig(config, 'dictation', { mode: 'local' }, 'cloud'),- ).not.toHaveProperty('privateModeReturn');- });-- it('survives picking another on-device model', () => {- const next = workflowSaveConfig(- fromProviders,- 'dictation',- { mode: 'local', modelId: 'whisper-base' },- 'private',- );- expect(next.privateModeReturn).toEqual(fromProviders.privateModeReturn);- });-- it.each([- ['Cloud', { mode: 'openwhispr' as const }],- ['Bring Your Own Key', groqDictation],- ])('is cleared when dictation leaves Local Mode for %s', (_label, selection) => {- const next = workflowSaveConfig(fromProviders, 'dictation', selection, 'private');- expect(next).toHaveProperty('privateModeReturn', undefined);- });-- it('holds what Bring Your Own Key held when dictation goes back to it', () => {- const next = workflowSaveConfig(fromProviders, 'dictation', groqDictation, 'private');- expect(next.inference).toEqual({ dictation: groqDictation, upload: { mode: 'openwhispr' } });- expect(next.pinnedInference).toEqual(['upload']);- });-- it('keeps a choice made in Local Mode over what Bring Your Own Key held', () => {- const config: UserConfig = {- ...fromProviders,- inference: {- dictation: { mode: 'local' },- upload: { mode: 'local', modelId: 'whisper-base' },- },- };- const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');- expect(next.inference?.upload).toEqual({ mode: 'local', modelId: 'whisper-base' });- expect(next).not.toHaveProperty('pinnedInference');- });-- // 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' } },- };- const next = workflowSaveConfig(config, 'dictation', groqDictation, 'private');- expect(next.pinnedInference).toEqual(['upload', 'notes', 'agent', 'noteChat']);+ expect(next.inference).toEqual({+ dictation: groqDictation,+ upload: { mode: 'local' },+ cleanup: { mode: 'local' },+ notes: { mode: 'local' },+ noteChat: { mode: 'local' },});+ expect(next.pinnedInference).toEqual(['upload', 'cleanup', 'notes', 'noteChat']);+ });- // Replaying onboarding writes the mode directly, and must not leave a stale return behind.- it.each(['cloud', 'private'] as const)('is cleared by choosing %s outright', (mode) => {- expect(dictationModeConfig(fromProviders, mode)).toHaveProperty(- 'privateModeReturn',- undefined,- );+ // Cloud cleanup held for an anonymous session can't run in Local Mode, which cleans on this+ // phone instead (workflowSelection); returning to Cloud finds it on Cloud again.+ it('ends a Cloud round trip through Local Mode on Cloud for an anonymous session', () => {+ const cloud: UserConfig = {+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' } },+ };+ const on = {+ ...cloud,+ ...workflowSaveConfig(cloud, 'dictation', { mode: 'local' }, 'cloud', 'session'),+ };+ expect(on.inference?.cleanup).toEqual({ mode: 'openwhispr' });+ expect(on.pinnedInference).toContain('cleanup');+ const off = {+ ...on,+ ...workflowSaveConfig(on, 'dictation', { mode: 'openwhispr' }, 'private', 'session'),+ };+ expect(off.inference).toEqual({+ dictation: { mode: 'openwhispr' },+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'openwhispr' },+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'openwhispr' },+ agent: { mode: 'openwhispr' },});});});@@ -373,15 +397,21 @@ describe('localModeUpgradeConfig', () => {expect(localModeUpgradeConfig({ defaultMode })).toEqual({ localModeUpgraded: true });});- it('is released when dictation leaves Local Mode, so Cloud runs them again', () => {+ it('is kept when dictation leaves Local Mode', () => {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();+ const next = workflowSaveConfig(+ upgraded,+ 'dictation',+ { mode: 'openwhispr' },+ 'private',+ 'account',+ );+ expect(next.inference?.upload).toEqual({ mode: 'local' });+ expect(next.inference?.cleanup).toEqual({ mode: 'local' });});});@@ -443,10 +473,8 @@ describe('noteChatSplitConfig', () => {defaultMode: 'private',inference: { agent: { mode: 'openwhispr' } },pinnedInference: ['upload', 'agent'],- privateModeReturn: { pinned: { agent: groqChat } },});expect(next.pinnedInference).toEqual(['upload', 'agent', 'noteChat']);- expect(next.privateModeReturn).toEqual({ pinned: { agent: groqChat, noteChat: groqChat } });});it("saves note chat's switch as it stood, following the voice assistant's", () => {@@ -493,6 +521,7 @@ it('holds note chat on this iPhone when dictation leaves Local Mode for Bring Yo'private',);expect(next.inference?.noteChat).toEqual({ mode: 'local' });- expect(next.inference?.agent).toEqual({ mode: 'local' });+ // Local Mode turns the voice assistant off, so there is nothing to hold for it.+ expect(next.inference?.agent).toBeUndefined();expect(next.pinnedInference).toContain('noteChat');});diff --git a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.tsindex f29625398..3d351f580 100644--- a/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/inferenceRouting.test.ts@@ -270,15 +270,24 @@ it.each([});// Uploads in Local Mode run what is saved for them, or OpenWhispr Cloud when there is a session.+const HELD = { mode: 'openwhispr' };it.each([['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'],+ ['Cloud saved, with no session', { mode: 'openwhispr' }, null, 'cloud'],+ ['Cloud held automatically, with a session', HELD, { id: 'a', isAnonymous: true }, 'cloud'],+ // Held when dictation left Cloud, before the user signed out and continued as a guest.+ ['Cloud held automatically, with no session', HELD, null, 'local'],])('routes a Local Mode upload with %s', (_label, upload, user, provider) => {mockProcessing.activeMode = 'private';mockUser = user;- mockState.config.inference = upload ? { upload } : {};+ mockState.config = {+ defaultMode: 'private',+ inference: upload ? { upload } : {},+ ...(upload === HELD ? { pinnedInference: ['upload'] } : {}),+ };expect(getTranscriptionProvider('upload')).toBe(provider);expect(getTranscriptionProvider('dictation')).toBe('local');});diff --git a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.tsindex 96c8081d4..e6e5884f6 100644--- a/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/onboardingMode.test.ts@@ -199,6 +199,51 @@ it('releases them when setup goes back to Cloud', async () => {});});+// A Dictation change in AI Models holds the other workflows where they ran, so replaying setup+// must release them even when it picks the mode dictation is already in.+it('releases what a Dictation change held when setup is replayed with Cloud', async () => {+ mockUser = { id: 'u', isAnonymous: false };+ mockConfig = {+ defaultMode: 'cloud',+ inference: {+ dictation: { mode: 'openwhispr' },+ upload: { mode: 'local' },+ cleanup: { mode: 'local' },+ notes: { mode: 'local' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes'],+ };+ await chooseOnboardingMode('cloud', 'privacy-mode');+ expect(mockUpdateConfig.mock.calls[0][0]).toEqual({+ defaultMode: 'cloud',+ inference: { dictation: { mode: 'openwhispr' } },+ pinnedInference: undefined,+ });+});++it('holds only uploads and cleanup when setup is replayed with Local', async () => {+ mockConfig = {+ defaultMode: 'private',+ inference: {+ dictation: { mode: 'local' },+ upload: { mode: 'local' },+ cleanup: { mode: 'local' },+ notes: { mode: 'openwhispr' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes'],+ };+ await chooseOnboardingMode('private', 'privacy-mode');+ expect(mockUpdateConfig.mock.calls[0][0]).toEqual({+ defaultMode: 'private',+ inference: {+ dictation: { mode: 'local' },+ upload: { mode: 'local' },+ cleanup: { mode: 'local' },+ },+ pinnedInference: ['upload', 'cleanup'],+ });+});+it('keeps a cleanup the user saved when setup picks Cloud', async () => {mockUser = { id: 'u', isAnonymous: false };const cleanup = { mode: 'local' };diff --git a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.tsindex 43c5be727..9114e82f8 100644--- a/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/transcribeAndCleanup.onDeviceCleanup.test.ts@@ -302,6 +302,36 @@ describe('in Local Mode with nothing of its own saved for cleanup', () => {expect(mockReadiness).toHaveBeenCalledWith({ refresh: true });expect(result.text).toBe('cleaned:um hello there');});++ // A dictation change from Cloud holds cleanup there, which Local Mode can't run without an+ // account, so it cleans on this phone like an unsaved one (workflowSelection).+ describe('with Cloud held automatically', () => {+ beforeEach(() => {+ mockConfig = {+ ...mockConfig,+ inference: { dictation: { mode: 'local' }, cleanup: { mode: 'openwhispr' } },+ pinnedInference: ['cleanup'],+ };+ });++ it('cleans on this phone', async () => {+ mockReadiness.mockResolvedValue({ status: 'ready', tokenCounting: true });++ const result = await transcribeOnDevice();++ expect(result.text).toBe('cleaned:um hello there');+ });++ it('skips quietly when Apple Intelligence cannot run', async () => {+ mockReadiness.mockResolvedValue({ status: 'unsupportedDevice', tokenCounting: false });++ const result = await transcribeOnDevice();++ expect(mockReason).not.toHaveBeenCalled();+ expect(result.text).toBe('um hello there');+ expect(result.transcription.cleanupWarning).toBeUndefined();+ });+ });});// Cleaning a dictation made on this phone with Cloud is a separate pass that refuses anonymousdiff --git a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.tsindex 34e794be2..2fd90dcd5 100644--- a/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts+++ b/openwhispr-mobile/src/lib/__tests__/workflowModeSwitch.test.ts@@ -29,7 +29,7 @@ jest.mock('@/lib/privateMode', () => ({}));jest.mock('@/lib/localReasoning', () => ({...jest.requireActual('@/lib/localReasoning'),- getLocalReasoningReadiness: () => mockLocalReasoningReadiness(),+ getLocalReasoningReadiness: (...args: unknown[]) => mockLocalReasoningReadiness(...args),getLocalReasoningUnavailableMessage: () => 'Apple Intelligence is turned off.',}));@@ -37,6 +37,20 @@ import { pickLocalModel, switchWorkflowMode } from '../workflowModeSwitch';let alert: jest.SpyInstance;+// Turning Local Mode on from Cloud moves only dictation; the rest stay on Cloud, where they ran.+const LOCAL_FROM_CLOUD = {+ defaultMode: 'private',+ inference: {+ dictation: { mode: 'local' },+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'openwhispr' },+ notes: { mode: 'openwhispr' },+ noteChat: { mode: 'openwhispr' },+ agent: { mode: 'openwhispr' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat', 'agent'],+};+beforeEach(() => {jest.clearAllMocks();mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };@@ -73,6 +87,20 @@ it('asks an anonymous user to create an account before Cloud cleanup in Local Moexpect(mockUpdateConfig).not.toHaveBeenCalled();});+// Bring Your Own Key dictation also needs the separate Cloud pass.+it('asks an anonymous user to create an account before Cloud cleanup under Bring Your Own Key', async () => {+ mockUser = { id: 'a', isAnonymous: true };+ mockActiveMode = 'providers';+ mockConfig = { defaultMode: 'providers' };+ await expect(switchWorkflowMode('cleanup', 'openwhispr')).resolves.toBe('refused');+ expect(alert).toHaveBeenCalledWith(+ 'Create an account',+ 'Create an account to use cloud cleanup with cloud processing, or set Dictation to On-Device in Account → AI Models.',+ 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');@@ -82,10 +110,7 @@ it('lets an anonymous user pick Cloud cleanup outside Local Mode, where Cloud diit('switches dictation to On-Device along with the app mode', async () => {await expect(switchWorkflowMode('dictation', 'local')).resolves.toBe('switched');expect(mockSetActiveMode).toHaveBeenCalledWith('private', true);- expect(mockUpdateConfig).toHaveBeenCalledWith({- defaultMode: 'private',- inference: { dictation: { mode: 'local' } },- });+ expect(mockUpdateConfig).toHaveBeenCalledWith(LOCAL_FROM_CLOUD);});it('opens the model list when no on-device transcription model is downloaded', async () => {@@ -206,20 +231,85 @@ 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(LOCAL_FROM_CLOUD);+ });++ // Only dictation moves: note formatting stays on this phone, where Local Mode ran it, and with an+ // account, uploads and cleanup stay on Cloud, where Local Mode ran them. Note chat, which Local+ // Mode asked about before sending it to Cloud, stays on this phone.+ it('to OpenWhispr Cloud turns Local Mode off and leaves the other workflows where they ran', async () => {+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ await expect(switchWorkflowMode('dictation', 'openwhispr')).resolves.toBe('switched');+ expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);expect(mockUpdateConfig).toHaveBeenCalledWith({- defaultMode: 'private',- inference: { dictation: { mode: 'local' } },+ defaultMode: 'cloud',+ inference: {+ dictation: { mode: 'openwhispr' },+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'openwhispr' },+ notes: { mode: 'local' },+ noteChat: { mode: 'local' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],});});- it('to OpenWhispr Cloud turns Local Mode off', async () => {+ // Saved On-Device notes never fall back to Cloud, so without Apple Intelligence they stay on+ // Cloud, which Local Mode asked before using.+ it('to OpenWhispr Cloud holds notes on Cloud when Apple Intelligence cannot run them', async () => {+ mockLocalReasoningReadiness.mockResolvedValue({ status: 'unavailable', tokenCounting: false });+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ await expect(switchWorkflowMode('dictation', 'openwhispr')).resolves.toBe('switched');+ expect(mockUpdateConfig.mock.calls[0][0].inference.notes).toEqual({ mode: 'openwhispr' });+ });++ // The cached readiness outlives a change in iOS Settings, so leaving Local Mode asks again.+ it('asks afresh whether Apple Intelligence can run only when leaving Local Mode', async () => {+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ await switchWorkflowMode('dictation', 'openwhispr');+ expect(mockLocalReasoningReadiness).toHaveBeenCalledWith({ refresh: true });++ mockLocalReasoningReadiness.mockClear();+ mockActiveMode = 'cloud';+ mockConfig = { defaultMode: 'cloud', inference: { dictation: { mode: 'openwhispr' } } };+ await switchWorkflowMode('dictation', 'local');+ expect(mockLocalReasoningReadiness).not.toHaveBeenCalled();+ });++ // The readiness check is awaited before the config is read, so a save made meanwhile is kept.+ it('builds the saved config from the config as it is after the readiness check', async () => {+ mockActiveMode = 'private';+ mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };+ mockLocalReasoningReadiness.mockImplementation(async () => {+ mockConfig = {+ defaultMode: 'private',+ inference: { dictation: { mode: 'local' }, agent: { mode: 'openwhispr' } },+ };+ return { status: 'ready', tokenCounting: false };+ });+ await switchWorkflowMode('dictation', 'openwhispr');+ expect(mockUpdateConfig.mock.calls[0][0].inference.agent).toEqual({ mode: 'openwhispr' });+ });++ // Without an account Local Mode cleaned on this phone, while a session uploaded to Cloud.+ it('to OpenWhispr Cloud holds cleanup on this phone for an anonymous session', async () => {+ mockUser = { id: 'a', isAnonymous: true };mockActiveMode = 'private';mockConfig = { defaultMode: 'private', inference: { dictation: { mode: 'local' } } };await expect(switchWorkflowMode('dictation', 'openwhispr')).resolves.toBe('switched');- expect(mockSetActiveMode).toHaveBeenCalledWith('cloud', true);expect(mockUpdateConfig).toHaveBeenCalledWith({defaultMode: 'cloud',- inference: { dictation: { mode: 'openwhispr' } },+ inference: {+ dictation: { mode: 'openwhispr' },+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'local' },+ notes: { mode: 'local' },+ noteChat: { mode: 'local' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],});});diff --git a/openwhispr-mobile/src/lib/aiWorkflows.ts b/openwhispr-mobile/src/lib/aiWorkflows.tsindex 19e3101dc..01d835130 100644--- a/openwhispr-mobile/src/lib/aiWorkflows.ts+++ b/openwhispr-mobile/src/lib/aiWorkflows.ts@@ -43,41 +43,58 @@ export const ON_DEVICE_MODE_NOTES: Partial<Record<MobileInferenceScope, string>>export const PRIVATE_MODE_LOCKED_REASON ='Off while Local Mode is on. Change Dictation in AI Models to turn it off.';-// Local Mode dictates on this iPhone, so cleaning with OpenWhispr Cloud is a separate Cloud pass,-// which needs a signed-in account.+// Outside Cloud dictation, cleaning with OpenWhispr Cloud is a separate Cloud pass, which needs a+// signed-in account.export const CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE =- 'In Local Mode, OpenWhispr Cloud cleans transcripts only for a signed-in account, so cleanup is skipped until you sign in.';+ 'OpenWhispr Cloud cleans transcripts made on this iPhone or with your own key only for a signed-in account, so cleanup is skipped until you sign in.';export function cloudAccessFor(user: AuthUser | null): CloudAccess {if (!user) return 'none';return user.isAnonymous ? 'session' : 'account';}-// 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).+// OpenWhispr Cloud runs for cleanup in Local Mode or Bring Your Own Key without an account to run+// it, so it is skipped (cleanupTranscript). In Local Mode that is a Cloud cleanup the user saved;+// unset or held there automatically, it runs on this iPhone without an account (workflowSelection).export function cloudCleanupNeedsAccount(config: UserConfig | null,activeMode: ProcessingMode,cloudAccess: CloudAccess,): boolean {return (- activeMode === 'private' &&- config?.inference?.cleanup?.mode === 'openwhispr' &&- cloudAccess !== 'account'+ activeMode !== 'cloud' &&+ cloudAccess !== 'account' &&+ workflowSelection(config, 'cleanup', activeMode, cloudAccess).mode === 'openwhispr');}-// 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).+// Cleanup runs On-Device when it is saved as On-Device, or in Local Mode when it is unset or held on+// Cloud automatically and OpenWhispr Cloud can't clean (workflowSelection).export function cleanupRunsOnDevice(config: UserConfig | null,activeMode: ProcessingMode,- cloudAccess: CloudAccess = 'none',+ cloudAccess: CloudAccess,): boolean {- return (- (config?.inference?.cleanup ?? unsetSelection('cleanup', activeMode, cloudAccess)).mode ===- 'local'- );+ return workflowSelection(config, 'cleanup', activeMode, cloudAccess).mode === 'local';+}++// What a workflow runs: its saved selection, else the mode's default (unsetSelection). In Local+// Mode, a Cloud selection held automatically (pinnedInference) when dictation left another mode runs+// as if unsaved, since Local Mode's default already uses Cloud wherever the user's access lets it:+// without a session uploads stay on this iPhone, and without an account so does cleanup. Leaving+// Local Mode finds it on Cloud again.+export function workflowSelection(+ config: UserConfig | null,+ scope: MobileInferenceScope,+ activeMode: ProcessingMode,+ cloudAccess: CloudAccess = 'none',+): InferenceSelection {+ const saved = config?.inference?.[scope];+ const heldOnCloudInLocalMode =+ activeMode === 'private' &&+ saved?.mode === 'openwhispr' &&+ !!config?.pinnedInference?.includes(scope);+ return saved && !heldOnCloudInLocalMode ? saved : unsetSelection(scope, activeMode, cloudAccess);}// Text Cleanup, Note Chat and the Voice Assistant have switches of their own; switched off, they@@ -135,7 +152,7 @@ export function workflowSummary(return `Skipped · ${onDeviceUnavailable}`;if (cloudCleanupNeedsAccount(config, activeMode, cloudAccess)) return 'Skipped · Sign in';}- const selection = config?.inference?.[scope] ?? unsetSelection(scope, activeMode, cloudAccess);+ const selection = workflowSelection(config, scope, activeMode, cloudAccess);// Local Mode runs dictation, note formatting and provider note chat on this phone first, whatever// is saved; note chat set to OpenWhispr, or not set, goes straight to Cloud. Uploads and cleanup// run what is saved for them.diff --git a/openwhispr-mobile/src/lib/inferenceModes.ts b/openwhispr-mobile/src/lib/inferenceModes.tsindex cf8df1c38..8ea44f1ff 100644--- a/openwhispr-mobile/src/lib/inferenceModes.ts+++ b/openwhispr-mobile/src/lib/inferenceModes.ts@@ -4,7 +4,6 @@ import type { InferenceSelection, MobileInferenceScope } from '@/lib/mobileProviimport { isDictationAgentEnabled } from '@/lib/dictationAgent';import {inferenceToProcessingMode,- processingToInferenceMode,type InferenceMode,type ProcessingMode,type UserConfig,@@ -80,31 +79,51 @@ export function localModeDefault(return onCloud ? 'openwhispr' : 'local';}-type DictationModeConfig = Pick<- UserConfig,- 'defaultMode' | 'inference' | 'pinnedInference' | 'privateModeReturn'->;+type DictationModeConfig = Pick<UserConfig, 'defaultMode' | 'inference' | 'pinnedInference'>;-// These workflows follow the dictation mode until they have a selection of their own, so they-// would silently change destination when dictation moves to Bring Your Own Key. Cleanup is left-// out: unsaved, it is skipped in that mode, which sends nothing anywhere. The voice assistant and-// note chat are pinned only when leaving On-Device; unsaved, the voice assistant is skipped rather-// than sent to Cloud, and note chat stays where it was before it had a setting of its own.-function scopesToPin(leavingMode: ProcessingMode): MobileInferenceScope[] {- return leavingMode === 'private' ? ['upload', 'notes', 'agent', 'noteChat'] : ['upload', 'notes'];+// The workflows besides dictation, which a dictation change never moves.+const OTHER_WORKFLOWS = ['upload', 'cleanup', 'notes', 'noteChat', 'agent'] as const;+type OtherWorkflow = (typeof OTHER_WORKFLOWS)[number];++// The on-device model picked for a workflow, else Automatic.+export function localSelection(+ config: Pick<UserConfig, 'rememberedInference'> | null,+ scope: MobileInferenceScope,+): InferenceSelection {+ return config?.rememberedInference?.[scope]?.local ?? { mode: 'local' };+}++// What a workflow with nothing saved runs in `mode`, or undefined when there is nothing to hold:+// cleanup and the voice assistant are skipped under Bring Your Own Key until a provider is saved+// for them, and Local Mode turns the voice assistant off. Note formatting saved as On-Device never+// falls back to Cloud, so Local Mode's is held on this iPhone only while Apple Intelligence can run+// it; otherwise Local Mode asks before using Cloud. Local Mode also asks before note chat leaves the+// phone, which no other mode does, so note chat is held On-Device rather than sent to Cloud unasked.+function unsavedRunsIn(+ config: Pick<UserConfig, 'rememberedInference'> | null,+ scope: OtherWorkflow,+ mode: ProcessingMode,+ cloudAccess: CloudAccess,+ localReasoningReady: boolean,+): InferenceSelection | undefined {+ if (mode === 'providers' && (scope === 'cleanup' || scope === 'agent')) return undefined;+ if (mode === 'private' && scope === 'agent') return undefined;+ const onDevice =+ mode === 'private' &&+ (scope === 'noteChat' ||+ (localModeDefault(scope, cloudAccess) === 'local' &&+ (scope !== 'notes' || localReasoningReady)));+ return onDevice ? localSelection(config, scope) : { mode: 'openwhispr' };}-// The Dictation page and onboarding own the dictation mode;-// writing the scope selection alongside defaultMode keeps routing and UI in step.+// Onboarding's config for the dictation mode it picks. It releases the automatic pins, replaying the+// same choice included, since a Dictation change in AI Models may have held them in that mode, so+// those workflows follow the picked mode again; selections the user saved themselves stay.export function dictationModeConfig(config: UserConfig | null,mode: 'cloud' | 'private',): DictationModeConfig {- // 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 pinned = config?.pinnedInference ?? [];const inference = Object.fromEntries(Object.entries(config?.inference ?? {}).filter(([scope]) => !pinned.includes(scope as MobileInferenceScope),@@ -115,82 +134,49 @@ export function dictationModeConfig(inference: {...inference,// On-Device restores the model picked on the Dictation page.- dictation:- mode === 'private'- ? (config?.rememberedInference?.dictation?.local ?? { mode: 'local' })- : { mode: 'openwhispr' },+ dictation: mode === 'private' ? localSelection(config, 'dictation') : { mode: 'openwhispr' },},- ...(modeChanged && config?.pinnedInference ? { pinnedInference: undefined } : {}),- // Only a switch from Bring Your Own Key sets where Private mode returns to (workflowSaveConfig).- ...(config?.privateModeReturn ? { privateModeReturn: undefined } : {}),+ ...(config?.pinnedInference ? { pinnedInference: undefined } : {}),};}-function providerDictationConfig(+// Changing the dictation mode changes only dictation: the automatic pins stay, and each workflow+// with nothing saved is saved as what it ran in the mode being left, as an automatic pin.+function dictationSwitchConfig(config: UserConfig | null,dictation: InferenceSelection,+ mode: ProcessingMode,leavingMode: ProcessingMode,cloudAccess: CloudAccess,+ localReasoningReady: boolean,): DictationModeConfig {const inference = { ...config?.inference, dictation };+ if (mode === leavingMode) return { defaultMode: mode, inference };const pinnedInference = [...(config?.pinnedInference ?? [])];- // Leaving Private mode for the provider it was turned on from holds what that provider held,- // 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'- ? []- : returning- ? (Object.entries(config?.privateModeReturn?.pinned ?? {}) as [- MobileInferenceScope,- InferenceSelection,- ][])- : scopesToPin(leavingMode).map((scope) => [- scope,- {- // Each holds what ran in the mode being left: uploads in Local Mode ran on- // OpenWhispr Cloud when there was a session. Unset note chat ran on Cloud after- // asking; Bring Your Own Key would send it there without asking, so it is held- // On-Device, as it was before it had a setting of its own.- mode:- leavingMode === 'private' && scope === 'upload'- ? localModeDefault(scope, cloudAccess)- : processingToInferenceMode(leavingMode),- },- ]);- for (const [scope, selection] of pins) {- const heldAutomatically = pinnedInference.includes(scope);- if (inference[scope] && !(returning && heldAutomatically)) continue;+ for (const scope of OTHER_WORKFLOWS) {+ if (inference[scope]) continue;+ const selection = unsavedRunsIn(config, scope, leavingMode, cloudAccess, localReasoningReady);+ if (!selection) continue;inference[scope] = selection;- if (!heldAutomatically) pinnedInference.push(scope);+ if (!pinnedInference.includes(scope)) pinnedInference.push(scope);}return {- defaultMode: 'providers',+ defaultMode: mode,inference,...(pinnedInference.length ? { pinnedInference } : {}),};}-// What Bring Your Own Key holds on the mode dictation came from, kept while Private mode is on.-function pinnedSelections(- config: UserConfig | null,-): Partial<Record<MobileInferenceScope, InferenceSelection>> {- return Object.fromEntries(- (config?.pinnedInference ?? []).flatMap((scope) => {- const selection = config?.inference?.[scope];- return selection ? [[scope, selection]] : [];- }),- );-}-// The config a workflow page writes when the user saves `selection` for `scope`. `cloudAccess` is-// what the user has on OpenWhispr Cloud, which decides what ran for uploads in Local Mode.+// what the user has on OpenWhispr Cloud, and `localReasoningReady` whether Apple Intelligence can+// run here; together they decide what an unsaved workflow ran in Local Mode.export function workflowSaveConfig(config: UserConfig | null,scope: MobileInferenceScope,selection: InferenceSelection,activeMode: ProcessingMode,cloudAccess: CloudAccess = 'none',+ localReasoningReady = false,): Partial<UserConfig> {const { providerId } = selection;const otherProviders = Object.fromEntries(@@ -207,21 +193,23 @@ export function workflowSaveConfig(: {};if (scope === 'dictation') {const mode = inferenceToProcessingMode(selection.mode);- // Picking another on-device model keeps where Private mode returns to; leaving it clears it.- const privateModeReturn =- mode !== 'private'- ? undefined- : activeMode === 'private'- ? config?.privateModeReturn- : activeMode === 'providers'- ? { pinned: pinnedSelections(config) }- : undefined;+ // On-Device restores the model picked on the Dictation page.+ const dictation =+ mode === 'providers'+ ? selection+ : mode === 'private'+ ? localSelection(config, 'dictation')+ : { mode: 'openwhispr' as const };return {...rememberedInference,- ...(mode === 'providers'- ? providerDictationConfig(config, selection, activeMode, cloudAccess)- : dictationModeConfig(config, mode)),- ...(privateModeReturn || config?.privateModeReturn ? { privateModeReturn } : {}),+ ...dictationSwitchConfig(+ config,+ dictation,+ mode,+ activeMode,+ cloudAccess,+ localReasoningReady,+ ),};}return {@@ -234,8 +222,8 @@ export function workflowSaveConfig(}// 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).+// They are automatic pins, which a dictation change keeps and only onboarding releases, 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'> {@@ -244,7 +232,7 @@ export function holdOnDeviceConfig(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' };+ inference[scope] = localSelection(config, scope);if (!pinnedInference.includes(scope)) pinnedInference.push(scope);}return { inference, pinnedInference };@@ -264,7 +252,6 @@ export function noteChatSplitConfig(config: UserConfig): Partial<UserConfig> {const agent = config.inference?.agent;const copied = !!agent && !config.inference?.noteChat;const rememberedAgent = config.rememberedInference?.agent;- const heldAgent = config.privateModeReturn?.pinned.agent;return {noteChatSplit: true,// Note chat's switch followed the voice assistant's until set; saving it keeps it put.@@ -278,12 +265,5 @@ export function noteChatSplitConfig(config: UserConfig): Partial<UserConfig> {...(copied && config.pinnedInference?.includes('agent')? { pinnedInference: [...config.pinnedInference, 'noteChat'] }: {}),- ...(heldAgent && !config.privateModeReturn?.pinned.noteChat- ? {- privateModeReturn: {- pinned: { ...config.privateModeReturn?.pinned, noteChat: heldAgent },- },- }- : {}),};}diff --git a/openwhispr-mobile/src/lib/inferenceRouting.ts b/openwhispr-mobile/src/lib/inferenceRouting.tsindex 35979593d..54b4b00dc 100644--- a/openwhispr-mobile/src/lib/inferenceRouting.ts+++ b/openwhispr-mobile/src/lib/inferenceRouting.ts@@ -9,7 +9,7 @@ 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 { cloudAccessFor, unsetSelection, workflowSelection } from '@/lib/aiWorkflows';import type { CloudAccess } from '@/lib/inferenceModes';export type ProviderRoute = Extract<InferenceRoute, { mode: 'providers' }>;@@ -35,13 +35,17 @@ function currentCloudAccess(): CloudAccess {export function getTranscriptionProvider(scope: InferenceScope): TranscriptionProvider {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).+ // saved or Cloud held automatically, OpenWhispr Cloud when there is a session (workflowSelection).if (activeMode === 'private' && scope !== 'upload') return 'local';const selection =- getInferenceSelection(scope) ??- (activeMode === 'private'- ? unsetSelection('upload', activeMode, currentCloudAccess())- : undefined);+ activeMode === 'private'+ ? workflowSelection(+ useConfigStore.getState().config,+ 'upload',+ activeMode,+ currentCloudAccess(),+ )+ : getInferenceSelection(scope);if (selection?.mode === 'providers') return 'byok';if (selection?.mode === 'local') return 'local';// Bring Your Own Key mode without a dictation choice must refuse (seediff --git a/openwhispr-mobile/src/lib/onboardingMode.ts b/openwhispr-mobile/src/lib/onboardingMode.tsindex d706b056a..5e636f57b 100644--- a/openwhispr-mobile/src/lib/onboardingMode.ts+++ b/openwhispr-mobile/src/lib/onboardingMode.ts@@ -50,8 +50,9 @@ export async function chooseOnboardingMode(pinnedInference: config?.pinnedInference,};// The dictation route moves with the mode, so a replayed pick also leaves a Providers route.- // Choosing Local in setup also keeps uploads and cleanup on this iPhone; going back to Cloud- // releases them, since the mode changes.+ // Choosing Local in setup also keeps uploads and cleanup on this iPhone; choosing Cloud releases+ // them. The other workflows follow the picked mode until a Dictation change in AI Models holds+ // them where they ran.const next = dictationModeConfig(config, mode);await saveOnboardingConfig(mode === 'private' ? { ...next, ...holdOnDeviceConfig({ ...config, ...next }) } : next,diff --git a/openwhispr-mobile/src/lib/transcribeAndCleanup.ts b/openwhispr-mobile/src/lib/transcribeAndCleanup.tsindex ddee7db6a..de00117df 100644--- a/openwhispr-mobile/src/lib/transcribeAndCleanup.ts+++ b/openwhispr-mobile/src/lib/transcribeAndCleanup.ts@@ -59,21 +59,23 @@ function rawTranscriptResult(transcription: TranscriptionResponse): DictationPro// 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.+// Whether a pinned On-Device cleanup still runs is read live, like cleanupEnabled. Apart from a+// saved On-Device cleanup, the local route is pinned only without an account, so it is read as one.function cleansLocalTranscript(request: TranscriptionRequest): boolean {if (!request.cleanupRoute) return false;if (request.cleanupRoute.mode !== 'local') return true;return cleanupRunsOnDevice(useConfigStore.getState().config,useProcessingModeStore.getState().activeMode,+ 'none',);}-// 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.+// Cleanup runs On-Device without the user having saved On-Device for it: unset or held on Cloud in+// Local Mode, or held there automatically (pinnedInference), which a dictation change keeps in any+// mode. 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;diff --git a/openwhispr-mobile/src/lib/workflowModeSwitch.ts b/openwhispr-mobile/src/lib/workflowModeSwitch.tsindex 9bc3a6364..fa966b353 100644--- a/openwhispr-mobile/src/lib/workflowModeSwitch.ts+++ b/openwhispr-mobile/src/lib/workflowModeSwitch.ts@@ -8,7 +8,8 @@ import {requiresRealAccount,showAccountRequiredAlert,} from '@/lib/accountAccess';-import { workflowSaveConfig } from '@/lib/inferenceModes';+import { cloudAccessFor } from '@/lib/aiWorkflows';+import { localSelection, workflowSaveConfig } from '@/lib/inferenceModes';import {canRunLocalReasoning,getLocalReasoningReadiness,@@ -16,6 +17,7 @@ import {} from '@/lib/localReasoning';import type { LocalModelKey } from '@/lib/localModelCatalog';import { type InferenceSelection, type MobileInferenceScope } from '@/lib/mobileProviders';+import type { InferenceMode, ProcessingMode } from '@/types';import { getPrivateModeReadiness, getPrivateModeUnavailableMessage } from '@/lib/privateMode';type SpeechScope = 'dictation' | 'upload';@@ -62,6 +64,18 @@ async function appleIntelligenceReady(): Promise<ModeSwitchResult | null> {return 'not-ready';}+// Whether Apple Intelligence can run here, which decides where note formatting with nothing saved+// is held when dictation leaves Local Mode (workflowSaveConfig). Asked only then, and afresh, since+// the cached answer outlives a change in iOS Settings.+export async function leavingLocalModeWithLocalReasoning(+ scope: MobileInferenceScope,+ activeMode: ProcessingMode,+ target: InferenceMode,+): Promise<boolean> {+ if (scope !== 'dictation' || activeMode !== 'private' || target === 'local') return false;+ return (await getLocalReasoningReadiness({ refresh: true })).status === 'ready';+}+// 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(@@ -73,11 +87,11 @@ export async function switchWorkflowMode(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.+ // Outside Cloud dictation, Cloud cleanup is a separate pass that needs an account.if (mode === 'openwhispr' &&scope === 'cleanup' &&- useProcessingModeStore.getState().activeMode === 'private' &&+ useProcessingModeStore.getState().activeMode !== 'cloud' &&requiresRealAccount(user)) {showAccountRequiredAlert('cloud cleanup');@@ -90,14 +104,22 @@ export async function switchWorkflowMode(if (blocked) return blocked;}- const { config, updateConfig } = useConfigStore.getState();const { activeMode, setActiveMode } = useProcessingModeStore.getState();+ const localReasoningReady = await leavingLocalModeWithLocalReasoning(scope, activeMode, mode);+ const { config, updateConfig } = useConfigStore.getState();if (scope === 'dictation') setActiveMode(mode === 'local' ? 'private' : 'cloud', true);const selection: InferenceSelection =- mode === 'local'- ? (config?.rememberedInference?.[scope]?.local ?? { mode: 'local' })- : { mode: 'openwhispr' };- await updateConfig(workflowSaveConfig(config, scope, selection, activeMode));+ mode === 'local' ? localSelection(config, scope) : { mode: 'openwhispr' };+ await updateConfig(+ workflowSaveConfig(+ config,+ scope,+ selection,+ activeMode,+ cloudAccessFor(user),+ localReasoningReady,+ ),+ );return 'switched';}@@ -117,7 +139,7 @@ export async function pickLocalModel(...config?.rememberedInference,[scope]: { ...config?.rememberedInference?.[scope], local: selection },},- // A picked model is the user's own choice, so leaving Bring Your Own Key keeps it.+ // A picked model is the user's own choice, so onboarding never releases it....(config?.pinnedInference? { pinnedInference: config.pinnedInference.filter((pinned) => pinned !== scope) }: {}),diff --git a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsxindex 063b8d279..9b3be26af 100644--- a/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx+++ b/openwhispr-mobile/src/screens/WorkflowSettingsScreen.tsx@@ -52,14 +52,18 @@ import {cloudAccessFor,cloudCleanupNeedsAccount,parseWorkflow,- unsetSelection,+ workflowSelection,workflowSwitchedOff,} from '@/lib/aiWorkflows';import { isLocalModelKey } from '@/lib/localModelCatalog';import { getDictationAgentName } from '@/lib/dictationAgent';import { safeHaptics } from '@/lib/utils';import { SystemIcon, type LucideIconName } from '@/components/ui/SystemIcon';-import { type ModeSwitchResult, switchWorkflowMode } from '@/lib/workflowModeSwitch';+import {+ leavingLocalModeWithLocalReasoning,+ type ModeSwitchResult,+ switchWorkflowMode,+} from '@/lib/workflowModeSwitch';import { getPrivateModeReadiness } from '@/lib/privateMode';import {getLocalReasoningReadiness,@@ -303,8 +307,7 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXconst setActiveMode = useProcessingModeStore((state) => state.setActiveMode);const activeMode = useProcessingModeStore((state) => state.activeMode);const cloudAccess = useAuthStore((state) => cloudAccessFor(state.user));- const storedSelection =- config?.inference?.[scope] ?? unsetSelection(scope, activeMode, cloudAccess);+ const storedSelection = workflowSelection(config, 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 =@@ -537,8 +540,9 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSX);return;}- // 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.+ // Tapping the shown mode saves it as the user's own when nothing of theirs is saved, since an+ // unsaved default follows the mode and the account (unsetSelection), and onboarding releases a+ // pin.const ownChoice = !!config?.inference?.[scope] && !config.pinnedInference?.includes(scope);if (mode === savedSelection.mode && ownChoice) {setSelection(savedSelection);@@ -653,8 +657,20 @@ function WorkflowSettings({ scope }: { scope: MobileInferenceScope }): React.JSXtry {const saved = await prepareSelection();if (!saved) return;+ const localReasoningReady = await leavingLocalModeWithLocalReasoning(+ scope,+ activeMode,+ saved.mode,+ );await updateConfig(- workflowSaveConfig(useConfigStore.getState().config, scope, saved, activeMode, cloudAccess),+ workflowSaveConfig(+ useConfigStore.getState().config,+ scope,+ saved,+ activeMode,+ cloudAccess,+ localReasoningReady,+ ),);if (useConfigStore.getState().error) {showError('Unable to save your selection. Please try again.');diff --git a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsxindex d65a62372..f9f0f2b30 100644--- a/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx+++ b/openwhispr-mobile/src/screens/__tests__/WorkflowSettingsScreen.test.tsx@@ -22,6 +22,7 @@ const mockDispatch = jest.fn();let mockStoredPrompt = '';const mockPush = jest.fn();const mockSwitchMode = jest.fn();+let mockLocalReasoningReady = false;const mockPrivateReadiness = jest.fn();let mockFocusEffect: (() => (() => void) | undefined) | undefined;const MockText = require('react-native').Text;@@ -47,6 +48,7 @@ jest.mock('@/lib/privateMode', () => ({}));jest.mock('@/lib/workflowModeSwitch', () => ({switchWorkflowMode: (...args: unknown[]) => mockSwitchMode(...args),+ leavingLocalModeWithLocalReasoning: async () => mockLocalReasoningReady,}));jest.mock('@/components/settings/OnDeviceModelSection', () => ({OnDeviceModelSection: ({@@ -125,7 +127,7 @@ jest.mock('@/services/providers/ProviderCredentials', () => ({}));import { WorkflowSettingsScreen } from '../WorkflowSettingsScreen';-import { PRIVATE_MODE_LOCKED_REASON } from '@/lib/aiWorkflows';+import { CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE, PRIVATE_MODE_LOCKED_REASON } from '@/lib/aiWorkflows';function chooseProvider(provider: string): void {fireEvent.press(screen.getByText('Provider'));@@ -145,6 +147,7 @@ function selectedMode(): string | undefined {}beforeEach(() => {+ mockLocalReasoningReady = false;jest.clearAllMocks();mockConfig = null;mockScope = 'dictation';@@ -495,11 +498,40 @@ it('says why a saved Cloud cleanup is skipped in Local Mode without an account',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();+ expect(screen.getByText(CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE)).toBeTruthy();+});++// Bring Your Own Key dictation also needs the separate Cloud pass, so a Cloud cleanup held when+// dictation left Cloud says why it is skipped rather than looking as if it runs.+it('says why a held Cloud cleanup is skipped under Bring Your Own Key without an account', () => {+ mockUser = { id: 'a', isAnonymous: true };+ mockConfig = {+ defaultMode: 'providers',+ inference: {+ dictation: { mode: 'providers', providerId: 'openai', modelId: 'whisper-1' },+ cleanup: { mode: 'openwhispr' },+ },+ pinnedInference: ['cleanup'],+ };+ mockActiveMode = 'providers';+ mockScope = 'cleanup';+ render(<WorkflowSettingsScreen />);+ expect(selectedMode()).toBe('OpenWhispr Cloud');+ expect(screen.getByText(CLOUD_CLEANUP_NEEDS_ACCOUNT_NOTE)).toBeTruthy();+});++// Local Mode formats notes on this phone first, so a Cloud hold shows what runs, as the AI Models+// row does.+it('shows note formatting held on Cloud as On-Device in Local Mode', () => {+ mockConfig = {+ defaultMode: 'private',+ inference: { dictation: { mode: 'local' }, notes: { mode: 'openwhispr' } },+ pinnedInference: ['notes'],+ };+ mockActiveMode = 'private';+ mockScope = 'notes';+ render(<WorkflowSettingsScreen />);+ expect(selectedMode()).toBe('On-Device');});it('keeps On-Device cleanup selected once a private-mode user has saved it', () => {@@ -543,12 +575,19 @@ it('keeps uploads on Cloud when a user with a session leaves Local Mode for a prfireEvent.press(screen.getByText('Save'));await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({- inference: { upload: { mode: 'openwhispr' } },- pinnedInference: ['upload', 'notes', 'agent', 'noteChat'],+ inference: {+ upload: { mode: 'openwhispr' },+ cleanup: { mode: 'local' },+ noteChat: { mode: 'local' },+ },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],});});-it('keeps notes and chat on this phone when dictation leaves Local Mode for a provider', async () => {+// Local Mode formatted notes with Apple Intelligence. It turned the voice assistant off, so that+// stays unset and is skipped until a provider is saved for it.+it('keeps notes on this phone when dictation leaves Local Mode for a provider', async () => {+ mockLocalReasoningReady = true;mockConfig = { defaultMode: 'private' };mockActiveMode = 'private';mockCredentialStatus.mockResolvedValue({ isConfigured: true });@@ -557,9 +596,10 @@ it('keeps notes and chat on this phone when dictation leaves Local Mode for a prfireEvent.press(screen.getByText('Save'));await waitFor(() => expect(mockUpdateConfig).toHaveBeenCalled());expect(mockUpdateConfig.mock.calls[0][0]).toMatchObject({- inference: { notes: { mode: 'local' }, agent: { mode: 'local' }, noteChat: { mode: 'local' } },- pinnedInference: ['upload', 'notes', 'agent', 'noteChat'],+ inference: { notes: { mode: 'local' }, noteChat: { mode: 'local' } },+ pinnedInference: ['upload', 'cleanup', 'notes', 'noteChat'],});+ expect(mockUpdateConfig.mock.calls[0][0].inference.agent).toBeUndefined();});it('switches dictation from Bring Your Own Key to Cloud on tap, without Save', async () => {diff --git a/openwhispr-mobile/src/types/index.ts b/openwhispr-mobile/src/types/index.tsindex addc61ef9..57f4c5ce3 100644--- a/openwhispr-mobile/src/types/index.ts+++ b/openwhispr-mobile/src/types/index.ts@@ -13,13 +13,10 @@ export type InferenceMode = 'openwhispr' | 'local' | 'providers';export interface UserConfig {inference?: Partial<Record<InferenceScope, InferenceSelection>>;rememberedInference?: Partial<Record<InferenceScope, Record<string, InferenceSelection>>>;- // Workflows held on the previous mode when dictation moved to Bring Your Own Key,- // as opposed to ones the user chose; only these are released when dictation leaves it.+ // Workflows set automatically, by Local Mode holding them on this iPhone or a dictation change+ // keeping them where they ran, as opposed to ones the user chose on their own page; a dictation+ // change keeps these and only onboarding releases them.pinnedInference?: MobileInferenceScope[];- // Set while Private mode is on after being turned on from Bring Your Own Key, so turning it- // off goes back to the last provider rather than to Cloud, with the workflows it held- // (pinnedInference) held on the same selections again.- privateModeReturn?: { pinned: Partial<Record<MobileInferenceScope, InferenceSelection>> };// 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;@@ -59,10 +56,6 @@ export function inferenceToProcessingMode(mode: InferenceMode): ProcessingMode {return mode === 'local' ? 'private' : mode === 'providers' ? 'providers' : 'cloud';}-export function processingToInferenceMode(mode: ProcessingMode): InferenceMode {- return mode === 'private' ? 'local' : mode === 'providers' ? 'providers' : 'openwhispr';-}-export interface TextInferenceSnapshot {cleanupRoute?: InferenceRoute;agentRoute?: InferenceRoute;