Repository navigation
fix(usage): label a proxied Claude account by its e-mail, and drop .json from hub rows #28065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ee19765
738f874
4f2f4c3
0277fd6
3734bd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import { | |
| type ProviderConsumeResetCreditInput, | ||
| type ServerProviderSlashCommand, | ||
| isProviderAvailable, | ||
| PROVIDER_DISPLAY_NAMES, | ||
| type ServerProvider, | ||
| type ServerProviderUsageLimits, | ||
| type ServerProviderUsageWindow, | ||
|
|
@@ -232,6 +233,8 @@ function accountKeyResolver(reports: Iterable<AccountReport>) { | |
| }; | ||
| } | ||
|
|
||
| const hubAccountName = (account: { readonly id: string }) => account.id.replace(/\.json$/i, ""); | ||
|
|
||
| export interface LimitAccount { | ||
| readonly key: string; | ||
| readonly driver: ServerProvider["driver"]; | ||
|
|
@@ -297,9 +300,18 @@ export function collectLimitAccounts(presentations: LimitPresentations): readonl | |
| ]; | ||
| const winner = fresher ? next : previous; | ||
| const creditSource = creditSources.get(key); | ||
| // A hub e-mail names the account better than the driver's default instance name. | ||
| const hubEmail = [previous, next].some( | ||
| (account) => account.environments.length === 0 && account.email, | ||
| ); | ||
| const displayName = previous.displayName ?? next.displayName; | ||
| accounts.set(key, { | ||
| ...previous, | ||
| displayName: previous.displayName ?? next.displayName, | ||
| displayName: | ||
| hubEmail && | ||
| displayName?.toLowerCase() === PROVIDER_DISPLAY_NAMES[previous.driver]?.toLowerCase() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle inherited keys in the display-name lookup. If a remote server sends two hub accounts with the schema-valid driver
|
||
| ? null | ||
| : displayName, | ||
| plan: planSources.get(key)?.plan ?? previous.plan ?? next.plan, | ||
| accentColor: previous.accentColor ?? next.accentColor, | ||
| environments, | ||
|
|
@@ -353,7 +365,7 @@ export function collectLimitAccounts(presentations: LimitPresentations): readonl | |
| merge(resolveKey(account) ?? key, { | ||
| key, | ||
| driver: account.driver, | ||
| displayName: account.email ? null : account.id.replace(/\.json$/i, ""), | ||
| displayName: account.email ? null : hubAccountName(account), | ||
| email: account.email, | ||
| plan: account.plan, | ||
| accentColor: undefined, | ||
|
|
@@ -843,7 +855,7 @@ export function collectProviderUsageLimits( | |
| accounts.push({ | ||
| id: `${source.id}:${account.id}`, | ||
| driver: account.driver, | ||
| label: `${source.label} · ${account.id}`, | ||
| label: `${source.label} · ${hubAccountName(account)}`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disambiguate IDs that normalize to the same label. If a source returns distinct IDs
|
||
| sourceLabel: "CLI Proxy", | ||
| ...(account.usageLimits.resetCredits?.nextCreditId | ||
| ? { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve chosen names across native merges.
If native instances named
ClaudeandWorkshare an email, the first native merge keepsClaudeand discardsWork. The later hub merge then clearsClaude, leaving no chosen name. Preserve the chosen-name candidate until the hub merge, without changing native-only output.