Skip to content

Clamp degenerate-saturation chrome seeds for Chromium - #10697

Open
1azza wants to merge 4 commits into
omacom:quattrofrom
1azza:fix/chromium-seed-blue
Open

1azza wants to merge 4 commits into
omacom:quattrofrom
1azza:fix/chromium-seed-blue

Conversation

@1azza

@1azza 1azza commented Sep 7, 2026

Copy link
Copy Markdown

Summary

BrowserThemeColor is a seed, not a paint color: Chromium derives the browser chrome color from it by adjusting lightness while preserving HSL saturation. At the luminance extremes HSL saturation is degenerate — a near-black seed's max+min is tiny (so s = (max-min)/(max+min) → 1.0 for any tint) and a near-white seed whose max channel is 255 also yields s = 1.0. A barely-tinted near-black background therefore renders the tab strip as a loud saturated tone of that hue: a theme with background = "#000107" renders Chromium's chrome as saturated blue #0018AC (#10696; dark-theme counterpart of #7624). Omarchy's fallback #1c2027 is blue-hued and does the same.

This changes the generated chromium.theme to use a clamped chrome seed instead of the raw background, and makes the browser-policy fallback neutral:

  • bin/omarchy-theme-set-templates: derive chrome_seed from background; seeds at the luminance extremes (max == 255 or max + min <= 16) with small chroma (<= 32) are neutralized to their channel average, so near-black and near-white backgrounds keep near-neutral chrome while genuinely colored backgrounds keep their hue.
  • default/themed/chromium.theme.tpl: {{ background_rgb }} → {{ chrome_seed_rgb }}.
  • install/helpers/browser-policy.sh: fallback #1c2027 → neutral #1f1f1f, with the reason in a comment.
  • Docs updated (docs/theming.md, manual/43-making-your-own-theme.md).
  • New test test/shell.d/chrome-seed-test.sh; fallback pins updated in browser-policy-dir-test.sh and browser-policy-sudoers-test.sh.

Theme authors who ship an explicit chromium.theme keep full control of their seed.

Verification

Standalone check of the clamp: #000107 → 030303, #fffcf0 → f9f9f9, #222222/#ff0000/#1a1b26/#738555/#ffffff/#1c2027 unchanged.

  • ./test/cli: 112 ok, 0 failures
  • ./test/shell: 231 passed / 5 failed — the 5 failures reproduce on a clean quattro tree (verified via git stash), so they are pre-existing and unrelated
  • theme-staging-test.sh, browser-policy-dir-test.sh, browser-policy-sudoers-test.sh, chrome-seed-test.sh: all pass

Rendered behavior on Chromium 151 (before → after, measured from screenshots): tab strip for a #000107 background goes from saturated blue #0018AC to neutral dark; the olive-seeded case renders dark olive tones matching the theme accent. Before/after captures attached.

Note: this intentionally does not touch BrowserColorScheme: "device" — that is #10054 / #10056.

Copilot AI lite review requested due to automatic review settings September 7, 2026 19:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One updated test still hard-codes the old default fallback color in a later validation check, and chrome_seed derivation should avoid overriding an explicitly provided chrome_seed / avoid running on non-hex backgrounds.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts Omarchy’s Chromium theming so BrowserThemeColor is treated as a seed (as Chromium does) rather than a paint color, preventing near-black / near-white tinted backgrounds from producing highly saturated chrome colors.

Changes:

  • Add a background→chrome_seed clamp in omarchy-theme-set-templates and switch chromium.theme generation to use chrome_seed_rgb.
  • Make the browser-policy fallback color neutral (#1f1f1f) and update related shell tests.
  • Document the behavior in theming docs/manual and add a dedicated clamp test.
File summaries
File Description
bin/omarchy-theme-set-templates Derives chrome_seed from background to avoid degenerate HSL saturation seeds at luminance extremes.
default/themed/chromium.theme.tpl Uses chrome_seed_rgb instead of background_rgb for generated chromium.theme.
install/helpers/browser-policy.sh Changes default policy color fallback to neutral #1f1f1f with rationale.
test/shell.d/chrome-seed-test.sh Adds test coverage for the clamp behavior across representative backgrounds.
test/shell.d/browser-policy-dir-test.sh Updates fallback expectations for malformed inputs (needs one more update; see comments).
test/shell.d/browser-policy-sudoers-test.sh Updates fallback expectations for malformed inputs.
docs/theming.md Documents that chromium.theme is generated from a clamped seed derived from background.
manual/43-making-your-own-theme.md Explains the clamped chrome-seed behavior for theme authors.
Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

for malformed in "" "not,a,color" "1,2" "1,2,3,4" "256,0,0" "999,999,999" "-1,0,0" \
"1,2,3;id" '1,2,$(id)' "0x10,0,0" "1,2,3 4,5,6"; do
[[ $(browser_policy_theme_hex "$malformed") == "#1c2027" ]] ||
[[ $(browser_policy_theme_hex "$malformed") == "#1f1f1f" ]] ||
@1azza
1azza requested a balanced review from Copilot September 8, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
omarchybot and others added 2 commits October 2, 2026 10:50
quattro now renders every template in one awk pass (omacom#13406), so the chrome seed is computed in bash and returned through REPLY like the other helpers, and a non-hex background's {{ chrome_seed_rgb }} goes into the value table rather than the sed script that no longer exists. theme-set-browser-test.sh, new on quattro, pins the fallback color, so it follows the fallback to #1f1f1f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1c2027 is not at a luminance extreme, so Chromium 152 does not saturate it: its toolbar renders blue-grey #39424f, not loud blue. The neutral fallback stays; the comment now says what it avoids.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot removed the bug Something isn't working label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 1caa829, on a worker built from the Omarchy ISO, running Chromium 152.

What I pushed. The branch had stopped merging into quattro, because #13406 rewrote omarchy-theme-set-templates to render templates in one awk pass. I merged quattro in. The chrome seed is now computed in bash and returned through REPLY, like the file's other helpers. A non-hex background's {{ chrome_seed_rgb }} now goes into the new value table, since the sed script it used to write to no longer exists. theme-set-browser-test.sh, which is new on quattro, pins the fallback colour, so it now expects #1f1f1f. I also corrected the comment on BROWSER_POLICY_DEFAULT_COLOR (see the last point below).

The bug is real, and the clamp fixes the reported cases. I set BrowserThemeColor by policy and sampled pixels from screenshots:

seed Chromium draws clamped seed Chromium draws
#000107 (dark) toolbar #0018ac #030303 toolbar #363636
#fffcf0 (light) tab strip #ffde5a #f9f9f9 tab strip #e1e1e1

chrome-seed-test.sh fails on quattro, passes on this head, and fails again with the two source changes reverted.

Still open: colours just outside the clamp stay saturated. The condition only fires when max == 255 or max + min <= 16, so colours one step away fall through unchanged and still render loud:

seed Chromium draws why it is missed
#04050f toolbar #232c84 max + min is 19
#fefbef tab strip #f7df8d max is 254

Chromium keeps the seed's HSL saturation, so the boundary that matches the cause is saturation itself, for example neutralising a low-chroma seed whose saturation is at least 0.5, as #7624 proposes. That changes which themes keep their tint, so it is for the author to choose.

The fallback change is separate from the bug. #1c2027 is not at a luminance extreme. Chromium draws its toolbar as a muted blue-grey #39424f, not loud blue. I kept #1f1f1f, and the comment now says what it avoids. Whether the stock fallback should change is the maintainer's call. It is probably also why the two models classifying this disagreed: I read it as a bug, while Codex Medium read it as an enhancement, a change of behaviour on purpose. So it carries no class label for now.

Tests on the worker. ./test/cli fails one vscode extension check, identically on quattro. With that check skipped on both trees, 114 pass on each. ./test/shell has 4060 passing and the same 6 failures as quattro (column width, logo animation, kernel headers, browser focus, network portal, pre_remove), none of them in files this touches. The PR's own tests pass: chrome-seed, browser-policy-dir, browser-policy-sudoers, theme-set-browser, theme-templates and theme-staging.

Second opinion. Codex Medium reviewed it. It found the near-boundary gap above, which I then confirmed in Chromium. It found nothing else wrong in the parsing, the non-hex path or the docs. It also judged the fallback change unnecessary for this bug.

Next. This waits on @1azza for the clamp boundary, and on the maintainer for the fallback colour and the classification. Once the boundary is settled, it would close #7624.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

[Medium risk] Changes how browser theme colors are generated from backgrounds.

The PR should not merge until adjacent saturated seeds are handled and valid explicit RGB-triple seeds produce usable browser-theme output.

Findings

  1. P1 Saturated seeds escape the clamp ▶
  2. P1 Explicit RGB seeds become placeholders ▶
  3. P2 Test accepts unusable browser color ▶

Summary

The PR derives a clamped Chromium chrome seed from theme backgrounds, changes the browser-policy fallback to neutral grey, and updates documentation and tests.

  • The clamp leaves adjacent highly saturated near-black and near-white seeds untreated.
  • Explicit RGB-triple seeds generate an unresolved template token, and a new test accepts non-RGB browser-theme output.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[colors.toml] --> B{Explicit chrome_seed?}
  B -- No --> C[Derive seed from background]
  B -- Yes --> D[Use explicit seed]
  C --> E[Render chromium.theme]
  D --> E
  E --> F{Valid RGB triple?}
  F -- Yes --> G[Apply BrowserThemeColor]
  F -- No --> H[Use neutral fallback]
Loading

Reviews (1) · Last reviewed commit: "Say what the old fallback color actually..."

(( g < min )) && min=$g
(( b < min )) && min=$b

if (( (max == 255 || max + min <= 16) && max - min <= 32 )); then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Saturated seeds escape the clamp A near-black background such as #000011 misses the cutoff because its maximum and minimum channels sum to 17. It remains fully saturated as a Chromium seed, so the browser can still show the conspicuous blue chrome this change aims to prevent. Near-white colors such as #fefdf0 also miss the max == 255 check.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

# derivation. A theme that defines its own chrome_seed keeps it; a
# background that is not plain hex passes through untouched so
# {{ chrome_seed_rgb }} still resolves instead of leaking a placeholder.
if [[ -z ${THEME_COLORS[chrome_seed]+_} && -n ${THEME_COLORS[background]+_} ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Explicit RGB seeds become placeholders If a theme sets chrome_seed = "18,52,86", the palette parser accepts it and browser policy could use it as an RGB triple. But an explicit seed skips this branch, and the template renderer creates chrome_seed_rgb only from six-digit hex values. The generated chromium.theme therefore contains the literal {{ chrome_seed_rgb }} placeholder, causing browser sync to use the fallback color instead of the requested seed.

Knowledge Base Used: Theme switching and application sync

Comment on lines +91 to +93
assert_chromium_theme \
"a non-hex background passes through as the chrome seed" \
"rgba(010203ee) rgba(040506ee) 45deg" "rgba(010203ee) rgba(040506ee) 45deg" ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Test accepts unusable browser color This test expects a gradient string in chromium.theme, but browser sync accepts only an RGB triple and falls back for that output. The test therefore passes even though the generated file cannot supply the browser color, leaving this handoff untested.

Knowledge Base Used: Theme catalog and assets

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.

3 participants