1- import { Button } from "../../components/ui/Button" ;
21import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime" ;
32import { AsyncResult } from "effect/reactivity" ;
43import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell" ;
54import { limitRecoveryOwnsSnooze } from "@t3tools/client-runtime/state/thread-execution" ;
65import type { EnvironmentId } from "@t3tools/contracts" ;
76import { useState } from "react" ;
8- import { View } from "react-native" ;
7+ import { Pressable , View } from "react-native" ;
98import { AppText as Text } from "../../components/ui/AppText" ;
109import { useDeadlinePassed } from "../../lib/clock" ;
1110import { threadEnvironment } from "../../state/threads" ;
@@ -78,34 +77,34 @@ export function UsageLimitRecoveryCard({
7877 }
7978 return (
8079 < View className = "mx-3 mb-2 gap-2 rounded-xl border border-warning-foreground/25 bg-screen p-3" >
81- < Text className = "text-sm text-warning-foreground " >
82- { displayAt
83- ? `Usage limit reached. ${ canSchedule && scheduled ? "Resumes" : "Resets" } ${ new Date (
84- displayAt ,
85- ) . toLocaleString ( undefined , {
86- month : "short" ,
87- day : "numeric " ,
88- hour : "numeric" ,
89- minute : "2-digit " ,
90- } ) } .`
91- : "Usage limit reached. The provider did not report a reset time. Retry manually when your limit is available." }
92- </ Text >
93- { canSchedule ? (
94- < View className = "flex-row flex-wrap gap-2" >
95- < Button
96- label = { scheduled ? "Cancel auto-resume" : "Resume at reset" }
97- tone = "secondary"
98- disabled = { pending }
99- onPress = { ( ) => void toggle ( "resume" ) }
100- />
101- < Button
102- label = { snoozed ? "Wake now" : "Snooze until reset" }
103- tone = "secondary"
104- disabled = { pending || ( ! snoozed && resetPassed ) }
105- onPress = { ( ) => void toggle ( "snooze" ) }
106- />
107- </ View >
108- ) : null }
80+ < View className = "flex-row flex-wrap items-baseline gap-x-4 gap-y-2 " >
81+ < Text className = "shrink text-sm text-warning-foreground" >
82+ { displayAt
83+ ? `Usage limit reached. ${ canSchedule && scheduled ? "Resumes" : "Resets" } ${ new Date (
84+ displayAt ,
85+ ) . toLocaleString ( undefined , {
86+ month : "short " ,
87+ day : "numeric" ,
88+ hour : "numeric " ,
89+ minute : "2-digit" ,
90+ } ) } .`
91+ : "Usage limit reached. The provider did not report a reset time. Retry manually when your limit is available." }
92+ </ Text >
93+ { canSchedule ? (
94+ < >
95+ < RecoveryAction
96+ label = { scheduled ? "Cancel auto-resume" : "Resume at reset" }
97+ disabled = { pending }
98+ onPress = { ( ) => void toggle ( "resume" ) }
99+ />
100+ < RecoveryAction
101+ label = { snoozed ? "Wake now" : "Snooze until reset" }
102+ disabled = { pending || ( ! snoozed && resetPassed ) }
103+ onPress = { ( ) => void toggle ( "snooze" ) }
104+ />
105+ < />
106+ ) : null }
107+ </ View >
109108 { error ? (
110109 < Text accessibilityRole = "alert" className = "text-sm text-destructive" >
111110 { error }
@@ -114,3 +113,30 @@ export function UsageLimitRecoveryCard({
114113 </ View >
115114 ) ;
116115}
116+
117+ function RecoveryAction ( props : {
118+ readonly label : string ;
119+ readonly disabled : boolean ;
120+ readonly onPress : ( ) => void ;
121+ } ) {
122+ return (
123+ < Pressable
124+ accessibilityRole = "button"
125+ accessibilityState = { { disabled : props . disabled } }
126+ disabled = { props . disabled }
127+ hitSlop = { { top : 12 , bottom : 12 , left : 8 , right : 8 } }
128+ onPress = { props . onPress }
129+ className = "active:opacity-70"
130+ >
131+ < Text
132+ className = {
133+ props . disabled
134+ ? "text-sm font-t3-medium text-foreground-muted"
135+ : "text-sm font-t3-medium text-primary"
136+ }
137+ >
138+ { props . label }
139+ </ Text >
140+ </ Pressable >
141+ ) ;
142+ }
0 commit comments