Skip to content

feat(settings): improve AI provider model discovery and error handling#73

Open
Frankli9986 wants to merge 1 commit into
LingyiChen-AI:mainfrom
Frankli9986:feat/provider-model-discovery
Open

feat(settings): improve AI provider model discovery and error handling#73
Frankli9986 wants to merge 1 commit into
LingyiChen-AI:mainfrom
Frankli9986:feat/provider-model-discovery

Conversation

@Frankli9986

Copy link
Copy Markdown

Summary

Improves the AI provider model-discovery experience in Settings:

  • Adds a shared model-fetcher module with provider-specific /models callers.
  • Surfaces fetch errors to the user instead of silently returning an empty list.
  • Allows manual model-name entry as a fallback.
  • Remembers the selected model per provider.
  • Migrates legacy persisted provider configs to a versioned shape.
  • Adds unit tests for the fetcher, route handler, and settings store.

Changes

Backend

  • New src/lib/ai/model-fetcher.ts with normalizeBaseURL and fetchModels.
  • src/lib/ai/provider.ts: exports AIProvider, PROVIDER_DEFAULTS, getDefaultBaseURL, getDefaultModel.
  • src/app/api/ai/models/route.ts: delegates to fetchModels, returns { models, error }.

Frontend

  • src/stores/settings-store.ts: versioned per-provider config persistence with legacy migration.
  • src/components/settings/settings-dialog.tsx: loading/error/retry states, AbortController for request races, manual model input, aria-* attributes.

i18n

  • messages/en.json / messages/zh.json: added settings.ai.apiKeyRequired, fetchModelsFailed, manualModel, retry.

Tests

  • src/lib/ai/model-fetcher.test.ts
  • src/app/api/ai/models/route.test.ts
  • src/stores/settings-store.test.ts
  • src/lib/ai/provider.test.ts

Design doc

See the workspace design spec for full context (internal reference).

Notes

- Add shared model-fetcher with normalizeBaseURL and provider-specific callers
- Return structured errors from /api/ai/models instead of empty lists
- Surface loading/error/retry UI in the model combobox
- Allow manual model-name entry as fallback
- Add versioned per-provider config persistence with legacy migration
- Add unit tests for fetcher, route, store, and provider defaults
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

@Frankli9986 is attempting to deploy a commit to the twwch's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant