Skip to content

feat(accounts): one usage switch per provider, in the provider's own header - #256

Merged
nplez1 merged 2 commits into
nplez1/mainfrom
nplez1/Accounts-Fixes
Oct 31, 2026
Merged

nplez1 merged 2 commits into
nplez1/mainfrom
nplez1/Accounts-Fixes

Conversation

@nplez1

@nplez1 nplez1 commented Oct 31, 2026

Copy link
Copy Markdown
Owner

What this fixes

AI Provider Accounts had one switch per provider, but the switch was not part of
any provider's own header. It was a bordered "Let Orca query " box rendered
above the section by a hand-written gateUsageProvider(...) call, once per
provider in AccountsPane.tsx. Two things followed:

  • It read as separate chrome, not as that provider's control. Ten repeated
    label+description blocks, none of them adjacent to the provider name they
    switched — the reported "hard to tell which switch is for which agent".
  • New providers never got one. antigravity and zcode shipped with no
    switch at all; service-configuration.ts even carried the comment "zcode has
    no switch-off entry in Settings, so its presence flag stays ungated"
    , and
    status-bar-provider-visibility.ts special-cased both ids as "not in
    USAGE_PROVIDER_IDS". kimi had 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.
    AccountsPane walks it — the twelve per-provider call sites are gone.
  • ProviderAccountsSection.tsx (new) renders that entry's header for every
    provider: the switch leads the row, then icon + name, then the header link on
    the right. Switched off, the name carries a quiet Off badge and the notice
    replaces the body; the header itself stays, so the provider remains findable
    and re-enableable. It replaces ProviderUsageEnableSwitch.tsx (deleted).
  • The twelve section renderers lost their duplicated <section>/<h3>/subtitle
    markup. 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 to
    is still produced, now by the shared header.

The three providers that had no switch now have one.

  • kimi, antigravity and zcode joined USAGE_PROVIDER_IDS, so the status
    bar hides them while off and the pane can switch them.
  • Main gates all three: Kimi's home resolver is not called while off (so no
    wsl.exe probe and no read of ~/.kimi-code), antigravity folds into
    antigravityFetchAllowed, and resolveZcodePlanConfig returns before the
    encrypted plan key is read.
  • kimi got a minimal section — the switch plus where its usage comes from; it
    has 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 three
    new 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 agy probe.

  • pnpm tc clean (node, cli, web).

  • orca-queue node local/gate-lint.mjs — PASS, 44/44.

  • orca-queue node local/gate-unit.mjs on this revision:

    Unit gate @f65253c97b (clean): PASS — 141856 passed; 18 failed (17 allowlisted, 0 unexpected); 1 flaky re-run passed; 0 unhandled error headline(s); 568 s
    

    (The first attempt at this gate inherited ORCA_WSL_HOSTS_GATE_STATE=closed
    from an app-launched shell, which reds three unrelated
    wsl-host-deployment-store cases; they pass 19/19 with that variable cleared,
    and the verdict above is the --no-cache re-run.)

Tests added. provider-accounts-sections.test.ts holds the registry and
USAGE_PROVIDER_IDS to each other in both directions, and a compile-time
assertion in usage-provider-enablement.ts now fails if a provider ever joins
ProviderRateLimits['provider'] without joining the switchable set — the
"provider with no switch" regression cannot be introduced silently again.
AccountsPane.test.tsx iterates the registry rather than a copied label list,
and AccountsPane.fixture.tsx renders 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:

  1. The registry was a module-level const, so every title, description, switch
    aria-label and off notice was translated once at import and never again —
    the regression the deleted gate had explicitly guarded. It is a
    createLocalizedCatalog getter now.
  2. None of the three new main-process gates had a test, so one dropped
    disabled.has(...) would have restored polling with nothing failing. Each has
    its 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

  • Mixed versions. An older build — a subordinate paired host, or a
    downgrade — runs normalizeDisabledUsageProviders without kimi,
    antigravity or zcode in the known set and drops them, so that host keeps
    polling a provider this pane shows as Off. The set is marked replicated in
    host-sync-settings-disposition.ts, so this resolves when the other end
    updates; there is no one-line fix on this side.
  • Two NITs from the delta review, deliberately not fixed (each would have
    voided the reviewed revision, and both are one hunk):
    • service-refresh-orchestration.test.ts asserts
      zcodePlanApiKeyConfigured === false without mocking hasZcodePlanApiKey,
      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 readonly would restore the previous guard.

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.
@nplez1
nplez1 merged commit 99ce813 into nplez1/main Oct 31, 2026
2 checks passed
@nplez1
nplez1 deleted the nplez1/Accounts-Fixes branch October 31, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant