Repository navigation
feat(accounts): one usage switch per provider, in the provider's own header - #256
Merged
Merged
Conversation
The per-provider switch added in #42 was bolted on outside each section: a bordered "Let Orca query <name>" box above the provider's own header, wired by a hand-maintained gateUsageProvider(...) call per section. Two consequences: - the switch never read as part of the provider it belongs to; - providers added later never got one. antigravity and zcode had no switch at all (service-configuration.ts said so in a comment), and kimi had no section. AI Provider Accounts is now driven by PROVIDER_ACCOUNTS_SECTIONS: one entry per provider (id, icon, title, description, search entries, header link, body renderer). ProviderAccountsSection renders that header with the switch leading the row, so a provider cannot reach the pane without one, and the shared header is what fixes the inconsistency the user sees. The twelve section renderers lost their duplicated <section>/<h3>/subtitle markup. kimi, antigravity and zcode joined USAGE_PROVIDER_IDS and are gated in main's cycle: Kimi's home resolver is not called while off, antigravity folds into antigravityFetchAllowed, and resolveZcodePlanConfig returns before reading the encrypted plan key. Kimi got a minimal section (switch plus where its usage comes from; it has no credentials to configure). Tests: provider-accounts-sections.test.ts holds the registry against USAGE_PROVIDER_IDS in both directions, and AccountsPane.test.tsx now iterates the registry instead of a copied label list. AccountsPane.fixture.tsx renders the whole pane for a screenshot in both states.
…r the new gates Review round 1 found two blocking gaps. The registry was a module-level const, so every provider title, description, the switch's accessible name and the off notice were translated once at import — a language change with no reload left them stale, and a non-English catalog that loads after the module could strand English headings. It is now a `createLocalizedCatalog` getter, the pattern `accounts-search.ts` already uses, and the deleted gate had guarded exactly this. The module-scope label comment that went with the old per-render labels is restored in spirit. None of the three new main-process gates had a test: kimi, antigravity and zcode were gated by one `disabled.has(...)` each with nothing to fail if it were dropped. `service-refresh-orchestration.test.ts` gains one case per provider asserting the resolver, the fetcher and the presence flag, not just the state. Also: a compile-time assertion that every `ProviderRateLimits['provider']` is in `USAGE_PROVIDER_IDS`, so a future metered provider cannot ship without a switch; two comments cited the wrong test filename; and the usage-row settings-target comment still said Kimi and Antigravity have no account settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
AI Provider Accountshad one switch per provider, but the switch was not part ofany provider's own header. It was a bordered "Let Orca query " box rendered
above the section by a hand-written
gateUsageProvider(...)call, once perprovider in
AccountsPane.tsx. Two things followed:label+description blocks, none of them adjacent to the provider name they
switched — the reported "hard to tell which switch is for which agent".
antigravityandzcodeshipped with noswitch at all;
service-configuration.tseven carried the comment "zcode hasno switch-off entry in Settings, so its presence flag stays ungated", and
status-bar-provider-visibility.tsspecial-cased both ids as "not inUSAGE_PROVIDER_IDS".kimihad a status-bar meter and no section at all.That second shape is the structural complaint: the switch was per-provider
boilerplate rather than part of the render path, so it could not keep up with
new providers.
What changed
The switch is in the provider's header, and the registry is the render path.
provider-accounts-sections.tsx(new) is one entry per provider: id, icon,title, description, search entries, optional console/docs link, body renderer.
AccountsPanewalks it — the twelve per-provider call sites are gone.ProviderAccountsSection.tsx(new) renders that entry's header for everyprovider: the switch leads the row, then icon + name, then the header link on
the right. Switched off, the name carries a quiet
Offbadge and the noticereplaces the body; the header itself stays, so the provider remains findable
and re-enableable. It replaces
ProviderUsageEnableSwitch.tsx(deleted).<section>/<h3>/subtitlemarkup. Codex's scope sentence moved into its body; the DeepSeek, Fireworks,
Copilot, MiniMax, Grok, Cursor and GLM console/docs links moved to the
registry. Every
#accounts-<id>anchor the status bar and other panes link tois still produced, now by the shared header.
The three providers that had no switch now have one.
kimi,antigravityandzcodejoinedUSAGE_PROVIDER_IDS, so the statusbar hides them while off and the pane can switch them.
wsl.exeprobe and no read of~/.kimi-code),antigravityfolds intoantigravityFetchAllowed, andresolveZcodePlanConfigreturns before theencrypted plan key is read.
kimigot a minimal section — the switch plus where its usage comes from; ithas no credentials to configure.
Verification
pnpm test src/renderer/src/components/settings— 212 files, 1492 tests pass.pnpm test src/main/rate-limits— 74 files, 1103 tests pass, including threenew cases asserting that a switched-off Kimi never resolves its home, a
switched-off GLM never reads its plan key, and a switched-off Antigravity never
spawns the
agyprobe.pnpm tcclean (node, cli, web).orca-queue node local/gate-lint.mjs— PASS, 44/44.orca-queue node local/gate-unit.mjson this revision:(The first attempt at this gate inherited
ORCA_WSL_HOSTS_GATE_STATE=closedfrom an app-launched shell, which reds three unrelated
wsl-host-deployment-storecases; they pass 19/19 with that variable cleared,and the verdict above is the
--no-cachere-run.)Tests added.
provider-accounts-sections.test.tsholds the registry andUSAGE_PROVIDER_IDSto each other in both directions, and a compile-timeassertion in
usage-provider-enablement.tsnow fails if a provider ever joinsProviderRateLimits['provider']without joining the switchable set — the"provider with no switch" regression cannot be introduced silently again.
AccountsPane.test.tsxiterates the registry rather than a copied label list,and
AccountsPane.fixture.tsxrenders the whole pane for a screenshot.Review
Reviewed by Opus 5.5, high: R1 (2 blocking fixed), delta clean on R2
Round 1 found no BLOCKERs and two SHOULD-FIX:
const, so every title, description, switcharia-labeland off notice was translated once at import and never again —the regression the deleted gate had explicitly guarded. It is a
createLocalizedCataloggetter now.disabled.has(...)would have restored polling with nothing failing. Each hasits own case now.
The delta re-check confirmed both, plus the compile-time assertion and two
comment fixes, as resolved, and found nothing blocking.
Known limits
downgrade — runs
normalizeDisabledUsageProviderswithoutkimi,antigravityorzcodein the known set and drops them, so that host keepspolling a provider this pane shows as Off. The set is marked
replicatedinhost-sync-settings-disposition.ts, so this resolves when the other endupdates; there is no one-line fix on this side.
voided the reviewed revision, and both are one hunk):
service-refresh-orchestration.test.tsassertszcodePlanApiKeyConfigured === falsewithout mockinghasZcodePlanApiKey,so that one assertion would pass anyway (the resolver and fetch assertions
carry the case).
getProviderAccountsSections()returns a mutable array from a shared cache;typing it
readonlywould restore the previous guard.