Commit Graph
3 Commits
Author SHA1 Message Date
yetone 37f2a2851f gui: a Usage card has a refresh of its own, left of its "Updated" time, that reads that card alone (Hu9956, #840: 在更新时间左侧加一个刷新按钮,鼠标悬停在套餐卡片上时显示,可以单独刷新某个套餐的用量,不用刷新全部) — only the page's Refresh read the allowances again, every card at once. Each card now has a ↻ that opens left of "Updated 3 min ago" (or of a failed reading's reason, or under a balance) as the card is hovered; at rest the line starts where the card's others do. A click POSTs /api/usage/quotas/refresh?provider=&user=: provider.RefreshUsage reads that subscription account, plan key or balance key again (a Claude account by running Claude Code's own /usage, as the page's Refresh does) and puts it in place in the caches, the other cards not asked and kept as they were read; the button turns while it reads. zh, ja, de strings. TestRefreshOneCard (two keys of one relay and another provider: a refresh asks that key alone, the others keep their figures) and the plugin case in TestPluginUsage (one account of three read) fail on the old code; usage-card-refresh.test.cjs (WebKit, en and zh: aligned at rest, left of the time when hovered, a click reads that card alone, turns meanwhile, doesn't scroll; a failed card's own button) fails on the old code. usage-quota-head, usage-checkin, click-scroll, quota-read-at, balance-parts, claude-usage-asked, gui-ja and gui-de pass on WebKit. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-05 08:59:47 +08:00
yishu 25194cbc0d fix(provider): a Step Plan's credits show when they never reset (#460)
A monthly Step Plan (Pro, plan_family 2) has no 5-hour or weekly window,
only credits that run out with the plan. QueryStepPlanRateLimit tells them as
subscription_credit_left_rate 0.9019661 with subscription_credit_reset_time
"0", and its credit_buckets entry says next_reset_at "0". readStepPlan dropped
every window whose reset doesn't parse, so the card showed the plan's name
and end date with no window at all, while StepFun's own usage page showed
90% of the credits left.

Credits with no reset are now kept when the answer lists credit_buckets: a
window with no ResetsAt, as other credit windows already are. The 5-hour and
weekly windows are unchanged: 0 left and 0 for the reset is still no window.

TestReadStepPlan gets the real answer from a Pro account (it fails on main
with []) and a plan whose credits are 0/0 with no bucket (still no window).
With a signed-in Pro account, magpie quota stepfun-cn on main shows
"Pro · expires Oct 15  plan" with nothing after it; with the change it shows
"Credits 10%". go vet and go test -tags nogui ./internal/provider pass.
2026-10-02 02:25:11 +08:00
yetone 9e9c2ce96c providers: StepFun and StepFun (China) show the Step Plan's 5-hour, weekly and credit windows on the Usage page (StepFun 国外版跟国内版这两个provider都应该支持显示额度) — the platform tells them only to a sign-in on platform.stepfun.ai or .com, never to a key ("api key not permitted for this method"), and its session cookie is HttpOnly with no way back to an app, so the user signs in in their own browser and brings the session over: the provider's editor has a bookmarklet that, on the signed-in platform page, asks the platform to renew the session as the page does and copies it, and a box to paste it into (the Oasis-Token cookie from developer tools is taken too). magpie keeps it in stepfun-auth.json (0600), one per site, renews it before it runs out and once more when it is refused, and asks QueryStepPlanRateLimit and GetStepPlanStatus for a card with the plan, its windows and when it ends; an anonymous session, another site's, or one renewed as someone else (past the refresh token's 30 days) is not kept or shown. Tested with a fake StepFun platform (renewal, early expiry, another account, pastes of each kind), the bookmarklet run against a stubbed page, and the field in a sandbox magpie web (signed out, a bad paste, signed in, sign out); not with a real StepFun sign-in 2026-09-29 16:04:47 +08:00