Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(settings): harden browse-only provider tabs and drop dead code

Gabriel Stein983bf58f3416
diff --git a/src/components/LocalModelPicker.tsx b/src/components/LocalModelPicker.tsx
index e650470a9..05f8d9f64 100644
--- a/src/components/LocalModelPicker.tsx
+++ b/src/components/LocalModelPicker.tsx
@@ -154,8 +154,11 @@ export default function LocalModelPicker({
// 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;
+ const {
+ selectedModel: current,
+ downloadedModels: downloaded,
+ knownModelIds: known,
+ } = selectionStateRef.current;
const selectionGone = known.has(current) && !downloaded.has(current);
if (!current || selectionGone) {
onModelSelect(downloadedId);
diff --git a/src/components/OnboardingFlow.tsx b/src/components/OnboardingFlow.tsx
index 08d25bed2..dff73413f 100644
--- a/src/components/OnboardingFlow.tsx
+++ b/src/components/OnboardingFlow.tsx
@@ -630,8 +630,11 @@ export default function OnboardingFlow({ onComplete }: OnboardingFlowProps) {
selectedLocalModel={
localTranscriptionProvider === "nvidia" ? parakeetModel : whisperModel
}
- onLocalModelSelect={(modelId, providerId) => {
- if (providerId === "nvidia" || (!providerId && localTranscriptionProvider === "nvidia")) {
+ onLocalModelSelect={(modelId, providerId) => {
+ if (
+ providerId === "nvidia" ||
+ (!providerId && localTranscriptionProvider === "nvidia")
+ ) {
updateTranscriptionSettings({ parakeetModel: modelId });
} else {
updateTranscriptionSettings({ whisperModel: modelId });
diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsx
index 4f3c20767..6cd9a5716 100644
--- a/src/components/ReasoningModelSelector.tsx
+++ b/src/components/ReasoningModelSelector.tsx
@@ -69,8 +69,6 @@ interface ReasoningModelSelectorProps {
setCustomReasoningApiKey?: (key: string) => void;
setReasoningMode?: (mode: InferenceMode) => void;
mode?: "cloud" | "local";
- /** Retained for callers that use scope-specific provider model memory. */
- onCloudProviderSelect?: (provider: string, fallbackModel: string) => void;
}
function GpuStatusBadge() {
@@ -335,7 +333,6 @@ export default function ReasoningModelSelector({
setCustomReasoningApiKey,
setReasoningMode: setReasoningModeProp,
mode,
- onCloudProviderSelect: _onCloudProviderSelect,
}: ReasoningModelSelectorProps) {
const { t } = useTranslation();
const openaiApiKey = useSettingsStore((s) => s.openaiApiKey);
@@ -465,12 +462,18 @@ export default function ReasoningModelSelector({
// A selection commits only on an explicit click: the model together with
// the provider tab it was clicked under. Tab switching is pure browsing.
+ // Local models resolve their provider from the registry so an async select
+ // (e.g. a download finishing while another tab is browsed) can never commit
+ // a mismatched (provider, model) pair.
const handleModelSelect = (modelId: string) => {
if (!modelId) {
setReasoningModel("");
return;
}
- const provider = effectiveMode === "local" ? selectedLocalProvider : displayedCloudProvider;
+ const provider =
+ effectiveMode === "local"
+ ? (modelRegistry.getModel(modelId)?.provider.id ?? selectedLocalProvider)
+ : displayedCloudProvider;
setLocalReasoningProvider(provider);
setReasoningModel(modelId);
};
@@ -501,12 +504,6 @@ export default function ReasoningModelSelector({
setSelectedLocalProvider(providerId);
};
- const handleLocalModelSelect = (modelId: string) => {
- const providerId = modelId ? modelRegistry.getModel(modelId)?.provider.id : undefined;
- if (providerId) setLocalReasoningProvider(providerId);
- setReasoningModel(modelId);
- };
-
const renderModeIcon = (id: string) => {
if (id === "cloud") return <Cloud className="w-4 h-4" />;
return <Lock className="w-4 h-4" />;
@@ -551,164 +548,8 @@ export default function ReasoningModelSelector({
{providerAllowed(displayedCloudProvider) && (
<div>
- {/* A model renders as selected only under its committed provider —
+ {/* A model renders as selected only under its committed provider —
free-form custom/OpenRouter ids can collide with registry ids. */}
- {displayedCloudProvider === OPENROUTER_TAB ? (
- <OpenAICompatiblePanel
- key={OPENROUTER_TAB}
- baseUrl={API_ENDPOINTS.OPENROUTER_BASE}
- setBaseUrl={() => {}}
- apiKey={openrouterApiKey}
- setApiKey={setOpenrouterApiKey}
- model={localReasoningProvider === OPENROUTER_TAB ? reasoningModel : ""}
- setModel={(m) => {
- setLocalReasoningProvider(OPENROUTER_TAB);
- setReasoningModel(m);
- }}
- lockedBaseUrl
- apiKeyRequired
- getKeyUrl={OPENROUTER_KEYS_URL}
- />
- ) : displayedCloudProvider === "custom" ? (
- <OpenAICompatiblePanel
- key="custom"
- baseUrl={cloudReasoningBaseUrl}
- setBaseUrl={setCloudReasoningBaseUrl}
- apiKey={customReasoningApiKey}
- setApiKey={setCustomReasoningApiKey || (() => {})}
- model={localReasoningProvider === "custom" ? reasoningModel : ""}
- setModel={(m) => {
- setLocalReasoningProvider("custom");
- setReasoningModel(m);
- }}
- defaultBaseUrl={API_ENDPOINTS.OPENAI_BASE}
- />
- ) : (
- <>
- {displayedCloudProvider === "openai" && (
- <div className="space-y-2">
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://platform.openai.com/api-keys" />
- </div>
- <ApiKeyInput
- apiKey={openaiApiKey}
- setApiKey={setOpenaiApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- {displayedCloudProvider === "anthropic" && (
- <div className="space-y-2">
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://console.anthropic.com/settings/keys" />
- </div>
- <ApiKeyInput
- apiKey={anthropicApiKey}
- setApiKey={setAnthropicApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- {displayedCloudProvider === "gemini" && (
- <div className="space-y-2">
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://aistudio.google.com/app/api-keys" />
- </div>
- <ApiKeyInput
- apiKey={geminiApiKey}
- setApiKey={setGeminiApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- {displayedCloudProvider === "groq" && (
- <div className="space-y-2">
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://console.groq.com/keys" />
- </div>
- <ApiKeyInput
- apiKey={groqApiKey}
- setApiKey={setGroqApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- {displayedCloudProvider === "tinfoil" && (
- <div className="space-y-2">
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://tinfoil.sh/inference?utm_source=referral&utm_campaign=openwhispr" />
- </div>
- <ApiKeyInput
- apiKey={tinfoilApiKey}
- setApiKey={setTinfoilApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- {displayedCloudProvider === "corti" && (
- <div className="space-y-2">
- <p className="text-xs text-muted-foreground">{t("reasoning.corti.euOnly")}</p>
- <div className="flex items-baseline justify-between">
- <h4 className="font-medium text-foreground">{t("common.apiKey")}</h4>
- <GetApiKeyLink url="https://www.corti.ai/?utm_source=referral&utm_campaign=openwhispr" />
- </div>
- <ApiKeyInput
- apiKey={cortiApiKey}
- setApiKey={setCortiApiKey}
- label=""
- helpText=""
- />
- </div>
- )}
-
- <div className="pt-3 space-y-2">
- <h4 className="text-sm font-medium text-foreground">
- {t("reasoning.selectModel")}
- </h4>
- <ModelCardList
- models={selectedCloudModels}
- selectedModel={
- localReasoningProvider === displayedCloudProvider ? reasoningModel : ""
- }
- onModelSelect={handleModelSelect}
- />
- {displayedCloudProvider === "tinfoil" && (
- <>
- {tinfoilModelsLoading && (
- <p className="text-xs text-muted-foreground">
- {t("reasoning.tinfoil.refreshingModels")}
- </p>
- )}
- {!tinfoilModelsLoading && tinfoilModelsError && (
- <p className="text-xs text-destructive">
- {t("reasoning.custom.unableToLoadModels")}
- </p>
- )}
- </>
- )}
- </div>
- </>
- )}
- </div>
- )}
- {/*
- {providerAllowed(displayedCloudProvider) && (
- <div>
{displayedCloudProvider === OPENROUTER_TAB ? (
<OpenAICompatiblePanel
key={OPENROUTER_TAB}
@@ -716,8 +557,11 @@ export default function ReasoningModelSelector({
setBaseUrl={() => {}}
apiKey={openrouterApiKey}
setApiKey={setOpenrouterApiKey}
- model={reasoningModel}
- setModel={setReasoningModel}
+ model={localReasoningProvider === OPENROUTER_TAB ? reasoningModel : ""}
+ setModel={(m) => {
+ setLocalReasoningProvider(OPENROUTER_TAB);
+ setReasoningModel(m);
+ }}
lockedBaseUrl
apiKeyRequired
getKeyUrl={OPENROUTER_KEYS_URL}
@@ -729,8 +573,11 @@ export default function ReasoningModelSelector({
setBaseUrl={setCloudReasoningBaseUrl}
apiKey={customReasoningApiKey}
setApiKey={setCustomReasoningApiKey || (() => {})}
- model={reasoningModel}
- setModel={setReasoningModel}
+ model={localReasoningProvider === "custom" ? reasoningModel : ""}
+ setModel={(m) => {
+ setLocalReasoningProvider("custom");
+ setReasoningModel(m);
+ }}
defaultBaseUrl={API_ENDPOINTS.OPENAI_BASE}
/>
) : (
@@ -832,8 +679,10 @@ export default function ReasoningModelSelector({
</h4>
<ModelCardList
models={selectedCloudModels}
- selectedModel={reasoningModel}
- onModelSelect={setReasoningModel}
+ selectedModel={
+ localReasoningProvider === displayedCloudProvider ? reasoningModel : ""
+ }
+ onModelSelect={handleModelSelect}
/>
{displayedCloudProvider === "tinfoil" && (
<>
@@ -854,7 +703,6 @@ export default function ReasoningModelSelector({
)}
</div>
)}
- */}
</div>
)}
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index cfe90eb2f..a8f428e35 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -74,7 +74,10 @@ import { useLocalStorage } from "../hooks/useLocalStorage";
import { validateHotkeyForSlot } from "../utils/hotkeyValidation";
import { getPlatform, getCachedPlatform } from "../utils/platform";
import { formatHotkeyLabel } from "../utils/hotkeys";
-import { getLinuxPasteInstallCommands, needsLinuxPasteToolGuidance } from "../utils/linuxPasteTools";
+import {
+ getLinuxPasteInstallCommands,
+ needsLinuxPasteToolGuidance,
+} from "../utils/linuxPasteTools";
import { ActivationModeSelector } from "./ui/ActivationModeSelector";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select";
import LinuxPttSetupInfo from "./ui/LinuxPttSetupInfo";
diff --git a/src/components/TranscriptionModelPicker.tsx b/src/components/TranscriptionModelPicker.tsx
index ca24f75dc..8536f6174 100644
--- a/src/components/TranscriptionModelPicker.tsx
+++ b/src/components/TranscriptionModelPicker.tsx
@@ -511,6 +511,9 @@ export default function TranscriptionModelPicker({
normalizedBaseUrl !== normalizeBaseUrl(API_ENDPOINTS.TRANSCRIPTION_BASE) &&
!knownProviderUrls.has(normalizedBaseUrl)
);
+ // Reconcile null means the input needs no correction — echo the browsed
+ // input, not the committed pair, or browsing to the Custom tab (always
+ // reconciled as valid) would never display it.
return (
reconcileCloudProviderSelection({
selectedProvider: browsedCloudProvider ?? selectedCloudProvider,
@@ -518,7 +521,10 @@ export default function TranscriptionModelPicker({
allowedProviders: cloudProviders,
customAllowed: !streamingOnly && providerAllowed("custom"),
hasCustomUrl,
- }) ?? { provider: selectedCloudProvider, model: selectedCloudModel }
+ }) ?? {
+ provider: browsedCloudProvider ?? selectedCloudProvider,
+ model: selectedCloudModel,
+ }
);
}, [
availableCloudProviders,
@@ -762,14 +768,11 @@ export default function TranscriptionModelPicker({
[providerAllowed]
);
- const handleLocalProviderChange = useCallback(
- (providerId: string) => {
- const tab = LOCAL_PROVIDER_TABS.find((t) => t.id === providerId);
- if (tab?.disabled) return;
- setInternalLocalProvider(providerId);
- },
- []
- );
+ const handleLocalProviderChange = useCallback((providerId: string) => {
+ const tab = LOCAL_PROVIDER_TABS.find((t) => t.id === providerId);
+ if (tab?.disabled) return;
+ setInternalLocalProvider(providerId);
+ }, []);
const handleCloudModelSelect = useCallback(
(modelId: string) => {
diff --git a/src/components/notes/NotesOnboarding.tsx b/src/components/notes/NotesOnboarding.tsx
index af689f085..9bd670546 100644
--- a/src/components/notes/NotesOnboarding.tsx
+++ b/src/components/notes/NotesOnboarding.tsx
@@ -51,13 +51,6 @@ export default function NotesOnboarding({ onComplete }: NotesOnboardingProps) {
);
const setCleanupModel = useSettingsStore((s) => s.setCleanupModel);
const setCleanupProvider = useSettingsStore((s) => s.setCleanupProvider);
- const switchCleanupProvider = useCallback(
- (provider: string, fallbackModel: string) =>
- useSettingsStore
- .getState()
- .switchReasoningProvider("dictationCleanup", provider, fallbackModel),
- []
- );
const setCleanupMode = useSettingsStore((s) => s.setCleanupMode);
const setCleanupCloudBaseUrl = useSettingsStore((s) => s.setCleanupCloudBaseUrl);
const setCleanupCustomApiKey = useSettingsStore((s) => s.setCleanupCustomApiKey);
@@ -181,7 +174,6 @@ export default function NotesOnboarding({ onComplete }: NotesOnboardingProps) {
setReasoningModel={setCleanupModel}
localReasoningProvider={cleanupConfig.provider}
setLocalReasoningProvider={setCleanupProvider}
- onCloudProviderSelect={switchCleanupProvider}
cloudReasoningBaseUrl={cleanupConfig.cloudBaseUrl ?? ""}
setCloudReasoningBaseUrl={setCleanupCloudBaseUrl}
customReasoningApiKey={cleanupConfig.customApiKey ?? ""}
diff --git a/src/components/settings/MeetingSettings.tsx b/src/components/settings/MeetingSettings.tsx
index 2dac5340e..97e83fecd 100644
--- a/src/components/settings/MeetingSettings.tsx
+++ b/src/components/settings/MeetingSettings.tsx
@@ -109,7 +109,10 @@ export function MeetingTranscriptionPanel() {
const handleLocalTranscriptionModelSelect = useCallback(
(modelId: string, providerId?: string) => {
- if (providerId === "nvidia" || (!providerId && meetingLocalTranscriptionProvider === "nvidia")) {
+ if (
+ providerId === "nvidia" ||
+ (!providerId && meetingLocalTranscriptionProvider === "nvidia")
+ ) {
setMeetingParakeetModel(modelId);
} else {
setMeetingWhisperModel(modelId);
diff --git a/src/components/settings/UploadSettings.tsx b/src/components/settings/UploadSettings.tsx
index 2f007f110..c82ac46d7 100644
--- a/src/components/settings/UploadSettings.tsx
+++ b/src/components/settings/UploadSettings.tsx
@@ -88,7 +88,10 @@ export function UploadTranscriptionPanel() {
const handleLocalTranscriptionModelSelect = useCallback(
(modelId: string, providerId?: string) => {
- if (providerId === "nvidia" || (!providerId && uploadLocalTranscriptionProvider === "nvidia")) {
+ if (
+ providerId === "nvidia" ||
+ (!providerId && uploadLocalTranscriptionProvider === "nvidia")
+ ) {
setUploadParakeetModel(modelId);
} else {
setUploadWhisperModel(modelId);