@@ -132,7 +132,7 @@ function Row({ label, children }: { readonly label: string; readonly children: R
132132
133133/**
134134 * Everything about one account in one window: plan, where it is signed in,
135- * the email on request, reset time and quota it restores, and the
135+ * the email on request, reset time and share of the pool it restores, and the
136136 * reset-credit action. Opens on hover for a glance, on click to act.
137137 */
138138function SegmentPopover ( {
@@ -194,7 +194,9 @@ function SegmentPopover({
194194 </ Row >
195195 ) : null }
196196 { reset && reset . restoresPercent > 0 ? (
197- < Row label = "Restores" > +{ reset . restoresPercent } %</ Row >
197+ < Row label = "Restores" >
198+ +{ reset . restoresPercent } % { account . driver === "codex" ? "of quota" : "of pool" }
199+ </ Row >
198200 ) : null }
199201 </ div >
200202 { credits && redeem ? (
@@ -236,7 +238,7 @@ function PoolSegment({
236238 readonly reset : LimitPoolWindow [ "resets" ] [ number ] | undefined ;
237239 readonly color : string ;
238240 readonly now : number ;
239- /** 1-based grid position of the bar and its legend row. */
241+ /** 1-based position in the bar, shown on the strip and its legend row to tie them together . */
240242 readonly index : number ;
241243 readonly showAccountName : boolean ;
242244} ) {
@@ -274,6 +276,14 @@ function PoolSegment({
274276 } }
275277 />
276278 ) : null }
279+ { account . driver !== "codex" ? (
280+ < span
281+ aria-hidden
282+ className = "absolute inset-0 flex items-center justify-center text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
283+ >
284+ { index }
285+ </ span >
286+ ) : null }
277287 < div className = "relative hidden h-full min-w-0 items-center gap-1.5 px-2 text-xs @2xl/pool:flex" >
278288 { showAccountName ? (
279289 < AccountName
@@ -301,7 +311,7 @@ function PoolSegment({
301311 </ span >
302312 </ div >
303313 </ PopoverTrigger >
304- < LegendRow account = { account } window = { window } now = { now } index = { index } />
314+ < LegendRow account = { account } window = { window } color = { color } now = { now } index = { index } />
305315 { account . redeem ? (
306316 < RedeemableSegmentPopup
307317 account = { account }
@@ -335,11 +345,13 @@ function PoolSegment({
335345function LegendRow ( {
336346 account,
337347 window,
348+ color,
338349 now,
339350 index,
340351} : {
341352 readonly account : LimitAccount ;
342353 readonly window : LimitPoolMember [ "window" ] ;
354+ readonly color : string ;
343355 readonly now : number ;
344356 readonly index : number ;
345357} ) {
@@ -352,6 +364,17 @@ function LegendRow({
352364 render = { < Button variant = "ghost" size = "compact" /> }
353365 className = "min-w-0 @2xl/pool:hidden"
354366 >
367+ { account . driver !== "codex" ? (
368+ < span className = "relative inline-flex size-4 shrink-0 items-center justify-center rounded-sm text-3xs leading-none font-semibold text-foreground/80 tabular-nums" >
369+ < span
370+ aria-hidden
371+ className = "absolute inset-0 rounded-sm opacity-35"
372+ style = { { backgroundColor : color } }
373+ />
374+ < span className = "sr-only" > Segment </ span >
375+ < span className = "relative" > { index } </ span >
376+ </ span >
377+ ) : null }
355378 < AccountName account = { account } className = "min-w-0 truncate font-medium text-foreground" />
356379 < span className = "shrink-0 font-semibold text-foreground tabular-nums" > { remaining } %</ span >
357380 < span className = "ms-auto flex shrink-0 items-center gap-1.5 text-2xs text-muted-foreground tabular-nums" >
@@ -425,8 +448,13 @@ function RedeemableSegmentPopup({
425448}
426449
427450/**
428- * An account's remaining quota and reset details. Wide, the bar carries the
429- * details; narrow, a legend below has room for them. Both open the same popover.
451+ * One pooled window as equal-width segments, one per account, each filled by
452+ * the share of that account's quota still open. Equal widths are honest: every
453+ * account contributes the same share of the pool, whatever its plan.
454+ *
455+ * Wide, each segment carries its own label. Narrow, the bar is a bare strip
456+ * and a legend below lists the accounts in the same order; both open the
457+ * same popover.
430458 */
431459function PoolBar ( {
432460 pool,
@@ -463,7 +491,10 @@ function PoolBar({
463491 ) ;
464492}
465493
466- /** One account's percentage, quota bar, reset time, and reset-credit action. */
494+ /**
495+ * Big pooled number and the segment bar. Accounts keep the same column across
496+ * windows; each segment's popover shows its own reset time and share restored.
497+ */
467498function PoolWindowCard ( {
468499 pool,
469500 color,
@@ -477,6 +508,8 @@ function PoolWindowCard({
477508 readonly label ?: ReactNode ;
478509 readonly description ?: string | undefined ;
479510} ) {
511+ // The soonest reset that hands anything back; an untouched account resets to no effect.
512+ const nextRefill = pool . resets . find ( ( reset ) => reset . restoresPercent > 0 ) ;
480513 return (
481514 < div className = "grid items-center gap-x-6 gap-y-3 rounded-lg border border-border/60 p-4 md:grid-cols-[11rem_minmax(0,1fr)]" >
482515 < div className = "flex flex-col gap-1" >
@@ -490,6 +523,11 @@ function PoolWindowCard({
490523 < span className = "text-sm text-muted-foreground" > left</ span >
491524 { pool . pace ? < PaceIcon pace = { pool . pace } /> : null }
492525 </ span >
526+ { nextRefill && pool . columns . length > 1 ? (
527+ < span className = "text-xs font-medium text-foreground tabular-nums" >
528+ ↻ +{ nextRefill . restoresPercent } %
529+ </ span >
530+ ) : null }
493531 </ div >
494532 < PoolBar pool = { pool } color = { color } now = { now } />
495533 { description ? (
@@ -502,6 +540,11 @@ function PoolWindowCard({
502540function PoolSection ( { pool, now } : { readonly pool : LimitPool ; readonly now : number } ) {
503541 const color = barColor ( pool . driver ) ;
504542 const label = getDriverOption ( pool . driver ) ?. label ?? String ( pool . driver ) ;
543+ // Codex workspaces can share an email but have independent subscription quotas.
544+ const separateAccounts = pool . driver === "codex" && pool . accounts . length > 1 ;
545+ const windows = separateAccounts
546+ ? pool . accounts . flatMap ( ( account ) => displayLimitWindows ( collectLimitPools ( [ account ] , now ) [ 0 ] ! ) )
547+ : displayLimitWindows ( pool ) ;
505548 return (
506549 < section className = "flex flex-col gap-3" >
507550 < h2 className = "flex items-center gap-2 text-sm font-medium text-foreground" >
@@ -514,43 +557,37 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu
514557 />
515558 { label }
516559 </ h2 >
517- { pool . accounts . flatMap ( ( account ) => {
518- // Each account has an independent allowance; averaging percentages across
519- // subscriptions hides which account can actually run the next request.
520- const accountPool = collectLimitPools ( [ account ] , now ) [ 0 ] ! ;
521- return displayLimitWindows ( accountPool ) . map ( ( window ) => {
522- const details =
523- pool . driver === "cursor" ? cursorUsageWindowDetails ( window . id ) : undefined ;
524- return (
525- < PoolWindowCard
526- key = { `${ account . key } :${ window . kind } :${ window . id } ` }
527- pool = { window }
528- color = { color }
529- now = { now }
530- label = {
531- pool . accounts . length > 1 ? (
532- < >
533- < AccountName account = { account } className = "min-w-0 truncate" />
534- < span className = "shrink-0 text-muted-foreground" >
535- · { details ?. label ?? window . label }
536- </ span >
537- </ >
538- ) : (
539- details ?. label
540- )
541- }
542- description = { details ?. description }
543- />
544- ) ;
545- } ) ;
560+ { windows . map ( ( window ) => {
561+ const details = pool . driver === "cursor" ? cursorUsageWindowDetails ( window . id ) : undefined ;
562+ const account = separateAccounts ? window . members [ 0 ] ! . account : undefined ;
563+ return (
564+ < PoolWindowCard
565+ key = { `${ account ?. key ?? "" } :${ window . kind } :${ window . id } ` }
566+ pool = { window }
567+ color = { color }
568+ now = { now }
569+ label = {
570+ account ? (
571+ < >
572+ < AccountName account = { account } className = "min-w-0 truncate" />
573+ < span className = "shrink-0 text-muted-foreground" > · { window . label } </ span >
574+ </ >
575+ ) : (
576+ details ?. label
577+ )
578+ }
579+ description = { details ?. description }
580+ />
581+ ) ;
546582 } ) }
547583 </ section >
548584 ) ;
549585}
550586
551587/**
552- * Accounts grouped by provider, with separate rows for each account's windows.
553- * Instances of the same account still share one row across environments.
588+ * Accounts pooled per provider: what is open across all of them, who resets
589+ * next, and how much of the pool that hands back. Answers "can I keep going"
590+ * before "on which account".
554591 */
555592export function UsageLimitsPooled ( {
556593 presentations,
0 commit comments