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
Merge branch 'main' into fix-model-override-in-settings
Idris Gadi6dc68d568744
diff --cc src/components/ReasoningModelSelector.tsxindex cce1dfd2a,9772ed60f..4f3c20767--- a/src/components/ReasoningModelSelector.tsx+++ b/src/components/ReasoningModelSelector.tsx@@@ -12,16 -12,14 +12,16 @@@ import { Cloud, Lock, Zap } from "lucidimport ApiKeyInput from "./ui/ApiKeyInput";import ModelCardList from "./ui/ModelCardList";import LocalModelPicker, { type LocalProvider } from "./LocalModelPicker";- import { ProviderTabs } from "./ui/ProviderTabs";+ import { ProviderTabs, type ProviderTabItem } from "./ui/ProviderTabs";import OpenAICompatiblePanel from "./OpenAICompatiblePanel";import { API_ENDPOINTS } from "../config/constants";-import logger from "../utils/logger";-import { REASONING_PROVIDERS, toReasoningModel } from "../models/ModelRegistry";+import {+ REASONING_PROVIDERS,+ toReasoningModel,+ modelRegistry,+ isProviderValidForMode,+} from "../models/ModelRegistry";import { useTinfoilModels } from "../hooks/useTinfoilModels";-import { pickDefaultTinfoilModel } from "../models/tinfoilModels";-import { modelRegistry } from "../models/ModelRegistry";import { getRemoteProviderIcon } from "../utils/providerIcons";import { GetApiKeyLink } from "./ui/GetApiKeyLink";import { getCachedPlatform } from "../utils/platform";@@@ -62,6 -67,11 +69,8 @@@ interface ReasoningModelSelectorPropssetCustomReasoningApiKey?: (key: string) => void;setReasoningMode?: (mode: InferenceMode) => void;mode?: "cloud" | "local";- /**- * Scope-aware provider switch (switchReasoningProvider) with per-provider- * model memory; receives the provider default for when nothing is remembered.- */++ /** Retained for callers that use scope-specific provider model memory. */+ onCloudProviderSelect?: (provider: string, fallbackModel: string) => void;}function GpuStatusBadge() {@@@ -326,6 -336,7 +335,7 @@@ export default function ReasoningModelSsetCustomReasoningApiKey,setReasoningMode: setReasoningModeProp,mode,- onCloudProviderSelect,++ onCloudProviderSelect: _onCloudProviderSelect,}: ReasoningModelSelectorProps) {const { t } = useTranslation();const openaiApiKey = useSettingsStore((s) => s.openaiApiKey);@@@ -426,44 -464,113 +463,49 @@@}}, [localProviders, localReasoningProvider]);- const loadDownloadedModels = useCallback(async () => {- try {- const result = await window.electronAPI?.modelGetAll?.();- if (result && Array.isArray(result)) {- const downloaded = new Set(- result- .filter((m: { isDownloaded?: boolean }) => m.isDownloaded)- .map((m: { id: string }) => m.id)- );- return downloaded;- }- } catch (error) {- logger.error("Failed to load downloaded models", { error }, "models");+ // 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) {+ setReasoningModel("");+ return;}- const provider = effectiveMode === "local" ? selectedLocalProvider : selectedCloudProvider;- return new Set<string>();- }, []);-- const defaultModelForProvider = useCallback(- (provider: string): string => {- // Custom/OpenRouter fetch their model list dynamically — clear instead of- // presetting so another provider's model id can't persist under this one.- if (provider === "custom" || provider === OPENROUTER_TAB) return "";- if (provider === "tinfoil") return pickDefaultTinfoilModel(tinfoilModels)?.id ?? "";- const providerData = REASONING_PROVIDERS[provider as keyof typeof REASONING_PROVIDERS];- return providerData?.models?.[0]?.value ?? "";- },- [tinfoilModels]- );-- const applyCloudProvider = useCallback(- (provider: string) => {- const fallbackModel = defaultModelForProvider(provider);- if (onCloudProviderSelect) {- onCloudProviderSelect(provider, fallbackModel);- return;- }- setLocalReasoningProvider(provider);- // Tinfoil's catalog may still be loading — keep the current model until it lands.- if (provider === "tinfoil" && !fallbackModel) return;- setReasoningModel(fallbackModel);- },- [defaultModelForProvider, onCloudProviderSelect, setLocalReasoningProvider, setReasoningModel]- );++ const provider = effectiveMode === "local" ? selectedLocalProvider : displayedCloudProvider;+ setLocalReasoningProvider(provider);+ setReasoningModel(modelId);+ };- const handleModeChange = async (newMode: "cloud" | "local") => {+ const handleModeChange = (newMode: "cloud" | "local") => {+ const policyMode = newMode === "local" ? "local" : "providers";+ if (!isModeAllowedByPolicy(policyState, "llm", policyMode)) return;+ if (newMode === "cloud" && cloudProviders.length === 0) return;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?.();}};- const handleCloudProviderChange = useCallback(- (provider: string) => {- if (!providerAllowed(provider)) return;- setSelectedCloudProvider(provider);- applyCloudProvider(provider);- },- [providerAllowed, applyCloudProvider]- );+ const handleCloudProviderChange = (provider: string) => {++ if (!providerAllowed(provider)) return;+ setSelectedCloudProvider(provider);+ };- const handleLocalProviderChange = async (providerId: string) => {+ const handleLocalProviderChange = (providerId: string) => {setSelectedLocalProvider(providerId);- setLocalReasoningProvider(providerId);- const downloaded = await loadDownloadedModels();- const provider = localProviders.find((p) => p.id === providerId);- const models = provider?.models ?? [];- if (models.length > 0) {- const firstDownloaded = models.find((m) => downloaded.has(m.id));- if (firstDownloaded) {- setReasoningModel(firstDownloaded.id);- } else {- setReasoningModel("");- }- }};- const MODE_TABS = [- { id: "cloud", name: t("reasoning.mode.cloud") },- { id: "local", name: t("reasoning.mode.local") },- ];+ 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" />;@@@ -491,169 -604,163 +539,322 @@@{effectiveMode === "cloud" && (<div className="space-y-2">- <ProviderTabs- providers={cloudProviders}- selectedId={selectedCloudProvider}- onSelect={handleCloudProviderChange}- colorScheme="purple"- wrap- />-- <div>+ {cloudProviderTabs.length > 0 && (+ <ProviderTabs+ providers={cloudProviderTabs}+ selectedId={displayedCloudProvider}+ onSelect={handleCloudProviderChange}+ colorScheme="purple"+ wrap+ />+ )}+++ {providerAllowed(displayedCloudProvider) && (++ <div>+ {/* A model renders as selected only under its committed provider —+ free-form custom/OpenRouter ids can collide with registry ids. */}- {selectedCloudProvider === OPENROUTER_TAB ? (++ {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}+ />- ) : selectedCloudProvider === "custom" ? (++ ) : 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}+ />+ ) : (+ <>- {selectedCloudProvider === "openai" && (++ {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>+ )}+- {selectedCloudProvider === "anthropic" && (++ {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>+ )}+- {selectedCloudProvider === "gemini" && (++ {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>+ )}+- {selectedCloudProvider === "groq" && (++ {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>+ )}+- {selectedCloudProvider === "tinfoil" && (++ {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>+ )}+- {selectedCloudProvider === "corti" && (++ {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 === selectedCloudProvider ? reasoningModel : ""++ localReasoningProvider === displayedCloudProvider ? reasoningModel : ""+ }+ onModelSelect={handleModelSelect}+ />- {selectedCloudProvider === "tinfoil" && (++ {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}+ baseUrl={API_ENDPOINTS.OPENROUTER_BASE}+ setBaseUrl={() => {}}+ apiKey={openrouterApiKey}+ setApiKey={setOpenrouterApiKey}+ model={reasoningModel}+ setModel={setReasoningModel}+ lockedBaseUrl+ apiKeyRequired+ getKeyUrl={OPENROUTER_KEYS_URL}+ />+ ) : displayedCloudProvider === "custom" ? (+ <OpenAICompatiblePanel+ key="custom"+ baseUrl={cloudReasoningBaseUrl}+ setBaseUrl={setCloudReasoningBaseUrl}+ apiKey={customReasoningApiKey}+ setApiKey={setCustomReasoningApiKey || (() => {})}+ model={reasoningModel}+ setModel={setReasoningModel}+ 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={reasoningModel}+ onModelSelect={setReasoningModel}+ />+ {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>+ )}++ */}</div>)}