[Bug] Setting account state to "ready" (PUT /api/accounts/{id}/state) clears all per-model quota cooldowns (runtimeState.Cooldowns)
发生了什么 / What happened
Summary
In v0.3.13, switching an account's state back to ready via the new account state dropdown (PUT /api/accounts/{id}/state with {"state":"ready"}) clears all entries in runtimeState.Cooldowns, including long-running per-model quota cooldowns (套餐限额 / 每日限额).
Minimal Reproduction
- Have an account with an active model quota cooldown in
runtime-state.json(e.g.gemini-4-neonin套餐限额until10:59). - Have that account become
restricted(e.g.403 verificationon another request),auth_required(401), or manuallydisabled. - In the Accounts page state dropdown, change the account state to
Ready(就绪). - Check
Requests -> Model cooldowns(GET /api/cooldowns) orruntime-state.json.
Expected vs Observed
- Expected: Changing account state to
Readyclears account-level blocking states (Restricted,AccountAuthRequired,disabled,stateMessage— and at most non-quota global*cooldowns), while preserving per-model upstream quota cooldowns (套餐限额,每日限额, etc.), which already have their own per-scope clear button (DELETE /api/accounts/{id}/cooldowns/{scope}). - Observed: All per-model quota cooldowns on the account are wiped immediately, causing the scheduler to route requests for exhausted models back to that account.
Root Cause Pointer (verified in v0.3.13 / c77dd89)
internal/app/admin.go(restoreAccount) callsadmin.pool.ClearAccountState(accountID).internal/aistudio/accounts.go(ClearAccountState) unconditionally runs:runtimeState.Restricted = "" clear(runtimeState.Cooldowns)
Note that ClearPageCooldownIfGeneration (internal/aistudio/accounts.go) already uses keepQuota = true (quotaCooldownReason) specifically to avoid clearing upstream quota cooldowns during recovery/sync, whereas ClearAccountState clears the entire Cooldowns map.
###Suggested Fix In ClearAccountState, keep entries where quotaCooldownReason(cooldown.Reason) is true (or only clear Restricted / auth_required / non-quota global * cooldowns), leaving per-model quota cooldowns manageable via the existing DELETE /api/accounts/{id}/cooldowns/{scope} endpoint.
版本 / Version
v0.3.13