Skip to content

fix(ui): serve a fixed-colour favicon URL per colour scheme - #14374

Open
oliver-mee wants to merge 1 commit into
paperclipai:masterfrom
oliver-mee:fix/favicon-scheme-urls
Open

oliver-mee wants to merge 1 commit into
paperclipai:masterfrom
oliver-mee:fix/favicon-scheme-urls

Conversation

@oliver-mee

Copy link
Copy Markdown

Thinking Path

  • Paperclip is the open source app people use to manage AI agents for work
  • People keep the board open in a browser tab, often next to many other tabs
  • The tab icon is how they find the board, so it must stay visible on a light or a dark tab strip
  • The default favicon.svg changes colour with prefers-color-scheme, but Chromium rasterizes an SVG favicon once and caches the bitmap by URL, so the icon can stay stuck in the wrong scheme
  • The PNG and ICO favicons are near-black only, so they are invisible on a dark tab strip
  • This pull request gives each colour scheme its own favicon URL with fixed colours, and the page picks the correct set from the browser scheme
  • The benefit is a tab icon that stays visible, also after a scheme change, and without the need to clear site data

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

  • Add ui/public/favicon-light.svg (stroke #18181b) and ui/public/favicon-dark.svg (stroke #e4e4e7). They use the same path as favicon.svg, with no media query.
  • Add light rasters for the dark scheme: favicon-dark-16x16.png, favicon-dark-32x32.png and favicon-dark.ico (16, 32 and 48 px).
  • In ui/index.html, add data-favicon-light and data-favicon-dark to the four default icon links. The href values do not change, so the page without JavaScript works as before.
  • In the inline head script, add a block that reads matchMedia("(prefers-color-scheme: dark)"), sets each tagged link to the URL for that scheme, and swaps them again on change. 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.
  • In server/src/ui-branding.ts, add the same attributes to DEFAULT_FAVICON_LINKS, so it stays identical to the block in index.html. The worktree favicon links do not get the attributes, so the script does not change them.
  • In server/src/app.ts, add the five new files to VITE_DEV_STATIC_PATHS.
  • Tests: server/src/__tests__/ui-branding.test.ts checks that each default link has both attributes, that the worktree links have none, and that DEFAULT_FAVICON_LINKS matches the block in ui/index.html. The new ui/src/lib/favicon-scheme-swap.test.ts runs the head scripts from ui/index.html in jsdom with a mocked matchMedia, 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.svg bitmap 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) from favicon-dark.svg at 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-convert on favicon-light.svg gives pixel-identical output to the current favicon-16x16.png and favicon-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:

Favicon renders on white, a light tab strip and a dark tab strip

Icon White #ffffff Light strip rgb(223,229,217) Dark strip #202124
favicon-light (#18181b) 17.72:1 13.79:1 1.10:1
favicon-dark (#e4e4e7) 1.27:1 1.01:1 12.69:1

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.
  • With the index.html from master, the new UI test fails 4 of 4 and the new block-match test in the server fails. The tests detect the defect.
  • tsc --noEmit in server and tsc -b in ui: no errors. I did not run the full pnpm typecheck, because the runner package needs cargo, which is not installed on my machine.
  • vite build in ui: passes. All new files are in ui/dist.
  • Browser check in Chromium 151, headful under Xvfb, with ui/dist on a local static server. I read the cached bitmaps from the profile's Favicons database:
    1. Load the master page with the browser dark. The cache has the pale /favicon.svg bitmap, (228,228,231).
    2. Control: open the master page again with the browser light. There is no favicon request, and the pale bitmap stays. This is the bug.
    3. Open this branch's build with the browser light in the same profile. The browser requests /favicon-light.svg and never requests /favicon.svg. The cache now has /favicon-light.svg with a (24,24,27) stroke.
    4. Switch the page to dark (media emulation) with the tab open. All four links change to the -dark URLs, and the browser requests /favicon-dark.svg. Switch back to light. The links return to the light set.
    5. Fresh profile with the browser dark: the browser requests /favicon-dark.svg and caches a (228,228,231) stroke.
  • I did not test Firefox or Safari. The script only changes href attributes, which all browsers support.

Risks

  • Low risk. The change adds static files and a small inline script. The default href values do not change, so a browser without JavaScript gets the same icons as before.
  • favicon.svg and the current rasters stay in place for direct links and for the page without JavaScript.
  • The worktree favicon (a data URI) does not get the attributes, so the script does not change it.
  • Platform limit: a page cannot read the colour of the tab strip. prefers-color-scheme is the only signal. If a browser shows a light custom-theme tab strip but reports dark to the page, the icon will be pale. This change does not make that case worse.

For core feature work, check ROADMAP.md first and discuss it in #dev before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See CONTRIBUTING.md.

Model Used

  • Claude Opus 5.5 (Anthropic, model id 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

  • I have included a thinking path that traces from project context to this change
  • I have specified the model used (with version and capability details)
  • I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work
  • I have searched GitHub for duplicate or related PRs and linked them above
  • I have either (a) linked existing issues with Fixes: # / Closes # / Refs # OR (b) described the issue in-PR following the relevant issue template
  • I have not referenced internal/instance-local Paperclip issues or links (only public GitHub #NNN / github.com/paperclipai/paperclip URLs)
  • My branch name describes the change (e.g. docs/..., fix/...) and contains no internal Paperclip ticket id or instance-derived details
  • I have run tests locally and they pass (the touched test files and the typecheck of server and ui; not the full suite)
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes (N/A: no documentation describes the default favicon files)
  • I have considered and documented any risks above
  • All Paperclip CI gates are green (pending at the time of opening)
  • Greptile is 5/5 with no open P2s, recommendations, or follow-ups (pending at the time of opening)
  • I will address all Greptile and reviewer comments before requesting merge

🤖 Generated with Claude Opus 5.5
🧑‍💻 Ideated, directed and reviewed by a human, @oliver-mee

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>
@greptile-apps

greptile-apps Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Adds colour-scheme-aware favicon assets and switching logic.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR adds fixed-colour favicon assets and switches the default icon links according to the browser colour scheme, while leaving worktree branding unchanged.

  • Adds development-server paths for the new assets.
  • Adds tests for the default links, branding separation, and scheme changes.

Reviews (2) · Last reviewed commit: "fix(ui): serve a fixed-colour favicon UR..."

@divyeshpcodezee-tech

Copy link
Copy Markdown

@oliver-mee

please merge this PR

@commitperclip

commitperclip Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@greptileai

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default favicon can become invisible: SVG favicon is cached in the wrong colour scheme, and raster favicons have no light variant

2 participants