@@ -5,13 +5,15 @@ import {
55 collectLimitAccounts ,
66 collectLimitNotices ,
77 collectLimitPools ,
8+ cursorUsageWindowDetails ,
9+ displayLimitWindows ,
810 formatDuration ,
911 formatResetsIn ,
1012 remainingPercent ,
1113 type LimitAccount ,
1214 type LimitPoolWindow ,
1315} from "@t3tools/shared/usageLimits" ;
14- import { useId , useState } from "react" ;
16+ import { Fragment , type ReactNode , useId , useState } from "react" ;
1517import { Pressable , ScrollView , View } from "react-native" ;
1618import { Defs , Path , Pattern , Rect , Svg } from "react-native-svg" ;
1719import { useSafeAreaInsets } from "react-native-safe-area-context" ;
@@ -70,11 +72,15 @@ function PoolWindowCard({
7072 color,
7173 now,
7274 environmentIds,
75+ label,
76+ description,
7377} : {
7478 readonly pool : LimitPoolWindow ;
7579 readonly color : string ;
7680 readonly now : number ;
7781 readonly environmentIds : readonly string [ ] | null ;
82+ readonly label ?: string ;
83+ readonly description ?: string ;
7884} ) {
7985 const navigation = useNavigation ( ) ;
8086 const nextRefill = pool . resets . find ( ( reset ) => reset . restoresPercent > 0 ) ;
@@ -96,7 +102,7 @@ function PoolWindowCard({
96102 < View className = "gap-3 rounded-[24px] border-continuous bg-card p-4" >
97103 < View className = "flex-row items-start justify-between gap-3" >
98104 < View className = "gap-1" >
99- < Text className = "text-sm font-t3-medium text-foreground" > { pool . label } </ Text >
105+ < Text className = "text-sm font-t3-medium text-foreground" > { label ?? pool . label } </ Text >
100106 < View className = "flex-row items-baseline gap-1.5" >
101107 < Text className = "text-3xl font-t3-bold tabular-nums text-foreground" >
102108 { pool . remainingPercent } %
@@ -108,6 +114,7 @@ function PoolWindowCard({
108114 < Text className = "text-xs text-foreground-tertiary" > { PACE_LABEL [ pool . pace ] } </ Text >
109115 ) : null }
110116 </ View >
117+ { description ? < Text className = "text-xs text-foreground-muted" > { description } </ Text > : null }
111118 { nextRefill ? (
112119 < Text className = "text-xs tabular-nums text-foreground-muted" >
113120 ↻ +{ nextRefill . restoresPercent } %{ " " }
@@ -196,10 +203,12 @@ export function UsageLimitsSection({
196203 now,
197204 failedLabels,
198205 selectedEnvironmentIds,
206+ cursorPrompt,
199207} : {
200208 readonly now : number ;
201209 readonly failedLabels : readonly string [ ] ;
202210 readonly selectedEnvironmentIds : ReadonlySet < EnvironmentId > | null ;
211+ readonly cursorPrompt ?: ReactNode ;
203212} ) {
204213 const presentations = useAtomValue ( environmentPresentations . presentationsAtom ) ;
205214 const selected =
@@ -209,34 +218,54 @@ export function UsageLimitsSection({
209218 const pools = collectLimitPools ( collectLimitAccounts ( selected ) , now ) ;
210219 const notices = collectLimitNotices ( selected ) ;
211220 const colors = useProviderColors ( ) ;
221+ const cursorPromptAt =
222+ Math . max (
223+ pools . findIndex ( ( pool ) => pool . driver === "codex" ) ,
224+ pools . findIndex ( ( pool ) => pool . driver === "claudeAgent" ) ,
225+ ) + 1 ;
212226 return (
213227 < View className = "gap-6" >
214- { pools . length === 0 && notices . length === 0 && failedLabels . length === 0 ? (
228+ { pools . length === 0 && notices . length === 0 && failedLabels . length === 0 && ! cursorPrompt ? (
215229 < Text className = "py-12 text-center text-base text-foreground-muted" >
216230 { selected . size === 0
217231 ? "Select an environment to see limits."
218232 : "No provider on the selected environments reports subscription limits." }
219233 </ Text >
220234 ) : null }
221- { pools . map ( ( pool ) => (
222- < View key = { pool . driver } className = "gap-3" >
223- < View className = "flex-row items-center gap-2 px-1" >
224- < ProviderIcon provider = { pool . driver } size = { 18 } />
225- < Text className = "text-base font-t3-medium text-foreground" >
226- { DRIVER_LABEL [ pool . driver ] ?? pool . driver }
227- </ Text >
228- </ View >
229- { pool . windows . map ( ( window ) => (
230- < PoolWindowCard
231- key = { `${ window . kind } :${ window . id } ` }
232- pool = { window }
233- color = { pool . driver === "claudeAgent" ? colors . claude : colors . codex }
234- now = { now }
235- environmentIds = { selectedEnvironmentIds === null ? null : [ ...selectedEnvironmentIds ] }
236- />
237- ) ) }
238- </ View >
239- ) ) }
235+ { pools . map ( ( pool , index ) => {
236+ const windows = displayLimitWindows ( pool ) ;
237+ return (
238+ < Fragment key = { pool . driver } >
239+ { index === cursorPromptAt ? cursorPrompt : null }
240+ < View className = "gap-3" >
241+ < View className = "flex-row items-center gap-2 px-1" >
242+ < ProviderIcon provider = { pool . driver } size = { 18 } />
243+ < Text className = "text-base font-t3-medium text-foreground" >
244+ { DRIVER_LABEL [ pool . driver ] ?? pool . driver }
245+ </ Text >
246+ </ View >
247+ { windows . map ( ( window ) => {
248+ const details =
249+ pool . driver === "cursor" ? cursorUsageWindowDetails ( window . id ) : undefined ;
250+ return (
251+ < PoolWindowCard
252+ key = { `${ window . kind } :${ window . id } ` }
253+ pool = { window }
254+ color = { pool . driver === "claudeAgent" ? colors . claude : colors . codex }
255+ now = { now }
256+ environmentIds = {
257+ selectedEnvironmentIds === null ? null : [ ...selectedEnvironmentIds ]
258+ }
259+ label = { details ?. label }
260+ description = { details ?. description }
261+ />
262+ ) ;
263+ } ) }
264+ </ View >
265+ </ Fragment >
266+ ) ;
267+ } ) }
268+ { cursorPromptAt === pools . length ? cursorPrompt : null }
240269 { notices . length > 0 || failedLabels . length > 0 ? (
241270 < View
242271 accessible
0 commit comments