Skip to content

feat(provider): add Xiaomi Token Plan providers for CN, SGP, and AMS#1556

Merged
zhangmo8 merged 1 commit intodevfrom
xiaomi-token-plan
Apr 28, 2026
Merged

feat(provider): add Xiaomi Token Plan providers for CN, SGP, and AMS#1556
zhangmo8 merged 1 commit intodevfrom
xiaomi-token-plan

Conversation

@zhangmo8
Copy link
Copy Markdown
Collaborator

@zhangmo8 zhangmo8 commented Apr 28, 2026

Summary by CodeRabbit

  • New Features

    • Added three new Xiaomi Token Plan providers enabling support for additional regions: China, Singapore, and Amsterdam.
  • UI Improvements

    • Expanded the sidebar width in the model provider settings interface for improved visibility and content accommodation.
    • Enhanced provider name display behavior with improved text truncation to prevent overflow in both enabled and disabled provider lists.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

📝 Walkthrough

Walkthrough

This change adds support for three region-specific Xiaomi Token Plan providers (CN, SGP, AMS) by registering them in the provider configuration and registry. Additionally, the model provider settings UI sidebar width increases from w-64 to w-80, with improved text truncation for provider names to prevent overflow.

Changes

Cohort / File(s) Summary
Provider Configuration & Registry
src/main/presenter/configPresenter/providers.ts, src/main/presenter/llmProviderPresenter/providerRegistry.ts
Adds three new region-specific Xiaomi Token Plan providers (xiaomi-token-plan-cn, xiaomi-token-plan-sgp, xiaomi-token-plan-ams) to DEFAULT_PROVIDERS with OpenAI-compatible configuration, and registers them in PROVIDER_ID_REGISTRY with provider-db model source and token-plan grouping.
UI Layout Updates
src/renderer/settings/components/ModelProviderSettings.vue
Increases left sidebar width from w-64 to w-80 and adds min-w-0 truncate styling to provider name display to constrain text to a single line and prevent row overflow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #1198: Adds Xiaomi provider entries to src/main/presenter/configPresenter/providers.ts in a related configuration pattern.
  • PR #1481: Similar pattern of adding new provider entries to both DEFAULT_PROVIDERS and PROVIDER_ID_REGISTRY.
  • PR #1485: Modifies the same DEFAULT_PROVIDERS array to manage provider configurations.

Poem

🐰 Three new Xiaomi friends hop into view,
CN, SGP, and AMS too!
The sidebar stretches wide and neat,
Text truncates for a cleaner seat! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding three Xiaomi Token Plan provider configurations for different regions (CN, SGP, AMS).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch xiaomi-token-plan

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/presenter/llmProviderPresenter/providerRegistry.ts`:
- Around line 401-426: The Xiaomi token-plan entries (keys like
'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams')
created via createDefinition({...CHINESE_SUMMARY_OPENAI, modelSource:
'provider-db', ...}) include inert fields providerDbSourceId and
providerDbGroup; remove those two fields from each Xiaomi token-plan
createDefinition call so the objects only include CHINESE_SUMMARY_OPENAI and
modelSource: 'provider-db' (this aligns with mapProviderDbModels resolution by
this.provider.id and the fact providerDbSourceId is only used by the 'config-db'
strategy).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9aa7c86c-0abd-4e24-ab48-a1c98ccf62ef

📥 Commits

Reviewing files that changed from the base of the PR and between c8dfd53 and aad9767.

📒 Files selected for processing (3)
  • src/main/presenter/configPresenter/providers.ts
  • src/main/presenter/llmProviderPresenter/providerRegistry.ts
  • src/renderer/settings/components/ModelProviderSettings.vue

Comment on lines +401 to +426
[
'xiaomi-token-plan-cn',
createDefinition({
...CHINESE_SUMMARY_OPENAI,
modelSource: 'provider-db',
providerDbSourceId: 'xiaomi-token-plan-cn',
providerDbGroup: 'token-plan'
})
],
[
'xiaomi-token-plan-sgp',
createDefinition({
...CHINESE_SUMMARY_OPENAI,
modelSource: 'provider-db',
providerDbSourceId: 'xiaomi-token-plan-sgp',
providerDbGroup: 'token-plan'
})
],
[
'xiaomi-token-plan-ams',
createDefinition({
...CHINESE_SUMMARY_OPENAI,
modelSource: 'provider-db',
providerDbSourceId: 'xiaomi-token-plan-ams',
providerDbGroup: 'token-plan'
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 3 -P 'providerDbSourceId|providerDbGroup|getProvider\s*\(' src/main/presenter

Repository: ThinkInAIXYZ/deepchat

Length of output: 11036


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check full implementation of mapProviderDbModels and how providerDbGroup is used
rg -A 15 'mapProviderDbModels\(group' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts

# Also check if there's any filtering logic that uses providerDbGroup
echo "=== Checking for providerDbGroup filtering logic ==="
rg -B 2 -A 5 'providerDbGroup' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts

Repository: ThinkInAIXYZ/deepchat

Length of output: 1187


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find resolveProviderId implementation
rg -B 2 -A 10 'function resolveProviderId|const resolveProviderId|export.*resolveProviderId' src/

# Also check where modelCapabilities is imported from
rg -B 2 -A 2 'import.*modelCapabilities|from.*modelCapabilities' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts

Repository: ThinkInAIXYZ/deepchat

Length of output: 796


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find PROVIDER_ID_ALIASES definition
rg -B 2 -A 30 'PROVIDER_ID_ALIASES' src/main/presenter/configPresenter/providerId.ts

Repository: ThinkInAIXYZ/deepchat

Length of output: 562


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find where provider DB is loaded from and check its structure
rg -B 2 -A 10 'getDb\(\)|this.db|const db' src/main/presenter/configPresenter/providerDbLoader.ts | head -100

# Also search for xiaomi in the codebase to see if there are any mappings
echo "=== Checking for xiaomi references ==="
rg 'xiaomi' src/main/presenter --no-heading -i

Repository: ThinkInAIXYZ/deepchat

Length of output: 4917


Remove unused providerDbSourceId and providerDbGroup fields from Xiaomi token plan entries.

The providerDbGroup parameter passed to mapProviderDbModels() is unused—the function resolves models purely by this.provider.id. Similarly, providerDbSourceId is only consumed in the config-db strategy path, not provider-db. Since these Xiaomi entries use modelSource: 'provider-db', both fields are inert and should be removed to avoid misleading future maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/presenter/llmProviderPresenter/providerRegistry.ts` around lines 401
- 426, The Xiaomi token-plan entries (keys like 'xiaomi-token-plan-cn',
'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams') created via
createDefinition({...CHINESE_SUMMARY_OPENAI, modelSource: 'provider-db', ...})
include inert fields providerDbSourceId and providerDbGroup; remove those two
fields from each Xiaomi token-plan createDefinition call so the objects only
include CHINESE_SUMMARY_OPENAI and modelSource: 'provider-db' (this aligns with
mapProviderDbModels resolution by this.provider.id and the fact
providerDbSourceId is only used by the 'config-db' strategy).

@zhangmo8 zhangmo8 merged commit b2e9d2e into dev Apr 28, 2026
3 checks passed
@zhangmo8 zhangmo8 deleted the xiaomi-token-plan branch April 28, 2026 09:20
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