Repository navigation
fix(ui): serve a fixed-colour favicon URL per colour scheme - #14374
Open
oliver-mee wants to merge 1 commit into
Open
oliver-mee wants to merge 1 commit into
oliver-mee wants to merge 1 commit into
Conversation
Chromium rasterizes an SVG favicon once, under the colour scheme that is active at fetch time, and caches the bitmap by icon URL. The default favicon.svg adapts with prefers-color-scheme, so a render from an earlier dark period stays cached and shows a pale icon on a light tab strip. The raster favicons were near-black only, so they were invisible on a dark tab strip. Add favicon-light.svg and favicon-dark.svg with fixed colours, plus light 16x16, 32x32 and ICO rasters for the dark scheme. The inline head script points each default icon link at the set for the current browser scheme and swaps them on a scheme change. The worktree favicon is unchanged. Fixes paperclipai#14371 Co-Authored-By: Paperclip <noreply@paperclip.ing>
Contributor
|
divyeshpcodezee-tech
approved these changes
Sep 28, 2026
|
please merge this PR |
5 tasks done
Contributor
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
Linked Issues or Issue Description
Fixes #14371
Related, not duplicates: #540 (worktree favicon branding), #1038 (worktree branding in vite dev), #13462 (theme follows the OS again).
What Changed
ui/public/favicon-light.svg(stroke#18181b) andui/public/favicon-dark.svg(stroke#e4e4e7). They use the same path asfavicon.svg, with no media query.favicon-dark-16x16.png,favicon-dark-32x32.pngandfavicon-dark.ico(16, 32 and 48 px).ui/index.html, adddata-favicon-lightanddata-favicon-darkto the four default icon links. Thehrefvalues do not change, so the page without JavaScript works as before.matchMedia("(prefers-color-scheme: dark)"), sets each tagged link to the URL for that scheme, and swaps them again onchange. It follows the browser scheme, not the stored in-app theme, because the in-app theme does not change how the browser renders the favicon.server/src/ui-branding.ts, add the same attributes toDEFAULT_FAVICON_LINKS, so it stays identical to the block inindex.html. The worktree favicon links do not get the attributes, so the script does not change them.server/src/app.ts, add the five new files toVITE_DEV_STATIC_PATHS.server/src/__tests__/ui-branding.test.tschecks that each default link has both attributes, that the worktree links have none, and thatDEFAULT_FAVICON_LINKSmatches the block inui/index.html. The newui/src/lib/favicon-scheme-swap.test.tsruns the head scripts fromui/index.htmlin jsdom with a mockedmatchMedia, and checks the light set, the dark set, the change listener, and that a stored dark in-app theme does not change the result.Why a fixed URL per scheme fixes the cause: the cache key is the URL. Each new URL has exactly one correct rendering, so a cached bitmap cannot be in the wrong scheme. A browser that has the old pale
/favicon.svgbitmap in its cache gets a different URL on the next load and fetches the correct icon, so users do not need to clear site data.Raster provenance: I made the PNG files with
rsvg-convert(librsvg) fromfavicon-dark.svgat 16 and 32 px, and the ICO with Pillow from the 48, 32 and 16 px renders of the same SVG. As a check on the method,rsvg-convertonfavicon-light.svggives pixel-identical output to the currentfavicon-16x16.pngandfavicon-32x32.png. I did not add build tooling.Renders (the 96 px SVG render, and the 32 px and 16 px rasters, on each background). Green borders show the icon that the page now serves for that scheme:
#ffffffrgb(223,229,217)#202124favicon-light(#18181b)favicon-dark(#e4e4e7)Bold is the pair the page now serves. The 1.01:1 cell is the reported failure: the pale icon stuck on a light strip.
Verification
cd server && npx vitest run src/__tests__/ui-branding.test.ts: 10 passed.cd ui && npx vitest run src/lib/favicon-scheme-swap.test.ts: 4 passed.index.htmlfrommaster, the new UI test fails 4 of 4 and the new block-match test in the server fails. The tests detect the defect.tsc --noEmitinserverandtsc -binui: no errors. I did not run the fullpnpm typecheck, because the runner package needscargo, which is not installed on my machine.vite buildinui: passes. All new files are inui/dist.ui/diston a local static server. I read the cached bitmaps from the profile'sFaviconsdatabase:masterpage with the browser dark. The cache has the pale/favicon.svgbitmap,(228,228,231).masterpage again with the browser light. There is no favicon request, and the pale bitmap stays. This is the bug./favicon-light.svgand never requests/favicon.svg. The cache now has/favicon-light.svgwith a(24,24,27)stroke.-darkURLs, and the browser requests/favicon-dark.svg. Switch back to light. The links return to the light set./favicon-dark.svgand caches a(228,228,231)stroke.hrefattributes, which all browsers support.Risks
hrefvalues do not change, so a browser without JavaScript gets the same icons as before.favicon.svgand the current rasters stay in place for direct links and for the page without JavaScript.prefers-color-schemeis the only signal. If a browser shows a light custom-theme tab strip but reportsdarkto the page, the icon will be pale. This change does not make that case worse.Model Used
claude-opus-5-5) in an agentic coding session with tool use (shell, file edits, test runs, headful Chromium). It did the root-cause reproduction, the code, the tests and this description. A human reviewed the approach before the work started.Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template#NNN/github.com/paperclipai/paperclipURLs)docs/...,fix/...) and contains no internal Paperclip ticket id or instance-derived detailsserverandui; not the full suite)🤖 Generated with Claude Opus 5.5
🧑💻 Ideated, directed and reviewed by a human, @oliver-mee