The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 05:45 UTC
fix(usage): label a proxied Claude account by its e-mail, and drop .json from hub rows (#28065)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 3, 2026 at 12:01 UTC
58cf69c835bc8346974e67ca53eb80f3dd49ecad
2 files changed
+88
-3
packages/shared/src/usageLimits.test.ts
+73
@@ -672,6 +672,57 @@ describe("pools", () => {
672
expect(accounts[0]?.displayName).toBe("claude-team-seat");
673
});
674
675
+ it("labels a default-named instance merged with a hub account by e-mail, keeping a chosen name", () => {
676
+ const native = provider({
677
+ driver: claude,
678
+ instanceId: ProviderInstanceId.make("claudeAgent"),
679
+ displayName: "Claude",
680
+ auth: { status: "authenticated", email: "a@example.com" },
681
+ usageLimits: { checkedAt, windows: [window] },
682
+ });
683
+ const named = provider({
684
+ driver: claude,
685
+ instanceId: ProviderInstanceId.make("claude-work"),
686
+ displayName: "Work",
687
+ auth: { status: "authenticated", email: "b@example.com" },
688
+ usageLimits: { checkedAt, windows: [window] },
689
+ });
690
+ const hubAccount = (email: string) => ({
691
+ id: `claude-${email}.json`,
692
+ driver: claude,
693
+ email,
694
+ usageLimits: { checkedAt, windows: [window] },
695
+ });
696
+ const input = new Map([
697
+ [
698
+ EnvironmentId.make("env-a"),
699
+ {
700
+ ...laptop,
701
+ serverConfig: {
702
+ providers: [native, named],
703
+ usageLimitSources: [
704
+ {
705
+ ...source,
706
+ accounts: [
707
+ hubAccount("a@example.com"),
708
+ hubAccount("b@example.com"),
709
+ hubAccount("c@example.com"),
710
+ ],
711
+ },
712
+ ],
713
+ },
714
+ },
715
+ ],
716
+ ]);
717
+ expect(
718
+ collectLimitAccounts(input).map(({ displayName, email }) => ({ displayName, email })),
719
+ ).toEqual([
720
+ { displayName: null, email: "a@example.com" },
721
+ { displayName: "Work", email: "b@example.com" },
722
+ { displayName: null, email: "c@example.com" },
723
+ ]);
724
+ });
725
+
726
it("pools Codex windows by kind, whichever slot reported them", () => {
727
const codexAccount = (id: string, slots: readonly string[]) => ({
728
id,
@@ -1138,6 +1189,28 @@ describe("/usage-limits", () => {
1189
expect(report?.accounts[0]?.limits.resetCredits?.availableCount).toBe(3);
1190
});
1191
1192
+ it("labels hub rows by account id without .json", () => {
1193
+ const hub = [
1194
+ {
1195
+ ...sources[0]!,
1196
+ label: "CLIProxyAPI",
1197
+ accounts: [
1198
+ {
1199
+ id: "claude-b@example.com.json",
1200
+ driver: selected.driver,
1201
+ email: "b@example.com",
1202
+ usageLimits: limits,
1203
+ },
1204
+ { id: "team-seat.json", driver: selected.driver, usageLimits: limits },
1205
+ ],
1206
+ },
1207
+ ];
1208
+ const report = collectProviderUsageLimits(selected.instanceId, [selected], hub, now);
1209
+ expect(
1210
+ report?.accounts.filter((account) => account.sourceLabel).map((account) => account.label),
1211
+ ).toEqual(["CLIProxyAPI · claude-b@example.com", "CLIProxyAPI · team-seat"]);
1212
+ });
1213
+
1214
it("keeps unidentified custom instances separate, filtering by driver", () => {
1215
const report = collectProviderUsageLimits(
1216
selected.instanceId,
packages/shared/src/usageLimits.ts
+15
-3
@@ -9,6 +9,7 @@ import {
9
type ProviderConsumeResetCreditInput,
10
type ServerProviderSlashCommand,
11
isProviderAvailable,
12
+ PROVIDER_DISPLAY_NAMES,
13
type ServerProvider,
14
type ServerProviderUsageLimits,
15
type ServerProviderUsageWindow,
@@ -232,6 +233,8 @@ function accountKeyResolver(reports: Iterable<AccountReport>) {
233
};
234
}
235
236
+const hubAccountName = (account: { readonly id: string }) => account.id.replace(/\.json$/i, "");
237
+
238
export interface LimitAccount {
239
readonly key: string;
240
readonly driver: ServerProvider["driver"];
@@ -297,9 +300,18 @@ export function collectLimitAccounts(presentations: LimitPresentations): readonl
300
];
301
const winner = fresher ? next : previous;
302
const creditSource = creditSources.get(key);
303
+ // A hub e-mail names the account better than the driver's default instance name.
304
+ const hubEmail = [previous, next].some(
305
+ (account) => account.environments.length === 0 && account.email,
306
+ );
307
+ const displayName = previous.displayName ?? next.displayName;
308
accounts.set(key, {
309
...previous,
302
- displayName: previous.displayName ?? next.displayName,
310
+ displayName:
311
+ hubEmail &&
312
+ displayName?.toLowerCase() === PROVIDER_DISPLAY_NAMES[previous.driver]?.toLowerCase()
313
+ ? null
314
+ : displayName,
315
plan: planSources.get(key)?.plan ?? previous.plan ?? next.plan,
316
accentColor: previous.accentColor ?? next.accentColor,
317
environments,
@@ -353,7 +365,7 @@ export function collectLimitAccounts(presentations: LimitPresentations): readonl
365
merge(resolveKey(account) ?? key, {
366
key,
367
driver: account.driver,
356
- displayName: account.email ? null : account.id.replace(/\.json$/i, ""),
368
+ displayName: account.email ? null : hubAccountName(account),
369
email: account.email,
370
plan: account.plan,
371
accentColor: undefined,
@@ -843,7 +855,7 @@ export function collectProviderUsageLimits(
855
accounts.push({
856
id: `${source.id}:${account.id}`,
857
driver: account.driver,
846
- label: `${source.label} · ${account.id}`,
858
+ label: `${source.label} · ${hubAccountName(account)}`,
859
sourceLabel: "CLI Proxy",
860
...(account.usageLimits.resetCredits?.nextCreditId
861
? {