Files
magpie/internal
yetoneandXudong Guo e697e7ddf6 tray: a plugin's menu bar card draws its stored picture, not its name's letter (#5772, guoxudong_ on X)
A plugin's quota card carries its picture as a stored "file:…" name
(PluginIcon → StoreIcon), and the Usage page draws it. trayIconFile, which
reads the menu bar card's logo, refused every name with a ':' in it, so
the card fell back to the name's first letter. A picture the user gave
their own provider was refused the same way.

trayIconFile now reads a "file:" name as pageIconOf, its sibling for the
day page, does: through provider.IconServed (IconFile's check, 16 hex
digits and a picture's ending, so no path of the caller's own; the
scaled copy for a big PNG/JPEG/WebP), at most maxPageIcon bytes, an SVG's
arc flags spaced out as the bundled ones are. Anything else with a
':', '/' or '\' stays refused.

Ported from sunny0826's fork (tray-plugin-logo, 080c11f98), reviewed for
harm first: no new dependency, network, or path outside the icons
folder. Changed from the fork: IconServed with the size cap and SVG
arc flags in place of a raw IconFile read; the refusal test writes each
file a refused name could reach, so it tests the check, not a missing
file.

Siblings: pageIconOf (day page) already reads stored pictures; app.js's
icon() does too; only the macOS tray draws cell logos, and every tray
goes through trayIconFile.

Run (mote, darwin arm64, at this tree):
- go test ./internal/gui ./internal/provider: ok.
- gofmt -l internal/gui: clean. go vet (darwin), GOOS=linux -tags nogui,
  GOOS=windows on internal/gui and internal/provider: ok.
- win-run TestTrayIconFileStored on xiaomi-gpu: ok (internal/gui, -run TestTrayIconFileStored).

Broken by hand:
- trayusage.go at origin/main: TestTrayIconFileStored and
  TestTrayImageStoredIcon fail (0 bytes for the stored picture).
- IconServed swapped for filepath.Join(IconDir(), own): the test reads
  "file:mine.png", "file:../providers.json" and
  "file:0123456789abcdef.exe" and goes red.

Not tried: a real plugin's card in the built app's menu bar (the fork's
author reports it drawn, light and dark); the full suite runs after the tag.

Co-authored-by: Xudong Guo <24563928+sunny0826@users.noreply.github.com>
2026-11-10 11:55:27 +08:00
..
…
…
…
…
…
…