Commit Graph
3 Commits
Author SHA1 Message Date
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 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