Skip to content

test(control-ui): guard the hand-mirrored theme --bg copies - #130444

Merged
steipete merged 1 commit into
mainfrom
steipete/theme-bg-mirror-guard
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/theme-bg-mirror-guard

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Each theme's --bg is copied by hand into two places outside base.css, because both have to paint before the app stylesheet is parsed:

  • index.html's pre-paint block, which fills the page during first paint so a persisted theme does not flash the default palette
  • the Appearance preview chips in config.css, which are deliberately theme-invariant (they must show other themes' colours while you are looking at the current one) and so cannot read the live token

Nothing tied those copies to the palette they mirror. Darkening Absolutely in #130239 moved --bg and left both copies behind; only a pre-paint assertion that happened to hardcode the old value caught one of them, and the chip was fixed by hand after noticing.

That is the same shape as both defects review found in the theme work — a hand-maintained list extended for new themes but not exhaustively (base-path font URLs in #129885, the dark-theme confirm-button selector list in #130232). Third time is enough to automate.

Why This Change Was Made

Derives the expected values from base.css rather than restating them, and asserts both mirrors for every palette. Coverage is checked rather than assumed: the tests count what they compared and fail if the set shrinks, so deleting a pre-paint rule cannot turn the assertion into a vacuous pass.

Current coverage is all 13 palettes — 12 themed pre-paint rules plus the bare html {} default — and every non-var() preview chip. The custom chip is intentionally skipped: it reads live variables, so there is nothing to drift.

User Impact

None directly; this is test-only, with no production change. It prevents a class of silent visual bug where a theme flashes the wrong colour on first paint, or the picker advertises a swatch the theme no longer uses — both of which look like "a bit off" rather than broken, and so ship unnoticed.

Evidence

The guard fails when either mirror drifts. Verified by mutating each one independently:

tide: pre-paint #123456 != --bg #10151b
beacon: chip #abcdef != --bg #000000

Coverage inventory at this commit:

Mirror Covered
index.html pre-paint rules 13 (12 themed + default)
Appearance preview chips every family with a literal --theme-chip-bg

Tests and checks. ui/src/styles (43 passed), pnpm format:check clean, oxlint exit 0 on the changed file. Autoreview clean.

Each theme's --bg is copied by hand into two places outside base.css, because
both have to paint before the app stylesheet is parsed: index.html's pre-paint
block, which fills the page during first paint, and the Appearance preview
chips, which are deliberately theme-invariant and so cannot read the live token.

Nothing tied those copies to the palette. Darkening Absolutely moved --bg and
left both behind; only a pre-paint assertion that happened to hardcode the old
value caught one of them. It is the same shape as the two defects review found
in the theme work — a hand-maintained list extended for new themes but not
exhaustively — and the third time is enough.

Derives the expected values from base.css and asserts both mirrors for every
palette (12 themed pre-paint rules plus the default), so a palette edit cannot
leave either copy stale. Verified by mutating each mirror:

  tide: pre-paint #123456 != --bg #10151b
  beacon: chip #abcdef != --bg #000000

Test-only; no production change.
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 22:00
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 26, 2026, 6:08 PM ET / 22:08 UTC.

ClawSweeper review

What this changes

The PR adds a Control UI test that derives theme backgrounds from the canonical stylesheet and checks first-paint and Appearance preview copies for drift.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: the new preview-chip guard is non-exhaustive, so it can pass after most theme swatches disappear.

Priority: P3
Reviewed head: a2b5018f2c7980e1b39370815d6b1ce6f4bd511b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch has a clear regression goal, but its asserted chip coverage does not yet match that goal.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR does not require external real-behavior proof.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR does not require external real-behavior proof.
Evidence reviewed 4 items Incomplete chip coverage: The test only requires more than one checked chip, so deleting every other literal preview-chip background still passes.
Affected product surface: Current main resolves seven built-in themes and renders their preview cards; config.css supplies dark and light literal chip backgrounds for those cards.
Current-main necessity: Current main has the existing token tests but lacks this mirror-coverage suite, so the central preventive change is not already implemented.
Findings 1 actionable finding [P2] Require complete preview-chip coverage
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs ui/src/styles/base-theme-tokens.node.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs ui/src/styles/base-theme-tokens.node.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs ui/src/styles/base-theme-tokens.node.test.ts"

[test] starting test/vitest/vitest.ui.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130444-Qt4WpY/target

 ✓  ui  ui/src/styles/base-theme-tokens.node.test.ts (5 tests) 1039ms
     ✓ routes every Web Awesome switch through the shared accent  957ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  22:08:58
   Duration  1.52s (transform 266ms, setup 93ms, import 11ms, tests 1.04s, environment 0ms)

[test] passed 1 Vitest shard in 2.02s

Assertions:

  • FAIL expect_output: Control UI theme --bg mirrors

How this fits together

Control UI resolves a selected theme into CSS tokens before rendering. The startup page paints a matching background early, while Appearance cards show fixed previews of every built-in theme.

flowchart LR
  A[Saved theme choice] --> B[Theme resolution]
  B --> C[Canonical theme tokens]
  C --> D[First-paint page background]
  C --> E[Appearance preview chips]
  F[Theme mirror test] --> C
  F --> D
  F --> E
Loading

Before merge

  • Require complete preview-chip coverage (P2) - The loop only counts literal chip rules it happens to find, and checked > 0 accepts a stylesheet with one surviving swatch. Since the Appearance view renders seven built-in themes, track observed resolved variants and assert the complete canonical set so a deleted or omitted dark/light chip fails.
  • Complete next step (P2) - The coverage gap is a narrow mechanical repair in the added test and can be resolved without changing production theme behavior.

Findings

  • [P2] Require complete preview-chip coverage — ui/src/styles/base-theme-tokens.node.test.ts:207
Agent review details

Security

None.

PR surface

Tests +127. Total +127 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 127 0 +127
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 127 0 +127

Review metrics

Metric Value Why it matters
Production versus test LOC production +0, tests +127 The PR is isolated regression coverage; its value depends on enforcing complete coverage of the mirrored values.

Technical review

Best possible solution:

Compare the observed resolved preview-chip variants with the complete canonical background set, then retain the existing value-equality checks.

Do we have a high-confidence way to reproduce the issue?

Yes, by source inspection: remove all but one literal preview-chip background and the new assertion still passes because it only requires checked > 0.

Is this the best way to solve the issue?

No. The value comparisons are sound for matched rules, but the test must also prove that every built-in dark and light preview rule was observed.

Full review comments:

  • [P2] Require complete preview-chip coverage — ui/src/styles/base-theme-tokens.node.test.ts:207
    The loop only counts literal chip rules it happens to find, and checked > 0 accepts a stylesheet with one surviving swatch. Since the Appearance view renders seven built-in themes, track observed resolved variants and assert the complete canonical set so a deleted or omitted dark/light chip fails.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 730b6ef8faf3.

Labels

Label changes:

  • add P3: This is a focused test-only safeguard for low-blast-radius visual drift.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored, test-only PR does not require external real-behavior proof.

Label justifications:

  • P3: This is a focused test-only safeguard for low-blast-radius visual drift.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored, test-only PR does not require external real-behavior proof.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs ui/src/styles/base-theme-tokens.node.test.ts.
  • [P1] node scripts/check-changed.mjs -- ui/src/styles/base-theme-tokens.node.test.ts.

What I checked:

Likely related people:

  • steipete: Introduced the recent merged built-in theme and surface-ramp work that owns the canonical tokens and their mirrored UI surfaces. (role: theme feature owner; confidence: high; commits: 80ecc7c8b5de, 08a42a561c8f, a868258156a6; files: ui/src/styles/base.css, ui/src/styles/config.css, ui/index.html)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Assert that observed preview-chip variants equal the full canonical dark/light background set, then run the focused style test.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit d4c8aaa into main Aug 26, 2026
140 checks passed
@steipete
steipete deleted the steipete/theme-bg-mirror-guard branch August 26, 2026 22:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (275 commits)
  fix(ai): require explicit compatible-provider endpoints (#130453)
  test(control-ui): guard the hand-mirrored theme --bg copies (#130444)
  fix(onboard): preserve the saved skills package manager (#130438)
  improve(worker): diagnose admission-deadline failures and widen daemon revalidation budget (#130435)
  fix(plugins): align diffs external install metadata (#130362)
  refactor(models): consolidate config normalization (#130439)
  fix(browser): accept common keyboard aliases (#130401)
  fix(release): refresh IMAP plugin baselines (#130351)
  fix(tests): type sticky model agent fixtures (#130441)
  fix(qa): track current Slack progress cards (#130354)
  feat(ui): refine the mobile composer (#130308)
  fix(ui): clarify gateway disconnect status in tab title (#130364)
  test(qa): await gateway startup before network probes (#130353)
  fix(qa): run Buzz profile scenarios with pooled credentials (#130316)
  fix(crabbox): keep the setup failure reason and name its phase (#130425)
  fix: dashboard tools target the wrong Gateway after admission (#130112)
  fix(ui): distinguish inherited model defaults from session pins (#120805)
  feat(feishu): let agents resend received stickers (#130374)
  refactor(models): prepare selection policy once (#130413)
  fix(ui): make dashboard side panels enter split view (#130426)
  ...

# Conflicts:
#	test/scripts/docker-build-helper.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…#130444)

Each theme's --bg is copied by hand into two places outside base.css, because
both have to paint before the app stylesheet is parsed: index.html's pre-paint
block, which fills the page during first paint, and the Appearance preview
chips, which are deliberately theme-invariant and so cannot read the live token.

Nothing tied those copies to the palette. Darkening Absolutely moved --bg and
left both behind; only a pre-paint assertion that happened to hardcode the old
value caught one of them. It is the same shape as the two defects review found
in the theme work — a hand-maintained list extended for new themes but not
exhaustively — and the third time is enough.

Derives the expected values from base.css and asserts both mirrors for every
palette (12 themed pre-paint rules plus the default), so a palette edit cannot
leave either copy stale. Verified by mutating each mirror:

  tide: pre-paint openclaw#123456 != --bg #10151b
  beacon: chip #abcdef != --bg #000000

Test-only; no production change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant