fix: auto-refresh model list when switching post-processing providers#854
fix: auto-refresh model list when switching post-processing providers#854that-lucas wants to merge 3 commits intocjpais:mainfrom
Conversation
Clear cached model options and auto-fetch available models when the user switches providers or changes the Custom provider's base URL. Prevents stale model values from silently causing 404s at runtime.
There was a problem hiding this comment.
Pull request overview
This PR improves the post-processing provider settings UX by keeping the model dropdown in sync with the active provider (and Custom provider endpoint), reducing cases where an invalid persisted model causes silent runtime failures.
Changes:
- Clear cached model options when switching post-processing providers.
- Auto-fetch available models after provider switch so the dropdown updates immediately.
- When Custom provider
base_urlchanges, clear cached models and reset the stored model value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/stores/settingsStore.ts | Clears cached model options on provider switch; clears cached models + resets stored model on base URL change. |
| src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts | Awaits provider switch and triggers a model auto-fetch for the newly selected provider. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
Outdated
Show resolved
Hide resolved
src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
Outdated
Show resolved
Hide resolved
- Fix race condition in updatePostProcessBaseUrl: persist base_url before clearing models so a failed write doesn't wipe the model - Fix indentation in handleProviderSelect callback body - Add guard before auto-fetching models: skip when provider has no API key or Custom has no base_url to avoid unnecessary errors
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/stores/settingsStore.ts:399
commands.setPostProcessProviderreturns aResult, but its status isn’t checked here. If the Tauri invoke fails and the binding returns{ status: "error" }(without throwing), this code will still callrefreshSettings()and won’t rollback topreviousId, leaving the UI in an incorrect provider state. Handle the returnedResult(throw or branch onstatus) so failures reliably trigger rollback and so callers can detect failure.
try {
await commands.setPostProcessProvider(providerId);
await refreshSettings();
} catch (error) {
console.error("Failed to set post-process provider:", error);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
Outdated
Show resolved
Hide resolved
src/components/settings/PostProcessingSettingsApi/usePostProcessProviderState.ts
Show resolved
Hide resolved
- Check changePostProcessBaseUrlSetting and changePostProcessModelSetting result status before proceeding; bail on error to avoid partial state - Clear cached model options only after both backend writes succeed - Run Prettier to fix line-length violations (dependency array, destructuring)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks this is a good change, I'll review the code when I can and pull it in |
No, thanks to you, man! Your tool is absolutely great. I use it every day, the whole day, and it makes my day so much easier. Thank you so much! |
Summary
Problem
When a user switches post-processing providers (or changes the Custom provider's base URL), the previously stored model value persists without validation. If that model doesn't exist on the new provider's API, the post-processing request silently 404s at runtime. The user receives no feedback — their transcription is pasted without post-processing, and there's no indication anything went wrong.
This is particularly likely with the Custom provider, where a user might point the base URL at different APIs over time (e.g., Groq → Cerebras), each with different model naming conventions (
openai/gpt-oss-120bvsgpt-oss-120b).Changes
usePostProcessProviderState.ts—handleProviderSelectnow awaits the provider switch and auto-fetches models for the new provider, so the dropdown is immediately populated with valid options.settingsStore.ts(setPostProcessProvider) — Clears cached model options when switching providers, preventing stale entries from a previous fetch.settingsStore.ts(updatePostProcessBaseUrl) — Clears cached models and resets the stored model to empty when the base URL changes, since the previous model is almost certainly invalid for the new endpoint.Note
This doesn't address the broader issue that post-processing failures are completely silent to the user — a toast or overlay notification on API errors would be a valuable follow-up. This PR reduces the likelihood of hitting that silent failure by keeping the model dropdown in sync with the active provider.
Origin story
This was discovered while setting up a debug workflow for transcript optimization prompts. The goal was to have two prompts in Handy: one using the Cerebras provider (structured output, clean text pasted) and a second using a Custom provider pointed at the same Cerebras API (legacy mode, JSON output with both original and improved text for comparison).
With structured-output providers (OpenAI, Cerebras, OpenRouter, etc.), Handy strips
${output}from the prompt, sends the transcript as the user message, and forces a{"transcription": "..."}response schema — so there's no way to get custom JSON output for debugging. The Custom provider uses the legacy path (single user message, no schema), which allows full control over the output format.After switching the Custom provider's base URL to Cerebras and selecting a debug prompt, post-processing silently failed. The cause: the model dropdown retained
openai/gpt-oss-120b(valid for the previous endpoint) instead ofgpt-oss-120b(what Cerebras expects), resulting in a 404 with no user-facing error.