Skip to content

fix(settings): persist custom provider baseUrl on creation (#414)#417

Merged
wyuc merged 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/custom-provider-baseurl
Apr 14, 2026
Merged

fix(settings): persist custom provider baseUrl on creation (#414)#417
wyuc merged 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/custom-provider-baseurl

Conversation

@YizukiAme
Copy link
Copy Markdown
Contributor

@YizukiAme YizukiAme commented Apr 13, 2026

Summary

Fix custom OpenAI-compatible provider baseUrl not being persisted on creation, causing verify-model and generation requests to fail.

Closes #414

Root Cause

handleAddProvider in components/settings/index.tsx hardcoded baseUrl: '' while storing the user-entered URL in defaultBaseUrl. All downstream consumers (model-selector, provider-config-panel, model-edit-dialog, use-chat-sessions) only read baseUrl, so the server received an empty string and fell back to SDK defaults (e.g. api.openai.com).

Changes

Core fix

  • components/settings/utils.ts: New createCustomProviderSettings() that stores the user-entered URL in both baseUrl (for requests) and defaultBaseUrl (for placeholder/preview)
  • components/settings/index.tsx: handleAddProvider now uses createCustomProviderSettings()

Migration

  • lib/store/settings.ts: promoteLegacyCustomProviderBaseUrls() runs on rehydrate — promotes defaultBaseUrlbaseUrl for existing custom providers (!isBuiltIn && !baseUrl && defaultBaseUrl). Does not affect built-in providers.

Refactor

  • components/settings/utils.ts: New createVerifyModelRequest() to unify verify-model request body construction across 3 call sites (model-selector, provider-config-panel, model-edit-dialog)

Tests

  • tests/settings/custom-provider-baseurl.test.ts: Tests that createCustomProviderSettings stores baseUrl correctly and createVerifyModelRequest builds the correct request body
  • tests/store/settings-server-sync.test.ts: Tests that migration promotes defaultBaseUrl for custom providers and leaves built-in providers untouched

Verification

  • npm test: 98 passed (0 failed)
  • npx eslint on changed files: all clean

Assisted by Claude Opus 4.6 and GPT 5.4

@YizukiAme YizukiAme marked this pull request as draft April 13, 2026 11:04
@YizukiAme YizukiAme force-pushed the fix/custom-provider-baseurl branch from 4fb85b8 to f3d5581 Compare April 13, 2026 11:09
@YizukiAme YizukiAme marked this pull request as ready for review April 13, 2026 11:13
@YizukiAme YizukiAme force-pushed the fix/custom-provider-baseurl branch from f3d5581 to 3856364 Compare April 13, 2026 15:16
Copy link
Copy Markdown
Contributor

@wyuc wyuc left a comment

Choose a reason for hiding this comment

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

LGTM

@wyuc wyuc merged commit 3961711 into THU-MAIC:main Apr 14, 2026
2 checks passed
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.

fix: custom provider baseUrl not persisted — stored as defaultBaseUrl instead

2 participants