@@ -121,6 +121,38 @@ function AccountName({
121121 ) ;
122122}
123123
124+ /** A visible label key; initials chips can collide even when the emails differ. */
125+ function accountNameKey ( account : LimitAccount ) : string {
126+ return (
127+ account . displayName ??
128+ ( account . email
129+ ? accountInitials ( account . email )
130+ : ( getDriverOption ( account . driver ) ?. label ?? String ( account . driver ) ) )
131+ ) ;
132+ }
133+
134+ /** Preserve distinct labels and allocate collision-free suffixes in stable key order. */
135+ function disambiguateAccountNames ( accounts : readonly LimitAccount [ ] ) : readonly LimitAccount [ ] {
136+ const names = accounts . map ( accountNameKey ) ;
137+ const used = new Set ( names ) ;
138+ const labels = new Map < string , string > ( ) ;
139+ accounts
140+ . toSorted ( ( left , right ) => left . key . localeCompare ( right . key ) )
141+ . forEach ( ( account , index ) => {
142+ const name = accountNameKey ( account ) ;
143+ if ( names . indexOf ( name ) === names . lastIndexOf ( name ) ) return ;
144+ let suffix = index + 1 ;
145+ let label = `${ account . displayName ?? "Account" } ${ suffix } ` ;
146+ while ( used . has ( label ) ) label = `${ account . displayName ?? "Account" } ${ ++ suffix } ` ;
147+ used . add ( label ) ;
148+ labels . set ( account . key , label ) ;
149+ } ) ;
150+ return accounts . map ( ( account ) => {
151+ const displayName = labels . get ( account . key ) ;
152+ return displayName ? { ...account , displayName } : account ;
153+ } ) ;
154+ }
155+
124156function Row ( { label, children } : { readonly label : string ; readonly children : ReactNode } ) {
125157 return (
126158 < div className = "grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-3" >
@@ -194,7 +226,9 @@ function SegmentPopover({
194226 </ Row >
195227 ) : null }
196228 { reset && reset . restoresPercent > 0 ? (
197- < Row label = "Restores" > +{ reset . restoresPercent } % of pool</ Row >
229+ < Row label = "Restores" >
230+ +{ reset . restoresPercent } % { account . driver === "codex" ? "of quota" : "of pool" }
231+ </ Row >
198232 ) : null }
199233 </ div >
200234 { credits && redeem ? (
@@ -274,12 +308,14 @@ function PoolSegment({
274308 } }
275309 />
276310 ) : null }
277- < span
278- aria-hidden
279- className = "absolute inset-0 flex items-center justify-center text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
280- >
281- { index }
282- </ span >
311+ { account . driver !== "codex" ? (
312+ < span
313+ aria-hidden
314+ className = "absolute inset-0 flex items-center justify-center text-3xs leading-none font-semibold text-foreground/80 tabular-nums @2xl/pool:hidden"
315+ >
316+ { index }
317+ </ span >
318+ ) : null }
283319 < div className = "relative hidden h-full min-w-0 items-center gap-1.5 px-2 text-xs @2xl/pool:flex" >
284320 { showAccountName ? (
285321 < AccountName
@@ -360,15 +396,17 @@ function LegendRow({
360396 render = { < Button variant = "ghost" size = "compact" /> }
361397 className = "min-w-0 @2xl/pool:hidden"
362398 >
363- < 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" >
364- < span
365- aria-hidden
366- className = "absolute inset-0 rounded-sm opacity-35"
367- style = { { backgroundColor : color } }
368- />
369- < span className = "sr-only" > Segment </ span >
370- < span className = "relative" > { index } </ span >
371- </ span >
399+ { account . driver !== "codex" ? (
400+ < 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" >
401+ < span
402+ aria-hidden
403+ className = "absolute inset-0 rounded-sm opacity-35"
404+ style = { { backgroundColor : color } }
405+ />
406+ < span className = "sr-only" > Segment </ span >
407+ < span className = "relative" > { index } </ span >
408+ </ span >
409+ ) : null }
372410 < AccountName account = { account } className = "min-w-0 truncate font-medium text-foreground" />
373411 < span className = "shrink-0 font-semibold text-foreground tabular-nums" > { remaining } %</ span >
374412 < span className = "ms-auto flex shrink-0 items-center gap-1.5 text-2xs text-muted-foreground tabular-nums" >
@@ -499,15 +537,17 @@ function PoolWindowCard({
499537 readonly pool : LimitPoolWindow ;
500538 readonly color : string ;
501539 readonly now : number ;
502- readonly label ?: string | undefined ;
540+ readonly label ?: ReactNode ;
503541 readonly description ?: string | undefined ;
504542} ) {
505543 // The soonest reset that hands anything back; an untouched account resets to no effect.
506544 const nextRefill = pool . resets . find ( ( reset ) => reset . restoresPercent > 0 ) ;
507545 return (
508546 < 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)]" >
509547 < div className = "flex flex-col gap-1" >
510- < span className = "text-sm font-medium text-foreground" > { label ?? pool . label } </ span >
548+ < span className = "flex min-w-0 items-center gap-1.5 text-sm font-medium text-foreground" >
549+ { label ?? pool . label }
550+ </ span >
511551 < span className = "flex items-baseline gap-2" >
512552 < span className = "text-3xl font-semibold text-foreground tabular-nums" >
513553 { pool . remainingPercent } %
@@ -532,7 +572,13 @@ function PoolWindowCard({
532572function PoolSection ( { pool, now } : { readonly pool : LimitPool ; readonly now : number } ) {
533573 const color = barColor ( pool . driver ) ;
534574 const label = getDriverOption ( pool . driver ) ?. label ?? String ( pool . driver ) ;
535- const windows = displayLimitWindows ( pool ) ;
575+ // Codex workspaces can share an email but have independent subscription quotas.
576+ const separateAccounts = pool . driver === "codex" && pool . accounts . length > 1 ;
577+ const windows = separateAccounts
578+ ? disambiguateAccountNames ( pool . accounts ) . flatMap ( ( account ) =>
579+ displayLimitWindows ( collectLimitPools ( [ account ] , now ) [ 0 ] ! ) ,
580+ )
581+ : displayLimitWindows ( pool ) ;
536582 return (
537583 < section className = "flex flex-col gap-3" >
538584 < h2 className = "flex items-center gap-2 text-sm font-medium text-foreground" >
@@ -547,13 +593,23 @@ function PoolSection({ pool, now }: { readonly pool: LimitPool; readonly now: nu
547593 </ h2 >
548594 { windows . map ( ( window ) => {
549595 const details = pool . driver === "cursor" ? cursorUsageWindowDetails ( window . id ) : undefined ;
596+ const account = separateAccounts ? window . members [ 0 ] ! . account : undefined ;
550597 return (
551598 < PoolWindowCard
552- key = { `${ window . kind } :${ window . id } ` }
599+ key = { `${ account ?. key ?? "" } : ${ window . kind } :${ window . id } ` }
553600 pool = { window }
554601 color = { color }
555602 now = { now }
556- label = { details ?. label }
603+ label = {
604+ account ? (
605+ < >
606+ < AccountName account = { account } className = "min-w-0 truncate" />
607+ < span className = "shrink-0 text-muted-foreground" > · { window . label } </ span >
608+ </ >
609+ ) : (
610+ details ?. label
611+ )
612+ }
557613 description = { details ?. description }
558614 />
559615 ) ;
0 commit comments