Repository navigation
fix(zcode): keep Coding Plan credentials and quota tied to the selected account - #24674
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the delta from e22d5a5 to f5ead0e — the hosted-CI fixture repair. Both touched files are test-only; no production code changed.
- Added a
zcodePlanCredentials.getStatusstub to theAccountsPanelifetime fixture returning{ apiKeyConfigured: false, zcodeCliConfigured: false, apiKeyProtection: null }, which matchesZcodePlanCredentialsStatusinsrc/shared/zcode-plan-sites.ts:27. - Added
'zcodePlanCredentials'to the expected web preload API inventory, in the exact position production composes it (src/renderer/src/web/web-preload-api.ts:111).
The substantive adapter, renderer setup section, i18n and fixtures are unchanged since the prior reviewed head (e22d5a5a05).
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A failed key replacement can leave the new credential readable by others with disk access. Remove the failed plaintext replacement before merging. Security Architecture Review
Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c56c86c8-8803-4e1a-b4fa-1341cda1ef69
📒 Files selected for processing (75)
src/main/ipc/register-core-handlers/register-core-handlers.test.tssrc/main/ipc/register-core-handlers/register-core-handlers.tssrc/main/ipc/zcode-plan-credentials.test.tssrc/main/ipc/zcode-plan-credentials.tssrc/main/rate-limits/service-zcode-usage.test.tssrc/main/rate-limits/service/service-account-refresh.tssrc/main/rate-limits/service/service-configuration.tssrc/main/rate-limits/service/service-fetch-policy.tssrc/main/rate-limits/service/service-fetch-targets.tssrc/main/rate-limits/service/service-full-cycle-application.tssrc/main/rate-limits/service/service-full-cycle-preparation.tssrc/main/rate-limits/service/service-state.tssrc/main/rate-limits/service/service-types.tssrc/main/rate-limits/zcode-usage-credentials.tssrc/main/rate-limits/zcode-usage-fetcher.test.tssrc/main/rate-limits/zcode-usage-fetcher.tssrc/main/runtime/runtime-client-settings.tssrc/main/runtime/runtime-store-contract.tssrc/main/startup/main-process-account-services.tssrc/main/zcode/fixtures/v2-upstream/bigmodel/credentials.jsonsrc/main/zcode/fixtures/v2-upstream/bigmodel/provider_config.jsonsrc/main/zcode/fixtures/v2-upstream/fallback-host/credentials.jsonsrc/main/zcode/fixtures/v2-upstream/fallback-host/provider_config.jsonsrc/main/zcode/fixtures/v2-upstream/provenance.jsonsrc/main/zcode/fixtures/v2-upstream/zai-other/credentials.jsonsrc/main/zcode/fixtures/v2-upstream/zai-other/provider_config.jsonsrc/main/zcode/fixtures/v2-upstream/zai/credentials.jsonsrc/main/zcode/fixtures/v2-upstream/zai/provider_config.jsonsrc/main/zcode/zcode-plan-api-key-store.test.tssrc/main/zcode/zcode-plan-api-key-store.tssrc/main/zcode/zcode-v2-personal-overlay-raw-json.test.tssrc/main/zcode/zcode-v2-personal-overlay.tssrc/main/zcode/zcode-v2-plan-credentials.test.tssrc/main/zcode/zcode-v2-plan-credentials.tssrc/preload/api-types.tssrc/preload/api/agent-account-api.tssrc/preload/api/zcode-plan-credentials-bridge.tssrc/preload/index.tssrc/renderer/src/components/settings/AccountsPane.section-lifetime.test.tsxsrc/renderer/src/components/settings/AccountsPane.tsxsrc/renderer/src/components/settings/ZcodeCliSetupSection.test.tsxsrc/renderer/src/components/settings/ZcodeCliSetupSection.tsxsrc/renderer/src/components/settings/ZcodePlanAccountsSection.test.tsxsrc/renderer/src/components/settings/ZcodePlanAccountsSection.tsxsrc/renderer/src/components/settings/accounts-search.test.tssrc/renderer/src/components/settings/accounts-search.tssrc/renderer/src/components/settings/use-zcode-plan-credentials.test.tsxsrc/renderer/src/components/settings/use-zcode-plan-credentials.tssrc/renderer/src/components/settings/zcode-plan-usage-windows.tsxsrc/renderer/src/components/status-bar/status-bar-provider-visibility.test.tssrc/renderer/src/components/status-bar/status-bar-provider-visibility.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.test.tssrc/renderer/src/components/status-bar/usage-provider-settings-target.tssrc/renderer/src/components/status-bar/use-status-bar-controller.tssrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/web/preload-api/web-agent-accounts-api.tssrc/renderer/src/web/preload-api/web-preferences-store.tssrc/renderer/src/web/preload-api/web-runtime-session.tssrc/renderer/src/web/preload-api/web-zcode-plan-site.tssrc/renderer/src/web/web-preload-api-composition.test.tssrc/renderer/src/web/web-preload-api.tssrc/renderer/src/web/web-zcode-plan-settings.test.tssrc/shared/default-global-settings.tssrc/shared/global-settings-types.tssrc/shared/node-bounded-file-reader-sync.test.tssrc/shared/node-bounded-file-reader.tssrc/shared/orca-workspace-layout.tssrc/shared/rate-limit-state-factory.tssrc/shared/rate-limit-types.tssrc/shared/rpc-contract/client-settings-params.tssrc/shared/zcode-plan-sites.tstests/e2e/helpers/electron-home-isolation.tstests/e2e/helpers/electron-home-isolation.unit.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
|
Final reviewed head: Recommend merge after #24964. All hosted PR Checks now pass, including all five Node test shards, Linux Electron Accounts regression, relay integration, and both packaging jobs. Local verification adds 209 focused tests, typecheck, changed-code quality, and rendered macOS proof. No provider authentication or paid quota request was performed; the remaining platform/authentication limits are in the body. This branch includes the original #24964 author's commits, so that safety fix can merge in its original PR first. The quota/account feature remains focused on the existing provider rather than a second GLM store or status-bar entry. |
Co-authored-by: Luchong <lu740528977@gmail.com> Co-authored-by: GuanBear <guanbear@users.noreply.github.com>
7ffac65 to
3f0e8a9
Compare

ELI5
Orca recognizes the Coding Plan selected in ZCode’s current credential store and keeps displayed quota tied to that account.
What Changed
Read the selected Z.AI or BigModel v2 account without modifying any CLI files. An Orca-saved quota key keeps priority. Broken or unsupported v2 selections cannot fall back to an unrelated legacy account. Recheck credential identity after requests and after other providers finish, so account changes cannot display an old account’s result.
Sign-in controls have been split into a separate PR. Credential writing and rollback remain in the original-author #24964; this PR adds no credential publication or deletion mechanism.
Why
Legacy discovery missed migrated credentials, and cached quota could outlive its account. A bounded, read-only adapter extends the existing quota service without reproducing authentication or altering the CLI’s credential store.
Linked Issue
Includes the separately reviewable lint prerequisite #27326. Merge that first; its identical cleanup is composed here so the final head can pass required checks.
Refs #8476. This covers account discovery and quota, with authentication and model selection owned by the CLI.
Credit: Luchong / @parkavenue9639 (#24618 and #24964) and GuanBear (#23520). Verified coauthor credit is retained. The original author’s safety commits remain in #24964, which should be reviewed and merged separately.
Visual Proof
Synthetic credentials, disposable profiles, hidden Electron renderers, and a stubbed quota endpoint. No personal login or paid request.
Before on main
8452fc33153, the same v2 account is not recognized:After on the reduced read-only branch:
A saved Orca key retains priority:
Testing
108 focused tests passed, plus an added read-only contract that repeats discovery 25 times and confirms all encrypted source files and bytes stay unchanged. Coverage includes encrypted/plaintext formats, root overrides, unsupported accounts, in-flight account switches, saved-key priority, bounded regular-file reads, and test-profile isolation.
A separate four-case compatibility probe generated fixtures with the production CLI cipher: both plan sites, custom and fallback secrets, and account identities containing spaces, URI characters, and Unicode. All decoded correctly; source bytes were unchanged; zero provider requests.
pnpm tc, changed-code quality, normal commit hooks, the Electron build, and the reduced hidden Accounts regression pass on macOS arm64. The new read-only credential/account contract matrix passes on macOS, Linux, and Windows at final head9b24926d1b9b. Platform verification. Broader hosted checks are still running; previous combined-head checks are not claimed as proof of this head. All four proposed PRs also merge without conflicts; the composed result passes 360 focused tests including the lint prerequisite, typecheck, quality, and all three rebuilt hidden Electron flows.Review
Existing execution-host ownership, saved-key storage, known HTTPS quota endpoints, folder workspaces, and mixed-version wire compatibility remain intact. No new required remote field, stream opcode, authentication flow, or agent-status store.
Agent skill upstream boundary
Notes
Risk reduction: read-only discovery and quota ownership are isolated from sign-in UI and credential publication. Low merge risk once this head’s hosted checks pass. Real provider authentication, native WSL/SSH sessions, and custom provider formats have not been exercised; unsupported formats fail closed.
Checklist