Skip to content

Treat empty theme colors as missing in gradient resolution - #19467

Open
ThePrimeagen wants to merge 6 commits into
omacom:quattrofrom
ThePrimeagen:fix/8c400ca8-24ca-47e6-bf7d-47b3b01e3d0d
Open

ThePrimeagen wants to merge 6 commits into
omacom:quattrofrom
ThePrimeagen:fix/8c400ca8-24ca-47e6-bf7d-47b3b01e3d0d

Conversation

@ThePrimeagen

Copy link
Copy Markdown
Contributor

Switching to a theme with no accent colour breaks omarchy theme set: omarchy-theme-set-templates prints THEME_COLORS: bad array subscript and leaves themed files such as slack.json unrendered, so the switch never completes.

Screenshots

Before After
before after

Reproduce

  1. Press Super+Return to open a terminal.
  2. Create a sparse theme with only background and foreground: mkdir -p ~/.config/omarchy/themes/my-sparse && printf 'mode = "light"\nbackground = "#eeeeee"\nforeground = "#111111"\n' > ~/.config/omarchy/themes/my-sparse/colors.toml
  3. Run omarchy theme set my-sparse
  4. See /usr/share/omarchy/bin/omarchy-theme-set-templates: line 61: THEME_COLORS: bad array subscript and the theme switch left incomplete.

More cases

Theme with explicitly empty accent

Before After
before after

Gradient naming an empty colour

Before After
before after

resolve_theme_ref() and resolve_gradient_color() used
${THEME_COLORS[key]+_}, which reports a key as present even when
its value is empty. Sparse themes get empty-valued keys (accent,
red, blue) from the alias cascade, so gradient_start accent blue
resolved to an empty string; color_to_shell_hex("") then looked
up ${THEME_COLORS[]}, aborting with 'bad array subscript'.

Check for a non-empty value (${THEME_COLORS[key]:-}) instead, so
an empty color falls back as a missing one does, and return early
from resolve_gradient_color() on an empty input so no empty
subscript lookup occurs. This fixes sparse themes, explicitly
empty values, and gradients naming an empty-valued color.
@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Gradient helpers now treat empty theme colors as missing and avoid looking up an empty array key.

  • Gradient templates use fallbacks when theme colors are empty.

Reviews (6) · Last reviewed commit: "Cover an empty gradient fallback alias" · Reviewed by Greptile

Comment thread bin/omarchy-theme-set-templates Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

Codex (GPT-6; reasoning effort not exposed by this session) read the gradient resolver, its template call sites and the existing regression coverage. No code changes or runtime tests were completed: the classification model, deepseek-v4p1-flash, returned no usable answer, so classification remains unsettled. No second opinion reviewed the code; Greptile's request for a regression test remains open. This is waiting on the maintainer to resolve classification before verification continues.

@omarchybot

Copy link
Copy Markdown
Collaborator

Codex (GPT-6; reasoning effort not exposed by this session) read head e119d21501d82f5198f7e8c683e4d7b19fb5853b, including the new sparse-palette and empty-color regression tests, the renderer and its template call sites. The test check fails in test/shell.d/theme-templates-test.sh with not ok - a sparse palette finishes rendering built-in templates. I have not reproduced or diagnosed that failure on a worker.

Classification remains unsettled: my classification is bug, but deepseek-v4p1-flash returned no usable class. The queue workflow stops here until classification completes, so no labels or code changes were applied and no runtime tests were run in this pass. The configured code reviewers answered the availability probe, but no second opinion reviewed the code. This is waiting on the maintainer to resolve classification before worker verification and CI diagnosis continue.

@omarchybot

Copy link
Copy Markdown
Collaborator

Codex (GPT-6; reasoning effort not exposed by this session) read head f725def0ccf1b0cb884a0395886801c32619c031, including the updated sparse-palette test, renderer, gradient callers and base-branch rules. The sparse-palette test now checks every built-in template and explicitly checks the gradient_start fallback. The previous CI failure was on an older head; this head's test check is still running.

Classification remains unsettled: my classification is bug, but deepseek-v4p1-flash again returned no usable class. The queue workflow requires stopping here, so no worker tests, code changes or labels were applied, and no second opinion reviewed the code. This is waiting on the maintainer to resolve the classification blocker before verification continues.

@omarchybot omarchybot added the bug Something isn't working label Nov 20, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 20, 2026
The two-colour palette test checked that each built-in template left a file behind, which the renderer does on quattro without this fix, and expected the word "blue" where a colour belongs. A palette with no accent, blue or color4 is incomplete with or without the fix. The explicitly empty key test fails on quattro for both reasons the fix exists: the border rendering as "" and the bad array subscript from gradient_start.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 20, 2026
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 20, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 88eb435. The three-line change to resolve_theme_ref and resolve_gradient_color is right, and it is the smallest of the open fixes for this cause. I pushed one commit that trims the tests.

What was run, on disposable workers built from the Omarchy ISO:

  • omarchy-theme-set-templates rendering six palettes from quattro at b20d787, from this branch, and from this branch merged into quattro. With hyprland_active_border = "" in a palette that defines blue, quattro renders the border as "" and prints THEME_COLORS: bad array subscript when a template calls gradient_start on it. This branch renders the fallback colour and prints nothing. Stock themes and an ANSI-only palette render the same before and after.
  • test/shell.d/theme-templates-test.sh passes on this head and fails with bin/omarchy-theme-set-templates put back to the base version. ./test/cli and the thirteen theme tests in test/shell.d/ pass.

What the description gets wrong, for whoever reads it later:

  • On quattro the two-colour theme no longer prints the error with the built-in templates. slack.json.tpl was the only one calling gradient_start, and Remove Slack theme sync #18788 removed it. A user template that calls gradient_start still triggers it. The switch completed in every run; the error is a line on stderr.
  • A colors.toml with only background and foreground stays incomplete after this change. Its border renders as the word accent where it rendered "", and its terminal configs still get empty colours. What this fixes for a usable theme is an explicitly empty key now falling back, as omarchy-theme-color <key> <fallback> already does.

What I pushed: 88eb435 removes the two-colour test. Its loop over the built-in templates only checked that each output file exists, which passes on quattro without the fix, and it expected the word blue as a colour. The explicitly empty key test stays; it is the one that fails on quattro. It pins the change on the first branch of resolve_theme_ref; the same change on the fallback branch and in resolve_gradient_color only alters output where neither result is a colour, so no test pins those.

Reviewed by Claude Fable 5.2, with Opus 5.5 High and muse-wonder (thinking high) as a second opinion over two rounds. They agreed with the findings above, with independence not guaranteed, and Opus added which changed lines the remaining test does and does not pin. One claim of theirs did not hold: that this branch needs a rebase. It merges into quattro cleanly and the test passes on the merge.

#19494 was the same change and is closed as a duplicate of this one. #19445 and #19474 are other open fixes for the same cause. This waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 24, 2026
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 25, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed the merge at 65c71c28d22cbfe1e6cf749856eb704297c675c8 against current quattro at a3bad0b1b7eb50e9913b4c616cf87cdec6f56931. No code changes were needed.

On a disposable Omarchy ISO worker, an independent reproduction using Tokyo Night with an explicitly empty hyprland_active_border fails on the base, passes on this head, and fails again with the renderer reverted. The base produces an empty Hyprland border and a bad array subscript diagnostic for a custom gradient_start template; this head uses the expected #7aa2f7 fallback. The live omarchy theme set command exits 0 in both cases, so the description's claim that switching aborts remains inaccurate. The earlier review's sparse-palette limitations still apply.

./test/cli passed 141 checks, and eleven relevant theme and icon test files passed 107 checks through the compositor-wired wrapper, with no skips. CI and Greptile's review are green on this head; the existing test-coverage finding is answered.

GPT-6 in Codex (reasoning effort not exposed) reviewed the merge and ran the checks. Opus 5.5 High and muse-wonder via pi, thinking high reviewed the same head and the completed evidence, found no actionable code defects, and agreed that the existing regression covers the failure. Their independence is not guaranteed. One earlier reviewer claim, that the error prevents every file from being generated, was rejected against the actual worker results.

#19445 and #19474 remain open alternatives. This is waiting on the maintainer's choice, including whether the description needs correcting.

The captures show the real theme command's diagnostics and generated configuration on the worker; they do not establish the appearance inside every application.

Before: empty generated border and bad array subscript from the base renderer

After: the PR renderer uses the expected colour in both outputs without the diagnostic

@omarchybot omarchybot removed the ready Good to merge label Nov 25, 2026
The existing empty-colour fixture always resolves through a non-empty blue or a literal fallback. Carry the sparse fallback scenario from omacom#19445 into the focused regression: a missing primary colour and an empty accent alias retain the fallback name without a subscript diagnostic. Reverting only the fallback non-empty check makes this assertion fail; the existing assertions still pass. This preserves the documented single-fallback grammar without claiming a sparse palette produces usable application colours.

Co-Authored-By: ThePrimeagen <the.primeagen@gmail.com>
Co-Authored-By: muse-wonder via pi, thinking high <noreply@openai.com>
Co-Authored-By: GPT-6 (reasoning effort not exposed) <noreply@openai.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review labels Nov 25, 2026
@omarchybot omarchybot added the ready Good to merge label Nov 25, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Pushed a04a18fd1cadb0705a50f1a25239b18f8f35f6be to add the narrow empty-fallback-alias regression handed over from #19445, with ThePrimeagen credited. The runtime fix is unchanged. The new case checks a missing primary colour with an empty accent alias; reverting only the fallback non-empty check makes this assertion fail while the earlier empty-primary assertions still pass. Its expected literal accent preserves the existing unresolved-fallback behaviour and does not establish a usable sparse palette.

On a fresh disposable Omarchy ISO worker, the complete-palette reproduction failed with the base renderer, passed on this head, and failed again with the renderer reverted. ./test/cli passed 141 checks, and eleven theme and icon test files passed 108 checks through the compositor wrapper, without skips. The worker's renderer and test hashes matched the committed files after restoration. All six GitHub checks are green on this head, including Greptile 5/5, with no new findings. The earlier before/after captures and description limits still apply to the identical runtime code.

GPT-6 in Codex (reasoning effort not exposed) reviewed the change and ran these checks. Opus 5.5 High and muse-wonder via pi, thinking high reviewed this exact head and found no actionable defects; their agreement does not guarantee independence. This is waiting on the maintainer's choice between the open fixes and whether to correct the description's claims about aborted switching and sparse themes.

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

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants