Skip to content

fix: validate all provider selections after server sync#266

Merged
cosarah merged 12 commits intomainfrom
fix/validate-all-providers
Mar 25, 2026
Merged

fix: validate all provider selections after server sync#266
cosarah merged 12 commits intomainfrom
fix/validate-all-providers

Conversation

@wyuc
Copy link
Contributor

@wyuc wyuc commented Mar 25, 2026

Summary

  • Extract isProviderUsable, validateProvider, validateModel into lib/store/settings-validation.ts
  • Replace PR fix: clear stale modelId/providerId after server provider sync #232's LLM-only inline validation with unified validation for all 6 provider types (LLM, TTS, ASR, PDF, Image, Video)
  • Usability checks isServerConfigured || apiKey — does NOT use requiresApiKey (e.g. mineru needs server baseUrl, not API key)
  • Auto-select fallback instead of clearing to empty: TTS→browser-native-tts, ASR→browser-native, PDF→unpdf
  • Image/Video: auto-recover provider+model from empty state when server adds providers; auto-disable generation when all providers removed; prevent re-enabling until a provider becomes available
  • No auto-enable on recovery — user controls when to turn on generation
  • PDF providers now recognized with baseUrl-only config (requiresBaseUrl option in loadEnvSection)
  • Remove "setup needed" prompt from header and home page (auto-select makes it unnecessary)
  • Clean up dead setup-indicator CSS animations

Closes #263

Test plan

  • 16 unit tests for validation functions (isProviderUsable, validateProvider, validateModel)
  • 34 integration tests for stale selection across all provider types
  • 23 server provider-config tests including baseUrl-only PDF scenarios
  • 74 total tests pass, typecheck clean, lint clean
  • Manual verification: provider add/remove/restore cycles for LLM, Image, TTS

🤖 Generated with Claude Code

wyuc and others added 5 commits March 25, 2026 12:31
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace inline LLM-only validation from PR #232 with unified validation
for all provider types (LLM, TTS, ASR, PDF, Image, Video).

- Extract isProviderUsable, validateProvider, validateModel into
  lib/store/settings-validation.ts
- Usability checks server config and client API key, not requiresApiKey
- Auto-select fallback to usable providers instead of clearing to empty
- TTS/ASR/PDF fall back to local defaults (browser-native, unpdf)
- Image/Video clear to empty when no server provider available

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Server-configured providers auto-select on first load, making the
manual configuration prompt unnecessary.
@wyuc wyuc force-pushed the fix/validate-all-providers branch from 45fe0ba to 2b73dfb Compare March 25, 2026 04:52
wyuc added 4 commits March 25, 2026 13:05
Auto-close imageGenerationEnabled/videoGenerationEnabled when server
removes all providers. Prevent re-enabling until a provider becomes
available.
When server adds image/video providers after empty state, auto-select
the first available provider+model and enable generation. When server
removes all providers, disable generation and prevent re-enabling.
Fix cases where provider matches default but generation stays disabled,
and where model is empty after provider recovery. Split provider and
model spreads so model updates independently of provider changes.
loadEnvSection now accepts allowBaseUrlOnly option. PDF providers like
mineru that only need a baseUrl (no API key) are now correctly included
in the server provider response.
@wyuc wyuc force-pushed the fix/validate-all-providers branch from ccda4ee to 6985225 Compare March 25, 2026 05:40
Only auto-disable image/video generation when no provider is usable.
Never auto-enable — user controls when to turn it on. First-run
auto-enable via autoConfigApplied guard is preserved.

Also remove dead setup-needed CSS animations from globals.css.
@wyuc wyuc marked this pull request as ready for review March 25, 2026 08:33
Copy link
Collaborator

@cosarah cosarah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues

Important

settings.ts:925-939 — Fallback arrays for TTS/ASR/PDF/Image/Video only include server-configured providers, while LLM's fallback also includes providers with client-side API keys. This means if a user manually sets a client API key for a non-LLM provider (e.g. OpenAI TTS) and the server config for that provider is later removed, the fallback will skip it and force-switch to browser-native — even though the client key is still valid. Consider unifying the fallback strategy across all provider types.

Minor

  • settings.ts:1150-1171 — Auto-select spreads after validation on first load, silently overriding validated results. A comment documenting the intended precedence would help maintainability.
  • settings-validation.ts:30 / settings.ts:977validateProvider('') short-circuits to '', forcing auto-recover to duplicate the "pick first fallback" logic.
  • settings.ts:1000-1003|| imageModels[0]?.id is redundant with validateModel's own fallback.

Summary

Solid PR — clean extraction of validation helpers, unified approach for all 6 provider types, thorough test coverage. Main concern is the inconsistent fallback strategy for non-LLM providers that could drop valid client-key configurations.

wyuc added 2 commits March 25, 2026 17:13
…types

All provider types now fall back to client-key-only providers (not just
server-configured ones), matching the LLM fallback strategy. Extracted
buildFallback helper to reduce duplication. Added spread precedence
comment per review feedback.
Copy link
Collaborator

@cosarah cosarah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All previous review items addressed:

  • Fallback strategy unified via buildFallback<T>() — all 6 provider types now include both server-configured and client-key providers. Core issue resolved.
  • Auto-select override precedence documented with clear comments.
  • Redundant imageModels[0]?.id fallback commented.

Clean fix. LGTM.

@cosarah cosarah merged commit 452e731 into main Mar 25, 2026
3 checks passed
@wyuc wyuc deleted the fix/validate-all-providers branch March 25, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate all provider selections after server sync, not just LLM

2 participants