gui: Claude's menu bar cards can show Anthropic's A\ mark (qingnianxiaozhe on X)

qingnianxiaozhe asked for Anthropic's A\ in the menu bar in place of
Claude's logo. Settings › Usage › Menu bar Claude logo (Mac only, shown
while logos are on and a ticked card is Claude's, under the magpie icon
row) picks Claude's logo
(the default, unchanged) or the A\.

- settings.TrayAnthropicMark, kept per computer through KeepOwn like the
  other menu bar choices; settingsapi.Keys saves it; a change wakes the
  menu bar (onTrayUsage).
- trayAnthropic swaps the icon of cells whose card logo is claude-color
  or a plugin's claudecode-color (trayCell.Logo) for trayAnthropicMark,
  an SVG drawn here (two paths, no other app's bytes), and marks it mono
  so mpGlyph paints it in the bar's text colour. Menu bar logos off
  wins.
- The row's code is trayClaudeRow in traywindows.js (lazy). app.js only
  adds the key to prefsKeep; to stay in TestCoreScriptBudget without a
  raise, renderTrayUsage's no-card branch moved into trayWindowsRow,
  which now hides Windows' figure row itself when no card is ticked.
- en, zh, zh-TW, ja, de strings; docs/subsystems/gui-shell.md bullet.

Tests: TestTrayAnthropicMark (which cells change, input not mutated,
plain cells stay plain), TestTrayAnthropicMarkSVG,
TestTrayAnthropicMarkSaved (POST as the page does, saved and woken once
per change), TestTrayImageAnthropicMark (darwin: renders the real
AppKit image light and dark, the logo rect differs, the rest of the
image is identical), tray-anthropic-mark.test.cjs (five languages, 900
and 400px, Chromium and WebKit: row, two logos, default Claude, A\
posts true, another setting's save keeps it, back to false, no row with
no Claude card / logos off / no card / Win32, no page errors, no
sideways scroll). The GUI test waits for the redraw after a save rather
than a fixed time: a click on a control drawn before the save lands
sends the old value back (any setting, not new here).

Broken by hand: trayAnthropicMark taken out of prefsKeep turns the GUI
test red ("a save of another setting keeps the A\") in all languages;
taken out of settingsapi.Keys turns TestTrayAnthropicMarkSaved red.

Run:
- mica, at 2fa9295ed (this tree less the doc bullet): go test -timeout
  45m -count=1 ./... : 103 ok, exit 0.
- mote, at this head's code: gofmt -l clean; go vet ./...;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./... ok;
  internal/settings, settingsapi, davsync ok; internal/gui -run
  "Tray|CoreScript|Budget|EveryRoute" ok.
- mote GUI, Chromium and WebKit, the 20 files that touch the menu bar
  rows, Settings search or prefs (tray-*, settings-search, side-effort,
  searcher-pick, quota-pace, proto-menu-overflow, classify/image-timeout,
  i18n-*): tray-bird first went red (its row must follow the logos row),
  so the Claude row sits after the magpie icon row. side-effort is 5/5
  red in both engines on origin/main a922e3864 too (#6353).
- After rebasing on a922e3864, at this head: gofmt clean; go vet
  internal/gui, settings; go test -run Tray|CoreScript|Budget|EveryRoute|
  Settings internal/gui, settings, settingsapi ok; tray-anthropic-mark,
  tray-bird, tray-logos, tray-windows, tray-usages, settings-search 51/51
  in Chromium and 51/51 in WebKit.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  (routing's ", with an image" in claude_image_budget_test.go), #6877.
- Real AppKit renders of the menu bar image (trayImagePNG, light and
  dark) looked at: "A\ 42%/18%" reads at 14pt.

Not run: the whole GUI suite (mote and mica each had another session's
full GUI suite running); the files above are the ones this can reach. Not tried: a screenshot of the live menu bar of a built app.
This commit is contained in:
yetone
2026-11-17 21:50:54 +08:00
parent d54b7acf43
commit 05d46f42e5
15 changed files with 463 additions and 12 deletions
+1
View File
@@ -790,6 +790,7 @@ covers it in both engines, every language and a narrow window.
- The tray's icon is the bird alone where the bar's other icons are glyphs: the Mac's menu bar takes `tray.png` as a template image, and a Linux bar (StatusNotifierItem `IconPixmap`) gets the same silhouette in one colour on transparency (`trayIconFor`, `linuxTrayIcon` in [`trayglyph.go`](../../internal/gui/trayglyph.go)), so a bar that tints its icons by their alpha tints the bird, not a tile (ylorn on Discord). A bar that doesn't tint shows it light, or dark when the portal's `org.freedesktop.appearance` `color-scheme` prefers light (`traySchemeLight`), and it is drawn again when that changes (`watchTrayScheme`). No `IconName` is set: a host that found a `-symbolic` name and drew it untinted would show a black bird on a dark bar, with no pixmap to fall back on. Windows' tray keeps the app's coloured icon, unless a card is in the menu bar: Windows' notification area shows no text beside an icon, so the icon itself is the first card's figure (Benjaminliang_1 on X; `trayIconFigure`, `trayNumberIcon` in [`traynumber.go`](../../internal/gui/traynumber.go)). It is the first row of the first card whose first row is a percentage, used or left as Allowance display has it, through *Menu bar windows*' pick, its digits alone, drawn in Segoe UI Semibold (Go's bold where the font can't be read) at `SM_CXSMICON`, white on a dark taskbar and near black on a light one, as tall as fits with a pixel above and below, centred by its ink, and three digits narrowed into the square. A balance or magpie's totals are skipped for the next card; with none the icon is the bird. It is drawn again when the figure, the icon size or the taskbar's theme changes (`SystemThemeChanged` wakes the loop); the tooltip still says every card. Settings › *Tray icon number* (`settings.TrayNoNumber`, Windows' alone, on by default) keeps the bird when off. One icon is set for the current theme, not a light and a dark one: Wails' Windows tray shares one handle between them. Linux keeps its label and tooltip; the Mac its cells. See `TestTrayIconFigure`, `TestTrayNumberIcon` and `tray-windows.test.cjs`. With no cards in the menu bar the tooltip is magpie over today's total (`trayIdleTip`: every token, split into input, output and cache as the today card's tooltip is, then the cost and the requests), brought up to date with the cards' refresh; the tray's menu stays Open, the version and Quit. Wails sets the tooltip only on Windows: on Linux `setTrayTip` sets the StatusNotifierItem's `ToolTip` and sends `NewToolTip` ([`traytip_linux.go`](../../internal/gui/traytip_linux.go)), and on the Mac it is the status item's button's `toolTip` (`trayTipNative` in [`trayimage_darwin.go`](../../internal/gui/trayimage_darwin.go); NextCommit on Discord: no hover there showed anything). See `TestTrayIconPerOS`, `TestTrayIdleTip` and `TestMacTrayTipIsSet`. Every tooltip, the idle one, magpie's totals' and each card's (its use or what is left, the pace, when it resets, "as of …"), is in magpie's language, as the tray menu is: `watchTrayUsage` passes `trayLang(settings.Lang, systemLang)` to `trayCardsView`, `trayUsageCards` and `trayIdleTip`, whose words are in `trayWords` beside the menu's, and a change of language in Settings refreshes it at once (`onTrayUsage`). A window's name and an error are the card's own (yi_time on Discord: English on a Windows magpie set to Chinese; `TestTrayTooltipFollowsMagpiesLanguage`).
- A window's Pace is a number on its card's reset line (fflake33 on Discord): the share used less the share of the window gone by, in points, "Pace +12%" over an even pace and "−8%" under it, turned with the meter when it shows what is left, amber while more is used than an even pace would have (`quotaPace`, `paceLine`). The window's start is the gateway's, `startsAt` from `provider.WithWindowStarts` (its reset less its span, `QuotaWindow.Bounds`); a window whose span isn't known, with no limit, or a past cycle has none. Settings › *Menu bar pace* (`settings.TrayPace`, off by default, hidden on Windows, whose tray shows no text but the first card's figure as its icon) puts the same number beside each figure in the menu bar and in its tooltip (`trayPace`, `QuotaWindow.Pace`). See `TestWindowPace`, `TestTrayUsagePace` and `quota-pace.test.cjs`.
- Settings › *Menu bar windows* (`settings.TrayWindows`, StrikingRaw on X) picks which of a subscription's windows its menu bar card shows, keyed by provider id (every account of it, the in-use `|*` card too) and by window kind, not position: `trayWindowKind` names a window by its span ("5h", "1d", "7d", "month", "15m"), by `name:` its name when the span isn't known. Unset shows every window, as before; a pick none of whose kinds the card still has shows every window again (`trayShownKinds`), never an empty card. Only the bar's rows, the Linux label and Windows' icon figure are filtered; the tooltip still says every window. Every window shown is drawn, not the first two (jen_celeus on X: Antigravity's four windows, two in the bar): a card with more than two has them in columns of two stacked rows, `mpColGap` apart, the shortest windows in the first column, a third alone on its column's top line (`mpRows`, `TestTrayImageColumns`, `TestTrayEveryWindow`); the Linux label lists them all. One row draws in the menu bar's own font (13pt regular), two or more stacked rows in 10pt regular, both with digits of one width (`mpRowFont`, `TestTrayRowFont`; qingnianxiaozhe on X found the old 9.5pt semibold and 11pt medium heavier than Surge's and iStat Menus' figures beside them). The GUI learns the kinds from `trayKind` on `/api/usage/quotas` (`withTrayKinds`; model and aside windows get none). The row lists a pill per ticked subscription with two or more kinds, opening the app's menu (All windows, then each kind), shown on Windows too, where the first card's pick decides the tray icon's figure; its code is in `traywindows.js`, imported when Settings draws ticked cards. Per computer through `KeepOwn`. See `TestTrayWindowsPicked`, `TestTrayWindowsKept` and `tray-windows.test.cjs`.
- Settings › *Menu bar Claude logo* (`settings.TrayAnthropicMark`, the Mac's alone, off by default; qingnianxiaozhe on X) draws Claude's cards in the menu bar with Anthropic's A\ mark in place of Claude's logo. `trayAnthropic` swaps a cell's icon when its card's logo is Claude's (`claude-color`, or a plugin's `claudecode-color`: `trayClaudeLogos`, kept as `trayCell.Logo`) for `trayAnthropicMark`, an SVG magpie draws itself, and marks it mono, so `mpGlyph` paints it in the bar's text colour like the other glyphs. *Menu bar logos* off wins: plain cells get no logo. The row shows on a Mac while logos are on and a ticked card is Claude's (a `claude` provider before the cards are read), two logos to pick from; its code is `trayClaudeRow` in `traywindows.js`. A change wakes the menu bar (`onTrayUsage`). Per computer through `KeepOwn`. See `TestTrayAnthropicMark`, `TestTrayAnthropicMarkSaved`, `TestTrayImageAnthropicMark` and `tray-anthropic-mark.test.cjs`.
- In Usage → Allowances, Trends → Cycle offers each account's own recorded cycle menu beside its curve (`quotaCurve`, `quotaRecordedCycles` in [`app.js`](../../internal/gui/assets/app.js)). The longest window (usually weekly) owns the menu; shorter windows are drawn over the selected dates with their own reset breaks. `/api/usage/quotas/history?days=45` supplies all retained readings, including remote cards. Completed cycles come from observed boundaries, not seven-day arithmetic; an early reset ends the previous cycle at the vendor's new start if it fits between readings, otherwise at the first new reading. Each menu option gives its observed duration, so an early reset is not labelled as a full seven days. The selected meters, plot, legend, tooltip and dashed pace use that cycle's last readings, never today's percentages. A window without a reading in the selected interval says so instead of showing a current value. A local account's past cycle asks `/api/usage/quotas/history/holds?provider=&user=&from=&to=` once per selection (`quotaCycleHoldsOf`), which asks no vendor (#2009, NorethSea): `HistoricalWindowHolds` in [`window_holds_history.go`](../../internal/usage/window_holds_history.go) reckons each window's whole at its own last reading in that cycle, from the request log up to that reading, so the 5-hour figure is the cycle's last 5-hour window, never its short windows added up. Its tooltip names that window's start and the reading's time. It shows "Loading…" until the answer comes. A window it can't reckon says "not enough data" with the reason, as a current card does; a reply that comes after another cycle was picked is dropped, and a card's Refresh or an asked read reckons again. Historical meters show the cycle end and sampling time; current account actions, balances and policies are left out until returning to the current view. Accounts are independent, and a selection survives card refreshes in the same page. Trends → 2 days temporarily shows recent readings; Off removes the curves; the tray always shows its current cycle. See `quota-curve.test.cjs` and the [history limits and reset inference](providers-accounts.md#constraints-and-failure-behavior).
- The Usage page's cards are packed into columns, never all stretched to a row's height (`packUsage`, #860): each card in that order goes to the leftmost column that ends highest, on 1px grid rows, so short cards stack beside a tall one. Every card is as tall as what it holds, the last in a column too: ikunbots on X had each column's last reach down to the tallest's end, which left a card with no windows (OpenCode Zen) as tall as Claude's beside it, mostly empty, and jen_celeus on X asked for cards as tall as their content. A head with nothing under it keeps no margin below. The page's order (DOM, dragging, Alt+arrows) stays `UsageOrder`. The column count is the most 260px columns that fit, or one fewer when that leaves much less empty room; it is chosen again only when the cards change or the width fits another number of columns, so a card opened or folded stays where it is, even as the scrollbar comes in. See `usage-pack.test.cjs`.
- The Providers page has a search box over its list (#1614, `findProviders` in [`app.js`](../../internal/gui/assets/app.js)): the words typed keep the rows, on and off, whose text or data say them all: name, id, preset, addresses, every model's id and name, the account's user and plan and each login's, account names and key names. The Turned off fold stays open while searching; Escape or clearing the box shows every row and the fold as it was. A row that is on reorders by dragging its logo, Alt+↑/↓, Alt+Shift+↑/↓ (top, bottom) or its right-click menu (`openProviderMenu`: Move to top, Move up, Move down, Move to bottom). While searching, a step or a drop moves it among the rows shown (it takes the place of the row it passes, `stepProvider`, `shownToOn`) and the hidden ones keep their order; Move to top and Move to bottom go to the ends of the whole list. Every move saves the whole order through `POST /api/providers/arrange`. See `provider-find.test.cjs` and `provider-order.test.cjs`.
+2 -2
View File
@@ -191,7 +191,7 @@ func TestSync(t *testing.T) {
a, b := newComputer(t), newComputer(t)
a.use(t)
provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k1"})
settings.Save(settings.Settings{Theme: "dark", Proxy: "http://127.0.0.1:7890", Window: []int{900, 700}, TrayUsages: []string{"claude|a@b.c"}, TrayUsageEvery: 5, TrayNoLogos: true, TrayNoBird: true, TrayNoNumber: true, TrayPace: true, TrayNoCost: true, TrayWindows: map[string][]string{"claude": {"5h"}}})
settings.Save(settings.Settings{Theme: "dark", Proxy: "http://127.0.0.1:7890", Window: []int{900, 700}, TrayUsages: []string{"claude|a@b.c"}, TrayUsageEvery: 5, TrayNoLogos: true, TrayAnthropicMark: true, TrayNoBird: true, TrayNoNumber: true, TrayPace: true, TrayNoCost: true, TrayWindows: map[string][]string{"claude": {"5h"}}})
profile.Save("work", profile.Profile{Fields: map[string]string{"claude.model": "x"}})
same := cfg
same.Passphrase = cfg.Password
@@ -236,7 +236,7 @@ func TestSync(t *testing.T) {
}
// nor does a's menu bar: what shows beside the icon is b's own (yoooo
// on Discord)
if s := settings.Load(); len(s.TrayUsages) != 0 || s.TrayUsage != "" || s.TrayUsageEvery == 5 || s.TrayNoLogos || s.TrayNoBird || s.TrayNoNumber || s.TrayPace || s.TrayNoCost || s.TrayWindows != nil {
if s := settings.Load(); len(s.TrayUsages) != 0 || s.TrayUsage != "" || s.TrayUsageEvery == 5 || s.TrayNoLogos || s.TrayAnthropicMark || s.TrayNoBird || s.TrayNoNumber || s.TrayPace || s.TrayNoCost || s.TrayWindows != nil {
t.Fatalf("b's menu bar: %+v", s)
}
if ps, _ := profile.Load(); len(ps) != 1 {
+2 -2
View File
@@ -1750,13 +1750,13 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
onDock(in)
}
// the cards the menu bar shows, any of them (TrayUsage is only the first),
// how often, with their logos or not, beside the bird or not, as
// how often, with their logos or not (Claude's or Anthropic's), beside the bird or not, as
// Windows' icon or not, and
// with their Pace numbers or not, with magpie's totals' cost or not,
// which of each subscription's windows, and the language the tooltip
// is in (yi_time), and the currency its totals' cost is in
if (!slices.Equal(settings.Load().TrayUsages, cur.TrayUsages) || in.TrayUsageEvery != cur.TrayUsageEvery ||
in.TrayNoLogos != cur.TrayNoLogos || in.TrayNoBird != cur.TrayNoBird || in.TrayNoNumber != cur.TrayNoNumber || in.TrayPace != cur.TrayPace ||
in.TrayNoLogos != cur.TrayNoLogos || in.TrayAnthropicMark != cur.TrayAnthropicMark || in.TrayNoBird != cur.TrayNoBird || in.TrayNoNumber != cur.TrayNoNumber || in.TrayPace != cur.TrayPace ||
in.TrayNoCost != cur.TrayNoCost || !maps.EqualFunc(in.TrayWindows, cur.TrayWindows, slices.Equal) || in.Lang != cur.Lang || in.ChineseUnits != cur.ChineseUnits ||
in.TrayCostIn() != cur.TrayCostIn()) && onTrayUsage != nil {
onTrayUsage()
+1
View File
@@ -224,6 +224,7 @@ code { font: var(--code-style, normal) var(--code-weight, 400) 11.5px var(--code
.row .field .ic-stack .disc > .ic { width: 11px !important; height: 11px !important; }
.row .field .ic-stack .disc + .disc { margin-left: -4px; }
.ic.generic svg { width: 100%; height: 100%; }
.ic.anthropic-mark svg { width: 100%; height: 100%; display: block; }
/* ---- header --------------------------------------------------------------- */
.top { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px; height: 46px; flex: none; position: relative; }
+3 -4
View File
@@ -20818,9 +20818,8 @@ function renderTrayUsage(s, keep) {
$("#trayPaceRow").hidden = !ids.length || document.documentElement.classList.contains("win");
$("#trayPaceSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.trayPace ? "on" : "off",
(v) => savePrefs({ ...keep, trayPace: v === "on" })));
// a card's windows
if (!ids.length) $("#trayWindowsRow").hidden = $("#trayNumberRow").hidden = true;
else import("./traywindows.js").then(() => trayWindowsRow(s, keep, ids, mac), () => {});
// a card's windows, Windows' figure and Claude's logo, each gone with no card (traywindows.js)
import("./traywindows.js").then(() => trayWindowsRow(s, keep, ids, mac), () => {});
// and the cost beside magpie's own totals, in their cards and the
// tooltip, which every OS shows with or without cards (BussanQ)
$("#trayCostSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.trayNoCost ? "off" : "on",
@@ -22908,7 +22907,7 @@ function prefsKeep(s) {
codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, checkinAt: s.checkinAt || "", noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly,
replyModel: s.replyModel || "", noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudeNoExtraUsage: !!s.claudeNoExtraUsage, claudePrintMode: !!s.claudePrintMode, refusalRetries: s.refusalRetries ?? null, retryAfterCap: s.retryAfterCap ?? null,
noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload, updateChannel: s.updateChannel || "",
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", videoGen: s.videoGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd", totalCurrency: s.totalCurrency || "", trayCurrency: s.trayCurrency || "",
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayAnthropicMark: !!s.trayAnthropicMark, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", videoGen: s.videoGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd", totalCurrency: s.totalCurrency || "", trayCurrency: s.trayCurrency || "",
chineseUnits: !!s.chineseUnits, dayStart: s.dayStart || 0, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0, resetReminder: s.resetReminder || 0,
turnDoneAlert: s.turnDoneAlert || 0, maskAlert: !!s.maskAlert };
}
+8
View File
@@ -1438,6 +1438,8 @@ const I18N = {
"How often the allowances beside the icon are asked for again": "图标旁的额度多久重新获取一次",
"Menu bar logos": "菜单栏订阅图标",
"Menu bar magpie icon": "菜单栏 magpie 图标",
"Menu bar Claude logo": "菜单栏 Claude 图标",
"Claude's logo, or Anthropic's A\\ mark, before Claude's allowances": "Claude 额度前显示 Claude 的图标,或 Anthropic 的 A\\ 标志",
"Pace {n}": "配速 {n}",
"{n} more of this window is used than an even pace through it would have used by now: at this rate it runs out before it resets": "比匀速多用了 {n}:按这个速度,会在重置前用完",
"{n} less of this window is used than an even pace through it would have used by now: at this rate it lasts until it resets": "比匀速少用了 {n}:按这个速度,能撑到重置",
@@ -6831,6 +6833,8 @@ const I18N = {
"How often the allowances beside the icon are asked for again": "圖示旁的額度多久重新取得一次",
"Menu bar logos": "選單列訂閱圖示",
"Menu bar magpie icon": "選單列 magpie 圖示",
"Menu bar Claude logo": "選單列 Claude 圖示",
"Claude's logo, or Anthropic's A\\ mark, before Claude's allowances": "Claude 額度前顯示 Claude 的圖示,或 Anthropic 的 A\\ 標誌",
"Pace {n}": "配速 {n}",
"{n} more of this window is used than an even pace through it would have used by now: at this rate it runs out before it resets": "比勻速多用了 {n}:照這個速度,會在重置前用完",
"{n} less of this window is used than an even pace through it would have used by now: at this rate it lasts until it resets": "比勻速少用了 {n}:照這個速度,能撐到重置",
@@ -15787,6 +15791,8 @@ const I18N = {
"API · Month": "API · 今月",
"Video · 7 days": "動画 · 7 日",
"Menu bar magpie icon": "メニューバーの magpie アイコン",
"Menu bar Claude logo": "メニューバーの Claude アイコン",
"Claude's logo, or Anthropic's A\\ mark, before Claude's allowances": "Claude の使用枠の前に Claude のロゴ、または Anthropic の A\\ マークを表示します",
"Pace {n}": "ペース {n}",
"{n} more of this window is used than an even pace through it would have used by now: at this rate it runs out before it resets": "均等なペースより {n} 多く使っています。このペースだとリセット前に使い切ります",
"{n} less of this window is used than an even pace through it would have used by now: at this rate it lasts until it resets": "均等なペースより {n} 少なく使っています。このペースならリセットまで持ちます",
@@ -17566,6 +17572,8 @@ const I18N = {
"How often the allowances beside the icon are asked for again": "Wie oft die Kontingente neben dem Symbol neu abgefragt werden",
"Menu bar logos": "Logos in der Menüleiste",
"Menu bar magpie icon": "magpie-Symbol in der Menüleiste",
"Menu bar Claude logo": "Claude-Logo in der Menüleiste",
"Claude's logo, or Anthropic's A\\ mark, before Claude's allowances": "Vor Claudes Kontingenten Claudes Logo oder das A\\-Zeichen von Anthropic",
"Pace {n}": "Tempo {n}",
"{n} more of this window is used than an even pace through it would have used by now: at this rate it runs out before it resets": "{n} mehr von diesem Fenster verbraucht, als ein gleichmäßiges Tempo bis jetzt verbraucht hätte: So ist es vor dem Zurücksetzen aufgebraucht",
"{n} less of this window is used than an even pace through it would have used by now: at this rate it lasts until it resets": "{n} weniger von diesem Fenster verbraucht, als ein gleichmäßiges Tempo bis jetzt verbraucht hätte: So reicht es bis zum Zurücksetzen",
+4
View File
@@ -319,6 +319,10 @@
<div class="who"><div class="name" data-t>Menu bar magpie icon</div><div class="sub" data-t>magpie's icon before the allowances; off, the allowances alone, and a click on one still opens the panel</div></div>
<div id="trayBirdSegs"></div>
</div>
<div class="row pref" id="trayClaudeRow" hidden>
<div class="who"><div class="name" data-t>Menu bar Claude logo</div><div class="sub" data-t>Claude's logo, or Anthropic's A\ mark, before Claude's allowances</div></div>
<div id="trayClaudeSegs"></div>
</div>
<div class="row pref" id="trayPaceRow" hidden>
<div class="who"><div class="name" data-t>Menu bar pace</div><div class="sub" data-t>Each window's Pace number beside its figure, as on the Usage page: +12% is 12% more of the window used than an even pace would have used by now, −8% that much less</div></div>
<div id="trayPaceSegs"></div>
+32 -2
View File
@@ -1,4 +1,4 @@
// Settings › Menu bar windows, and Windows' Tray icon number. app.js imports this only when the menu bar
// Settings › Menu bar windows, Menu bar Claude logo, and Windows' Tray icon number. app.js imports this only when the menu bar
// shows a card (renderTrayUsage), so it weighs nothing on the core.
// which of a subscription's windows its menu bar card shows, by kind
@@ -9,9 +9,10 @@
window.trayWindowsRow = function trayWindowsRow(s, keep, ids, mac) {
// Windows' tray shows no text: the first card's figure is its icon, or
// the bird (Benjaminliang_1 on X)
$("#trayNumberRow").hidden = !document.documentElement.classList.contains("win");
$("#trayNumberRow").hidden = !ids.length || !document.documentElement.classList.contains("win");
$("#trayNumberSegs").replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s.trayNoNumber ? "off" : "on",
(v) => savePrefs({ ...keep, trayNoNumber: v === "off" })));
trayClaudeRow(s, keep, ids, mac);
const pick = s.trayWindows || {}, box = $("#trayWindowsPick"), subs = [];
for (const pid of new Set(ids.filter((id) => !id.startsWith("usage:")).map((id) => id.split("|")[0]))) {
const ws = [], q = (quotas || []).find((q) => q.provider === pid);
@@ -39,3 +40,32 @@ window.trayWindowsRow = function trayWindowsRow(s, keep, ids, mac) {
return b;
}));
};
// the logos of Claude's cards (gui.trayClaudeLogos)
const TRAY_CLAUDE_LOGOS = ["claude-color", "claudecode-color"];
// Claude's cards in the Mac's menu bar with Claude's logo or Anthropic's
// A\ (settings.TrayAnthropicMark, qingnianxiaozhe on X): asked only where a
// ticked card is Claude's and the logos are shown. Until the cards are read,
// a Claude Code one goes by its id.
function trayClaudeRow(s, keep, ids, mac) {
const claude = ids.some((id) => {
const q = (quotas || []).find((q) => trayCardID(q) === id || q.provider + IN_USE === id);
return q ? TRAY_CLAUDE_LOGOS.includes(q.icon) : id.split("|")[0] === "claude";
});
$("#trayClaudeRow").hidden = !mac || !!s.trayNoLogos || !claude;
const opt = (logo, name) => {
logo.setAttribute("role", "img");
logo.setAttribute("aria-label", name);
return logo;
};
$("#trayClaudeSegs").replaceChildren(segs([["claude", opt(icon("claude-color"), "Claude")], ["anthropic", opt(anthropicMark(), "Anthropic")]],
s.trayAnthropicMark ? "anthropic" : "claude", (v) => savePrefs({ ...keep, trayAnthropicMark: v === "anthropic" })));
}
// Anthropic's A\ as the menu bar draws it (gui.trayAnthropicMark)
function anthropicMark() {
const e = el("span", "ic anthropic-mark");
e.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" fill-rule="evenodd" d="M0.6 20 6.84 4h3.6l6.24 16h-3.4l-1.4-3.6H5.4L4 20Zm6.05-6.8h3.98L8.64 8.1Z"/><path fill="currentColor" d="M12.84 4h3.4l6.24 16h-3.4Z"/></svg>';
return e;
}
@@ -0,0 +1,181 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Settings → Menu bar Claude logo (qingnianxiaozhe on X: Anthropic's A\ in
// the menu bar): on a Mac with a Claude card in the menu bar and its logos
// shown, a row of two logos, Claude's and the A\; the A\ posts
// trayAnthropicMark and Claude's takes it back; a save of another setting
// keeps it; no row without a Claude card, with the logos off, nor off a
// Mac. Every language, wide and narrow; no backend, the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const { openPart } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
const quotas = [
{ provider: "claude", name: "Claude Code", icon: "claude-color", user: "a@b.c", plan: "Max",
windows: [{ name: "5-hour", used: 42 }, { name: "Weekly", used: 18 }] },
{ provider: "codex", name: "Codex", icon: "codex-color", user: "x@y.z", plan: "Pro",
windows: [{ name: "5-hour", used: 8 }, { name: "Weekly", used: 30 }] },
];
function settingsPayload(over) {
return {
theme: "light", lang: "en", tray: "panel", quotaLeft: false, currency: "usd",
dock: false, dockWindow: false, proxy: "", redact: false, redactPersonal: false, redactWords: [],
codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "", workbuddyCheckin: false, noStats: false,
trayUsage: "claude|a@b.c", trayUsages: ["claude|a@b.c", "codex|x@y.z"], trayUsageEvery: 3, vision: "", imageGen: "",
version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425",
proxyNow: "none", proxySource: "none", login: false,
visionModels: [], imageGenModels: [], workbuddyCheckins: [], lanURLs: [],
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
...over,
};
}
function server(lang, posts, over) {
let cur = settingsPayload({ lang, ...over });
return async (route) => {
const req = route.request(), url = new URL(req.url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" }, fx: cur.fx });
if (url.pathname === "/api/settings") {
if (req.method() === "POST") {
const body = req.postDataJSON();
posts.push(body);
cur = { ...cur, ...body, trayUsage: (body.trayUsages || [])[0] || "" };
}
return json(cur);
}
if (url.pathname === "/api/usage/quotas") return json(quotas);
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
await route.fulfill({ body: await fs.readFile(file), contentType });
};
}
async function open(browser, lang, posts, platform, over, width = 900) {
const context = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" });
await context.addInitScript((p) => Object.defineProperty(Navigator.prototype, "platform", { get: () => p }), platform);
const page = await context.newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
await page.route("**/*", server(lang, posts, over));
await page.goto("http://magpie.test/?view=usage");
await page.locator("#prefs").click();
await openPart(page, "usage");
await page.locator("#trayUsagePick button").waitFor();
return { context, page };
}
const posted = async (page, posts, sent) => {
for (let i = 0; i < 50 && posts.length === sent; i++) await page.waitForTimeout(50);
assert(posts.length > sent, "nothing was posted");
return posts.at(-1);
};
const names = {
en: "Menu bar Claude logo",
zh: "菜单栏 Claude 图标",
"zh-TW": "選單列 Claude 圖示",
ja: "メニューバーの Claude アイコン",
de: "Claude-Logo in der Menüleiste",
};
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
test(engine + ": Claude's menu bar logo or Anthropic's A\\", async (t) => {
assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit");
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const pages = [];
t.after(async () => {
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
for (const [i, p] of pages.entries()) await p.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-tray-anthropic-mark-${i}.png`) }).catch(() => {});
}
await browser.close();
});
for (const [lang, name] of Object.entries(names)) for (const width of [900, 400]) {
await t.test(lang + " " + width, async () => {
const errors = [], posts = [];
const { context, page } = await open(browser, lang, posts, "MacIntel", {}, width);
pages.push(page);
page.on("pageerror", (e) => errors.push(e.message));
const row = page.locator("#trayClaudeRow");
await row.waitFor();
assert.equal((await row.locator(".name").textContent()).trim(), name);
const sub = (await row.locator(".sub").textContent()).trim();
assert.match(sub, /A\\/, "the sub names the A\\ mark: " + sub);
const opts = row.locator("#trayClaudeSegs .opt");
assert.equal(await opts.count(), 2);
assert.deepEqual(await opts.evaluateAll((bs) => bs.map((b) => b.querySelector("[aria-label]")?.getAttribute("aria-label"))), ["Claude", "Anthropic"]);
// each a logo drawn, the A\ in the text's colour
for (const i of [0, 1]) {
const box = await opts.nth(i).locator(".ic").boundingBox();
assert(box && box.width >= 12 && box.height >= 12, "logo " + i + " drawn: " + JSON.stringify(box));
}
assert.equal(await opts.nth(1).locator("path").first().evaluate((p) => p.getAttribute("fill")), "currentColor");
// Claude's logo, as before
assert.equal(await opts.nth(0).evaluate((b) => b.classList.contains("on")), true, "Claude's logo by default");
// narrow, the row's control stays in the row and the page doesn't scroll sideways
await row.scrollIntoViewIfNeeded();
const [rb, sb] = await Promise.all([row.boundingBox(), page.locator("#trayClaudeSegs").boundingBox()]);
assert(sb.x >= rb.x - 1 && sb.x + sb.width <= rb.x + rb.width + 1, `the logos ${JSON.stringify(sb)} past the row ${JSON.stringify(rb)}`);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "the page scrolls sideways");
// the page is drawn again once a save is in; a control from before
// that still carries the choices from before (savePrefs)
const mark = () => page.evaluate(() => { document.querySelector("#currencySegs .opt").stale = true; });
const redrawn = () => page.waitForFunction(() => !document.querySelector("#currencySegs .opt")?.stale);
await mark();
await opts.nth(1).click();
assert.equal((await posted(page, posts, 0)).trayAnthropicMark, true, "the A\\ posts trayAnthropicMark");
await redrawn();
assert.equal(await page.locator("#trayClaudeSegs .opt").nth(1).evaluate((b) => b.classList.contains("on")), true, "the A\\ shown as chosen");
// another setting saved keeps it
let sent = posts.length;
await mark();
await page.locator("#currencySegs .opt").nth(1).evaluate((b) => b.click());
const other = await posted(page, posts, sent);
assert.equal(other.currency, "cny");
await redrawn();
assert.equal(other.trayAnthropicMark, true, "a save of another setting keeps the A\\");
// and Claude's takes it back
sent = posts.length;
await row.scrollIntoViewIfNeeded();
await page.locator("#trayClaudeSegs .opt").nth(0).click();
assert.equal((await posted(page, posts, sent)).trayAnthropicMark, false, "Claude's logo posts it back");
assert.deepEqual(errors, []);
await context.close();
});
}
await t.test("no row", async () => {
// no Claude card, the logos off, no card at all, or not a Mac
for (const [platform, over] of [
["MacIntel", { trayUsage: "codex|x@y.z", trayUsages: ["codex|x@y.z"] }],
["MacIntel", { trayNoLogos: true }],
["MacIntel", { trayUsage: "", trayUsages: [] }],
["Win32", {}],
]) {
const { context, page } = await open(browser, "en", [], platform, over);
await page.waitForTimeout(300);
assert.equal(await page.locator("#trayClaudeRow").isVisible(), false, platform + " " + JSON.stringify(over));
await context.close();
}
// the account in use stands for Claude's cards too
const { context, page } = await open(browser, "en", [], "MacIntel", { trayUsage: "claude|*", trayUsages: ["claude|*"] });
await page.locator("#trayClaudeRow").waitFor();
await context.close();
});
});
}
@@ -0,0 +1,66 @@
//go:build darwin && cgo
package gui
import (
"bytes"
"image"
"image/png"
"os"
"testing"
"time"
)
// AppKit draws the A\ mark where Claude's logo was, in the bar's ink on
// light and dark bars alike: the logo's square differs from Claude's, and
// the digits beside it are where they were. MAGPIE_TRAY_PNG names a folder
// to write the images to, to look at them.
func TestTrayImageAnthropicMark(t *testing.T) {
cells, _, _ := trayUsageView(trayCards()[:2], time.Now(), false, false)
marked := trayAnthropic(cells)
for _, dark := range []bool{false, true} {
cb, cw, ch := trayImagePNG(cells, nil, 22, 2, dark, true)
ab, aw, ah := trayImagePNG(marked, nil, 22, 2, dark, true)
if cw != aw || ch != ah {
t.Fatalf("dark %v: %dx%d with Claude's logo, %dx%d with the mark", dark, cw, ch, aw, ah)
}
if dir := os.Getenv("MAGPIE_TRAY_PNG"); dir != "" {
name := map[bool]string{false: "light", true: "dark"}[dark]
os.WriteFile(dir+"/claude-"+name+".png", cb, 0o644)
os.WriteFile(dir+"/anthropic-"+name+".png", ab, 0o644)
}
claude, err := png.Decode(bytes.NewReader(cb))
if err != nil {
t.Fatal(err)
}
mark, err := png.Decode(bytes.NewReader(ab))
if err != nil {
t.Fatal(err)
}
// the first logo: 14pt at 2x from the left edge
logo := image.Rect(0, 0, 28, ah)
if ink := inkIn(mark, logo, dark); ink < 150 {
t.Errorf("dark %v: %d px of the mark's ink", dark, ink)
}
if differ := pxDiffer(claude, mark, logo); differ < 50 {
t.Errorf("dark %v: the mark differs from Claude's logo in %d px", dark, differ)
}
if differ := pxDiffer(claude, mark, image.Rect(30, 0, aw, ah)); differ > 0 {
t.Errorf("dark %v: %d px differ past the first logo", dark, differ)
}
}
}
func pxDiffer(a, b image.Image, r image.Rectangle) int {
n := 0
for y := r.Min.Y; y < r.Max.Y; y++ {
for x := r.Min.X; x < r.Max.X; x++ {
ar, ag, ab, aa := a.At(x, y).RGBA()
br, bg, bb, ba := b.At(x, y).RGBA()
if ar != br || ag != bg || ab != bb || aa != ba {
n++
}
}
}
return n
}
+26
View File
@@ -747,6 +747,7 @@ func trayName(q provider.SubscriptionQuota) string {
// "18%"), in columns of two when it has more, or its balance alone.
type trayCell struct {
ID string // stable provider/account identity, captured with the drawn cell
Logo string // the card's icon name ("claude-color"), as the Usage page names it
Icon []byte // the logo as the Usage page has it (SVG or PNG); nil for none
Mono bool // a black glyph, drawn in the menu bar's text colour
Letter string // drawn in its place when there is no logo, or it can't be read
@@ -764,6 +765,30 @@ func trayPlain(cells []trayCell) []trayCell {
return out
}
// trayClaudeLogos are the logos of Claude's cards: Claude Code's
// subscription, and a plugin's that signs in to Anthropic.
var trayClaudeLogos = []string{"claude-color", "claudecode-color"}
// trayAnthropic are the cells with Anthropic's "A\" mark in place of
// Claude's logo (settings.TrayAnthropicMark): a black glyph, drawn in the
// menu bar's text colour as every logo there is.
func trayAnthropic(cells []trayCell) []trayCell {
out := slices.Clone(cells)
for i, c := range out {
if !c.Plain && slices.Contains(trayClaudeLogos, c.Logo) {
out[i].Icon, out[i].Mono = trayAnthropicMark, true
}
}
return out
}
// trayAnthropicMark is Anthropic's mark drawn here, not taken from any
// file of theirs: a bold "A" whose legs slant as its counter does, and a
// backslash of the same weight and slant beside it.
var trayAnthropicMark = []byte(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">` +
`<path fill="#000" fill-rule="evenodd" d="M0.6 20 6.84 4h3.6l6.24 16h-3.4l-1.4-3.6H5.4L4 20Zm6.05-6.8h3.98L8.64 8.1Z"/>` +
`<path fill="#000" d="M12.84 4h3.4l6.24 16h-3.4Z"/></svg>`)
// trayUsageView is trayCardsView with every window shown, in English.
func trayUsageView(cards []provider.SubscriptionQuota, now time.Time, left, pace bool) (cells []trayCell, label, tip string) {
return trayCardsView("en", cards, now, left, pace, nil)
@@ -795,6 +820,7 @@ func trayCardsView(lang string, cards []provider.SubscriptionQuota, now time.Tim
cells = append(cells, c)
continue
}
c.Logo = q.Icon
c.Icon, c.Mono = trayIconFile(q.Icon)
if r := []rune(strings.TrimSpace(q.Name)); len(r) > 0 {
c.Letter = strings.ToUpper(string(r[0]))
+129
View File
@@ -0,0 +1,129 @@
package gui
import (
"bytes"
"encoding/json"
"encoding/xml"
"io"
"net/http"
"net/http/httptest"
"path/filepath"
"slices"
"testing"
"time"
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/settings"
)
// Claude's cards can show Anthropic's A\ in the menu bar in place of
// Claude's logo (settings.TrayAnthropicMark, qingnianxiaozhe on X): the
// mark, a black glyph in the bar's colour, goes on Claude Code's card and a
// plugin's with Claude's logo, and every other card keeps its own.
func TestTrayAnthropicMark(t *testing.T) {
cards := append(trayCards(), provider.SubscriptionQuota{Provider: "anthropic-plugin", Name: "Anthropic", Icon: "claudecode-color",
Windows: []provider.QuotaWindow{{Name: "5-hour", Used: 3, Span: 5 * time.Hour}}})
cells, _, _ := trayUsageView(cards, time.Now(), false, false)
marked := trayAnthropic(cells)
if len(marked) != len(cells) {
t.Fatalf("%d cells, want %d", len(marked), len(cells))
}
for i, c := range marked {
claude := cells[i].Logo == "claude-color" || cells[i].Logo == "claudecode-color"
if claude != (i == 0 || i == len(cells)-1) {
t.Fatalf("cell %d's logo %q", i, cells[i].Logo)
}
if claude {
if !bytes.Equal(c.Icon, trayAnthropicMark) || !c.Mono {
t.Errorf("cell %d (%s): mono %v, %d bytes, not the A\\ mark", i, c.ID, c.Mono, len(c.Icon))
}
} else if !bytes.Equal(c.Icon, cells[i].Icon) || c.Mono != cells[i].Mono {
t.Errorf("cell %d (%s) lost its own logo", i, c.ID)
}
if c.ID != cells[i].ID || c.Letter != cells[i].Letter || !slices.Equal(c.Rows, cells[i].Rows) {
t.Errorf("cell %d changed beside its logo: %+v", i, c)
}
// the cells drawn with Claude's logo are left as they were
if claude && bytes.Equal(cells[i].Icon, trayAnthropicMark) {
t.Errorf("cell %d: the cells given were changed", i)
}
}
// without logos there is none to swap
for i, c := range trayAnthropic(trayPlain(cells)) {
if c.Icon != nil || c.Mono {
t.Errorf("plain cell %d got a logo", i)
}
}
}
// The mark is an SVG AppKit reads (the menu bar's NSImage) and the page
// draws: well-formed, square, filled black, nothing fetched.
func TestTrayAnthropicMarkSVG(t *testing.T) {
d := xml.NewDecoder(bytes.NewReader(trayAnthropicMark))
paths := 0
for {
tok, err := d.Token()
if err == io.EOF {
break
}
if err != nil {
t.Fatal(err)
}
if se, ok := tok.(xml.StartElement); ok && se.Name.Local == "path" {
paths++
}
}
if paths != 2 || !bytes.Contains(trayAnthropicMark, []byte(`viewBox="0 0 24 24"`)) || bytes.Contains(trayAnthropicMark, []byte("href")) {
t.Fatalf("the mark: %s", trayAnthropicMark)
}
}
// Settings saves the choice, and the menu bar is drawn again at once with
// it, not at its next tick.
func TestTrayAnthropicMarkSaved(t *testing.T) {
h := t.TempDir()
t.Setenv("HOME", h)
t.Setenv("USERPROFILE", h)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(h, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache"))
t.Setenv("APPDATA", filepath.Join(h, "AppData", "Roaming"))
t.Setenv("LOCALAPPDATA", filepath.Join(h, "AppData", "Local"))
woke := 0
was := onTrayUsage
onTrayUsage = func() { woke++ }
t.Cleanup(func() { onTrayUsage = was })
// as the page posts: every setting it was drawn with (prefsKeep), one changed
post := func(on bool) *httptest.ResponseRecorder {
var body map[string]any
b, _ := json.Marshal(settings.Load())
if err := json.Unmarshal(b, &body); err != nil {
t.Fatal(err)
}
body["trayAnthropicMark"] = on
b, _ = json.Marshal(body)
rec := httptest.NewRecorder()
Handler(nil, nil).ServeHTTP(rec, httptest.NewRequest("POST", "/api/settings", bytes.NewReader(b)))
return rec
}
post(false) // the page's first save, everything as it is
woke = 0
for _, c := range []struct {
on bool
woke int
}{
{true, 1},
{true, 1}, // saved again unchanged
{false, 2},
} {
rec := post(c.on)
if rec.Code != http.StatusOK {
t.Fatalf("%v: %d %s", c.on, rec.Code, rec.Body)
}
if got := settings.Load().TrayAnthropicMark; got != c.on {
t.Fatalf("after %v the mark is %v", c.on, got)
}
if woke != c.woke {
t.Fatalf("after %v the menu bar was woken %d times, want %d", c.on, woke, c.woke)
}
}
}
+2
View File
@@ -53,6 +53,8 @@ func (h *host) watchTrayUsage() {
cancel()
if s.TrayNoLogos {
cells = trayPlain(cells)
} else if s.TrayAnthropicMark {
cells = trayAnthropic(cells)
}
if tip == "" {
currency, rate := trayCurrency()
+5 -1
View File
@@ -712,6 +712,10 @@ type Settings struct {
// cards are there, the cards alone (KevinXC on Discord); a click on one
// still opens the panel, and with no cards the bird is shown.
TrayNoBird bool `json:"trayNoBird,omitempty"`
// TrayAnthropicMark draws Claude's cards in the Mac menu bar with
// Anthropic's "A\" mark in place of Claude's logo (qingnianxiaozhe on
// X); off by default, Claude's logo as the Usage page has it.
TrayAnthropicMark bool `json:"trayAnthropicMark,omitempty"`
// TrayNoNumber keeps magpie's icon in Windows' tray while cards are
// picked; off by default, the icon is the first card's figure
// (Benjaminliang_1 on X), as Windows' tray shows no text beside it.
@@ -1813,7 +1817,7 @@ func (s *Settings) KeepOwn(cur Settings) {
s.WindowMaximised, s.KeepAwake, s.KeepAwakeDisplay = cur.WindowMaximised, cur.KeepAwake, cur.KeepAwakeDisplay
s.WindowAt, s.OnTop = cur.WindowAt, cur.OnTop
s.TrayUsages, s.TrayUsage, s.TrayUsageEvery, s.TrayNoLogos, s.TrayNoBird, s.TrayPace, s.TrayNoCost = cur.TrayUsages, cur.TrayUsage, cur.TrayUsageEvery, cur.TrayNoLogos, cur.TrayNoBird, cur.TrayPace, cur.TrayNoCost
s.TrayWindows, s.TrayNoNumber, s.TrayCurrency = cur.TrayWindows, cur.TrayNoNumber, cur.TrayCurrency
s.TrayWindows, s.TrayNoNumber, s.TrayCurrency, s.TrayAnthropicMark = cur.TrayWindows, cur.TrayNoNumber, cur.TrayCurrency, cur.TrayAnthropicMark
s.GatewayMode = cur.GatewayMode
s.NoWSLAgents = cur.NoWSLAgents
s.QuotaReads = cur.QuotaReads
+1 -1
View File
@@ -33,7 +33,7 @@ var Keys = []string{
"tray", "dock", "dockWindow", "dockNever", "lightweight", "keepAwake", "keepAwakeDisplay",
"noWSLAgents", "sessionTerminal", "signInLinkOnly", "quitNoAsk", "restoreOnQuit", "name",
// the menu bar's allowance cards
"trayUsages", "trayUsage", "trayUsageEvery", "trayNoLogos", "trayNoBird", "trayNoNumber", "trayPace", "trayNoCost", "trayWindows",
"trayUsages", "trayUsage", "trayUsageEvery", "trayNoLogos", "trayAnthropicMark", "trayNoBird", "trayNoNumber", "trayPace", "trayNoCost", "trayWindows",
// usage and alerts
"currency", "totalCurrency", "trayCurrency", "chineseUnits", "dayStart", "usageAlert", "balanceAlert", "resetReminder", "turnDoneAlert", "maskAlert",
// network