Skip to content

feat: add China LLM providers guided login flow#1254

Open
YuanyuanMa03 wants to merge 5 commits into
claude-code-best:mainfrom
YuanyuanMa03:feat/china-llm-providers-login
Open

feat: add China LLM providers guided login flow#1254
YuanyuanMa03 wants to merge 5 commits into
claude-code-best:mainfrom
YuanyuanMa03:feat/china-llm-providers-login

Conversation

@YuanyuanMa03

@YuanyuanMa03 YuanyuanMa03 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a guided login experience for 4 domestic (China) LLM providers in the /login command: DeepSeek, Zhipu GLM, Tongyi Qianwen, and MiMo Xiaomi
  • Each provider includes model presets with pricing (CNY), context windows, and optional Coding Plan / Token Plan integration
  • All providers are OpenAI-compatible — credentials saved as OPENAI_BASE_URL + OPENAI_API_KEY under modelType: 'openai'

New file

  • src/utils/chinaLlmProviders.ts — Provider preset configurations with types, model data, pricing, and helper functions

Modified file

  • src/components/ConsoleOAuthFlow.tsx — Added 4-step guided flow:
    1. Select provider (DeepSeek / Zhipu GLM / Tongyi Qianwen / MiMo Xiaomi)
    2. Select access mode (Pay-as-you-go vs Coding Plan, only for providers that offer one)
    3. Select model (with pricing and context window info)
    4. Enter API key (with key format hint and free tier info)

Providers

Provider Models Coding Plan
DeepSeek deepseek-v4-pro, deepseek-v4-flash No
Zhipu GLM glm-5.1, glm-4.7, glm-4.7-flash (free) Yes (Lite/Pro/Max)
Tongyi Qianwen qwen3-max, qwen3.5-plus, qwen3.5-flash Yes (Pro)
MiMo Xiaomi mimo-v2.5-pro, mimo-v2.5, mimo-v2-flash Yes (Lite/Standard/Pro/Max)

Test plan

  • Run /login and verify "China LLM Providers" option appears in the menu
  • Select each provider and verify the guided flow works end-to-end
  • Verify providers with Coding Plans show mode selection step
  • Verify API key is saved correctly to settings
  • Run bun run precheck — all checks pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for China LLM providers with a dedicated multi-step setup flow.
    • Users can pick provider, choose access mode (API vs coding plan), select models (with pricing/context labels) or enter a custom model, and provide credentials.
    • Validation, persistence of chosen settings, success handling, analytics events, and a keyboard shortcut to return to model selection.

YuanyuanMa03 and others added 4 commits May 25, 2026 04:07
Add a guided login experience for 4 domestic (China) LLM providers
in the /login command: DeepSeek, Zhipu GLM, Tongyi Qianwen, and
MiMo Xiaomi. Each provider includes model presets with pricing,
context windows, and optional Coding Plan integration.

- New file: src/utils/chinaLlmProviders.ts — provider preset configs
- Modified: src/components/ConsoleOAuthFlow.tsx — 4-step guided flow
  (select provider → select mode → select model → enter API key)

All providers are OpenAI-compatible; credentials saved as
OPENAI_BASE_URL + OPENAI_API_KEY under modelType: 'openai'.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bfe4ddb0-c9e3-4cd8-8ed4-6f58d7dfb7bd

📥 Commits

Reviewing files that changed from the base of the PR and between dc90f0d and a02e4f2.

📒 Files selected for processing (2)
  • src/components/ConsoleOAuthFlow.tsx
  • src/utils/chinaLlmProviders.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/chinaLlmProviders.ts
  • src/components/ConsoleOAuthFlow.tsx

📝 Walkthrough

Walkthrough

This PR adds China LLM provider support to the OAuth flow. It introduces a new utility module defining provider types and presets (including URLs and pricing), then integrates a four-step provider setup flow into the existing OAuth component for provider, mode, model, and API key selection.

Changes

China LLM Providers OAuth Integration

Layer / File(s) Summary
China provider types and presets
src/utils/chinaLlmProviders.ts
TypeScript types (ProviderModel, CodingPlanTier, ProviderPreset) and exported CHINA_LLM_PROVIDERS constant define provider base URLs, API key pages, optional coding-plan configs, and per-model token pricing and context windows. Helper functions findChinaProviderById and resolveChinaProviderBaseURL provide lookup and URL selection.
OAuth state and option integration
src/components/ConsoleOAuthFlow.tsx (lines 22, 69–72, 463–471, 551–553)
Imports China provider helpers, extends OAuthStatus union with four new China-specific steps, adds "China LLM Providers" as a login method option in the selection list, and wires the option click handler to log analytics and initialize the China provider selection flow.
Multi-step China provider OAuth UI
src/components/ConsoleOAuthFlow.tsx (lines 1292–1559)
Implements provider selection, access-mode selection, model selection with dynamic per-model pricing labels and tags, and API key/custom-model entry with validation; resolves provider base URL via resolveChinaProviderBaseURL, persists settings via updateSettingsForSource('userSettings', { modelType: 'openai', env }), mirrors env into process.env, logs success, and transitions to completion; includes a confirm:no keybinding to return to model selection.

Sequence Diagram(s)

sequenceDiagram
  participant ConsoleOAuthFlow
  participant resolveChinaProviderBaseURL
  participant SettingsService
  participant process_env
  participant Analytics
  ConsoleOAuthFlow->>resolveChinaProviderBaseURL: resolveChinaProviderBaseURL(providerId, mode)
  ConsoleOAuthFlow->>SettingsService: updateSettingsForSource('userSettings', { modelType: 'openai', env })
  SettingsService->>process_env: mirror env into process.env
  ConsoleOAuthFlow->>Analytics: analytics.logEvent('china_login_success', ...)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through providers bright,
China LLM flows—a setup flight!
From models to keys, step by step,
OAuth dreams in configs kept. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add China LLM providers guided login flow' accurately and clearly summarizes the main change: adding a guided login experience for China LLM providers.
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 unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/components/ConsoleOAuthFlow.tsx (2)

22-22: ⚡ Quick win

Use the src/* alias for the new provider import.

This adds another relative import inside src/, which goes against the repo import-path rule and makes future file moves harder.

Suggested change
-import { CHINA_LLM_PROVIDERS, type ProviderPreset, resolveChinaProviderBaseURL } from '../utils/chinaLlmProviders.js';
+import {
+  CHINA_LLM_PROVIDERS,
+  type ProviderPreset,
+  resolveChinaProviderBaseURL,
+} from 'src/utils/chinaLlmProviders.js';

As per coding guidelines "Import paths must use the src/* alias (e.g., import { ... } from 'src/utils/...'); tsconfig maps src/* to ./src/*."

🤖 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/components/ConsoleOAuthFlow.tsx` at line 22, Replace the relative import
in ConsoleOAuthFlow.tsx with the repo alias import: update the import that
currently pulls CHINA_LLM_PROVIDERS, ProviderPreset, and
resolveChinaProviderBaseURL via a relative path to use the src/* alias (e.g.,
import { CHINA_LLM_PROVIDERS, type ProviderPreset, resolveChinaProviderBaseURL }
from 'src/utils/chinaLlmProviders.js') so the module resolution follows the
tsconfig mapping and avoids future breakage when files move.

1425-1428: ⚡ Quick win

Don't reintroduce as any in the new src/ save path.

The China flow bypasses the settings payload type right at the persistence boundary. doOpenAISave in this same file already shows the typed pattern to reuse here.

As per coding guidelines "Do not use as any in production code; use as unknown as SpecificType for double assertions or use proper interface definitions."

🤖 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/components/ConsoleOAuthFlow.tsx` around lines 1425 - 1428, The call to
updateSettingsForSource in ConsoleOAuthFlow.tsx is bypassing types with "as
any"; replace that with the same typed pattern used by doOpenAISave: construct a
properly typed payload (or cast via as unknown as YourSettingsType) and pass
that instead of using "as any", referencing updateSettingsForSource and
doOpenAISave to mirror the typed save path and ensure the modelType/env object
conforms to the expected settings interface.
🤖 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.

Inline comments:
In `@src/components/ConsoleOAuthFlow.tsx`:
- Around line 1418-1437: The saved env is merged so an existing OPENAI_AUTH_MODE
can persist; when switching to provider API keys you must explicitly clear it:
add OPENAI_AUTH_MODE: undefined to the env object you pass into
updateSettingsForSource (the env declared before the call to
updateSettingsForSource) so persisted settings remove that key, and after a
successful save also delete process.env.OPENAI_AUTH_MODE (or set it to
undefined) in the success branch where you copy env into process.env to ensure
the in-memory env is cleared as well.
- Around line 1456-1459: The help text always uses provider.apiKeyPage and
provider.keyFormat which is wrong for coding-plan providers (e.g., Qwen, MiMo);
update the rendering in ConsoleOAuthFlow.tsx so the Text nodes that currently
reference provider.apiKeyPage and provider.keyFormat instead first check for and
use the coding-plan metadata for the selected provider (e.g., locate the
provider's plan with id 'coding-plan' or a codingPlan/metadata field on the
provider and read its apiKeyPage/keyFormat) and only fall back to
provider.apiKeyPage/provider.keyFormat if that metadata is absent; update the
three Text lines near the Box flexDirection="column" block to prefer coding-plan
metadata to ensure correct key page and format are shown.

---

Nitpick comments:
In `@src/components/ConsoleOAuthFlow.tsx`:
- Line 22: Replace the relative import in ConsoleOAuthFlow.tsx with the repo
alias import: update the import that currently pulls CHINA_LLM_PROVIDERS,
ProviderPreset, and resolveChinaProviderBaseURL via a relative path to use the
src/* alias (e.g., import { CHINA_LLM_PROVIDERS, type ProviderPreset,
resolveChinaProviderBaseURL } from 'src/utils/chinaLlmProviders.js') so the
module resolution follows the tsconfig mapping and avoids future breakage when
files move.
- Around line 1425-1428: The call to updateSettingsForSource in
ConsoleOAuthFlow.tsx is bypassing types with "as any"; replace that with the
same typed pattern used by doOpenAISave: construct a properly typed payload (or
cast via as unknown as YourSettingsType) and pass that instead of using "as
any", referencing updateSettingsForSource and doOpenAISave to mirror the typed
save path and ensure the modelType/env object conforms to the expected settings
interface.
🪄 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: 91a46235-d775-4aa1-9dc9-e8cedb4c4947

📥 Commits

Reviewing files that changed from the base of the PR and between d8892f1 and dc90f0d.

📒 Files selected for processing (2)
  • src/components/ConsoleOAuthFlow.tsx
  • src/utils/chinaLlmProviders.ts

Comment thread src/components/ConsoleOAuthFlow.tsx Outdated
Comment thread src/components/ConsoleOAuthFlow.tsx Outdated
@claude-code-best

Copy link
Copy Markdown
Owner

@YuanyuanMa03 有验证截图么

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author
iShot_2026-06-11_19 46 51 iShot_2026-06-11_19 47 26

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author
iShot_2026-06-11_19 48 59

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author
iShot_2026-06-11_19 49 55

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author

但是我不确定这种方式好不好,因为是编码了模型名称,后面如果有新的模型,需要迭代。

@claude-code-best

Copy link
Copy Markdown
Owner

问题不大, 你支持一下用户重新声明名称呗 @YuanyuanMa03

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author

OK好的

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author

已实现自定义模型名称功能,改动如下:

模型选择页

  • 在模型列表底部新增 ✏️ Custom model · enter model name manually 选项

自定义模型输入

  • 选择后进入自定义模型输入界面,标题显示 "— Custom Model"
  • 模型提示:输入为空时显示该厂商全部已知模型(ID + 名称 + 厂商),输入时实时过滤匹配的模型(大小写不敏感)
  • 官网链接:显示 "Browse models: {url}",可跳转各厂商模型列表页查看完整模型列表
  • 输入任意模型名称后进入 API Key 输入步骤

已知模型列表链接

厂商 链接
DeepSeek https://api-docs.deepseek.com/zh-cn/
Zhipu GLM https://docs.bigmodel.cn/cn/guide/start/model-overview
Tongyi Qianwen https://help.aliyun.com/zh/model-studio/getting-started/models
MiMo Xiaomi https://platform.xiaomimimo.com/models

同时修复 CodeRabbit review 的问题

  • Import 路径改为 src/* alias
  • 清除切换厂商时残留的 OPENAI_AUTH_MODE
  • 类型安全:移除 as any,使用 Parameters<typeof updateSettingsForSource>[1]
  • Coding Plan 模式下正确显示对应的 purchasePagekeyFormat

@YuanyuanMa03

Copy link
Copy Markdown
Contributor Author
iShot_2026-06-12_12 00 08

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.

2 participants