Skip to content

Commit ebd0ad7

Browse files
author
Amartuvshin Surenjav
committed
fix(usage): give each ACP Registry agent its own limits section
1 parent 60b0107 commit ebd0ad7

4 files changed

Lines changed: 35 additions & 9 deletions

File tree

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,13 @@ export function UsageLimitsSection({
440440
{pools.map((pool, index) => {
441441
const windows = displayLimitWindows(pool);
442442
return (
443-
<Fragment key={pool.driver}>
443+
<Fragment key={pool.key}>
444444
{index === cursorPromptAt ? cursorPrompt : null}
445445
<View className="gap-3">
446446
<View className="flex-row items-center gap-2 px-1">
447447
<ProviderIcon provider={pool.driver} size={18} />
448448
<Text className="text-base font-t3-medium text-foreground">
449-
{DRIVER_LABEL[pool.driver] ?? pool.driver}
449+
{pool.title ?? DRIVER_LABEL[pool.driver] ?? pool.driver}
450450
</Text>
451451
</View>
452452
{windows.map((window) => {

‎apps/web/src/components/usage/UsageLimitsPooled.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ function PoolWindowCard({
570570

571571
function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: number }) {
572572
const color = barColor(pool.driver);
573-
const label = providerClients.get(pool.driver)?.label ?? String(pool.driver);
573+
const label = pool.title ?? providerClients.get(pool.driver)?.label ?? String(pool.driver);
574574
const windows = displayLimitWindows(pool);
575575
return (
576576
<section className="flex flex-col gap-3">
@@ -629,7 +629,7 @@ export function UsageLimitsPooled({
629629
) : null}
630630
<SegmentPopoverContext value={segmentPopover}>
631631
{pools.map((pool, index) => (
632-
<Fragment key={pool.driver}>
632+
<Fragment key={pool.key}>
633633
{index === cursorPromptAt ? cursorPrompt : null}
634634
<PoolSection pool={pool} now={now} />
635635
</Fragment>

‎packages/shared/src/usageLimits.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,22 @@ describe("pooled account columns", () => {
800800
expect(keys(collectLimitPools(accounts.toReversed(), now)[0]!)).toEqual(keys(pool!));
801801
});
802802

803+
it("gives each ACP Registry agent its own pool while one driver's accounts share one", () => {
804+
const acp = (key: string) => ({
805+
...account(key, [window]),
806+
driver: ProviderDriverKind.make("acpRegistry"),
807+
});
808+
const pools = collectLimitPools(
809+
[acp("Claude ACP"), acp("Codex ACP"), account("a", [window]), account("b", [window])],
810+
now,
811+
);
812+
expect(pools.map((pool) => [pool.title, keys(pool)])).toEqual([
813+
["Claude ACP", [["Claude ACP"]]],
814+
["Codex ACP", [["Codex ACP"]]],
815+
[null, [["a", "b"]]],
816+
]);
817+
});
818+
803819
it.each([undefined, "invalid", "2026-09-03T11:30:00.000Z"])(
804820
"keeps blocked sessions empty without predicting a refill from a missing or stale clock (%s)",
805821
(resetsAt) => {

‎packages/shared/src/usageLimits.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ export interface LimitPoolWindow {
333333
}
334334

335335
export interface LimitPool {
336+
readonly key: string;
336337
readonly driver: ServerProvider["driver"];
338+
readonly title: string | null;
337339
readonly accounts: readonly LimitAccount[];
338340
readonly windows: readonly LimitPoolWindow[];
339341
}
@@ -369,13 +371,15 @@ export function collectLimitPools(
369371
accounts: readonly LimitAccount[],
370372
now: number,
371373
): readonly LimitPool[] {
372-
const byDriver = new Map<ServerProvider["driver"], LimitAccount[]>();
374+
const byGroup = new Map<string, LimitAccount[]>();
373375
for (const account of accounts) {
374-
const list = byDriver.get(account.driver);
376+
const group = account.driver === "acpRegistry" ? account.key : account.driver;
377+
const list = byGroup.get(group);
375378
if (list) list.push(account);
376-
else byDriver.set(account.driver, [account]);
379+
else byGroup.set(group, [account]);
377380
}
378-
return [...byDriver].map(([driver, members]) => {
381+
return [...byGroup].map(([key, members]) => {
382+
const driver = members[0]!.driver;
379383
const orderWindow = members
380384
.flatMap((account) => account.limits.windows)
381385
.sort((left, right) => WINDOW_KIND_ORDER[left.kind] - WINDOW_KIND_ORDER[right.kind])[0];
@@ -394,7 +398,13 @@ export function collectLimitPools(
394398
accountSortName(left).localeCompare(accountSortName(right)) ||
395399
left.key.localeCompare(right.key),
396400
);
397-
return { driver, accounts: sorted, windows: poolWindows(sorted, now) };
401+
return {
402+
key,
403+
driver,
404+
title: driver === "acpRegistry" ? members[0]!.displayName : null,
405+
accounts: sorted,
406+
windows: poolWindows(sorted, now),
407+
};
398408
});
399409
}
400410

0 commit comments

Comments
 (0)