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: Mode-switch validity guard
Chadpiha58d9af0d2f37
diff --git a/src/components/LocalModelPicker.tsx b/src/components/LocalModelPicker.tsxindex c24ea5f7a..e650470a9 100644--- a/src/components/LocalModelPicker.tsx+++ b/src/components/LocalModelPicker.tsx@@ -110,9 +110,8 @@ export default function LocalModelPicker({useEffect(() => {const initAndValidate = async () => {const downloaded = await loadDownloadedModels();- // Only clear a selection this picker owns (a known model that is no- // longer on disk). A foreign id — e.g. a cloud model selected while- // the user browses the local tab — must survive untouched.+ // Only clear ids this picker owns — a foreign id (e.g. a cloud model)+ // must survive untouched.if (downloaded &&selectedModel &&@@ -152,12 +151,8 @@ export default function LocalModelPicker({const handleDownload = useCallback((modelId: string) => {- // Bootstrap only: auto-select the freshly downloaded model when there- // is no current selection, or the selection is a known model that was- // deleted. Decided when the download finishes — possibly minutes after- // the click — against the ref'd current state, so a model the user- // picked while the download ran is never stolen. A foreign selection- // (e.g. a cloud model id) blocks the bootstrap too.+ // Bootstrap auto-select, decided against current state when the download+ // finishes so a model picked while it ran is never stolen.downloadModel(modelId, (downloadedId) => {const { selectedModel: current, downloadedModels: downloaded, knownModelIds: known } =selectionStateRef.current;diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsxindex f78d98c16..cce1dfd2a 100644--- a/src/components/ReasoningModelSelector.tsx+++ b/src/components/ReasoningModelSelector.tsx@@ -15,9 +15,13 @@ import LocalModelPicker, { type LocalProvider } from "./LocalModelPicker";import { ProviderTabs } from "./ui/ProviderTabs";import OpenAICompatiblePanel from "./OpenAICompatiblePanel";import { API_ENDPOINTS } from "../config/constants";-import { REASONING_PROVIDERS, toReasoningModel } from "../models/ModelRegistry";+import {+ REASONING_PROVIDERS,+ toReasoningModel,+ modelRegistry,+ isProviderValidForMode,+} from "../models/ModelRegistry";import { useTinfoilModels } from "../hooks/useTinfoilModels";-import { modelRegistry } from "../models/ModelRegistry";import { getRemoteProviderIcon } from "../utils/providerIcons";import { GetApiKeyLink } from "./ui/GetApiKeyLink";import { getCachedPlatform } from "../utils/platform";@@ -422,16 +426,10 @@ export default function ReasoningModelSelector({}}, [localProviders, localReasoningProvider]);- // The persisted selection is only ever written by an explicit user action:- // clicking a model card commits that model together with the provider tab- // it was clicked under. Switching provider tabs is pure browsing and never- // touches the persisted selection, so a previously chosen model (and its- // "Active" tag) survives tab hopping. The only implicit selection is the- // first-download bootstrap in LocalModelPicker.+ // A selection commits only on an explicit click: the model together with+ // the provider tab it was clicked under. Tab switching is pure browsing.const handleModelSelect = (modelId: string) => {if (!modelId) {- // Stale-selection clear (selected model was deleted) — leave the- // provider untouched.setReasoningModel("");return;}@@ -442,7 +440,12 @@ export default function ReasoningModelSelector({const handleModeChange = (newMode: "cloud" | "local") => {setSelectedMode(newMode);- setReasoningModeProp?.(newMode === "local" ? "local" : "providers");+ const inferenceMode: InferenceMode = newMode === "local" ? "local" : "providers";+ setReasoningModeProp?.(inferenceMode);+ if (!isProviderValidForMode(localReasoningProvider, inferenceMode)) {+ setLocalReasoningProvider("");+ setReasoningModel("");+ }if (newMode === "cloud") {window.electronAPI?.llamaServerStop?.();@@ -497,16 +500,8 @@ export default function ReasoningModelSelector({/><div>- {/*- Custom/OpenRouter fetch their model list dynamically — the model- id is committed explicitly from the panel (together with this- provider) so another provider's model id can't persist under- this one. Tab switches never clear or overwrite it. The panel- only shows a model as selected when this tab is the committed- provider: a same-id model committed under another provider must- not render as active, or it would suppress the "select a model"- hint and the click that commits the provider would never happen.- */}+ {/* A model renders as selected only under its committed provider —+ free-form custom/OpenRouter ids can collide with registry ids. */}{selectedCloudProvider === OPENROUTER_TAB ? (<OpenAICompatiblePanelkey={OPENROUTER_TAB}@@ -636,7 +631,9 @@ export default function ReasoningModelSelector({</h4><ModelCardListmodels={selectedCloudModels}- selectedModel={reasoningModel}+ selectedModel={+ localReasoningProvider === selectedCloudProvider ? reasoningModel : ""+ }onModelSelect={handleModelSelect}/>{selectedCloudProvider === "tinfoil" && (diff --git a/src/components/settings/InferenceConfigEditor.tsx b/src/components/settings/InferenceConfigEditor.tsxindex 77d5f8401..889e5d06a 100644--- a/src/components/settings/InferenceConfigEditor.tsx+++ b/src/components/settings/InferenceConfigEditor.tsx@@ -16,29 +16,11 @@ import { Toggle } from "../ui/toggle";import type { InferenceMode } from "../../types/electron";import type { InferenceScope } from "../../config/inferenceScopes";import {- modelRegistry,- isEnterpriseProvider,+ isProviderValidForMode,getCloudModel,getLocalModel,} from "../../models/ModelRegistry";-function isProviderValidForMode(provider: string, mode: InferenceMode): boolean {- switch (mode) {- case "providers":- return (- provider === "custom" ||- provider === "openrouter" ||- modelRegistry.getCloudProviders().some((p) => p.id === provider)- );- case "local":- return modelRegistry.getAllProviders().some((p) => p.id === provider);- case "enterprise":- return isEnterpriseProvider(provider);- default:- return true;- }-}-const MODE_LABEL_PREFIX: Record<InferenceScope, string> = {dictationCleanup: "settingsPage.aiModels.modes",noteFormatting: "settingsPage.aiModels.modes",diff --git a/src/models/ModelRegistry.ts b/src/models/ModelRegistry.tsindex 837c68967..6fe3163da 100644--- a/src/models/ModelRegistry.ts+++ b/src/models/ModelRegistry.ts@@ -1,6 +1,7 @@import modelDataRaw from "./modelRegistryData.json";import { isCloudCleanupMode, getSettings } from "../stores/settingsStore";import { readCachedTinfoilModels } from "./tinfoilModelCache";+import type { InferenceMode } from "../types/electron";export interface ModelDefinition {id: string;@@ -237,6 +238,23 @@ export function isEnterpriseProvider(value: unknown): value is EnterpriseProvidereturn typeof value === "string" && (ENTERPRISE_PROVIDERS as readonly string[]).includes(value);}+export function isProviderValidForMode(provider: string, mode: InferenceMode): boolean {+ switch (mode) {+ case "providers":+ return (+ provider === "custom" ||+ provider === "openrouter" ||+ modelRegistry.getCloudProviders().some((p) => p.id === provider)+ );+ case "local":+ return modelRegistry.getAllProviders().some((p) => p.id === provider);+ case "enterprise":+ return isEnterpriseProvider(provider);+ default:+ return true;+ }+}+export function toReasoningModel(m: CloudModelDefinition): ReasoningModel {return {value: m.id,