@@ -157,6 +157,16 @@ class Ruixen {
157157 return ;
158158 }
159159
160+ // If daily free limit is exhausted for the chosen model, short-circuit to offline
161+ if ( isFreeModel ( this . model ) ) {
162+ const today = new Date ( ) . toDateString ( ) ;
163+ const d = loadDailyCount ( ) ;
164+ if ( getExhausted ( ) === today || d . count >= DAILY_FREE_LIMIT ) {
165+ resolve ( this . offlineHeuristic ( pet , fullEntry ) ) ;
166+ return ;
167+ }
168+ }
169+
160170 // Else enqueue to respect rate limits
161171 this . queue . push ( { pet, entry, resolve, reject } ) ;
162172 this . queueSize . set ( this . queue . length ) ;
@@ -195,6 +205,17 @@ class Ruixen {
195205 }
196206
197207 if ( ! this . limiter . canRequest ( this . model ) ) {
208+ // If the daily free limit is exhausted, resolve offline immediately
209+ if ( isFreeModel ( this . model ) ) {
210+ const today = new Date ( ) . toDateString ( ) ;
211+ const d = loadDailyCount ( ) ;
212+ if ( getExhausted ( ) === today || d . count >= DAILY_FREE_LIMIT ) {
213+ next . resolve ( this . offlineHeuristic ( next . pet , this . toJournalEntry ( next . entry , next . pet ) ) ) ;
214+ this . queue . shift ( ) ;
215+ this . queueSize . set ( this . queue . length ) ;
216+ continue ;
217+ }
218+ }
198219 const wait = this . limiter . msUntilAvailable ( ) ;
199220 await new Promise ( ( r ) => setTimeout ( r , Math . min ( wait , 1500 ) ) ) ;
200221 continue ;
0 commit comments