WorkBuddy 积分的失效时间到不了卡片:QuotaSpan 把 runsOutAt 丢了
Confirmed on my setup — it reads right. Closed.
Built origin/main at 8f023b51 (v0.1.1623, which carries b9ab1723) and ran it against a copy of my config with XDG_CONFIG_HOME/XDG_CACHE_HOME pointed at the copy, so the instance I use daily was untouched. Then sent one real request through that gateway to a group that routes free first, which is what makes the gateway fill .free at all (routing.go:1597, only under st.ByFree), and opened the Routing page in a browser.
What the page does now, in zh:
- the four seats the trace carries as
free: trueshow 「免费 · 不花额度」 and their row isclass="nobar"— no bar, no percentage. - a paid seat beside them still shows its share (「已用 75%」 and its bar), and the one that is resting still says its rest first (「额度用尽 · 58 分钟后恢复」).
Both points in your message are right, and they were the ones I had wrong: .free does arrive only with a routing that weighs by it, so my fixture described a shape the gateway never sends, and my German string did fail /verbraucht/. Building the case on the real shape was the fix.
One thing worth knowing for whoever reads this next, not a defect: FreeModel (models.go:1697) also answers free when a model's four prices are all 0, not only when the plugin lists it free. So a seat serving a model whose plugin declares input: 0, output: 0 reads 「不花额度」 even under a paid subscription tier — that's two of my four free seats here (qoder/dfmodel, under a personal_standard account). The word is accurate for what the vendor charges; the account's own windows are what the other models on it draw from, which is exactly the confusion this issue was about.
Thanks for taking it, and for the co-author credit.
Thanks @MYCF711. Shipped in v0.1.1615 (80857a66c), built on your QuotaSpan fields (you're co-author).
quotaReport now copies RunsOutAt/RunsOut, so /v1/magpie/quotas and magpie quota --json say when a window's credits run out. A free WorkBuddy account has no reset at all, so this is the only end date it has. A new test walks every JSON field of QuotaWindow. Each one has to be carried onto QuotaSpan or named as left out on purpose, with the reason, so the next new field can't be dropped quietly.
One correction: the GUI's Usage card already had runsOutAt. It reads /api/usage/quotas, which sends the window unchanged. The fields were missing only from the quotas API and the CLI's JSON. The CLI's text table still has no run-out column.
Your test didn't compile on current main (UsageWindow.Used is a *float64 now), so it was adapted. Leaving this open for you to confirm.
确认:修复在 v0.1.1615 上生效,测试与两条真机路径都复跑了。
测试 —— go test ./internal/provider/ -run 'Quota|Credits|RunsOut|Span' 全过。三处对照也做了:
quotas.go回到修复前 → 两个新测试都 FAIL(field missing)- 只删掉
quotaReport里的两处拷贝 → 两个都 FAIL(quotaReport leaves it empty) - 给
QuotaWindow加一个新字段(dummyField)→TestQuotaSpanCarriesEveryWindowField立刻点名"dummyField" isn't on QuotaSpan
第三个就是你写的那个守卫:下一个字段不能再悄悄丢。gofmt -l internal/provider 干净,go vet ./internal/provider 干净。
真机(真实账号配置的副本 + 隔离的 XDG_CONFIG_HOME/XDG_CACHE_HOME,只读;线上那份没碰):
| 修复前构建 | 修复后构建 | |
|---|---|---|
magpie quota --json |
8 个窗口,0 个带 runsOutAt |
8 个窗口,8 个带 |
GET /v1/magpie/quotas |
9 个窗口,0 个带 | 9 个窗口,8 个带 |
第 9 个是 workbuddy-ai 账号的窗口 —— 插件本身就没给它这个字段,修复前后都一样。例:133****0660 → runsOutAt 2026-11-05T02:08:52Z、runsOut 14.58,resetsAt 仍然缺席,正是免费账号的样子。
你的更正对,我复核过:用修复前的构建验 GUI 那条路,GET /api/usage/quotas 当时就已经 8/9 带 runsOutAt(它原样发 QuotaWindow,不经过 QuotaSpan)。所以「缺的只有 quotas API 和 CLI 的 JSON」是准确的;我在 issue 里把 Usage 页和托盘面板也写进受影响面,那是我写错了。
UsageWindow.Used 变 *float64(#3650)之后我那份测试确实编译不过,改编版断言的和原来一致(值、JSON 字段名、不编造 resetsAt),没有异议。CLI 文本表格仍无 run-out 列 —— --json 够用,不用动。
我这边没了,关掉。