Files
magpie/internal/settings
yetone c3dc7aefba provider, settings: an idle magpie no longer parses settings.json for every account of every model's price (xsw on Discord)
xsw reported v0.1.1222 sitting at ~15% CPU while idle, with no gateway
requests. Since 8c5b9f928 (#1535, v0.1.1176), provider.All asks
settings.AccountDiscoveryOff for each account provider, and that reads
settings.json through Load, which caches the bytes but runs json.Unmarshal
on every call. agent.magpieModels prices each model under one Hold, and
each price asks All. So one pricing pass parsed settings.json models ×
accounts times. That pass runs on the GUI's drift poll (every 15s) and on
KeepDshWired (every 30s), per agent.

Evidence: `sample` of the owner's live dev build (26% average over 11.5h,
6–10% while sampled) had its top stacks in settings.loadChecked →
encoding/json under provider.All ← EntryPriceIn ← magpieModels, reached
from the drift handler and keepDshWired. A sandbox serve with an empty
config sat at 0.0%. A throwaway bench (not committed) priced 300 models
with 2 accounts: 81ms and 639 parses before, 11.5ms and 40 parses after.

All now asks once per call, from the settings the held look has already
read (heldSettings), through the new settings.AccountDiscoveryOffIn.
settings.Parses counts parses for the test, and loadChecked's comment no
longer claims the file is "parsed once".

Test: TestAllReadsNoSettingsPerLookWhileHeld prices 200 looks under one
Hold with 2 signed-in accounts and fails at >= 200 parses. Putting back
the per-account call by hand: "settings.json parsed 840 times for 200
looks at 2 accounts". With the fix: ~40, all from the first provider
build. It also checks MAGPIE_NO_ACCOUNTS=1 still hides account providers.

Run: gofmt -l; go vet -tags nogui on darwin, GOOS=linux and GOOS=windows
for internal/settings, internal/provider, internal/agent; sandbox-HOME
go test -tags nogui of those three packages, before and after rebasing
on origin/main. Other short tickers were checked (plugin host stop,
sessions readSlot, gui glide, update/claude sign-in polls): all bounded,
none run while idle.

Not run: a reproduction on xsw's machine or OS (unknown yet), a Linux or
Windows runtime CPU check, the GUI suite (no assets touched). Accounts()
still parses settings ~40 times per provider build; that is once per held
second, left for later.
2026-10-13 16:34:15 +08:00
..
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