magpie icon indicating copy to clipboard operation
magpie copied to clipboard

routing: a prepaid wallet's row tells only its total, not the windows that expire first

Open MYCF711 opened this issue 1 month ago • 3 comments

TL;DR

After #3950 a prepaid wallet can be one balance window, and a plugin can add aside detail windows (today's / timed / permanent). The Usage card shows those, but the Routing page's account row shows only the total: Weighed carries one Balance/Unit and no window detail. For SuperMagic the row reads 剩余 6,291 积分 while 185 of it expires at 23:59 today; a user routing by “who has what left” cannot see the daily batch at all.

Where the data stops today

  • The plugin sends 积分余额 (balance, unit) plus 今日 / 限时 / 永久 as aside display rows; magpie-magicrew-auth commit daca18e does this.
  • quotaOfPlugin (internal/provider/plugin_usage.go) keeps each window's Display, Balance, RunsOutAt, RunsOut.
  • allowanceOf (internal/provider/routing.go) skips Aside/Text windows whole, so the detail rows never become provider.Limit.
  • weighRouted (internal/gateway/routing.go) stores only left.bal, left.balUnit, left.balIn from Allowance.Left(model), which is the least balance of windows that tell one.
  • Weighed (internal/gateway/trace.go) carries only one Balance/Unit; the Routing UI has nothing else to render.
  • Result: Usage card shows all four rows; Routing row shows only the total.

Suggested shape

Minimal, without changing routing semantics:

  1. provider.Limit: keep the window's Display (and RunsOut/RunsOutAt) when it is the balance window.
  2. provider.Allowance: expose a BalanceDetail (or a small []Limit of the aside detail rows) beside Left; allowanceOf must not drop those rows for display.
  3. gateway.left: carry balDetail alongside bal/balUnit.
  4. trace.Weighed: add BalanceDetail (or Notes []string) to the JSON.
  5. internal/gui/assets/plugins/routing/client.js: append it to the balance row/tooltip — at least the earliest expiring balance + date, e.g. 剩余 6,291 积分 · 185 今日 23:59 到期; ideally the full 今日 / 限时 / 永久 lines when space allows.

The plugin side is ready; this is the host-side surface that was missing from #3950.

Test plan

  • Go: a plugin usage with one balance + three aside rows round-trips into QuotaWindow/Allowance/Weighed with the detail preserved; a wallet with no aside rows still reads as before.
  • GUI: a Routing fixture with a wallet balance and detail rows shows the total and the earliest expiry (and/or the three lines) on the account row; a share account is unchanged.
  • The existing routing-wallet-balance and usage-wallet-balance tests stay green.

MYCF711 avatar Oct 28 '26 01:10 MYCF711

v0.1.1817(5ced5b1aa)已修:

  • 路由页上钱包类账号那一行,现在除了总余额,还会写出最先到期的那部分,和用量页卡片一样。用你插件的数据就是「剩余 6,291 积分 · 185 积分 将于 23:59 过期」。
  • 另外说明一下:在这之前,路由页其实已经显示了今日 / 限时 / 永久这几行,鼠标停在那一行上的提示里有,账号列表里每个账号下面的小字里也有,用的都是用量页同一份数据。之前缺的只是那一行本身的文字。
  • 路由的权重还是只看总余额。今日 / 限时 / 永久这几行只用来显示。

我们没有 SuperMagic 账号,测试用的是你插件(daca18e)发出的窗口数据。更新后如果还有哪里和用量页对不上,请在这里说一声,这个 issue 先开着。

yetone avatar Oct 28 '26 04:10 yetone

Confirmed on magpie 0.1.1969 (Windows), on both halves — the data and the code.

The data still arrives in the shape this issue assumed. Read live from /v1/magpie/quotas on this machine, the SuperMagic account that matters here is:

{"name":"积分余额","balance":1682,"unit":"积分","runsOut":184,
 "runsOutAt":"2026-10-29T15:59:59Z","display":"1,682 积分"}
{"name":"今日积分","unit":"积分","text":true,"display":"184 / 200 积分 · 今日 23:59 到期"}
{"name":"限时积分","unit":"积分","text":true,"display":"498 积分 · 最早 2026-11-27 到期"}
{"name":"永久积分","unit":"积分","text":true,"display":"1,000 积分"}

(The plugin is 0.3.42 now, not the daca18e I filed against; the window shape has not changed.)

5ced5b1aa reads as you describe. quota() calls lapses(w) for a wallet seat, which looks up cardOf(w).windows for the window whose balance and unit match the seat, then appends runsOutText. Routing still weighs the total only, exactly what I asked for.

What I did not verify: the window itself. This is a Windows WebView2 build and I have no screenshot of the Routing page with those four rows. My confirmation is the code path plus the data it reads, not the pixels. If you want a screenshot before closing, say so; otherwise treat this as confirmed as far as I can check it here.

One observation rather than a complaint: lapses() returns nothing when the page is showing a kept day (const ws = day ? [] : …). That matches winsOf — a kept day's figures were read earlier and are not live — so the row loses the lapse text in the history view only. I read that as intended.

MYCF711 avatar Oct 29 '26 00:10 MYCF711

关门依据:5ced5b1aa 已在 0.1.1969 上核过——quota() 对钱包座位调 lapses(w),按 cardOf(w).windows 匹配 balance+unit 后追加 runsOutText;同一台机器的 /v1/magpie/quotas 仍按四行送(积分余额 / 今日积分 / 限时积分 / 永久积分)。窗口像素没截图,按代码路径+活数据确认。

MYCF711 avatar Oct 30 '26 06:10 MYCF711