Commit Graph
2 Commits
Author SHA1 Message Date
yetone 5e6fb27702 perf(gui): the page's mime types are added when a page is served, not at launch
gui's init called mime.AddExtensionType, and the mime package reads and
parses the system's whole type table (/etc/apache2/mime.types on macOS,
/etc/mime.types on Linux) the first time anything asks it. So every
launch, `magpie statusline` on each Claude Code message included, paid
~18,000 allocations for a table only a served page uses. Handler now
adds the types once (sync.OnceFunc) before it builds the mux.

TestAssetTypesHoldAgainstTheRegistry now sets each type wrong first and
asks Handler to set it right. The old form passed with the call removed
on both mote and the Windows box (both tables already agree), so it
guarded nothing; with the call removed the new one is red on mote
(.css, .js, .html, .svg, .png served as application/x-other).

Measured on mote, sandbox HOME, t43 (v0.1.3517) against t44 (this):
- GODEBUG=inittrace=1 sum: 4.63 MB / 46,795 allocs -> 3.94 MB / 28,742
- `magpie statusline`, 3 runs: instructions retired ~177M -> ~156M,
  peak footprint 16.4-17.0 MB -> 16.1-16.3 MB

Run: go vet ./internal/gui (darwin, GOOS=windows) ok; go test
./internal/gui ok (130s); root go vet ./... after rebase below.
2026-11-10 13:02:57 +08:00
yetone 54e8bc6e1a gui: a provider icon always draws — the page's files are served with their own types, not the ones Windows' registry gives, which another program may have changed (an SVG not served as one draws no mask icon), and a mask icon that fails to load becomes the generic one, as a picture of the user's own does. Issue #97 2026-09-27 03:44:55 +08:00