Skip to content

fix(web): hub account badges use the account name the picker uses - #2

Open
daTuzzo wants to merge 1 commit into
mainfrom
fix/hub-account-badges
Open

daTuzzo wants to merge 1 commit into
mainfrom
fix/hub-account-badges

Conversation

@daTuzzo

@daTuzzo daTuzzo commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Problem

A CLIProxyAPI hub account shows different letters in two places. The model picker badges a provider instance with providerInstanceInitials(displayName), so an instance named work reads WO. Usage → Limits draws the same account with accountInitials(email), the first letter before and after the @, so alice@example.com reads AE. With several hub accounts, the bars cannot be matched to the instances in the picker.

A hub account has no name that could fix this. T3 reads only the file id and the e-mail from the hub's auth-files list, and UsageLimitSourceConfig has no field that names hub accounts.

Change

  • packages/contracts: UsageLimitSourceConfig gets an optional accountNames map, from e-mail to name. UsageLimitSourceAccount gets an optional displayName.
  • apps/server: UsageLimitSources names each hub account from that map. The e-mail match ignores letter case. A lent last good reading takes the current name, so a renamed account does not show its old name.
  • packages/shared: a hub account's displayName becomes the LimitAccount name. When it merges with a native login under the driver's default name, the hub name wins. Failure notices and the composer usage label use the name too.
  • apps/web: the account chip takes its letters from the name with providerInstanceInitials, the function the picker uses. A named hub account keeps its chip in the bars, so the e-mail stays hidden there. The segment popover shows the name and the e-mail. The chip grows into a pill like the picker's badge (min-w-4 px-0.5 instead of size-4), because wide pairs such as WO spilled out of the 16 px circle.
  • apps/mobile: the same letters for a named hub account's chip.
  • The add-hub dialog keeps a saved hub's accountNames when the same hub is added again.

An account with no name keeps today's e-mail letters. Nothing in the app writes accountNames yet: it is set in settings.json, for example by a script that knows which instance uses which login.

{
  "usageLimitSources": {
    "cliproxy-hub": {
      "kind": "cliproxy",
      "url": "http://127.0.0.1:8317",
      "managementKey": "…",
      "accountNames": { "alice@example.com": "work", "bob@example.com": "personal" }
    }
  }
}

This touches the same components as pingdotgg#40029. If that lands first, its AccountAvatar already badges any named account with ProviderInstanceIcon, and this change reduces to the name it supplies plus the chip rule.

Scope

A bug fix: one account shows two different badges. The name map is the smallest change that gives a hub account a name. Matching hub accounts to provider instances on their own would need the hub and the instance to share an address, and a usage adapter in front of the hub breaks that.

Verification

  • Added tests:
    • apps/server/src/usage/UsageLimitSources.test.ts: a named account gets its name, the e-mail match ignores case, and an unnamed account gets none.
    • packages/shared/src/usageLimits.test.ts: names on accounts, the merge with a default-named native login, composer labels and failure notices.
    • apps/web/src/components/usage/UsageLimitsPooled.browser.test.tsx: chips read WO for the named account and BE for the unnamed one, and the popover shows the name and the e-mail toggle.
    • apps/server/src/serverSettings.test.ts: accountNames is kept on disk through a later settings patch.
  • Ran the dev app against a local fake hub with alice@example.com named work, bob@example.com with no name and carol@example.com named personal.

Before (main): every hub account shows e-mail letters.

Before

After: named accounts show WO and PE, as the picker badges work and personal. The unnamed account keeps BE.

After

The segment popover of the named account: the name, and the e-mail behind its reveal toggle.

Popover

Also checked against a real hub with four Claude accounts: each bar showed the letters its instance shows in the picker.

Not checked: the mobile app on a device. It was typechecked only. Seen but not changed here: the pace tick can cross a chip when an account's bar is short, as on main.

A CLIProxyAPI hub account showed letters from its e-mail in Usage, while
the model picker badges its provider instance from the instance name.
One account showed two different badges.

The hub keeps no name per account, so a usage limit source can now name
its accounts: `accountNames` maps an e-mail to a name. The server puts
the name on each hub account it reads, and the Usage chips take their
letters from it with providerInstanceInitials, the function the picker
uses. An account with no name keeps its e-mail letters.
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant