Commit Graph
27 Commits
Author SHA1 Message Date
yetone f49f6ba686 tray: a usage window's name and unit read as its card says them (yi_time)
yi_time on Discord (Windows, v0.1.2777, magpie in Chinese): the tray
icon's tooltip said "WorkBuddy / Credits 0 / 500 credits · 已用 0% · 27 天
13 小时 后重置". The window's name and unit come from the WorkBuddy plugin
in English. The Usage page's card says both with t() (t(w.name),
t(w.unit)), so it read 积分 there, but trayCardText wrote them as given.

The fix is for every window, not WorkBuddy only:
- traywords.go reads the page's own table (embedded assets/i18n.js, once)
  and trayCardText says each window's name, and each " · " part of a
  pool's or family's name, and its count's unit, from it. The tray now
  reads as the card does in zh, zh-TW, ja and de; English is unchanged.
- i18n.js gains the window names and units plugins report that it lacked
  in every language, so the card had them in English too: Extra credits,
  Prepaid credits, Free model tokens (workbuddy); Add-on, Dedicated,
  Shared, Total credits (qoder); Monthly credits, Purchased credits,
  5-hour window (agnes); Promotional Credits (gcp-ai); Free models
  (devin); Free usage, Monthly, Included (cursor); Free trial (kiro);
  Dollar Usage (trae); Neurons/day (free allowance) (cloudflare-workers-ai);
  AI Q&A and the unit "questions" (orcaterm). Collected from
  magpie-community/plugins origin/main usage() results. No plugin change
  is needed: the plugins send English words, and magpie translates them.

Tests:
- TestTrayTooltipSaysWindowWordsAsTheCard: yi_time's card (Credits,
  0 / 500 credits, 27d 13h) gives the exact tooltip in all five languages,
  and a pool's window ("Gemini · 5 hours") is said in its parts.
- TestPluginWindowWordsSaidInEveryLanguage: each word above is in every
  language's table. TestParsePageWords: two pairs to a line, escapes, a
  comment and NOTICES left out.
- quota-window-words.test.cjs: the Usage card says WorkBuddy's and
  Qoder's window names and unit in en, zh, zh-TW, ja, de, chromium and
  webkit, 1100px and 420px.

Run at the pushed head 3886c2cc0's tree (on origin/main 84da86ebd), on mote:
- go test -run 'Tray|PageWords|PluginWindow|Translated|Budget'
  ./internal/gui: ok. GOOS=linux go vet -tags nogui ./internal/gui,
  GOOS=windows go vet ./internal/gui: ok. gofmt -l: clean.
- node --test quota-window-words, i18n-keys, quota-credits,
  quota-name-translated: 52 pass, 0 fail.
Before the rebase (on 05aba5ca4): go test ./internal/gui whole: all ok but
TestMainWindowCorners/macOS_26_SDK, which is #3949 (mote's macOS 27). The
GUI files that name any new key (credit-days, fold-show-grip,
plugin-namesake, plugin-option-words, quota-curve, usage-fold,
usage-merge, quota-pools, quota-pool-order, quota-warm, warm-reset-asleep,
warm-at-times, gateway-systemone): 250 pass, 6 fail, all in usage-fold,
en included; usage-fold fails 4 of 10 on an untouched 05aba5ca4 too
(#3415).

Broken by hand: with trayusage.go as it was, the tray test is red with
the reporter's line ("Credits 0 / 500 credits · 已用 0%"); with i18n.js as
it was, the words test and quota-window-words are red in zh, zh-TW, ja, de.

Not tried: the tooltip in a real tray on Windows; the whole GUI suite (no
layout change or API call). A window name a plugin adds later, and the
Chinese names some Chinese plugins send (积分, 限时积分), still read as sent
until i18n.js has them. A balance window's display text ("120 credits")
is the plugin's text and stays as sent, on the card too.
2026-11-03 11:38:09 +08:00
yetone eb779ce92a gui: the tray icon's tooltip is in magpie's language (yi_time)
yi_time in #feedback: magpie set to Chinese on Windows, and the tray
icon's hover tooltip said "Today: 121K tokens (2.9K in · 180 out ·
118K cached)" and "3 requests" in English. The tray menu already
followed magpie's language (trayLang, #301); the tooltip's words were
hard-coded English in trayusage.go.

Now every tooltip is in trayLang(settings.Lang, systemLang), on
Windows, macOS and Linux alike. That covers trayIdleTip, magpie's
totals (trayTotalCard), and each subscription card (trayCardText: its
use or what is left, the pace, when it resets, until's d/h/m, "as of
…"). The words are in trayWords beside the menu's, for zh, zh-TW, ja
and de; English stays the key and the fallback. A window's name and an
error are still the card's own. A change of language in Settings now
also refreshes the tooltip (onTrayUsage); before, only the menu was
relabelled. The test-only trayUsageText and trayUsageView stay in
English, so the existing tests keep their strings.

Test: TestTrayTooltipFollowsMagpiesLanguage.
- yi_time's own numbers in zh: "magpie\n今天:121K token(输入 2.9K ·
  输出 180 · 缓存 118K)\n3 个请求".
- The same numbers in en are unchanged.
- Covers the total card and a card's used, left, reset and as-of.
- For zh, zh-TW, ja and de, no English word in the idle, totals, card
  (with pace) or combined tooltips.

Run at this head (rebased on 5573f7923):
- mote: gofmt -l clean; CGO_ENABLED=0 GOOS=linux go vet -tags nogui
  and GOOS=windows go vet of ./internal/gui ok.
- mote: go test ./internal/gui. Everything passes except
  TestMainWindowCorners/macOS_26_SDK, which is #3949 (red on mote's
  macOS 27, not touched here).
- Windows (xiaomi-gpu, win-run): go test -run Tray ./internal/gui ok.

Broken by hand: with the tooltip words taken out of trayWords, the
test goes red. Its zh output is then exactly the old English tooltip.

Not tried:
- The real tray on Windows, hovering the icon.
- The watch loop's choice of language has no test of its own. Passing
  "en" there would not go red.
2026-11-03 10:14:23 +08:00
yetone 94f6f60925 tray: every window a card reports can be picked alone for the menu bar, Cursor's Grok Bot too (CrazyJal on X)
CrazyJal on X (tweet 2116833523604886006): Settings > Usage > Menu bar
windows, Cursor's pill had no choice for the Grok Bot window alone.

Why: the picker offered only the windows the menu bar shows unpicked
(trayWindows), which leaves out every window set aside. The Cursor
plugin reports Grok Bot aside (so it doesn't stop Cursor's models), so
it was never offered. And kinds were only a span ("7d"): Grok Bot and a
weekly plan's Weekly are both 7 days, as are Antigravity's two pools, so
two windows shared one kind, the GUI showed one of them, and picking it
picked both. The plugin reports the window fine; nothing changes there.

Fix (the class, every provider): trayChoices lists every window of a
card that the menu bar can say as a percent (trayCounted): the usual
ones first, then the rest (money aside, one model's window, Grok Bot),
marked TrayExtra and shown only when picked. Every choice has a kind of
its own: a usual window keeps its span's kind where it is the only one
of that span (so existing picks like claude:["5h"] keep working);
another of that span, and every extra, gets its model or name after it
("7d:grok bot", "7d:gemini · 7 days"). Unpicked, every card shows what
it showed before. The Settings pill offers the extras, and drops a pick
only when it is empty or exactly the usual windows.

Run (mote, at this tree, committed then as 0750aa783, on origin/main 15b035eef):
- go test -count=1 ./internal/gui ./internal/provider ./internal/settings:
  provider ok, settings ok; gui red only on TestMainWindowCorners,
  red the same on origin/main 15b035eef on mote (filed #3949).
- GOOS=windows go vet ./internal/gui ./internal/provider: ok. gofmt -l clean.
- win-run go test ./internal/gui -run 'TestTray|TestWithTrayKinds': ok.
- GUI (Chromium + WebKit, en/zh/zh-TW/ja/de, narrow): tray-windows 20/20;
  with i18n-keys, old-webkit, tray-usages, tray-totals, tray-cost,
  tray-logos, tray-inuse: every one ok but tray-windows' new subtest
  before its names were read through t() (fixed, then 20/20).
- No size budget touched; traywindows.js is loaded only with the menu bar.

Broken by hand: trayChoices without the extras -> TestWithTrayKinds and
TestTrayWindowsPickAside red; the old save rule (v.length < ws.length)
-> tray-windows red in every language.

Not tried: a real Cursor account in the real menu bar (the fixture is the
plugin's own window shape, index.mjs botUsage: aside, 7 days); the Linux
gui package (wsl-run lacks webkitgtk-6.0 headers to build it). A user who
picked "7d" on a card with two 7-day usual windows (Antigravity's pools)
falls back to every window and picks again; that pick was ambiguous before.

Rebased on c0477aa72 (app.js, Providers reset rows; nothing in common)
and run again at the pushed head on mote: go test ./internal/gui -run
'Budget|Tray|Size' ok; tray-windows + i18n-keys (both engines, every
language) 24/24.
2026-11-01 21:10:48 +08:00
yetone f823657d7f gui: the menu bar sums magpie's total at most once a minute (#4366)
The menu bar is read again whenever an allowance read lands, an account
answers or the agent switches account (toldUsage, servedMoved), seconds
apart on a busy day. With no cards to show, each read summed today for
the tooltip through usage.QueryPage. That read every session file's
state (readRequestState), and right after a request it hashed the
gateway log too (#4368), then built a Requests page. In KaranocaVe's
profile that was 7.2s of CPU in 30s. A total card did the same.

trayTotalSum now keeps each period's sum for a minute, for the day it
was made on. The tooltip and the cards can lag the Requests tab by up
to a minute. A new day is summed at once, and the sum is still the
Requests tab's own.

Not changed: one sum still costs a QueryPage, now at most once a minute
instead of on every wake. A Totals read that builds no page is #4366's
other suggestion; this keeps the sum exactly the page's.

Run:
- TestTrayTotalSummedOnceAMinute: 20 reads 2s apart sum once, 7d is
  its own, a minute later and past midnight sum again. With the memo
  taken out by hand it fails: "read 1: summed 2 times".
- go test -run TestTray ./internal/gui on mote (macOS 27.2): ok.
- GOOS=windows go vet, GOOS=linux -tags nogui go vet: ok. gofmt: clean.

Not tried: the reporter's profile after the change.
2026-11-01 17:50:59 +08:00
yetone f4a134d78f tray: a ticked card with no account-wide window still shows (Antigravity, nivekxft on X)
nivekxft on X: Antigravity ticked under Settings › Allowances in the menu
bar, and the Mac's menu bar showed the other three cards but none for it.

Cause: trayWindows kept only windows that are neither Aside nor a single
model's (Model set). Antigravity's card has nothing else: a window per
model, and its pools' windows ("Gemini", "Claude & GPT"), which
google.go's pools() marks Aside so routing goes on reading the
per-model windows. So trayCardText returned an empty label and an empty
tooltip, and trayCardsView dropped the card. The real card read from
quotas.json (an Antigravity Starter account, 10-31) has 13 per-model
windows and two pool 7-day windows, and nothing the old filter kept.

Fix: when a card has no account-wide window, the menu bar takes, in
order,
- trayShared: its windows over all models that routing sets aside and
  that tell a share (Antigravity's pools, named "Gemini · 7 days" as the
  Usage page names them; Ollama's plan windows, all Aside while bought
  credits carry the account),
- trayModels: else its per-model windows, the tightest of each family
  (as the Usage page shows one a family), most used first (Gemini CLI,
  whose card is per-model only; Antigravity when the pool summary can't
  be read).
Text rows, unlimited rows, wallet balances and a money figure with no
share are never shown as a percent. A card with an account-wide window
is as before. withTrayKinds now marks the windows trayWindows returns, so
Settings' window picker follows the same choice.

Siblings: Gemini CLI (per-model windows only) and Ollama with bought
credits (every window Aside) were dropped the same way and are covered.

Run (mote, at 394a92f0f + this change):
- go test -run 'Tray[^C]|WithTrayKinds|TrayAntigravity|TrayModel|TraySetAside'
  ./internal/gui: ok. The three new tests (trayusage_shared_test.go,
  fixture from the real quotas.json card) are red on the old
  trayusage.go: "cells []" each.
- go test ./internal/gui (AppKit window tests skipped/killed): reds are
  the AppKit tests killed at their deadline on mote (#4125, #2645),
  TestColdTurnsTaken (#4510), and TestSettingsSaveKeepsWhatItDoesNotSend,
  red on origin/main 394a92f0f without this change (#4514).
- gofmt -l: clean. go vet, GOOS=linux go vet -tags nogui,
  GOOS=windows go vet of ./internal/gui (and provider for linux): ok.
Not run: the full suite (another session's go test was running on
mote); GUI Playwright suites (no app.js/traywindows.js change).
Not tried: the reporter's real menu bar; the Settings window picker
with Antigravity's pool kinds in a running app.
2026-10-31 11:24:04 +08:00
yetone 7d4a631480 tray: pick which of a subscription's windows the menu bar shows (StrikingRaw on X)
Claude Pro's menu bar card drew its 5-hour and 7-day windows as two
small stacked numbers, and the user wanted one of them alone. Settings ›
Usage › Menu bar windows (under Allowances in the menu bar) lists a pill
per ticked subscription with two or more windows ("Claude Code · All
windows"), opening the app's menu: All windows, then each window. The
choice is settings.TrayWindows, by provider id (every account of it, the
in-use "|*" card too) and by window kind from the span ("5h", "1d", "7d",
"month", "15m", "name:<name>" when the span is unknown), so a vendor
reordering windows changes nothing. Unset shows every window as before;
a pick whose windows are all gone shows every window again, never an
empty card. Only the bar's rows and the Linux label are filtered; the
tooltip still says every window. One row draws at mpRowFont's 11pt
single-row size. Hidden on Windows (its tray shows no text). Per
computer through KeepOwn. The GUI learns kinds from trayKind on
/api/usage/quotas (withTrayKinds; model and aside windows get none). The
row's code is a lazily imported traywindows.js, so the core script
budget is not raised (app.js +4 lines for the call and the prefs keep).

Run:
- mote (macOS): go test -run 'TrayWindow|TrayUsage|WithTrayKinds|
  CoreScriptBudget|AppScript|TrayImage' ./internal/gui/ ok;
  ./internal/settings/ ok; davsync TestSync ok. TestTrayImageOneWindow
  draws through AppKit: Claude's card one line ("42%"), both windows two;
  the PNGs were looked at.
- mote: gofmt -l empty; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... ok; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build ok.
- magpie-desktop (Linux VM), --test-concurrency=1, BROWSER=chromium and
  webkit: tray-windows (en, zh, zh-TW, ja, de; picking All; hidden on
  Windows / single-window / no cards; 360px narrow), i18n-keys,
  old-webkit, tray-usages, tray-logos, tray-cost, quota-pace: 43/43 each.
After rebasing on ec5571d6f: the focused Go run above, davsync and vet of
the touched packages ok on mote; tray-windows, i18n-keys, old-webkit,
tray-usages 27/27 in chromium and webkit on the Linux VM.
Broken by hand: the row filter in trayCardText off -> TestTrayWindowsPicked
and TestTrayImageOneWindow red; trayWindows out of prefsKeep ->
tray-windows.test.cjs red in every language. Restored, green.
Not run: the full Go suite (owner: ship each verified fix at once; mote
was at load 20-27 under another session's full GUI suite) and the whole
GUI suite. The GUI ran on the Linux VM because mote's browsers crash or
hang under that load (#4125; TestTrayCellClickReleasedPanel is red the
same way on origin/main c84c3e1c0 there).
Not tried: the live app's real menu bar with a signed-in Claude account
(the AppKit drawer was exercised in-process instead); Linux tray label
on a real desktop.
2026-10-30 23:14:08 +08:00
yetone 1242367020 gui: the menu bar's idle tooltip splits today's tokens into input, output and cache (NextCommit on Discord)
With no cards ticked, the tooltip said only "Today: 6.3M tokens". It
now says "Today: 6.3M tokens (912K in · 318K out · 5.1M cached)" over the
cost and requests, as the usage:today card's tooltip has since #1984
(trayTokens, shared by both; cached left out when nothing was cached).

Run: TestTrayIdleTip and the SNI tip case, updated. gofmt -l clean.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 5ca37ef86b tray: Settings › Menu bar cost off shows magpie's today and 7-day totals as tokens alone, in the menu bar and its tooltip (BussanQ on Discord)
BussanQ asked for the menu bar's today card with the token count only.
A new Settings › Usage › Menu bar row, "Menu bar cost" (On by default,
segs, every OS, shown with or without cards since the no-card tooltip
says the cost too), saves settings.TrayNoCost. Off, trayMoney drops a
total's cost and its count of unpriced calls before trayTotalCard and
trayIdleTip see it, so the macOS cells and title, and the tooltip on
macOS, Windows and Linux, say the tokens and requests alone. A relay's
or subscription's balance card is money itself and stays. TrayNoCost is
per computer (KeepOwn, beside the other Tray* fields), and a change
redraws the tray (api.go). Translated in zh, zh-TW, ja and de.

Run:
- TestTrayNoCost (internal/gui): broken by hand (trayMoney a no-op) it
  fails with label "Σ47M · $128 | Σ6.3M · $3.40+", want tokens alone,
  plus the tooltip and idle tooltip.
- TestSync (internal/davsync) now sets TrayNoCost on one computer; with
  TrayNoCost left out of KeepOwn it fails "b's menu bar: … TrayNoCost:true".
- tray-cost.test.cjs: Chromium + WebKit, en/zh/zh-TW/ja/de, widths 1100
  and 420, Mac/Windows/Linux and no cards: 22/22 pass. With trayNoCost
  dropped from the prefs it fails "a save of another setting keeps the
  cost off". Also green: i18n-keys, tray-bird, tray-logos, tray-totals,
  tray-usages, tray-usage-redraw, quota-pace, tray-inuse.
- gofmt -l clean; go vet ./... and -tags nogui for GOOS=darwin, linux,
  windows clean.
- go test ./internal/tune ./internal/gui ./internal/settings ./internal/davsync
  green at this head, rebased on origin/main 95e7c6bcc.

Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
yetone 52ee847612 gui: a Linux bar's tray icon is the bird's silhouette, not the app's tile, and the tooltip says today's total (ylorn on Discord)
ylorn (Hyprland, 0.1.1241): the StatusNotifierItem's IconPixmap was the
coloured app icon on an opaque white tile, which clashed with a bar's
monochrome icons and became a solid block on bars that tint icons by
alpha; the tooltip said only "magpie".

- Linux now gets the macOS menu bar's template bird (tray.png) in one
  colour on transparency (trayIconFor / linuxTrayIcon, trayglyph.go):
  light, or dark when xdg-desktop-portal's org.freedesktop.appearance
  color-scheme is 2 (prefer light); it is set again on the portal's
  SettingChanged (watchTrayScheme, own D-Bus connection). An unreadable
  portal counts as no preference (light). No IconName is set: a host
  that resolves a -symbolic name but draws it untinted would show a
  black bird on a dark bar with no pixmap fallback. macOS keeps its
  template icon, Windows the coloured app icon.
- With no cards in the menu bar the tooltip is "magpie" over one line of
  today's total, as the panel's Usage tab sums it (trayIdleTip: all
  tokens, cost in Settings' currency, requests), refreshed with the
  cards' loop. Cards picked: unchanged.
- The menu is unchanged (Open / version / Quit): no info lines. The
  panel one click away has the models and usage, and the menu is shared
  with Windows and macOS.

Run (sandbox HOME, pinned GOMODCACHE, shared GOCACHE), on origin/main
21aa40285:
- TestTrayIconPerOS fails with Linux given appIcon back ("linux:
  (0,0)-(64,64), want the menu bar bird's (0,0)-(44,44)"); TestTrayIdleTip
  fails with the tooltip back to plain "magpie". Both pass restored, with
  TestPortalLight, TestTrayTotals, TestTrayIconSize, TestSNITipIsSafeMarkup.
- gofmt -l clean; go vet ./... (darwin), GOOS=windows go vet ./...,
  GOOS=linux go vet -tags nogui ./... clean; GOOS=windows go build and
  GOOS=linux go build -tags nogui OK.
- traytip_linux.go (linux && !nogui, cgo) can't be vetted from macOS: the
  two new functions were copied into a darwin build and vetted there.
- go test -p 4 -timeout 40m ./...: exit 0, 53 ok, no FAIL.
- GUI: tray-*.test.cjs (Playwright 1.62.0): 112/112 pass.

Not tried on a real Linux bar (the Windows box with its WSL2/Omarchy VM
was unreachable over ssh): the pixmap, its colour on a light/dark scheme
and the tooltip on waybar/Quickshell/KDE are unverified on hardware.
2026-10-15 05:30:58 +08:00
yetone 7d4ad7c628 gui: the menu bar's total is every token, cache too, marked Σ, as the Requests tab sums it (NextCommit)
NextCommit on Discord: the menu bar's usage showed only input tokens, and
more input than the Usage page. It showed input + output, unlabelled, so
it read as the input and came out above the page's input. And it was summed
as the Overview sums (usage.SummarizeTop: the gateway's calls only, cache
aside), while a click opens the panel's Usage tab, which sums the ledger
(the agents' own session-file calls too) and counts the cache's tokens
in its Tokens. Two numbers under one name.

- trayTotalSum is the ledger's cached sum, usage.QueryPage(p, {}, 0, 1).Sum,
  the one the panel's Usage tab and the window's Requests tab show.
- The cell's top row is every token (in + out + cache read + write, as
  allTokens) prefixed Σ; the cost stays under it. The tooltip spells out
  "N tokens (a in · b out · c cached)".
- With the window as the tray's, a click opens the Requests tab at the
  period (quotaView), not the Overview, which sums differently.
- docs/reference.md and gui-shell.md say so.

Run:
- TestTrayTotalIsTheLedgers (new): a Codex session-file call of 1000 in,
  200 out, 8000 cache read; the menu bar's sum equals ledgerPage's and the
  cell reads Σ9.2K. With trayTotalSum put back to SummarizeTop it fails
  (menu bar all zeros, ledger 1 call).
- TestTrayTotals/BesideCards updated for Σ, the cache and tab=requests.
- go test -tags nogui ./internal/gui (sandbox HOME via the package): ok.
- tray-totals, tray-usages, tray-cell-click .test.cjs, chromium and
  webkit, five languages, 1100 and 420: 70 pass.
- The Mac cell rendered with trayImagePNG and looked at: "Σ6.3M" over
  "$3.40", "Σ47M" alone, both inside the row width.
- gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows; builds.
Not tried: the real menu bar on the reporter's data.
2026-10-14 17:29:43 +08:00
yetone 3a7d0314a9 usage: a window's Pace as a number on its card, and in the menu bar when asked (fflake33)
fflake33 on Discord asked for the pace as a figure, "+12%" or "−8%"
against an even pace through the window, on the Usage cards and in the
menu bar.

- provider: QuotaWindow.Pace(readAt, now) is the share used (0-100) less
  the share of the window gone by, from Bounds (reset less span; a
  month's window a calendar month); none for an unlimited window, one
  whose span or reset isn't known, or outside it. WithWindowStarts sets
  startsAt on copies of the cards for the GUI (the caches' cards are
  left alone); /api/usage/quotas and its refresh send it.
- Usage page: "Pace +20%" on the reset line after the wait (quotaPace,
  paceLine), its sign turned with the meter in Left mode, amber while
  more is used than an even pace would have, what it means in its
  tooltip. Past cycles and windows with no known start show none.
- Menu bar: Settings > Menu bar pace (settings.TrayPace, off by default;
  hidden on Windows, whose tray shows no text) puts " +12%" beside each
  figure ("42% −14%", at most 10 runes, trayRowMax) and "pace −14%" in
  the tooltip. KeepOwn keeps it device-local like the other tray
  settings; the Settings save keeps it (prefsKeep).
- Strings in en, zh, zh-TW, ja, de. gui-shell.md says it.

Run:
- go test -tags nogui ./internal/provider ./internal/gui ./internal/settings
  ./internal/usage: ok; ./internal/davsync: ok (now covers TrayPace;
  red with TrayPace taken out of KeepOwn). go test ./internal/gui -run
  Tray (darwin, with the tray image tests): ok.
- New TestWindowPace, TestWithWindowStarts (input not mutated),
  TestTrayUsagePace (off unchanged, used and left, rows, tooltip).
- quota-pace.test.cjs, chromium and webkit: 4 pass; cards in en, zh,
  zh-TW, ja, de at 1100 and 420px, used and left, amber, tooltips, no
  sideways scroll, a click moves nothing; the Settings row in all five
  at both widths, On posts trayPace, a currency save keeps it, no
  scroll; hidden with no card and on Windows, shown on Linux. Red with
  paceLine not called, with trayPace out of prefsKeep, and with the
  Left-mode sign not turned.
- gui-de, gui-ja, gui-zh-tw, i18n-keys: 12 pass; tray-bird 6, quota-holds
  2, quota-read-at 4 pass.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean.
Not tried: the real menu bar on a Mac or Linux tray.
2026-10-14 13:02:48 +08:00
yetone db0af71864 gui: the menu bar can show today's or the last 7 days' tokens and cost (#1984)
Settings → Usage → "In the menu bar" lists two more rows after the
subscriptions: "Tokens and cost today" and "Tokens and cost, last 7 days",
ticked and saved as a card is (ids "usage:today", "usage:7d" in
trayUsages; provider ids are [a-z0-9-], so the prefix can't collide). They
show beside the allowances or alone.

- trayusage.go: a total is a card built from usage.SummarizeTop(p, 0)'s
  Totals (the Usage page's own cached numbers, Input+Output as its
  tokensOf counts them): tokens over cost, in the currency Settings picks,
  "+" when some requests had no known price. On the Mac it is a Plain cell
  (no vendor logo; the bird beside it says whose it is); on Windows/Linux
  the tray's text label and tooltip ("Today in magpie / 1.2M tokens (912K
  in · 318K out) / ≈$3.40+ / 152 requests…"). Quotas aren't fetched when
  only totals are picked.
- Clicked, a total opens the Usage page's Overview at its period
  (quotaView → ?view=usage&tab=usage&period=…, read and dropped from the
  URL) or the panel's Usage tab at that period (panelUseFocus).
- Only today and 7d: the Usage page has no 3-day window, and a menu-bar
  number nobody can open in magpie at the same span would disagree with it.
- The pill names a lone total, and counts a mix as "{n} shown" rather than
  calling it subscriptions. Strings in en/zh/zh-TW/ja/de.
- docs/reference.md and gui-shell.md say so.

Run:
- go test -tags nogui ./internal/gui/ (sandbox HOME): ok. The new
  TestTrayTotals/BesideCards/TrayCount went red with each piece broken by
  hand (no Plain, no text branch, no quotaView branch, 3d accepted).
- tray-totals.test.cjs (new) plus tray-usages, tray-inuse,
  proto-menu-overflow (updated for the two rows), i18n-keys, panel-usage,
  allowance-open-read, tray-cell-click: 46/46 in Chromium and WebKit, five
  languages, 1100 and 420 wide. tray-totals fails 5/5 against the old
  app.js.
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- The Mac cell image rendered and looked at (bird, "1.2M" over "$3.40").

Not tried: a real macOS menu bar, nor a Windows or Linux tray; the tray
tooltip is English, as the existing tray tooltips are.
2026-10-13 18:15:18 +08:00
yetone cd93bbec0e provider, gui: a signed-in account can be given a name of the user's own, and a GLM seat's account card keeps the key plan's name and no longer flickers back to two cards (#1515, aindijrncom)
The same GLM Coding Plan team seat was added twice: as a key provider the
user had named, and as a ZCode plugin account. The Usage page kept only the
account's card, which read "31****36@qq.com" or just "ZCode", and whenever
either read failed ("BigModel API keys: not JSON") or a window had no reset
yet, the key's card came back beside it.

Seat (the flicker): the old check returned "different" on any error. It
now returns same, different or unknown (seatMatch). A match is remembered in
seats.json beside quotas.json; while the remembered account is signed in an
unknown check keeps the key card hidden, windows that disagree forget it,
and a signed-out account brings the key card back (seatCards, used by
quotas, Allotted and CachedCards). A failed read is "unknown", never "not
the same".

Names: providers.json gains accountNames (by the account in lower case,
like accountCaps), set by provider.SetAccountName. They are magpie's own
and never written into the vendor's or a plugin's sign-in. Built-in and
plugin accounts both take one; key providers are refused. Each card carries
Alias (the user's name, else the seat) and Seat (the key provider's name,
and the key's when it has several).
- GUI: the editor's account row shows the name with the address beside
  it, or the address with "≡ <key plan>"; a click or Enter renames it in
  place (posted once to provider/accountname; Escape leaves it, empty
  clears it). The name stays selectable text: dragging across it renames
  nothing.
  The Usage page's cards and the tray panel name the account the same way.
  Hide accounts hides the name too. Strings in zh, zh-TW, ja, de.
- The tray tooltip says "ZCode · <name>".
- CLI: `magpie accounts alias <agent> <email> [<name>|--clear]`.
  `magpie accounts` and `magpie quota` show the name; quota also matches
  on it.
- /v1/magpie/quotas carries alias and seat.

Run:
- account_seats_test TestSeatKeptThroughAFailedRead fails on the old code
  ("a failed read brought the key's card back") and passes now.
  TestAccountNameOfAPluginAccount uses the fake plugin and checks that
  plugin-auth.json and logins.json are byte-for-byte unchanged.
  TestAccountsAlias checks that Codex's auth.json is unchanged.
  TestTrayNamesTheAccountByItsAlias.
- account-alias.test.cjs: Chromium and WebKit; en, zh, zh-TW, ja, de;
  900 and 360px; 20/20 pass. It covers no scroll on a click, keyboard,
  selectable text, no select, no stripe, no sideways scroll and masking.
  With the post-once guard removed it goes red. account-arrange (text
  selection) passes in both engines.
- Sandbox HOME, built binary, vendors behind a dead proxy:
  - `magpie accounts alias codex Me@Example.com 某某·GLM高级版`, then
    `magpie accounts` and `magpie quota` showed the name.
  - An unknown account was refused.
  - `magpie web` on spare ports: POST /api/provider/accountname saved
    "Team seat" (whitespace folded), and an unknown account got an error.
  - Gateway /v1/magpie/quotas and /api/usage/quotas carried the alias.
  - auth.json's sha was unchanged throughout.
- go test -tags nogui ./... (temp HOME, load ~200): all ok except
  TestSetAnswersWhileDevinAndProvidersHang (15.5s under load), which
  passes alone 3/3 at ~250ms.
- gofmt -l; GOOS=linux and GOOS=windows go vet on internal/provider,
  internal/gui and the root package.
- The whole GUI suite in Chromium and WebKit, each failed file rerun
  alone. These are red on the parent commit 472b36cec as well:
  mobile-web (9), usage-heatmap (11), old-webkit (Safari 15 :has and
  :focus-visible rules), usage-alert on WebKit (2), and routing-proxy,
  which flakes 2 of 3 runs on the base. Every other file passes alone.
Not run: a real GLM key plus a real ZCode account. The seat match against
real BigModel/ZCode answers is covered only by the fake-upstream tests.
2026-10-11 03:42:35 +08:00
yetone bc2496dca8 gui, provider: the menu bar's "Account in use" moves as soon as another account answers, and a plugin's shows the one that answered last (#1516, ikxlpz)
f5c062677 made the menu bar's account-in-use card ("codex|*") follow the
account that answered through the gateway within the last hour. Two gaps
were left:

- The tray read its cards again only every few minutes, so after the
  gateway moved to another account, or the user switched, the menu bar
  kept the old account's numbers until the next tick. NoteServed now calls
  OnServedMoved when a provider's answers move to another account or key
  (and on the first one this process sees), and SwitchLogin calls it after
  a switch; the tray loop is woken by it, as by OnSubscriptionUsage.
- A plugin's accounts (moved Kiro, Devin, ...) are no sign-in InUseLogin
  knows, so with nothing served in the last hour the first card was shown
  even when the gateway had last gone to another. trayInUseCard now takes,
  after InUseLogin, the one that answered last at any age, before the first.

Run: TestTrayInUsePluginFollowsLastServed fails without the fallback
("plugin: ... User:k1@x.y"); TestServedMovedWakesTheMenuBar fails with
the hook's firing removed ("the first answer told nobody", "b@ answering
after a@ told nobody"); both pass now, with TestTrayInUse and
TestTrayInUseFollowsWhoAnswered. go test -tags nogui ./... (-timeout 40m)
passes; gofmt -l, go vet (gui with and without nogui), GOOS=linux and
GOOS=windows go vet -tags nogui on gui, provider, autostart pass. No GUI asset changed.
Not tried with the real menu bar and two real accounts.
2026-10-11 01:20:18 +08:00
yetone f5c0626770 tray, usage: the menu bar's account in use is the one that answered last, and the Usage page's cards are told when each did (okingkee on X)
okingkee on X: three Codex accounts, the menu bar set to follow the account
in use. A used its allowance up and the gateway went on to B, but the menu
bar stayed on A; changing the first account moved it, the gateway moving
on did not. trayInUseCard asked InUseLogin, which reckons from the account
the agent is signed in to, and that lags the gateway (and under Smart it
picks any account).

- provider: SubscriptionQuota gains lastServedAt, set by Quotas
  (cardsServed) from served.json the way /v1/magpie/quotas already was,
  on this computer's own cards only and on copies, the caches untouched.
  withServed's matching moved into servedBy.at, shared by both.
  This also makes the Usage page and tray panel's "show the account that
  answered last in full" (ae6b4c93) work: it read q.lastServedAt, which the
  window's API never sent, so it always showed the first.
- tray: a "<provider>|*" card takes the provider's account that answered
  within the last hour (trayServedFresh), else InUseLogin's as before.

Run:
- TestTrayInUseFollowsWhoAnswered (A at 100% answered 40 min ago, B 1 min
  ago → B; both stale → InUseLogin's A; one account → it) fails with the
  served pick disabled and passes; TestCardsLastServed (subscription by
  user, balance with no user, a remote card left alone, inputs unwritten)
  passes; TestTrayInUse and TestQuotasLastServed unchanged and pass.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... pass.
- go test ./... passes except internal/gateway, which hit the 10m default
  timeout under this machine's load; run alone with -timeout 20m it passes
  (726s). No JS changed, so no GUI test run.
2026-10-10 22:45:01 +08:00
yetone bd45fa452a gui: Linux tray quotas reach the bar's tooltip (atie on Discord: on Omarchy, hovering magpie's tray icon showed no quota with 设置 › 用量 › 菜单栏显示额度 on, after opening the panel and restarting) — Wails v3.0.0-beta.24's Linux SetTooltip is a "TBD" no-op: the StatusNotifierItem's ToolTip stayed the {title: "magpie"} it was made with and no NewToolTip was ever sent, so every bar showed "magpie" (Omarchy's bar shows tooltipTitle before Title, waybar ToolTip before Title too, and waybar reads ToolTip again only on NewToolTip). magpie now sets the ToolTip itself after Wails' SetTooltip: through the prop.Properties Wails exported (reached by reflection, so the (sa(iiay)ss) type it was made with is kept and PropertiesChanged goes out), then sends org.kde.StatusNotifierItem.NewToolTip from the same session-bus connection. The quotas go in the title, the part both Omarchy's bar and waybar show; waybar reads it as Pango markup, so &, < and > become look-alikes (sniTip) rather than losing the whole tooltip. Until the tray is up (or should a Wails update move the field) the loop tries again next time. TestSNITipIsSafeMarkup covers the markup. In the omarchy VM (Omarchy 4, Quickshell bar), built there with -tags "production gtk3", in a sandbox HOME with the VM's DeepSeek and Kimi balance keys: the released magpie's item kept ToolTip "magpie" (Title "¥79.15 | $8.83"); this build's ToolTip is (sa(iiay)ss) "DeepSeek · ¥79.15\n\nKimi · $8.83", dbus-monitor shows PropertiesChanged then NewToolTip from the item's connection, and hovering its icon in Omarchy's bar shows both balances. Waybar itself wasn't run (the VM's Omarchy 4 has none); what it does is from its source (sni/item.cpp). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but TestProvidersAnswerWhileListsComeIn and TestClaudeSignedOut, timing tests that pass alone. 2026-10-03 20:57:39 +08:00
lizhuo ebcd5281c2 gui: open matching allowance cards from macOS menu-bar quotas (#662)
* gui: navigate menu-bar quota cells to allowance cards

* gui: fix quota navigation in lightweight and folded views

Route quota hits through the existing status-item monitor rather than relying on local monitor ordering. Recreate released panels through panelWin, and expand hidden accounts before focusing them. Keep panel headers non-draggable and cancel pending navigation after five seconds or purposeful scrolling.

Add a native AppKit subprocess regression that fails with the former nil-panel dereference and verifies runtime-queued focus, closing, and recreation. Extend browser checks for folded accounts, expiry, cancellation, and panel drag state.
2026-10-03 19:01:13 +08:00
yetone 37809ac722 usage: WorkBuddy's credits are said beside their share — on the Routing page, the Usage page and the menu bar, used or left as the share is (#659)
Moody-Sin: the Routing page showed a WorkBuddy account as "已用 71%" only, which for a plan counted in credits says little. A quota window now carries its own count when the vendor counts in amounts — amount of limit, in unit (QuotaWindow, QuotaSpan for quota --json and /v1/magpie/quotas, and the routing trace's Weighed, from the window its share is of: Allowance.Count). WorkBuddy's built-in fills it from the resource summary, and @magpie-community/opencode-workbuddy-auth 0.1.8 tells it from auth.usage (amount / limit / unit, passed through host.js); the workbuddy mover's min is 0.1.8. The Routing page's stage and its list of what each account did, the Usage page's meter, the menu bar's tooltip and the TUI say "3,550 / 5,000 credits · 71% used", or "1,450 / 5,000 credits · 29% left" with Left on (积分 in Chinese); a window counted in shares alone reads as before.

quota-credits.test.cjs (WebKit, en/zh, used/left, Routing and Usage pages) fails on the old assets and passes; TestQuotaWindowCount, TestAllowanceCount, TestTraceTellsTheCount, TestPluginUsage (the count through the host) and TestWorkBuddyAccounts cover the Go side. Tried with the real WorkBuddy and WorkBuddy AI accounts in a sandbox magpie: moved onto the local plugin, /api/usage/quotas gives 33.29 / 3900 and 13.47 / 2250 credits and the Usage page reads "33.29 / 3,900 积分 · 已用 0.9%", "3,866.71 / 3,900 积分 · 剩余 99.1%" after a click on the count; not moved, the built-in gives the same for WorkBuddy. The Routing page with two real accounts of one provider wasn't tried (one account each). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.
2026-10-03 16:45:48 +08:00
Fanbuz 5ebb053ce1 fix: 统一额度相关的中英文界面文案 (#493) 2026-10-02 09:37:00 +08:00
yetone 044f61f50f usage: a custom balance's card says when it was read, shows each of its amounts on a line of its own and a percent as a meter (#420 by emo172: 余额卡片显示读取时间、百分比进度条) — a balance read from a provider's own Balance URL showed one line, "Balance $2.00 · Today $2.50 · Used 90%", and nothing said how old it was. magpie now hands the card the amounts the user's expression names, each with its label, and a "%" one's share; the Usage page shows each on a line of its own, the user's label quiet and the first amount the larger, "Balance" only where no label was given, and a percent as the quota meter, amber from 90%. Every card that was read says so, "Updated 3 minutes ago" (3分钟前更新), and one standing in for a reading that failed just now says "As of … — couldn't be read just now" (截至 …,暂时无法获取最新用量), allowance cards too. The menu bar panel's Balances show the same amounts and meter and an amber "As of" (截至), and the tray's tooltip adds "as of …, couldn't be read just now". One amount alone reads as it did, and the balance line, the CLI and the expression syntax are unchanged. No balance URL, path or site is added: /api/usage/token and unlimited_quota are one kind of relay's and stay the user's to write. TestBalanceParts, TestTrayUsageText and balance-parts.test.cjs fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; balance-parts, click-scroll, old-webkit, quota-families, panel-usage, tray-usages, balance-fix, usage-refresh, currency, claude-usage-asked pass. 2026-10-01 19:44:44 +08:00
yetone a91385c175 gui: the menu bar's usage can go without its logos (Jevin on Discord: 为什么托盘的额度显示要带小图标啊 反而丑了一些) — on the Mac each card in the menu bar was a small logo before its stacked percentages, with no way to drop it. Settings has a Menu bar logos On/Off row under Menu bar refresh (shown on a Mac with a card picked), On by default as before; Off draws each card as its percentages alone, a faint hairline between one card and the next, and the bar is redrawn at once. TestTrayPlain, TestTrayImagePlain and tray-logos.test.cjs (Chromium, WebKit, en/zh) fail without the change; tray-usages.test.cjs clicks Currency where it is, as Playwright otherwise scrolled to it under the footer now the row sits above it. go vet, go build (darwin GUI), go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; click-scroll, old-webkit, tray-usages, tray-inuse, settings-groups, usage-alert, update-hide, currency pass. 2026-10-01 12:26:05 +08:00
yetone 52c8e838d2 providers, sign-in, tray, plugins: four of StringKe's reports on Discord — (1) Removing a provider left its editor open and listed, and a second Remove said there was no such provider: the removal had been made, but moving the agents off its models failed on one agent whose config couldn't be written, and Reseat returned that as the change's error; now such an agent is a move with its error ("still on X, not moved: …", a warning in the panel, a line in the CLI and TUI), the others are moved, and the panel, told a delete failed, re-reads the list and closes the editor when the provider is gone. (2) The sign-in waiting sheet shows the sign-in link itself, selected whole on a click, with a copy button, for a browser other than the one that opens. (3) A subscription with several accounts offers "Account in use" among the menu bar's usages, following the account the gateway goes to first. (4) The Antigravity plugin's sign-in never started: magpie called every plugin's authorize with an inputs object, the way OpenCode's CLI does, and opencode-antigravity-auth then asked its Project ID on the terminal — magpie's stdin — until the minute ran out; inputs now go only to a method with prompts, as OpenCode's TUI passes them (checked against the real package under Bun in a sandbox: the Google sign-in URL comes back at once). TestReseatUnmovable, TestTrayInUse, TestInUseOf, TestAuthorizeNoPrompts, provider-remove.test.cjs, signin-link.test.cjs and tray-inuse.test.cjs fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; click-scroll, old-webkit, tray-usages, plugin-signin, signin-callback, factory-sub pass. 2026-09-30 20:45:23 +08:00
yetone ef4edf8c58 tray: the menu bar shows several subscriptions' usage side by side (KevinXC on Discord) — Settings → Usage in the menu bar picked one card; its menu now ticks any number (kept open while ticking, saved once when it closes, Off unticks all, a ticked card that has gone stays listed to untick) and the pill says "3 subscriptions". settings.TrayUsages keeps them in order; a file with only the older trayUsage shows that one, and trayUsage is still written as the first for an older magpie. On the Mac the bird and a cell per card are drawn as one image by AppKit on the status item's button: the card's logo (a black glyph tinted in the menu bar's text colour, a coloured one as it is, the name's letter in a ring when there is none) and its two windows stacked, "42%" over "18%", in the bar's colour light or dark and sharp at any scale; the bird's flap goes through it. Arc flags run into numbers (Codex's logo) are spaced out for AppKit's SVG reader. A row longer than 10 characters (a plan's balance read from its page) is cut with an ellipsis in the bar and whole in the tooltip. Windows and Linux show the cards as text, " | " between them. TestTrayUsageCells, TestSVGArcFlags, TestTrayImage (darwin, renders 0-3 cards light and dark at 2x), TestTrayUsagesMigrate and tray-usages.test.cjs (Chromium, WebKit, en/zh) are new. go vet, go build (darwin GUI), go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./..., go test ./internal/gui pass; tray-usages, settings-groups, panel-*, click-scroll, old-webkit pass. Not seen in a live menu bar. 2026-09-30 19:45:44 +08:00
bcb9db9356 fix(gui): 用量文字与提示显示最多一位小数 (#287)
* feat(gui): 订阅用量百分比保留两位小数

Co-authored-by: Codex <codex@openai.com>

* feat(gui): 支持配置订阅用量小数位

Co-authored-by: Codex <codex@openai.com>

* fix(gui): 默认用量百分比保持整数显示

Co-authored-by: Codex <codex@openai.com>

* fix(gui): 整数用量保留原有圆环尺寸

Co-authored-by: Codex <codex@openai.com>

* fix(gui): 按原布局显示用量小数

菜单栏与圆环维持整数;仅在用量文字和提示中为非整数比例显示一位小数。移除小数位配置及相关布局调整。

Co-authored-by: Codex <codex@openai.com>

---------

Co-authored-by: louis.ning <louis.ning@nio.com>
Co-authored-by: Codex <codex@openai.com>
2026-09-30 16:37:23 +08:00
yetone e31a6a15b0 usage: the menu bar's usage is refreshed as often as asked — every 1, 3, 5, 10 or 30 minutes, 3 as before — and reads as used or left as the Usage page does; that choice is a setting now rather than the browser's, so the page, the panel and the menu bar agree, and Settings has it too; a browser's choice from before is carried over once (#122) 2026-09-28 09:27:49 +08:00
yetone a7dd920e8a tray: the terminal-only build builds again — the menu bar's usage watcher, which needs the tray, is in a file of its own left out of nogui builds; 9cbcb68 had it beside the card's text, which every build has 2026-09-27 19:33:03 +08:00
yetone 9cbcb681dd tray: a subscription's use can sit beside the icon in the menu bar — Settings → Usage in the menu bar picks one of the Usage page's cards, and its windows' use shows there ("42% · 18%", the shortest window first; a key's balance as it reads), with each window and when it starts again in the tooltip, brought up to date every few minutes from the page's own caches, so the vendors are asked no more often. Windows' tray has no room for text and shows the tooltip only. Asked for on Discord 2026-09-27 19:10:27 +08:00