feat(xai): add Grok account management UI with four-locale strings

Add XaiOAuthSection (device-code login, account list, default selection)
backed by the generalized useManagedAuth hook, wire it into the Auth
Center and both Claude provider forms, and expose model fetching for
signed-in accounts.

- Accounts requiring re-auth stay visible in the account selector as
  disabled items with an expired badge instead of silently vanishing.
- Auth status refetches periodically so a revoked refresh token surfaces
  without reloading the panel.
- All strings ship in zh/en/ja/zh-TW; a locale coverage test pins every
  required key in all four locales.
This commit is contained in:
Jason
2026-07-19 00:20:17 +08:00
parent 615c99c62b
commit e9317f476e
16 changed files with 936 additions and 68 deletions
+28 -1
View File
@@ -326,7 +326,8 @@
"description": "Use your other subscriptions in Claude Code — please be mindful of compliance risks.",
"beta": "Beta",
"copilotDescription": "Manage GitHub Copilot accounts",
"codexOauthDescription": "Manage ChatGPT accounts"
"codexOauthDescription": "Manage ChatGPT accounts",
"xaiOauthDescription": "Manage xAI / Grok accounts"
},
"advanced": {
"configDir": {
@@ -1014,6 +1015,7 @@
"customApiKeyHint": "💡 Custom configuration requires manually filling all necessary fields",
"omoHint": "💡 OMO config manages Agent model assignments and supports both oh-my-openagent.jsonc and oh-my-opencode.jsonc",
"officialHint": "💡 Official provider uses browser login, no API Key needed",
"providerKeyStatusLoading": "Provider identifier status is still loading. Please try again shortly.",
"getApiKey": "Get API Key",
"partnerPromotion": {
"sudocode": "With one SudoCode key, Claude Code and Claude Desktop use Claude Opus 4.8, while Codex uses GPT-5.6. Sign up, join QQ group 726213516, and contact the group owner to claim CNY ¥10 in trial credit.",
@@ -1222,6 +1224,31 @@
"fastMode": "FAST mode",
"fastModeDescription": "Send service_tier=\"priority\" for lower latency. Off by default — enabling it consumes your ChatGPT quota at a higher rate."
},
"xaiOauth": {
"authStatus": "xAI OAuth authentication",
"accountCount": "Usable accounts: {{count}}",
"reauthRequired": "Sign-in required",
"notAuthenticated": "Not authenticated",
"selectAccount": "Select account",
"selectAccountPlaceholder": "Select an xAI account",
"useDefaultAccount": "Use default account",
"accounts": "xAI accounts",
"defaultAccount": "Default",
"expired": "Credentials expired",
"setAsDefault": "Set as default",
"removeAccount": "Remove account",
"addOrReauth": "Add account or sign in again",
"login": "Sign in with xAI",
"waitingForAuth": "Waiting for xAI authorization…",
"enterCode": "If the browser did not fill it in automatically, enter:",
"retry": "Retry",
"logoutAll": "Remove all xAI accounts",
"loginRequired": "Sign in to an xAI account first"
},
"managedAuth": {
"selectedAccountNeedsReauth": "The linked account is missing or needs you to sign in again",
"selectedAccountUnavailable": "The linked account is missing or needs you to sign in again. Select another account."
},
"endpointTest": {
"title": "API Endpoint Management",
"endpoints": "endpoints",
+28 -1
View File
@@ -326,7 +326,8 @@
"description": "Claude Code で他のサブスクリプションをご利用いただけます。コンプライアンスリスクにご注意ください。",
"beta": "Beta",
"copilotDescription": "GitHub Copilot アカウントを管理します",
"codexOauthDescription": "ChatGPT アカウントを管理します"
"codexOauthDescription": "ChatGPT アカウントを管理します",
"xaiOauthDescription": "xAI / Grok アカウントを管理します"
},
"advanced": {
"configDir": {
@@ -1014,6 +1015,7 @@
"customApiKeyHint": "💡 カスタム設定では必要な項目をすべて手動で入力してください",
"omoHint": "💡 OMO 設定は Agent のモデル割り当てを管理し、oh-my-openagent.jsonc / oh-my-opencode.jsonc の両方に対応します",
"officialHint": "💡 公式プロバイダーはブラウザログインで、API Key は不要です",
"providerKeyStatusLoading": "プロバイダー識別子の状態を読み込んでいます。しばらくしてからもう一度お試しください",
"getApiKey": "API Key を取得",
"partnerPromotion": {
"sudocode": "SudoCode の1つのキーで、Claude Code と Claude Desktop では Claude Opus 4.8、Codex では GPT-5.6 を利用できます。登録後 QQ グループ 726213516 に参加し、管理者へ連絡すると CNY ¥10 のトライアルクレジットを受け取れます。",
@@ -1222,6 +1224,31 @@
"fastMode": "FAST モード",
"fastModeDescription": "低遅延のため service_tier=\"priority\" を送信します。既定ではオフ——オンにすると ChatGPT のクォータがより速く消費されます。"
},
"xaiOauth": {
"authStatus": "xAI OAuth 認証",
"accountCount": "利用可能なアカウント: {{count}} 件",
"reauthRequired": "再ログインが必要です",
"notAuthenticated": "未認証",
"selectAccount": "アカウントを選択",
"selectAccountPlaceholder": "xAI アカウントを選択",
"useDefaultAccount": "デフォルトアカウントを使用",
"accounts": "xAI アカウント",
"defaultAccount": "デフォルト",
"expired": "認証情報が失効しました",
"setAsDefault": "デフォルトに設定",
"removeAccount": "アカウントを削除",
"addOrReauth": "アカウントを追加または再ログイン",
"login": "xAI でログイン",
"waitingForAuth": "xAI の認証を待っています…",
"enterCode": "ブラウザに自動入力されていない場合は、次を入力してください:",
"retry": "再試行",
"logoutAll": "すべての xAI アカウントを削除",
"loginRequired": "先に xAI アカウントへログインしてください"
},
"managedAuth": {
"selectedAccountNeedsReauth": "リンクされたアカウントが存在しないか、再ログインが必要です",
"selectedAccountUnavailable": "リンクされたアカウントが存在しないか、再ログインが必要です。別のアカウントを選択してください"
},
"endpointTest": {
"title": "API エンドポイント管理",
"endpoints": "エンドポイント",
+28 -1
View File
@@ -326,7 +326,8 @@
"description": "在 Claude Code 中使用您的其他訂閱,請注意合規風險。",
"beta": "Beta",
"copilotDescription": "管理 GitHub Copilot 帳號",
"codexOauthDescription": "管理 ChatGPT 帳號"
"codexOauthDescription": "管理 ChatGPT 帳號",
"xaiOauthDescription": "管理 xAI / Grok 帳號"
},
"advanced": {
"configDir": {
@@ -985,6 +986,7 @@
"customApiKeyHint": "自訂設定需手動填寫所有必要欄位",
"omoHint": "OMO 設定管理 Agent 模型指派,相容 oh-my-openagent.jsonc / oh-my-opencode.jsonc",
"officialHint": "官方供應商使用瀏覽器登入,無需設定 API Key",
"providerKeyStatusLoading": "正在載入供應商識別碼狀態,請稍後再試",
"getApiKey": "取得 API Key",
"partnerPromotion": {
"sudocode": "SudoCode 讓 Claude Code 與 Claude Desktop 使用 Claude Opus 4.8Codex 使用 GPT-5.6,一個 Key 統一管理。CC Switch 使用者註冊並加入 QQ 群 726213516,聯絡群主領取人民幣 ¥10 試用額度。",
@@ -1194,6 +1196,31 @@
"fastMode": "FAST 模式",
"fastModeDescription": "發送 service_tier=\"priority\" 換取更低延遲。預設關閉——開啟後會以更高速率消耗 ChatGPT 配額。"
},
"xaiOauth": {
"authStatus": "xAI OAuth 驗證",
"accountCount": "{{count}} 個可用帳號",
"reauthRequired": "需要重新登入",
"notAuthenticated": "尚未驗證",
"selectAccount": "選擇帳號",
"selectAccountPlaceholder": "選擇 xAI 帳號",
"useDefaultAccount": "使用預設帳號",
"accounts": "xAI 帳號",
"defaultAccount": "預設",
"expired": "憑證已失效",
"setAsDefault": "設為預設",
"removeAccount": "移除帳號",
"addOrReauth": "新增帳號或重新登入",
"login": "使用 xAI 登入",
"waitingForAuth": "正在等待 xAI 授權…",
"enterCode": "若瀏覽器未自動填入,請輸入:",
"retry": "重試",
"logoutAll": "移除所有 xAI 帳號",
"loginRequired": "請先登入 xAI 帳號"
},
"managedAuth": {
"selectedAccountNeedsReauth": "已綁定的帳號不存在或需要重新登入",
"selectedAccountUnavailable": "已綁定的帳號不存在或需要重新登入,請重新選擇帳號"
},
"endpointTest": {
"title": "請求位址管理",
"endpoints": "個端點",
+28 -1
View File
@@ -326,7 +326,8 @@
"description": "在 Claude Code 中使用您的其他订阅,请注意合规风险。",
"beta": "Beta",
"copilotDescription": "管理 GitHub Copilot 账号",
"codexOauthDescription": "管理 ChatGPT 账号"
"codexOauthDescription": "管理 ChatGPT 账号",
"xaiOauthDescription": "管理 xAI / Grok 账号"
},
"advanced": {
"configDir": {
@@ -1014,6 +1015,7 @@
"customApiKeyHint": "💡 自定义配置需手动填写所有必要字段",
"omoHint": "💡 OMO 配置管理 Agent 模型分配,兼容 oh-my-openagent.jsonc / oh-my-opencode.jsonc",
"officialHint": "💡 官方供应商使用浏览器登录,无需配置 API Key",
"providerKeyStatusLoading": "正在加载供应商标识状态,请稍后再试",
"getApiKey": "获取 API Key",
"partnerPromotion": {
"sudocode": "SudoCode 让 Claude Code 与 Claude Desktop 接入 Claude Opus 4.8Codex 接入 GPT-5.6,一个 Key 统一使用。CC Switch 用户注册并加入 QQ 群 726213516,联系群主领取 ¥10 试用额度。",
@@ -1222,6 +1224,31 @@
"fastMode": "FAST 模式",
"fastModeDescription": "发送 service_tier=\"priority\" 换取更低延迟。默认关闭——开启后会按更高速率消耗 ChatGPT 配额。"
},
"xaiOauth": {
"authStatus": "xAI OAuth 认证",
"accountCount": "{{count}} 个可用账号",
"reauthRequired": "需要重新登录",
"notAuthenticated": "未认证",
"selectAccount": "选择账号",
"selectAccountPlaceholder": "选择 xAI 账号",
"useDefaultAccount": "使用默认账号",
"accounts": "xAI 账号",
"defaultAccount": "默认",
"expired": "凭据已失效",
"setAsDefault": "设为默认",
"removeAccount": "移除账号",
"addOrReauth": "添加账号或重新登录",
"login": "使用 xAI 登录",
"waitingForAuth": "等待 xAI 授权中…",
"enterCode": "若浏览器未自动填入,请输入:",
"retry": "重试",
"logoutAll": "移除所有 xAI 账号",
"loginRequired": "请先登录 xAI 账号"
},
"managedAuth": {
"selectedAccountNeedsReauth": "已绑定账号不存在或需要重新登录",
"selectedAccountUnavailable": "已绑定账号不存在或需要重新登录,请重新选择账号"
},
"endpointTest": {
"title": "请求地址管理",
"endpoints": "个端点",