Skip to content

fix(anthropic): preserve weekly usage across 5h resets - #7990

Closed
sisttri wants to merge 1 commit into
Wei-Shaw:mainfrom
sisttri:fix/7989-preserve-weekly-quota
Closed

sisttri wants to merge 1 commit into
Wei-Shaw:mainfrom
sisttri:fix/7989-preserve-weekly-quota

Conversation

@sisttri

@sisttri sisttri commented Oct 10, 2026 •

Copy link
Copy Markdown

5 小时额度重置后,Fable 周额度不应跟着变成空白。这里让普通周额度和 Fable 周额度分别检查自己的重置时间:没到时间就保留上次的值,已过期或没有有效重置时间就清空。新的响应头仍按原来的方式更新。

账号经过 JSON 保存、重新加载,再创建新的服务实例,检查未过期的周窗口仍保持原来的到期时间,停机期间已经过期的 Fable 窗口会被清理。包含 UTC+8 时间和 JSON 数字反序列化的情况。

Fixes #7989

验证

  • go test -tags=unit ./internal/service -run '^TestUpdateSessionWindow' -count=1 通过。
  • go test -race -tags=unit ./internal/service -run '^TestUpdateSessionWindow' -count=10 通过。
  • go vet -tags=unit ./internal/service 通过。
  • 整个 service 包测试通过;全后端测试也完整通过。

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@sisttri

sisttri commented Oct 10, 2026

Copy link
Copy Markdown
Author

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign, please reply with the following comment:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once — it will be valid for all your future contributions to this project.

I have read the CLA Document and I hereby sign the CLA

You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

I have read the CLA Document and I hereby sign the CLA

@sisttri
sisttri marked this pull request as ready for review October 10, 2026 06:32
@sisttri

sisttri commented Oct 10, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Oct 10, 2026
@sisttri
sisttri force-pushed the fix/7989-preserve-weekly-quota branch 2 times, most recently from 408d973 to 5578cea Compare October 12, 2026 09:52
Keep shared and Fable weekly snapshots until their own reset times.
Continue clearing expired or invalid windows and accepting new response
headers. Also clear a kept snapshot once its own reset time passes while
the 5h window is still active, so an expired weekly value is not shown as
current usage. Cover independent window expiry and account reloads after
restart.

Fixes Wei-Shaw#7989
@sisttri
sisttri force-pushed the fix/7989-preserve-weekly-quota branch from 5578cea to e051bee Compare October 12, 2026 10:06
riofutab added a commit to riofutab/sub2api that referenced this pull request Oct 14, 2026
- 普通周额度与 Fable 周额度各按自己的重置时间判断:未到期保留,已到期清除,没有有效重置时间的只在 5h 换窗时清除
- 与 fork 的会话窗口写入节流冲突处采用上游写法,原 windowReset 变量无其他引用

测试:service 包会话窗口与限流相关单测通过。
riofutab added a commit to riofutab/sub2api that referenced this pull request Oct 14, 2026
- OpenAI/Codex 稳定性:OAuth 缺过期时间时按 JWT 判定并在 WS 上恢复 401(Wei-Shaw#8034,替换 fork 原有的 Wei-Shaw#7826 实现)、模型拒绝不计入调度错误率(Wei-Shaw#8013)、首包前预算耗尽换号(Wei-Shaw#8005)、Sol 别名误判修正(Wei-Shaw#8063)
- 流与协议:原生 Claude 转 Chat 转发心跳(Wei-Shaw#8052)、Codex 流式出图兼容 JSON 响应(Wei-Shaw#8028)、Antigravity 工具结果图片(Wei-Shaw#8045)
- 用量显示:5h 换窗保留未到期周额度(Wei-Shaw#7990)、缓存命中率口径修正与单次命中率显示(Wei-Shaw#8018、Wei-Shaw#7995)

测试:go test -tags=unit ./... 全部通过,golangci-lint 0 issues;前端 make test-frontend 通过;集成测试交 CI。
@sisttri

sisttri commented Oct 29, 2026

Copy link
Copy Markdown
Author

@Wei-Shaw

@Wei-Shaw

Copy link
Copy Markdown
Owner

感谢贡献!5h 窗口重置时误清周用量读数的问题,已由修复相同问题的 #8723 合入 main 解决。两个 PR 重写的是同一段 UpdateSessionWindow 清理逻辑,现在本 PR 已与 main 冲突,所以作为重复关闭。本 PR 额外实现的“周读数到期即清”,如果仍有需要,欢迎基于最新 main 单独提一个小 PR。

Thanks! #8723 (now merged) fixes the same weekly-usage-cleared-on-5h-reset issue and rewrites the same UpdateSessionWindow block, so this now conflicts and is closed as a duplicate. If the extra clear-weekly-reading-at-expiry behavior is still needed, please send it as a small follow-up PR against the latest main.

@Wei-Shaw Wei-Shaw closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 5 小时额度重置后,Fable 周额度变成空白

2 participants