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): close stale-state gaps in explicit model selection
Chadpiha82fd37aaf9e5
diff --git a/src/components/LocalModelPicker.tsx b/src/components/LocalModelPicker.tsxindex 1700a3620..c24ea5f7a 100644--- a/src/components/LocalModelPicker.tsx+++ b/src/components/LocalModelPicker.tsx@@ -55,6 +55,11 @@ export default function LocalModelPicker({const [downloadedModels, setDownloadedModels] = useState<Set<string>>(new Set());const loadDownloadedModelsRequestRef = useRef(0);+ const knownModelIds = useMemo(+ () => new Set(providers.flatMap((provider) => provider.models.map((model) => model.id))),+ [providers]+ );+const { confirmDialog, showConfirmDialog, hideConfirmDialog } = useDialogs();const styles = useMemo(() => MODEL_PICKER_COLORS[colorScheme], [colorScheme]);@@ -105,12 +110,20 @@ export default function LocalModelPicker({useEffect(() => {const initAndValidate = async () => {const downloaded = await loadDownloadedModels();- if (downloaded && selectedModel && !downloaded.has(selectedModel)) {+ // 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.+ if (+ downloaded &&+ selectedModel &&+ knownModelIds.has(selectedModel) &&+ !downloaded.has(selectedModel)+ ) {onModelSelect("");}};initAndValidate();- }, [loadDownloadedModels, selectedModel, onModelSelect]);+ }, [loadDownloadedModels, selectedModel, onModelSelect, knownModelIds]);const handleDownloadComplete = useCallback(async () => {await loadDownloadedModels();@@ -132,20 +145,29 @@ export default function LocalModelPicker({onModelsCleared: loadDownloadedModels,});+ const selectionStateRef = useRef({ selectedModel, downloadedModels, knownModelIds });+ useEffect(() => {+ selectionStateRef.current = { selectedModel, downloadedModels, knownModelIds };+ }, [selectedModel, downloadedModels, knownModelIds]);+const handleDownload = useCallback((modelId: string) => {// Bootstrap only: auto-select the freshly downloaded model when there- // is no valid current selection (first download, or the previous- // selection was deleted). Never steal the selection from a model the- // user explicitly picked.+ // 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.downloadModel(modelId, (downloadedId) => {- const hasValidSelection = Boolean(selectedModel) && downloadedModels.has(selectedModel);- if (!hasValidSelection) {+ const { selectedModel: current, downloadedModels: downloaded, knownModelIds: known } =+ selectionStateRef.current;+ const selectionGone = known.has(current) && !downloaded.has(current);+ if (!current || selectionGone) {onModelSelect(downloadedId);}});},- [downloadModel, onModelSelect, selectedModel, downloadedModels]+ [downloadModel, onModelSelect]);const handleDelete = useCallback(diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsxindex 3b5a49392..f78d98c16 100644--- a/src/components/ReasoningModelSelector.tsx+++ b/src/components/ReasoningModelSelector.tsx@@ -501,7 +501,11 @@ export default function ReasoningModelSelector({Custom/OpenRouter fetch their model list dynamically — the modelid is committed explicitly from the panel (together with thisprovider) so another provider's model id can't persist under- this one. Tab switches never clear or overwrite it.+ 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.*/}{selectedCloudProvider === OPENROUTER_TAB ? (<OpenAICompatiblePanel@@ -510,7 +514,7 @@ export default function ReasoningModelSelector({setBaseUrl={() => {}}apiKey={openrouterApiKey}setApiKey={setOpenrouterApiKey}- model={reasoningModel}+ model={localReasoningProvider === OPENROUTER_TAB ? reasoningModel : ""}setModel={(m) => {setLocalReasoningProvider(OPENROUTER_TAB);setReasoningModel(m);@@ -526,7 +530,7 @@ export default function ReasoningModelSelector({setBaseUrl={setCloudReasoningBaseUrl}apiKey={customReasoningApiKey}setApiKey={setCustomReasoningApiKey || (() => {})}- model={reasoningModel}+ model={localReasoningProvider === "custom" ? reasoningModel : ""}setModel={(m) => {setLocalReasoningProvider("custom");setReasoningModel(m);