chen2652 (Discord #help) reported that Open Design's icon is almost invisible
in dark mode, with no browser dark-mode extension on. The icon is the plugin's
own picture, open-design.ai/favicon.svg: a single fill, #26251E, drawn as an
<img> on the dark card (#232327).
Now icon() judges each picture once, after the picture's own load, so lazy
loading is kept (#909). The result is cached per src. If every opaque pixel
of a picture is one tone (the range of each channel is at most 24), and that
tone is near-black (every channel at most 72) or near-white (every channel at
least 224), the picture is replaced by maskSpan, the way a mono logo is drawn:
a mask in the text colour. This holds on any ground, Omarchy's themes
included. It covers user pictures (file:), plugin pictures, and bundled
-color and PNG icons.
Audit: every bundled picture icon, plus the plugin registry's pictures, was
measured in CIELAB against #232327 and #fff. Two were invisible in dark mode:
Open Design's plugin picture and bundled voyage-color.svg (#012E33, in the
provider icon picker). Both are now masks. Multi-tone and tiled logos stay as
they are (pipellm, zcode, mothx, deepinfra and others: low contrast in places
but readable). Mono icons were masks already.
Test: icon-one-tone.test.cjs, with the real favicon bytes in fixtures/.
- It draws every picture logo on the dark and the light card and measures,
on a screenshot, how much of each stands apart from the ground.
- It opens Open Design's Installed row on the Plugins page and checks that it
is a mask in the icon's text colour and visible in both themes: 5
languages, 980px and 420px, Chromium and WebKit.
icon-url and icon-url-saved served a plain black square as the fetched
picture. That square is one tone, so it is now a mask. Their fixture is now a
coloured tile, like the letter icons the server makes (favicon.go).
Run (on mote unless named):
- icon-one-tone: 48/48. The 14 icon/theme GUI files (icon-tile,
plugin-own-icon, mono-icon-redraw, plugin-registry-icon,
models-add-and-icons, market-icon-corners, request-provider-icon,
routing-client-icons, routing-log-icons, tray-logos, api-key-theme,
icon-url, icon-url-saved, icon-one-tone): green in both engines.
- go test ./internal/gui -run 'Budget|I18n|Asset', gofmt -l,
GOOS=linux go vet -tags nogui and GOOS=windows go vet of ./internal/gui:
all clean, and no size budget was raised.
- A whole GUI suite on Linux (WSL) was cut off when the SSH connection to
xiaomi-gpu dropped, after about 9,160 passes and 277 reds:
- 40 of the reds were icon-url and icon-url-saved (fixed above).
- The rest were in 75 other files. Those 75 files were run on mote with
this change and at origin/main 76f00399c: 196 reds with the change and
208 at main, in the same files.
- The one file red only with the change, copilot-ghe (webkit zh,
"route.fulfill: Target page ... has been closed"), is #1949's teardown
race and passes 6/6 alone.
- Every file red at main already has an open issue except
redact-words-list, filed as #5288 and fixed by a18ff505b before this
rebase.
- At the pushed head (a18ff505b + this commit): the budget/vet/gofmt checks
above, the 14 icon files, redact-words-list and copilot-ghe, rerun.
Broken by hand: with both toneCheck(img) calls commented out,
icon-one-tone fails 46 of 48. voyage-color shows 0.0% ink in dark, and the
Open Design row stays an <img>. Before and after screenshots of the row in
both themes were taken from the same test.
Not tried: the real desktop app (Wails, WebKitGTK) and a real install of the
Open Design plugin. The page was driven with the API faked and the real
favicon bytes. The whole GUI suite has not had a complete run.