Repository navigation
Conversation
…fore its save A text send is charged before its save. When the file attach's window closed in between, the save was refused and the unit stayed charged. The charge's unit is now refunded on that refusal, for /chat/start and /chat/edit. - lib/rate-limiter-mutations: refundLimitUnits writes the window's remaining count back, capped at its rate, to the row the limiter reads. - chat/daily-charge: refundDailyCharge also releases a keyed charge's claim, so the send's retry is charged normally. - chat/lib/daily-limit: refundDailyLimit, the send-side helper; admins and tiers without the kind give nothing back. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
|
ⓘ Qodo did not review this PR because this workspace reached its daily trial limit of 100 reviews. Reviews start again at 00:00 UTC. Choose a plan to continue now. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Thank you for following the naming conventions! 🙏 |
PR Summary by QodoRefund chat quota when a file-attach window expires before save
AI Description
Merge Risk
|
Code Review by Qodo
1. Overlapping retries can bypass daily quota
|
Summary
Follow-up to #831. A text send is charged one daily unit before its save. When the file attach's safe window closed between the charge and the save, the save was refused but the unit stayed charged. This gives the unit back on that refusal, for
/chat/startand/chat/edit.Changes
lib/rate-limiter-mutations.ts:refundLimitUnitswrites the fixed window's remaining count back, capped at its rate, to the row the limiter reads (neore:<key>:<identifier>).chat/daily-charge.ts:refundDailyChargealso releases a keyed charge's claim, so the retry is charged normally instead of being found already charged.chat/lib/daily-limit.ts:refundDailyLimit, the send-side helper. Admins and tiers without the kind give nothing back.chat/http.ts: the send's charge records a refund; the window refusal runs it before answering 409.Testing
chat/daily-refund.test.ts: refund restores the unit; capped at the rate; a keyed refund frees the claim so a retry is charged once.Not covered
🤖 Generated with Claude Code