fix(usage): antigravity /usage display — dedupe by tier, fix account count, add projectId identity
- Antigravity usage provider now deduplicates model quota entries by tier instead of emitting one bar per model (15+ redundant bars for one account). The upstream API groups quota by tier — models within the same tier share the same quota bucket, so per-model bars were misleading noise. - Reports now carry credential email and accountId in metadata so the /usage display and deduplicator can show meaningful account identities instead of 'account 1'. - formatAggregateAmount no longer uses limits.length as account count. Instead counts unique accountId values from limit scopes — a single account's N incomplete limits no longer display as 'N accts'. - Usage report dedup now considers metadata.projectId for Google Cloud providers so duplicate credential rows with the same project merge. - account labels in both TUI and ACP markdown paths now fall back to metadata.projectId before the generic 'account N' placeholder.
This commit is contained in:
@@ -1272,6 +1272,8 @@ function formatAccountLabel(limit: UsageLimit, report: UsageReport, index: numbe
|
||||
if (email) return email;
|
||||
const accountId = (report.metadata?.accountId as string | undefined) ?? limit.scope.accountId;
|
||||
if (accountId) return accountId;
|
||||
const projectId = report.metadata?.projectId as string | undefined;
|
||||
if (projectId) return projectId;
|
||||
return `account ${index + 1}`;
|
||||
}
|
||||
|
||||
@@ -1280,6 +1282,8 @@ function formatUnlimitedReportLabel(report: UsageReport, index: number): string
|
||||
if (email) return email;
|
||||
const accountId = report.metadata?.accountId as string | undefined;
|
||||
if (accountId) return accountId;
|
||||
const projectId = report.metadata?.projectId as string | undefined;
|
||||
if (projectId) return projectId;
|
||||
return `account ${index + 1}`;
|
||||
}
|
||||
|
||||
@@ -1365,7 +1369,12 @@ function formatAggregateAmount(limits: UsageLimit[]): string {
|
||||
return `${formatNumber(remainingPct)}% free`;
|
||||
}
|
||||
|
||||
return `${limits.length} accts`;
|
||||
// Count unique accounts from limit scopes — not limits.length.
|
||||
const uniqueAccountIds = new Set(
|
||||
limits.map(limit => limit.scope.accountId).filter((id): id is string => typeof id === "string" && id.length > 0),
|
||||
);
|
||||
if (uniqueAccountIds.size === 0) return "";
|
||||
return `${uniqueAccountIds.size} ${uniqueAccountIds.size === 1 ? "acct" : "accts"}`;
|
||||
}
|
||||
|
||||
function resolveResetRange(limits: UsageLimit[], nowMs: number): string | null {
|
||||
|
||||
Reference in New Issue
Block a user