From 41433cfab204135007542befb83e9840d24f81ae Mon Sep 17 00:00:00 2001 From: Jason Date: Sat, 30 May 2026 21:19:30 +0800 Subject: [PATCH] Add Codex restart hint after provider switch --- src/hooks/useProviderActions.ts | 5 ++++- src/i18n/locales/en.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/zh-TW.json | 1 + src/i18n/locales/zh.json | 1 + tests/hooks/useProviderActions.test.tsx | 4 ++++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hooks/useProviderActions.ts b/src/hooks/useProviderActions.ts index e345fdf8a..afc8827a0 100644 --- a/src/hooks/useProviderActions.ts +++ b/src/hooks/useProviderActions.ts @@ -247,7 +247,10 @@ export function useProviderActions( if (!proxyRequiredReason) { let messageKey = "notifications.switchSuccess"; let defaultMessage = "切换成功!"; - if (activeApp === "claude-desktop") { + if (activeApp === "codex") { + messageKey = "notifications.codexRestartRequired"; + defaultMessage = "切换成功,请重启客户端以生效"; + } else if (activeApp === "claude-desktop") { if (provider.meta?.claudeDesktopMode === "proxy") { messageKey = "notifications.claudeDesktopProxyRestartRequired"; defaultMessage = diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 8aac25c91..0e2a109fb 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -225,6 +225,7 @@ "providerSaved": "Provider configuration saved", "providerDeleted": "Provider deleted successfully", "switchSuccess": "Switch successful!", + "codexRestartRequired": "Switched successfully. Restart the client to apply changes.", "claudeDesktopRestartRequired": "Switched successfully. Restart Claude Desktop to apply changes.", "claudeDesktopProxyRestartRequired": "Switched successfully. Keep CC Switch running and restart Claude Desktop to apply changes.", "addToConfigSuccess": "Added to config", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 1d156e347..d1d1956a1 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -225,6 +225,7 @@ "providerSaved": "プロバイダー設定を保存しました", "providerDeleted": "プロバイダーを削除しました", "switchSuccess": "切り替え成功!", + "codexRestartRequired": "切り替えました。反映するにはクライアントを再起動してください", "claudeDesktopRestartRequired": "切り替えました。反映するには Claude Desktop を再起動してください", "claudeDesktopProxyRestartRequired": "切り替えました。CC Switch を起動したまま Claude Desktop を再起動してください", "addToConfigSuccess": "設定に追加しました", diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json index 178721b1d..45997bb7f 100644 --- a/src/i18n/locales/zh-TW.json +++ b/src/i18n/locales/zh-TW.json @@ -225,6 +225,7 @@ "providerSaved": "供應商設定已儲存", "providerDeleted": "供應商刪除成功", "switchSuccess": "切換成功!", + "codexRestartRequired": "切換成功,請重新啟動客戶端以套用", "claudeDesktopRestartRequired": "切換成功,重新啟動 Claude Desktop 後生效", "claudeDesktopProxyRestartRequired": "切換成功,請保持 CC Switch 執行,並重新啟動 Claude Desktop 後生效", "addToConfigSuccess": "已新增至設定", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 70096cadc..58aac2f8f 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -225,6 +225,7 @@ "providerSaved": "供应商配置已保存", "providerDeleted": "供应商删除成功", "switchSuccess": "切换成功!", + "codexRestartRequired": "切换成功,请重启客户端以生效", "claudeDesktopRestartRequired": "切换成功,重启 Claude Desktop 后生效", "claudeDesktopProxyRestartRequired": "切换成功,请保持 CC Switch 运行,并重启 Claude Desktop 后生效", "addToConfigSuccess": "已添加到配置", diff --git a/tests/hooks/useProviderActions.test.tsx b/tests/hooks/useProviderActions.test.tsx index 2387b76a2..fa1826e98 100644 --- a/tests/hooks/useProviderActions.test.tsx +++ b/tests/hooks/useProviderActions.test.tsx @@ -192,6 +192,10 @@ describe("useProviderActions", () => { expect(switchProviderMutateAsync).toHaveBeenCalledWith(provider.id); expect(settingsApiGetMock).not.toHaveBeenCalled(); expect(settingsApiApplyMock).not.toHaveBeenCalled(); + expect(toastSuccessMock).toHaveBeenCalledWith( + "切换成功,请重启客户端以生效", + { closeButton: true }, + ); }); it("warns but still switches providers that require proxy when proxy is not running", async () => {