diff --git a/packages/cli/src/constants/codingPlan.ts b/packages/cli/src/constants/codingPlan.ts index 0a3084658..5393b75c0 100644 --- a/packages/cli/src/constants/codingPlan.ts +++ b/packages/cli/src/constants/codingPlan.ts @@ -113,8 +113,8 @@ export function getCodingPlanConfig(region: CodingPlanRegion) { : 'https://coding-intl.dashscope.aliyuncs.com/v1'; const regionName = region === CodingPlanRegion.CHINA - ? 'Bailian Coding Plan (China)' - : 'Bailian Coding Plan (Global/Intl)'; + ? 'Coding Plan (Bailian, China)' + : 'Coding Plan (Bailian, Global/Intl)'; return { template, diff --git a/packages/cli/src/i18n/locales/de.js b/packages/cli/src/i18n/locales/de.js index 2a00a7b9e..4ff5a3c28 100644 --- a/packages/cli/src/i18n/locales/de.js +++ b/packages/cli/src/i18n/locales/de.js @@ -1418,11 +1418,11 @@ export default { // ============================================================================ 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (Bailian, China)', - 'Bailian Coding Plan (Global/Intl)': 'Bailian Coding Plan (Global/Intl)', + 'Coding Plan (Bailian, Global/Intl)': 'Coding Plan (Bailian, Global/Intl)', "Paste your api key of Bailian Coding Plan and you're all set!": 'Fügen Sie Ihren Bailian Coding Plan API-Schlüssel ein und Sie sind bereit!', - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - 'Fügen Sie Ihren Bailian Coding Plan (Global/Intl) API-Schlüssel ein und Sie sind bereit!', + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + 'Fügen Sie Ihren Coding Plan (Bailian, Global/Intl) API-Schlüssel ein und Sie sind bereit!', Custom: 'Benutzerdefiniert', 'More instructions about configuring `modelProviders` manually.': 'Weitere Anweisungen zur manuellen Konfiguration von `modelProviders`.', @@ -1436,12 +1436,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + 'Neue Modellkonfigurationen sind für {{region}} verfügbar. Jetzt aktualisieren?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': 'Neue Modellkonfigurationen sind für Bailian Coding Plan (China) verfügbar. Jetzt aktualisieren?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'Neue Modellkonfigurationen sind für Bailian Coding Plan (Global/Intl) verfügbar. Jetzt aktualisieren?', - '{{region}} configuration updated successfully. New models are now available.': - '{{region}}-Konfiguration erfolgreich aktualisiert. Neue Modelle sind jetzt verfügbar.', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'Neue Modellkonfigurationen sind für Coding Plan (Bailian, Global/Intl) verfügbar. Jetzt aktualisieren?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + '{{region}}-Konfiguration erfolgreich aktualisiert. Modell auf "{{model}}" umgeschaltet.', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': 'Erfolgreich mit {{region}} authentifiziert. API-Schlüssel ist in settings.env gespeichert.', }; diff --git a/packages/cli/src/i18n/locales/en.js b/packages/cli/src/i18n/locales/en.js index 234ff3ab8..d4dc217c9 100644 --- a/packages/cli/src/i18n/locales/en.js +++ b/packages/cli/src/i18n/locales/en.js @@ -1419,11 +1419,11 @@ export default { // ============================================================================ 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (Bailian, China)', - 'Bailian Coding Plan (Global/Intl)': 'Bailian Coding Plan (Global/Intl)', + 'Coding Plan (Bailian, Global/Intl)': 'Coding Plan (Bailian, Global/Intl)', "Paste your api key of Bailian Coding Plan and you're all set!": "Paste your api key of Bailian Coding Plan and you're all set!", - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!", + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!", Custom: 'Custom', 'More instructions about configuring `modelProviders` manually.': 'More instructions about configuring `modelProviders` manually.', @@ -1435,12 +1435,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + 'New model configurations are available for {{region}}. Update now?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': 'New model configurations are available for Bailian Coding Plan (China). Update now?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?', - '{{region}} configuration updated successfully. New models are now available.': - '{{region}} configuration updated successfully. New models are now available.', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + '{{region}} configuration updated successfully. Model switched to "{{model}}".', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': 'Authenticated successfully with {{region}}. API key is stored in settings.env.', }; diff --git a/packages/cli/src/i18n/locales/ja.js b/packages/cli/src/i18n/locales/ja.js index e094dfb09..c00954858 100644 --- a/packages/cli/src/i18n/locales/ja.js +++ b/packages/cli/src/i18n/locales/ja.js @@ -929,11 +929,12 @@ export default { // ============================================================================ 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (Bailian, 中国)', - 'Bailian Coding Plan (Global/Intl)': 'Bailian Coding Plan (グローバル/国際)', + 'Coding Plan (Bailian, Global/Intl)': + 'Coding Plan (Bailian, グローバル/国際)', "Paste your api key of Bailian Coding Plan and you're all set!": 'Bailian Coding PlanのAPIキーを貼り付けるだけで準備完了です!', - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - 'Bailian Coding Plan (グローバル/国際) のAPIキーを貼り付けるだけで準備完了です!', + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + 'Coding Plan (Bailian, グローバル/国際) のAPIキーを貼り付けるだけで準備完了です!', Custom: 'カスタム', 'More instructions about configuring `modelProviders` manually.': '`modelProviders`を手動で設定する方法の詳細はこちら。', @@ -946,12 +947,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + '{{region}} の新しいモデル設定が利用可能です。今すぐ更新しますか?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': 'Bailian Coding Plan (中国) の新しいモデル設定が利用可能です。今すぐ更新しますか?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'Bailian Coding Plan (グローバル/国際) の新しいモデル設定が利用可能です。今すぐ更新しますか?', - '{{region}} configuration updated successfully. New models are now available.': - '{{region}} の設定が正常に更新されました。新しいモデルが利用可能になりました。', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'Coding Plan (Bailian, グローバル/国際) の新しいモデル設定が利用可能です。今すぐ更新しますか?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + '{{region}} の設定が正常に更新されました。モデルが "{{model}}" に切り替わりました。', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': '{{region}} での認証に成功しました。APIキーは settings.env に保存されています。', }; diff --git a/packages/cli/src/i18n/locales/pt.js b/packages/cli/src/i18n/locales/pt.js index 1720a891a..a6130b2fb 100644 --- a/packages/cli/src/i18n/locales/pt.js +++ b/packages/cli/src/i18n/locales/pt.js @@ -1432,11 +1432,11 @@ export default { // ============================================================================ 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (Bailian, China)', - 'Bailian Coding Plan (Global/Intl)': 'Bailian Coding Plan (Global/Intl)', + 'Coding Plan (Bailian, Global/Intl)': 'Coding Plan (Bailian, Global/Intl)', "Paste your api key of Bailian Coding Plan and you're all set!": 'Cole sua chave de API do Bailian Coding Plan e pronto!', - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - 'Cole sua chave de API do Bailian Coding Plan (Global/Intl) e pronto!', + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + 'Cole sua chave de API do Coding Plan (Bailian, Global/Intl) e pronto!', Custom: 'Personalizado', 'More instructions about configuring `modelProviders` manually.': 'Mais instruções sobre como configurar `modelProviders` manualmente.', @@ -1450,12 +1450,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + 'Novas configurações de modelo estão disponíveis para o {{region}}. Atualizar agora?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': 'Novas configurações de modelo estão disponíveis para o Bailian Coding Plan (China). Atualizar agora?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'Novas configurações de modelo estão disponíveis para o Bailian Coding Plan (Global/Intl). Atualizar agora?', - '{{region}} configuration updated successfully. New models are now available.': - 'Configuração do {{region}} atualizada com sucesso. Novos modelos agora estão disponíveis.', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'Novas configurações de modelo estão disponíveis para o Coding Plan (Bailian, Global/Intl). Atualizar agora?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + 'Configuração do {{region}} atualizada com sucesso. Modelo alterado para "{{model}}".', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': 'Autenticado com sucesso com {{region}}. A chave de API está armazenada em settings.env.', }; diff --git a/packages/cli/src/i18n/locales/ru.js b/packages/cli/src/i18n/locales/ru.js index 49a5c7226..7534c54ed 100644 --- a/packages/cli/src/i18n/locales/ru.js +++ b/packages/cli/src/i18n/locales/ru.js @@ -1422,12 +1422,12 @@ export default { // ============================================================================ 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (Bailian, Китай)', - 'Bailian Coding Plan (Global/Intl)': - 'Bailian Coding Plan (Глобальный/Международный)', + 'Coding Plan (Bailian, Global/Intl)': + 'Coding Plan (Bailian, Глобальный/Международный)', "Paste your api key of Bailian Coding Plan and you're all set!": 'Вставьте ваш API-ключ Bailian Coding Plan и всё готово!', - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - 'Вставьте ваш API-ключ Bailian Coding Plan (Глобальный/Международный) и всё готово!', + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + 'Вставьте ваш API-ключ Coding Plan (Bailian, Глобальный/Международный) и всё готово!', Custom: 'Пользовательский', 'More instructions about configuring `modelProviders` manually.': 'Дополнительные инструкции по ручной настройке `modelProviders`.', @@ -1440,12 +1440,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + 'Доступны новые конфигурации моделей для {{region}}. Обновить сейчас?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': 'Доступны новые конфигурации моделей для Bailian Coding Plan (Китай). Обновить сейчас?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'Доступны новые конфигурации моделей для Bailian Coding Plan (Глобальный/Международный). Обновить сейчас?', - '{{region}} configuration updated successfully. New models are now available.': - 'Конфигурация {{region}} успешно обновлена. Новые модели теперь доступны.', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'Доступны новые конфигурации моделей для Coding Plan (Bailian, Глобальный/Международный). Обновить сейчас?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + 'Конфигурация {{region}} успешно обновлена. Модель переключена на "{{model}}".', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': 'Успешная аутентификация с {{region}}. API-ключ сохранён в settings.env.', }; diff --git a/packages/cli/src/i18n/locales/zh.js b/packages/cli/src/i18n/locales/zh.js index a1d6651ef..1d6e6df68 100644 --- a/packages/cli/src/i18n/locales/zh.js +++ b/packages/cli/src/i18n/locales/zh.js @@ -1254,11 +1254,11 @@ export default { 'API-KEY': 'API-KEY', 'Coding Plan': 'Coding Plan', 'Coding Plan (Bailian, China)': 'Coding Plan (百炼, 中国)', - 'Bailian Coding Plan (Global/Intl)': 'Bailian Coding Plan (百炼, 全球/国际)', + 'Coding Plan (Bailian, Global/Intl)': 'Coding Plan (百炼, 全球/国际)', "Paste your api key of Bailian Coding Plan and you're all set!": '粘贴您的百炼 Coding Plan API Key,即可完成设置!', - "Paste your api key of Bailian Coding Plan (Global/Intl) and you're all set!": - '粘贴您的 Bailian Coding Plan (全球/国际) API Key,即可完成设置!', + "Paste your api key of Coding Plan (Bailian, Global/Intl) and you're all set!": + '粘贴您的 Coding Plan (百炼, 全球/国际) API Key,即可完成设置!', Custom: '自定义', 'More instructions about configuring `modelProviders` manually.': '关于手动配置 `modelProviders` 的更多说明。', @@ -1269,12 +1269,14 @@ export default { // ============================================================================ // Coding Plan International Updates // ============================================================================ + 'New model configurations are available for {{region}}. Update now?': + '{{region}} 有新的模型配置可用。是否立即更新?', 'New model configurations are available for Bailian Coding Plan (China). Update now?': '百炼 Coding Plan (中国) 有新的模型配置可用。是否立即更新?', - 'New model configurations are available for Bailian Coding Plan (Global/Intl). Update now?': - 'Bailian Coding Plan (全球/国际) 有新的模型配置可用。是否立即更新?', - '{{region}} configuration updated successfully. New models are now available.': - '{{region}} 配置更新成功。新模型现已可用。', + 'New model configurations are available for Coding Plan (Bailian, Global/Intl). Update now?': + 'Coding Plan (百炼, 全球/国际) 有新的模型配置可用。是否立即更新?', + '{{region}} configuration updated successfully. Model switched to "{{model}}".': + '{{region}} 配置更新成功。模型已切换至 "{{model}}"。', 'Authenticated successfully with {{region}}. API key is stored in settings.env.': '成功通过 {{region}} 认证。API Key 已存储在 settings.env 中。', }; diff --git a/packages/cli/src/ui/auth/AuthDialog.tsx b/packages/cli/src/ui/auth/AuthDialog.tsx index 8c9a0aba7..7f43fa582 100644 --- a/packages/cli/src/ui/auth/AuthDialog.tsx +++ b/packages/cli/src/ui/auth/AuthDialog.tsx @@ -80,7 +80,7 @@ export function AuthDialog(): React.JSX.Element { }, { key: 'coding-plan-intl', - label: t('Bailian Coding Plan (Global/Intl)'), + label: t('Coding Plan (Bailian, Global/Intl)'), value: 'coding-plan-intl' as ApiKeySubMode, }, { diff --git a/packages/cli/src/ui/hooks/useCodingPlanUpdates.test.ts b/packages/cli/src/ui/hooks/useCodingPlanUpdates.test.ts index b2fe21e98..1e6a40722 100644 --- a/packages/cli/src/ui/hooks/useCodingPlanUpdates.test.ts +++ b/packages/cli/src/ui/hooks/useCodingPlanUpdates.test.ts @@ -33,6 +33,7 @@ describe('useCodingPlanUpdates', () => { const mockConfig = { reloadModelProvidersConfig: vi.fn(), refreshAuth: vi.fn(), + getModel: vi.fn().mockReturnValue('qwen-max'), }; const mockAddItem = vi.fn(); diff --git a/packages/cli/src/ui/hooks/useCodingPlanUpdates.ts b/packages/cli/src/ui/hooks/useCodingPlanUpdates.ts index 1646b5aef..dee70e035 100644 --- a/packages/cli/src/ui/hooks/useCodingPlanUpdates.ts +++ b/packages/cli/src/ui/hooks/useCodingPlanUpdates.ts @@ -82,7 +82,22 @@ export function useCodingPlanUpdates( ...(nonCodingPlanConfigs as Array>), ] as Array>; - // Persist updated model providers + // Hot-reload model providers configuration first (in-memory only) + const updatedModelProviders = { + ...(settings.merged.modelProviders as + | Record + | undefined), + [AuthType.USE_OPENAI]: updatedConfigs, + }; + config.reloadModelProvidersConfig( + updatedModelProviders as unknown as ModelProvidersConfig, + ); + + // Refresh auth with the new configuration + // This validates the configuration before persisting + await config.refreshAuth(AuthType.USE_OPENAI); + + // Persist to settings only after successful auth refresh settings.setValue( persistScope, `modelProviders.${AuthType.USE_OPENAI}`, @@ -95,26 +110,14 @@ export function useCodingPlanUpdates( // Update the region settings.setValue(persistScope, 'codingPlan.region', region); - // Hot-reload model providers configuration - const updatedModelProviders = { - ...(settings.merged.modelProviders as - | Record - | undefined), - [AuthType.USE_OPENAI]: updatedConfigs, - }; - config.reloadModelProvidersConfig( - updatedModelProviders as unknown as ModelProvidersConfig, - ); - - // Refresh auth with the new configuration - await config.refreshAuth(AuthType.USE_OPENAI); + const activeModel = config.getModel(); addItem( { type: 'info', text: t( - '{{region}} configuration updated successfully. New models are now available.', - { region: regionName }, + '{{region}} configuration updated successfully. Model switched to "{{model}}".', + { region: regionName, model: activeModel }, ), }, Date.now(),