Repository navigation
feat(zai): add Z.AI support - #5354
abilliontokens wants to merge 2 commits into
Conversation
Replace the broken Z.AI OAuth account flow with the documented API-key fallback in settings and preload IPC. Refresh Z.AI quota state immediately after save and clear so the bottom-left status chip appears without waiting for the poll interval. Wire Z.AI into the shared rate-limit surfaces, status bar, and localization updates while removing the unused managed-account plumbing from the fallback branch.
📝 WalkthroughWalkthroughThis PR integrates Z.AI as a new rate-limited provider across the full application stack. It adds 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 12
🧹 Nitpick comments (3)
src/preload/index.ts (1)
1631-1635: ⚡ Quick winBind the new Z.AI bridge to
PreloadApi['zaiApiKey'].These methods currently return
Promise<unknown>, so this file will not fail typecheck if the IPC response shape drifts fromsrc/preload/api-types.ts. Please lock the new bridge to the declared contract here as well.♻️ Proposed fix
- zaiApiKey: { - getStatus: (): Promise<unknown> => ipcRenderer.invoke('zaiApiKey:getStatus'), - save: (apiKey: string): Promise<unknown> => ipcRenderer.invoke('zaiApiKey:save', apiKey), - clear: (): Promise<unknown> => ipcRenderer.invoke('zaiApiKey:clear') - }, + zaiApiKey: { + getStatus: (): Promise<{ configured: boolean }> => ipcRenderer.invoke('zaiApiKey:getStatus'), + save: (apiKey: string): Promise<{ configured: boolean }> => + ipcRenderer.invoke('zaiApiKey:save', apiKey), + clear: (): Promise<{ configured: boolean }> => ipcRenderer.invoke('zaiApiKey:clear') + } satisfies PreloadApi['zaiApiKey'],src/renderer/src/web/web-preload-api.ts (1)
2249-2255: ⚡ Quick winDocument why the web Z.AI bridge always reports
configured: false.This stub is intentionally non-obvious; a short why-comment here would keep the next caller from treating it like a broken implementation instead of a browser-only limitation.
Suggested comment
function createZaiApiKeyApi(): NonNullable<Partial<PreloadApi>['zaiApiKey']> { + // Why: paired web clients cannot access the desktop-local encrypted key + // store, so Z.AI API-key management stays unavailable in the browser adapter. return { getStatus: () => Promise.resolve({ configured: false }), save: () => Promise.resolve({ configured: false }), clear: () => Promise.resolve({ configured: false }) } }As per coding guidelines,
**/*.{ts,tsx,js,jsx}: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."Source: Coding guidelines
src/renderer/src/components/settings/AccountsPane.tsx (1)
1217-1221: ⚡ Quick winAdd a short “why” comment for Z.AI keyword flattening.
This flattening is non-obvious and mirrors the Codex search behavior; a 1–2 line rationale here will prevent accidental regressions.
As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 916c4b9f-f87a-4d76-9d5a-98b8b9639aeb
📒 Files selected for processing (38)
src/main/index.tssrc/main/ipc/register-core-handlers.test.tssrc/main/ipc/register-core-handlers.tssrc/main/ipc/zai-api-key.tssrc/main/rate-limits/service.test.tssrc/main/rate-limits/service.tssrc/main/rate-limits/zai-fetcher.test.tssrc/main/rate-limits/zai-fetcher.tssrc/main/runtime/rpc/methods/accounts.tssrc/main/zai-api-key-store.test.tssrc/main/zai-api-key-store.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.test.tsxsrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/AppearancePane.tsxsrc/renderer/src/components/settings/accounts-search.tssrc/renderer/src/components/settings/appearance-status-bar-search.tssrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/StatusBarUsageEmptyCta.tsxsrc/renderer/src/components/status-bar/icons.tsxsrc/renderer/src/components/status-bar/status-bar-agent-gating.test.tssrc/renderer/src/components/status-bar/status-bar-agent-gating.tssrc/renderer/src/components/status-bar/tooltip.test.tssrc/renderer/src/components/status-bar/tooltip.tsxsrc/renderer/src/hooks/useSettingsNavigationMetadata.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/rate-limits.tssrc/renderer/src/store/slices/ui.test.tssrc/renderer/src/store/slices/ui.tssrc/renderer/src/web/web-preload-api.tssrc/shared/rate-limit-types.tssrc/shared/status-bar-defaults.tssrc/shared/types.ts
Type the preload bridge, harden Z.AI key loading against resolver and storage mode changes, and translate the remaining locale copy for the API-key flow.
|
Addressed the remaining non-threaded CodeRabbit quick wins as well: the Z.AI preload bridge is now typed against |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/renderer/src/i18n/locales/zh.json (1)
4200-4200:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUntranslated English string remains in the Chinese locale
Line 4200 is still English (
"Use your current"), which will produce mixed-language UI inzh. Translate this key to Simplified Chinese for consistency.Suggested fix
- "350b2a1aa7": "Use your current", + "350b2a1aa7": "使用您当前的",
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 64a46069-7a37-4e20-92ac-fcf534fac824
📒 Files selected for processing (13)
src/main/ipc/register-core-handlers.test.tssrc/main/rate-limits/service.test.tssrc/main/rate-limits/service.tssrc/main/zai-api-key-store.test.tssrc/main/zai-api-key-store.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/web/web-preload-api.ts
✅ Files skipped from review due to trivial changes (2)
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/ja.json
🚧 Files skipped from review as they are similar to previous changes (7)
- src/preload/index.ts
- src/main/ipc/register-core-handlers.test.ts
- src/main/zai-api-key-store.test.ts
- src/main/zai-api-key-store.ts
- src/main/rate-limits/service.test.ts
- src/main/rate-limits/service.ts
- src/renderer/src/components/settings/AccountsPane.tsx
|
Thanks for being early on Z.AI support. It now ships on main via ZCode (#24674), so we're closing this as superseded. We appreciate the contribution. |
Summary
Testing
Notes
ELI5
Adds Z.AI as an AI provider account: save an API key, see quota in the status bar, and use Anthropic-compatible Z.AI from Orca.