fix(providers): discover import paths#1649
Conversation
📝 WalkthroughWalkthroughThis PR adds comprehensive CC Switch provider import support to DeepChat, including SQLite-based provider scanning, credential-only import mode (preserving built-in endpoints when credentials differ), desktop configuration path discovery for both CC Switch and Cherry Studio, UI visibility filtering, 12-language localization updates, and extensive test coverage with mock SQLite infrastructure. ChangesProvider Import: CC Switch and Cherry Studio Discovery
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes The PR introduces substantial new logic across multiple layers: CC Switch SQLite reading with app-type-specific parsing, a new credentials-only import mode affecting provider application behavior, desktop configuration path discovery for two different providers with platform-specific handling, refactored provider mapping logic with base-URL detection, UI visibility filtering, and extensive test coverage. The changes are heterogeneous, spanning contracts, core service logic, UI/rendering, localization across 12 languages, and test infrastructure with mock databases. While individual sections follow consistent patterns, each layer requires separate reasoning about correctness and interaction with existing code. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/routes/providers/providerImportService.ts (1)
1204-1208:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAlign preview selectability with apply-time URL validation.
canSelectCustomProviderWithOptions()only requires a non-emptybaseUrl, buthasRequiredCredentials()now rejects custom imports unless that URL is HTTP(S). That makes some providers selectable in the dialog even thoughapply()can only returnskippedfor them. ReusehasHttpBaseUrl()here so scan results and apply behavior stay consistent.Suggested fix
private canSelectCustomProviderWithOptions( rawProvider: ProviderImportRawProvider, mapping: ProviderImportMapping ): boolean { - return mapping.targetKind === 'custom' && Boolean(rawProvider.baseUrl.trim()) + return mapping.targetKind === 'custom' && hasHttpBaseUrl(rawProvider.baseUrl) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/routes/providers/providerImportService.ts` around lines 1204 - 1208, canSelectCustomProviderWithOptions currently only checks for a non-empty baseUrl causing UI selectability to mismatch apply() which uses hasRequiredCredentials/hasHttpBaseUrl; change canSelectCustomProviderWithOptions to reuse hasHttpBaseUrl(rawProvider) (instead of Boolean(rawProvider.baseUrl.trim())) so preview selection matches the HTTP(S) URL validation used by hasRequiredCredentials and apply().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/main/routes/providers/providerImportService.ts`:
- Around line 1204-1208: canSelectCustomProviderWithOptions currently only
checks for a non-empty baseUrl causing UI selectability to mismatch apply()
which uses hasRequiredCredentials/hasHttpBaseUrl; change
canSelectCustomProviderWithOptions to reuse hasHttpBaseUrl(rawProvider) (instead
of Boolean(rawProvider.baseUrl.trim())) so preview selection matches the HTTP(S)
URL validation used by hasRequiredCredentials and apply().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: eb04dc4c-27d0-4dff-9c46-342f5ef7e2cf
📒 Files selected for processing (27)
docs/features/cc-switch-provider-import/plan.mddocs/features/cc-switch-provider-import/spec.mddocs/features/cc-switch-provider-import/tasks.mddocs/issues/cc-switch-config-path-discovery/plan.mddocs/issues/cc-switch-config-path-discovery/spec.mddocs/issues/cc-switch-config-path-discovery/tasks.mddocs/issues/cherry-studio-config-path-discovery/plan.mddocs/issues/cherry-studio-config-path-discovery/spec.mddocs/issues/cherry-studio-config-path-discovery/tasks.mdsrc/main/routes/providers/providerImportService.tssrc/renderer/settings/components/ProviderConfigImportDialog.vuesrc/renderer/src/i18n/da-DK/settings.jsonsrc/renderer/src/i18n/en-US/settings.jsonsrc/renderer/src/i18n/fa-IR/settings.jsonsrc/renderer/src/i18n/fr-FR/settings.jsonsrc/renderer/src/i18n/he-IL/settings.jsonsrc/renderer/src/i18n/ja-JP/settings.jsonsrc/renderer/src/i18n/ko-KR/settings.jsonsrc/renderer/src/i18n/pt-BR/settings.jsonsrc/renderer/src/i18n/ru-RU/settings.jsonsrc/renderer/src/i18n/zh-CN/settings.jsonsrc/renderer/src/i18n/zh-HK/settings.jsonsrc/renderer/src/i18n/zh-TW/settings.jsonsrc/shared/contracts/routes/providers.routes.tssrc/shared/providerImport.tstest/main/routes/providers/providerImportService.test.tstest/main/routes/providers/providerRouteHandler.test.ts
Summary
Tests
Summary by CodeRabbit
Release Notes
New Features
User Interface
Localization