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(settings): stop the post-sign-in cloud switch from overriding Local dictation (#2093)
Chad Pihab7906dd9f38a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 520880b38..abcd39f5f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed- Windows and Linux media pause/resume no longer block the main process. A slow or stuck PowerShell, nircmd, playerctl or dbus-send helper previously froze hotkeys, IPC and the dictation window until it exited, so a dictation could no longer be stopped and its recording was lost. Pause, resume and toggle now also run one at a time, so a quick tap can no longer strand media paused — previously possible on macOS. (#2073)+- **Signing in no longer silently reroutes dictation to OpenWhispr Cloud.** Restarting onboarding from Settings (Create Free Account, the plan cards, or picking OpenWhispr Cloud while signed out) armed a post-sign-in "cloud migration" that rewrote how audio was routed but not the mode the Settings picker reads. Whether you had chosen Local, your own API keys, or your own endpoint, Settings kept showing that choice while your audio went to OpenWhispr Cloud — and clicking the mode already shown did nothing. That migration is gone, and a profile already stuck this way is repaired on the next launch from the mode its picker shows, for dictation and audio upload. The repair only ever moves away from our servers, so it can never start sending audio that was staying on your device or going to your own provider. Note Recording was never affected: it reads the same setting its picker shows. (#2086)+- One consequence of that repair worth knowing: the picker is the only record of what you asked for, so a profile is moved back to what it shows even if it has been transcribing elsewhere for a while. A picker reading "Local" returns to Local, and one reading "API Keys" or a self-hosted endpoint returns to your own credential. If the local model was never downloaded, or the API key has since been removed or expired, dictation now says so instead of quietly using OpenWhispr Cloud — pick a mode again in Settings → Speech to Text to settle it. (#2086)## [1.9.2] - 2026-08-29diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 0b15325e3..1920b7b97 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -137,7 +137,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro} | null>(null);const [showSearch, setShowSearch] = useState(false);const showDiscarded = useShowDiscarded();- const [showCloudMigrationBanner, setShowCloudMigrationBanner] = useState(false);const [activeView, setActiveView] = useState<ControlPanelView>("home");const {collapsed: sidebarCollapsed,@@ -162,12 +161,11 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProconst [gpuBannerDismissed, setGpuBannerDismissed] = useState(() => localStorage.getItem("gpuBannerDismissedUnified") === "true");- const cloudMigrationProcessed = useRef(false);const updateReadyToastShown = useRef(false);const updateErrorToastShown = useRef<Error | null>(null);const { hotkey } = useHotkey();const { toast } = useToast();- const { useCleanupModel, setUseLocalWhisper, setCloudTranscriptionMode } = useSettings();+ const { useCleanupModel } = useSettings();const { isSignedIn, isLoaded: authLoaded, user } = useAuth();// Suppressed while a deep-linked invitation is open so the two never stack.const {@@ -399,19 +397,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro}}, [authLoaded, isSignedIn]);- useEffect(() => {- if (!authLoaded || !isSignedIn || cloudMigrationProcessed.current) return;- const isPending = localStorage.getItem("pendingCloudMigration") === "true";- const alreadyShown = localStorage.getItem("cloudMigrationShown") === "true";- if (!isPending || alreadyShown) return;-- cloudMigrationProcessed.current = true;- setUseLocalWhisper(false);- setCloudTranscriptionMode("openwhispr");- localStorage.removeItem("pendingCloudMigration");- setShowCloudMigrationBanner(true);- }, [authLoaded, isSignedIn, setUseLocalWhisper, setCloudTranscriptionMode]);-useEffect(() => {const drain = async () => {const data = await window.electronAPI?.getPendingMeetingNoteNavigation?.();@@ -1174,8 +1159,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProhistory={history}isLoading={isLoading}hotkey={hotkey}- showCloudMigrationBanner={showCloudMigrationBanner}- setShowCloudMigrationBanner={setShowCloudMigrationBanner}aiCTADismissed={aiCTADismissed}setAiCTADismissed={setAiCTADismissed}useCleanupModel={useCleanupModel}diff --git a/src/components/HistoryView.tsx b/src/components/HistoryView.tsxindex b857e4203..fc7b2b689 100644--- a/src/components/HistoryView.tsx+++ b/src/components/HistoryView.tsx@@ -1,7 +1,7 @@import { Fragment, useMemo } from "react";import { useTranslation } from "react-i18next";import { Button } from "./ui/button";-import { Loader2, Sparkles, Cloud, X, Mic, Trash2, Archive } from "lucide-react";+import { Loader2, Sparkles, X, Mic, Trash2, Archive } from "lucide-react";import TranscriptionItem from "./ui/TranscriptionItem";import type { TranscriptionItem as TranscriptionItemType } from "../types/electron";import { formatHotkeyLabel, parseHotkeyList } from "../utils/hotkeys";@@ -16,8 +16,6 @@ interface HistoryViewProps {history: TranscriptionItemType[];isLoading: boolean;hotkey: string;- showCloudMigrationBanner: boolean;- setShowCloudMigrationBanner: (show: boolean) => void;aiCTADismissed: boolean;setAiCTADismissed: (dismissed: boolean) => void;useCleanupModel: boolean;@@ -36,8 +34,6 @@ export default function HistoryView({history,isLoading,hotkey,- showCloudMigrationBanner,- setShowCloudMigrationBanner,aiCTADismissed,setAiCTADismissed,useCleanupModel,@@ -96,46 +92,6 @@ export default function HistoryView({<div className="px-4 pt-4 pb-6"><div className="mx-auto max-w-5xl">{history.length === 0 && <div className="mb-2 flex justify-end">{discardedToggle}</div>}- {showCloudMigrationBanner && (- <div className="mb-3 relative rounded-lg border border-primary/20 bg-primary/5 dark:bg-primary/10 p-3">- <button- onClick={() => {- setShowCloudMigrationBanner(false);- localStorage.setItem("cloudMigrationShown", "true");- }}- aria-label={t("common.close")}- className="absolute top-2 right-2 p-1 rounded-sm text-muted-foreground hover:text-foreground hover:bg-black/5 dark:hover:bg-white/5 transition-colors"- >- <X size={14} />- </button>- <div className="flex items-start gap-3 pr-6">- <div className="shrink-0 w-8 h-8 rounded-md bg-primary/10 dark:bg-primary/20 flex items-center justify-center">- <Cloud size={16} className="text-primary" />- </div>- <div className="flex-1 min-w-0">- <p className="text-xs font-medium text-foreground mb-0.5">- {t("controlPanel.cloudMigration.title")}- </p>- <p className="text-xs text-muted-foreground mb-2">- {t("controlPanel.cloudMigration.description")}- </p>- <Button- variant="default"- size="sm"- className="h-7 text-xs"- onClick={() => {- setShowCloudMigrationBanner(false);- localStorage.setItem("cloudMigrationShown", "true");- onOpenSettings("transcription");- }}- >- {t("controlPanel.cloudMigration.viewSettings")}- </Button>- </div>- </div>- </div>- )}-{!useCleanupModel && !aiCTADismissed && (<div className="mb-3 relative rounded-lg border border-primary/20 bg-primary/5 dark:bg-primary/10 p-3"><buttondiff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex c1f523caa..01a373af9 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -99,7 +99,7 @@ import { Skeleton } from "./ui/skeleton";import { Progress } from "./ui/progress";import { useToast } from "./ui/useToast";import { useTheme } from "../hooks/useTheme";-import { resetOnboardingProgress } from "./onboarding/flow";+import { useStartOnboarding } from "../hooks/useStartOnboarding";import type {ChineseScriptPreference,GpuDevice,@@ -1851,11 +1851,7 @@ export default function SettingsPage({} | null>(null);const [previewLoading, setPreviewLoading] = useState(false);- const startOnboarding = useCallback(() => {- localStorage.setItem("pendingCloudMigration", "true");- resetOnboardingProgress(localStorage);- window.location.reload();- }, []);+ const startOnboarding = useStartOnboarding();const handleSwitchPlan = useCallback(async (plan: "monthly" | "annual", tier: "pro" | "business") => {diff --git a/src/components/UpgradePrompt.tsx b/src/components/UpgradePrompt.tsxindex a41ca8841..7dcda97b3 100644--- a/src/components/UpgradePrompt.tsx+++ b/src/components/UpgradePrompt.tsx@@ -74,6 +74,7 @@ export default function UpgradePrompt({onClick={() => {const s = useSettingsStore.getState();s.setTranscriptionMode("providers");+ s.setUseLocalWhisper(false);s.setCloudTranscriptionMode("byok");onOpenChange(false);}}diff --git a/src/components/settings/InferenceConfigEditor.tsx b/src/components/settings/InferenceConfigEditor.tsxindex e93c20082..6ed8a9960 100644--- a/src/components/settings/InferenceConfigEditor.tsx+++ b/src/components/settings/InferenceConfigEditor.tsx@@ -29,7 +29,7 @@ import { useManagedScopeResolution } from "../../stores/enterpriseIdentityStore"import TestConnectionButton from "../TestConnectionButton";import { getEnterpriseCallSettings } from "../../services/ai/enterpriseSettings";import { Button } from "../ui/button";-import { resetOnboardingProgress } from "../onboarding/flow";+import { useStartOnboarding } from "../../hooks/useStartOnboarding";const MODE_LABEL_PREFIX: Record<InferenceScope, string> = {dictationCleanup: "settingsPage.aiModels.modes",@@ -40,12 +40,6 @@ const MODE_LABEL_PREFIX: Record<InferenceScope, string> = {dictationTranslation: "settingsPage.aiModels.modes",};-function startCloudOnboarding() {- localStorage.setItem("pendingCloudMigration", "true");- resetOnboardingProgress(localStorage);- window.location.reload();-}-interface InferenceConfigEditorProps {scope: InferenceScope;onModeChange?: (mode: InferenceMode) => void;@@ -59,6 +53,7 @@ export default function InferenceConfigEditor({allowedModes,}: InferenceConfigEditorProps) {const { t } = useTranslation();+ const startOnboarding = useStartOnboarding();const policyState = usePolicySnapshot();const config = useSettingsStore(useShallow((settings) =>@@ -129,7 +124,7 @@ export default function InferenceConfigEditor({(mode: InferenceMode) => {if (!isModeAllowed(mode)) return;if (mode === "openwhispr" && !isSignedIn) {- startCloudOnboarding();+ startOnboarding();return;}if (mode === effectiveMode) return;@@ -150,7 +145,15 @@ export default function InferenceConfigEditor({onModeChange?.(mode);},- [scope, config.provider, effectiveMode, isSignedIn, onModeChange, isModeAllowed]+ [+ scope,+ config.provider,+ effectiveMode,+ isSignedIn,+ onModeChange,+ isModeAllowed,+ startOnboarding,+ ]);const setMode = setField("mode");diff --git a/src/hooks/useStartOnboarding.ts b/src/hooks/useStartOnboarding.tsindex 8666da136..3d4ebf187 100644--- a/src/hooks/useStartOnboarding.ts+++ b/src/hooks/useStartOnboarding.ts@@ -1,11 +1,12 @@import { useCallback } from "react";import { resetOnboardingProgress } from "../components/onboarding/flow";-// Restart the onboarding flow from the cloud-migration step (used when a-// settings panel needs the user to sign in for OpenWhispr Cloud).-export function useStartOnboarding() {+// Restart onboarding from the auth step so the user can sign in for OpenWhispr+// Cloud. The restarted flow's setup-choice step commits whatever the user picks+// via setCloudTranscriptionForAllScopes, so nothing is pre-armed here: a+// pre-armed cloud switch is what overrode Local for #2086.+export function useStartOnboarding(): () => void {return useCallback(() => {- localStorage.setItem("pendingCloudMigration", "true");resetOnboardingProgress(localStorage);window.location.reload();}, []);diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 184aca4ae..568ab99ea 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "Übersetzungsmodus"},- "cloudMigration": {- "title": "Willkommen bei OpenWhispr Cloud",- "description": "Wir haben die Transkription auf OpenWhispr Cloud umgestellt für schnellere und genauere Ergebnisse. Ihre bisherigen Einstellungen sind gespeichert – wechseln Sie jederzeit in den Einstellungen zurück.",- "viewSettings": "Einstellungen anzeigen"- },"aiCta": {"title": "Verbessern Sie Ihre Transkriptionen mit KI","description": "Korrigiert automatisch Grammatik, Zeichensetzung und Formatierung, während Sie sprechen.",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 1954a47fa..16c1fc05b 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "Translation Mode"},- "cloudMigration": {- "title": "Welcome to OpenWhispr Cloud",- "description": "We've switched your transcription to OpenWhispr Cloud for faster, more accurate results. Your previous settings are saved — switch back anytime in Settings.",- "viewSettings": "View Settings"- },"aiCta": {"title": "Enhance your transcriptions with AI","description": "Automatically fix grammar, punctuation, and formatting as you speak.",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex f320d2659..a8e9df3ac 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -680,11 +680,6 @@"rawTranscript": "Transcripción sin procesar","retryTranslationMode": "Modo Traducción"},- "cloudMigration": {- "title": "Bienvenido a OpenWhispr Cloud",- "description": "Cambiamos tu transcripción a OpenWhispr Cloud para resultados más rápidos y precisos. Tu configuración anterior se guardó: puedes volver cuando quieras en Ajustes.",- "viewSettings": "Ver ajustes"- },"aiCta": {"title": "Mejora tus transcripciones con IA","description": "Corrige automáticamente gramática, puntuación y formato mientras hablas.",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 76298b1c7..2d3274f74 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "Mode Traduction"},- "cloudMigration": {- "title": "Bienvenue sur OpenWhispr Cloud",- "description": "Nous avons basculé la transcription vers OpenWhispr Cloud pour des résultats plus rapides et plus précis. Vos anciens réglages sont conservés : vous pouvez revenir en arrière à tout moment dans Paramètres.",- "viewSettings": "Voir les paramètres"- },"aiCta": {"title": "Améliorez vos transcriptions avec l'IA","description": "Corrige automatiquement grammaire, ponctuation et mise en forme pendant que vous parlez.",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 64113c692..1a42f9ab2 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "Modalità Traduzione"},- "cloudMigration": {- "title": "Benvenuto in OpenWhispr Cloud",- "description": "Abbiamo spostato la trascrizione su OpenWhispr Cloud per risultati più rapidi e accurati. Le impostazioni precedenti sono state salvate: puoi tornare indietro in qualsiasi momento dalle Impostazioni.",- "viewSettings": "Apri impostazioni"- },"aiCta": {"title": "Migliora le tue trascrizioni con l'IA","description": "Corregge automaticamente grammatica, punteggiatura e formattazione mentre parli.",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 68b96767e..8f534c4bb 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "翻訳モード"},- "cloudMigration": {- "title": "OpenWhispr Cloud へようこそ",- "description": "より高速で正確な文字起こしのために OpenWhispr Cloud に切り替えました。以前の設定は保存されています。設定からいつでも戻せます。",- "viewSettings": "設定を表示"- },"aiCta": {"title": "AI で文字起こしを向上させましょう","description": "話しながら文法、句読点、書式を自動的に修正します。",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex 6db8e0eda..66fd63f07 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -659,11 +659,6 @@},"retryTranslationMode": "Modo de Tradução"},- "cloudMigration": {- "title": "Boas-vindas ao OpenWhispr Cloud",- "description": "Mudamos sua transcrição para o OpenWhispr Cloud para resultados mais rápidos e precisos. Suas configurações anteriores foram salvas — volte quando quiser em Configurações.",- "viewSettings": "Ver configurações"- },"aiCta": {"title": "Melhore suas transcrições com IA","description": "Corrija automaticamente gramática, pontuação e formatação enquanto você fala.",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 20373d5a7..9938b2d27 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "Режим перевода"},- "cloudMigration": {- "title": "Добро пожаловать в OpenWhispr Cloud",- "description": "Мы переключили транскрипцию на OpenWhispr Cloud для более быстрых и точных результатов. Ваши предыдущие настройки сохранены — вы можете вернуться к ним в любой момент в настройках.",- "viewSettings": "Открыть настройки"- },"aiCta": {"title": "Улучшите транскрипции с помощью ИИ","description": "Автоматически исправляйте грамматику, пунктуацию и форматирование прямо во время диктовки.",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 47435ffd5..357c40c66 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "翻译模式"},- "cloudMigration": {- "title": "欢迎使用 OpenWhispr 云端",- "description": "我们已将转录切换到 OpenWhispr 云端,以获得更快、更准确的结果。你之前的设置已保存——随时可以在设置中切换回去。",- "viewSettings": "查看设置"- },"aiCta": {"title": "用 AI 提升你的转录质量","description": "在你说话的同时,自动修正语法、标点和格式。",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex 1f64b427b..1827327a1 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -680,11 +680,6 @@},"retryTranslationMode": "翻譯模式"},- "cloudMigration": {- "title": "歡迎使用 OpenWhispr Cloud",- "description": "我們已將轉錄切換至 OpenWhispr Cloud,提供更快、更準確的結果。你之前的設定已儲存,隨時可在設定中切換回來。",- "viewSettings": "查看設定"- },"aiCta": {"title": "用 AI 增強你的轉錄品質","description": "說話時自動修正文法、標點和格式。",diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.tsindex a122aadf1..f6dc083ee 100644--- a/src/stores/settingsStore.ts+++ b/src/stores/settingsStore.ts@@ -472,6 +472,63 @@ function migrateUploadTranscription() {migrateUploadTranscription();+// Dictation and upload render `*TranscriptionMode` in their picker but route on+// `*UseLocalWhisper` (audioManager, fileTranscription) and `*CloudTranscriptionMode`+// (the `isOpenWhisprCloud` test), so routing can disagree with what the user sees+// (#2086). Must run after the upload one-shot copy, which mirrors the dictation+// keys desync-and-all and then latches.+//+// Note Recording is excluded: resolveMeetingTranscriptionOptions branches on+// `meetingTranscriptionMode`, the key MeetingSettings renders, so it cannot+// disagree, and no router reads `meetingUseLocalWhisper`.+//+// Never complete either rule symmetrically — it would start uploading audio from+// profiles that exist: the mode-less Settings toggle wrote the local flag alone+// until 6fb0c906, and ProviderSetupStep writes `cloudTranscriptionMode` before the+// commit that derives the mode.+const TRANSCRIPTION_ROUTING_KEYS: ReadonlyArray<{+ mode: keyof SettingsState;+ useLocal: keyof SettingsState;+ cloudMode: keyof SettingsState;+}> = [+ { mode: "transcriptionMode", useLocal: "useLocalWhisper", cloudMode: "cloudTranscriptionMode" },+ {+ mode: "uploadTranscriptionMode",+ useLocal: "uploadUseLocalWhisper",+ cloudMode: "uploadCloudTranscriptionMode",+ },+];++function reconcileTranscriptionRouting(): void {+ if (!isBrowser) return;+ const repaired: string[] = [];+ for (const keys of TRANSCRIPTION_ROUTING_KEYS) {+ const mode = localStorage.getItem(keys.mode);+ if (mode === "local" && localStorage.getItem(keys.useLocal) !== "true") {+ localStorage.setItem(keys.useLocal, "true");+ repaired.push(keys.useLocal);+ }+ // Stored value, not the upload resolver's inherited one: these modes are only+ // derivable when the scope's own cloud key is set, so unset is not a desync.+ if (+ (mode === "providers" || mode === "self-hosted") &&+ localStorage.getItem(keys.cloudMode) === "openwhispr"+ ) {+ localStorage.setItem(keys.cloudMode, "byok");+ repaired.push(keys.cloudMode);+ }+ }+ if (repaired.length === 0) return;++ logger.info(+ "Repaired transcription routing that disagreed with the selected mode",+ { keys: repaired },+ "settings"+ );+}++reconcileTranscriptionRouting();+function migrateAgentMode() {if (!isBrowser) return;if (localStorage.getItem("_agentModeMigrated") === "1") return;diff --git a/test/helpers/settingsStoreTranscriptionModeReconcile.test.js b/test/helpers/settingsStoreTranscriptionModeReconcile.test.jsnew file mode 100644index 000000000..abb4c1082--- /dev/null+++ b/test/helpers/settingsStoreTranscriptionModeReconcile.test.js@@ -0,0 +1,223 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");++// Pins reconcileTranscriptionRouting() in settingsStore.ts, where the rationale+// for each rule lives (#2086).+//+// `_providerSettingsMigrated: "1"` must be seeded: migrateProviderSettings() runs+// first and would otherwise re-derive `transcriptionMode` from the very flag+// under test.+const MIGRATED = { _providerSettingsMigrated: "1" };+// The meeting and upload one-shot copies mirror the dictation keys once and then+// latch, so seed them done except where a case is about that copy.+const COPIES_DONE = { meetingFollowsTranscription: "false", uploadTranscriptionMigrated: "true" };++test("startup repairs transcription routing that disagrees with the selected mode", async (t) => {+ const { storage } = installBrowserGlobals(t);+ const vite = await createRendererServer(t, {+ cachePrefix: "openwhispr-transcription-mode-reconcile-test-",+ });++ // Migrations run once per module evaluation, so every case re-evaluates the store.+ const writes = [];+ const setItem = storage.setItem.bind(storage);+ storage.setItem = (key, value) => {+ writes.push(key);+ setItem(key, value);+ };+ const load = async (seed) => {+ storage.clear();+ for (const [key, value] of Object.entries(seed)) storage.setItem(key, value);+ writes.length = 0;+ vite.moduleGraph.invalidateAll();+ const { useSettingsStore } = await vite.ssrLoadModule("/stores/settingsStore.ts");+ return useSettingsStore.getState();+ };++ await t.test("a Local selection whose flag says cloud routes locally again", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "local",+ useLocalWhisper: "false",+ });+ assert.equal(state.useLocalWhisper, true);+ assert.equal(state.transcriptionMode, "local");+ assert.equal(storage.getItem("useLocalWhisper"), "true");+ });++ for (const mode of ["providers", "self-hosted"]) {+ await t.test(+ `a stale "${mode}" mode over managed-cloud routing goes back to BYOK`,+ async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: mode,+ useLocalWhisper: "false",+ cloudTranscriptionMode: "openwhispr",+ });+ assert.equal(state.cloudTranscriptionMode, "byok");+ assert.equal(storage.getItem("cloudTranscriptionMode"), "byok");+ assert.equal(state.transcriptionMode, mode);+ assert.equal(state.useLocalWhisper, false, "still cloud, just the user's own");+ }+ );+ }++ await t.test("the upload scope's cloud mode is repaired too", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ uploadTranscriptionMode: "providers",+ uploadUseLocalWhisper: "false",+ uploadCloudTranscriptionMode: "openwhispr",+ });+ assert.equal(state.uploadCloudTranscriptionMode, "byok");+ assert.equal(storage.getItem("uploadCloudTranscriptionMode"), "byok");+ });++ await t.test("an OpenWhispr Cloud mode never claims a BYOK credential", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "openwhispr",+ useLocalWhisper: "false",+ cloudTranscriptionMode: "byok",+ });+ assert.equal(state.cloudTranscriptionMode, "byok");+ assert.equal(storage.getItem("cloudTranscriptionMode"), "byok");+ });++ for (const mode of ["openwhispr", "providers", "self-hosted", "enterprise", "nonsense"]) {+ await t.test(`a stale "${mode}" mode never flips a local user to the cloud`, async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: mode,+ useLocalWhisper: "true",+ });+ assert.equal(state.useLocalWhisper, true);+ assert.equal(storage.getItem("useLocalWhisper"), "true");+ });+ }++ await t.test("the upload scope's local flag is repaired too", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "local",+ useLocalWhisper: "false",+ uploadTranscriptionMode: "local",+ uploadUseLocalWhisper: "false",+ });+ assert.equal(state.uploadUseLocalWhisper, true);+ assert.equal(storage.getItem("uploadUseLocalWhisper"), "true");+ });++ await t.test("the meeting scope is left alone, because it routes on its own mode", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ meetingTranscriptionMode: "local",+ meetingUseLocalWhisper: "false",+ });+ assert.equal(state.meetingTranscriptionMode, "local", "the mode its router reads");+ assert.equal(storage.getItem("meetingUseLocalWhisper"), "false", "left untouched");+ assert.equal(+ writes.includes("meetingUseLocalWhisper"),+ false,+ "no write to a key nothing reads"+ );+ });++ await t.test("a desync copied into the upload scope by its one-shot is repaired", async () => {+ const state = await load({+ ...MIGRATED,+ meetingFollowsTranscription: "false",+ transcriptionMode: "local",+ useLocalWhisper: "false",+ });+ assert.equal(storage.getItem("uploadTranscriptionMode"), "local", "the copy ran");+ assert.equal(state.uploadUseLocalWhisper, true);+ assert.equal(storage.getItem("uploadUseLocalWhisper"), "true");+ });++ await t.test("the local rule leaves the cloud mode alone", async () => {+ await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "local",+ useLocalWhisper: "false",+ cloudTranscriptionMode: "openwhispr",+ });+ assert.equal(storage.getItem("useLocalWhisper"), "true", "repaired");+ assert.equal(storage.getItem("cloudTranscriptionMode"), "openwhispr", "untouched");+ });++ for (const mode of ["openwhispr", "enterprise", "nonsense"]) {+ await t.test(`a "${mode}" mode never triggers the cloud rule`, async () => {+ await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: mode,+ useLocalWhisper: "false",+ cloudTranscriptionMode: "openwhispr",+ });+ assert.equal(storage.getItem("cloudTranscriptionMode"), "openwhispr");+ });+ }++ await t.test("both rules can fire on one launch", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "local",+ useLocalWhisper: "false",+ uploadTranscriptionMode: "providers",+ uploadUseLocalWhisper: "false",+ uploadCloudTranscriptionMode: "openwhispr",+ });+ assert.equal(state.useLocalWhisper, true, "dictation repaired toward local");+ assert.equal(state.uploadCloudTranscriptionMode, "byok", "upload repaired toward BYOK");+ });++ // The only case that lets migrateMeetingFollowFlags run; every other seeds it done.+ await t.test("the meeting one-shot copy still runs, and is still not repaired", async () => {+ await load({+ ...MIGRATED,+ uploadTranscriptionMigrated: "true",+ transcriptionMode: "local",+ useLocalWhisper: "false",+ });+ assert.equal(storage.getItem("meetingTranscriptionMode"), "local", "the copy ran");+ assert.equal(storage.getItem("meetingUseLocalWhisper"), "false", "copied desync, left alone");+ assert.equal(storage.getItem("useLocalWhisper"), "true", "dictation still repaired");+ });++ await t.test("an agreeing profile is not rewritten", async () => {+ const state = await load({+ ...MIGRATED,+ ...COPIES_DONE,+ transcriptionMode: "local",+ useLocalWhisper: "true",+ cloudTranscriptionMode: "byok",+ });+ assert.equal(state.useLocalWhisper, true);+ assert.deepEqual(+ writes.filter((key) =>+ /UseLocalWhisper$|^useLocalWhisper$|CloudTranscriptionMode$/.test(key)+ ),+ [],+ "no routing key should be written when the profile already agrees"+ );+ });++ await t.test("a profile with no stored mode is left untouched", async () => {+ const state = await load({ ...MIGRATED, ...COPIES_DONE, useLocalWhisper: "true" });+ assert.equal(state.useLocalWhisper, true);+ assert.equal(storage.getItem("useLocalWhisper"), "true");+ assert.equal(storage.getItem("uploadUseLocalWhisper"), null);+ });+});diff --git a/test/hooks/useStartOnboarding.test.js b/test/hooks/useStartOnboarding.test.jsnew file mode 100644index 000000000..28449a9ec--- /dev/null+++ b/test/hooks/useStartOnboarding.test.js@@ -0,0 +1,60 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const React = require("react");+const { createRoot } = require("react-dom/client");+const {+ createRendererServer,+ installBrowserGlobals,+ installHookDom,+} = require("../lib/rendererTestHarness");++// Restarting onboarding used to arm `pendingCloudMigration`, which a ControlPanel+// effect consumed after sign-in to force cloud routing regardless of the setup+// the user then chose in onboarding (#2086). The hook must only reset onboarding+// progress and reload; the routing pair is onboarding's to decide.+test("restarting onboarding resets progress without arming a cloud switch", async (t) => {+ let root = null;+ t.after(async () => {+ if (root) await React.act(async () => root.unmount());+ });+ let reloads = 0;+ const { storage } = installBrowserGlobals(t, {+ initialStorage: {+ onboardingCompleted: "true",+ transcriptionMode: "local",+ useLocalWhisper: "true",+ },+ window: {+ location: {+ reload() {+ reloads += 1;+ },+ },+ },+ });+ const container = installHookDom(t);+ const vite = await createRendererServer(t, {+ cachePrefix: "openwhispr-use-start-onboarding-test-",+ });+ const { useStartOnboarding } = await vite.ssrLoadModule("/hooks/useStartOnboarding.ts");+ const { LEGACY_ONBOARDING_STEP_KEY } = await vite.ssrLoadModule("/components/onboarding/flow.ts");++ let startOnboarding;+ function Harness() {+ startOnboarding = useStartOnboarding();+ return null;+ }+ root = createRoot(container);+ await React.act(async () => {+ root.render(React.createElement(Harness));+ });++ startOnboarding();++ assert.equal(reloads, 1);+ assert.equal(storage.getItem("pendingCloudMigration"), null);+ assert.equal(storage.getItem("onboardingCompleted"), null);+ assert.equal(storage.getItem(LEGACY_ONBOARDING_STEP_KEY), "0");+ assert.equal(storage.getItem("transcriptionMode"), "local");+ assert.equal(storage.getItem("useLocalWhisper"), "true");+});