@@ -157,6 +157,16 @@ class Ruixen {
157
157
return ;
158
158
}
159
159
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
+
160
170
// Else enqueue to respect rate limits
161
171
this . queue . push ( { pet, entry, resolve, reject } ) ;
162
172
this . queueSize . set ( this . queue . length ) ;
@@ -195,6 +205,17 @@ class Ruixen {
195
205
}
196
206
197
207
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
+ }
198
219
const wait = this . limiter . msUntilAvailable ( ) ;
199
220
await new Promise ( ( r ) => setTimeout ( r , Math . min ( wait , 1500 ) ) ) ;
200
221
continue ;
0 commit comments