Skip to content

fix(ui): make chat inline code readable on dark themes - #121376

Merged
vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/inline-code-contrast
Aug 10, 2026
Merged

vyctorbrzezowski merged 1 commit into
mainfrom
brzezowski/inline-code-contrast

Conversation

@vyctorbrzezowski

Copy link
Copy Markdown
Member

Closes #121374

What Problem This Solves

Fixes an issue where operators on any dark Control UI appearance would see inline code spans and fenced code blocks blend into the surrounding message. The chip had no usable surface step and no visible edge, so commands, paths, and flags in agent replies read as ordinary body text. Light mode was already correct, which is why the defect only ever showed on the default dark families.

Why This Change Was Made

The chat markdown rule painted code surfaces with --secondary and --border. Every dark palette in ui/src/styles/base.css defines --secondary with the exact hex of --card, so a chip inside a message bubble was a 1.00:1 match with the bubble and only 1.06-1.08:1 against the flat assistant column, while --border sat at 1.08-1.13:1 against --card. Light mode looked right only because ui/src/styles/chat/text.css overrode both properties for :root[data-theme-mode="light"], choosing --bg-muted plus a real border.

The fix promotes that light override into the single canonical rule instead of adding a second dark-only override: code chips and code blocks now paint --bg-muted with a --border-strong edge in every theme, and both mode-specific overrides (including the raw rgba(0, 0, 0, 0.1) border) are deleted. Dark deliberately lands slightly below light's edge presence, since a bright hairline reads stronger on a dark surface at equal ratio. Custom (shadcn-style) themes benefit too: --bg-muted maps to the theme's own muted surface and --border-strong is derived as color-mix(in srgb, var(--border) 72%, var(--text) 28%), so both are guaranteed to separate.

The change also repairs the guard that should have caught this. ui/src/styles/base-theme-contrast.node.test.ts overwrote repeated :root blocks instead of merging them, and base.css declares :root more than once (palette, then the standalone --cursor-action blocks). The last tiny block won, so the default dark theme resolved to an empty token map and every assertion for it was silently skipped. With merging restored, a new case reads the chip's surface and border tokens out of the shipped rule and asserts separation from --card and --bg on all six themes, so swapping the tokens back for a collapsing pair fails in CI.

Sibling surfaces were checked and intentionally left alone: ui/src/styles/sidebar-markdown.css uses a different, working idiom (rgba(0, 0, 0, 0.12), which darkens against a dark surface and does separate), and ui/src/styles/chat/tool-cards.css deliberately strips the pill from command and diff <code> used for semantics only.

User Impact

Inline code and code blocks in chat are now clearly identifiable as code on Claw dark, OpenKnot dark, and Dash dark, with the same restrained weight light mode already had - a distinct surface and a soft edge, not a loud highlight. Light appearances are visually unchanged. No config, no migration, no opt-in.

Evidence

Measured with the same WCAG relative-luminance math as the contrast guard. Chip surface and border, before -> after:

Theme chip vs --card chip vs --bg border vs --card
dark 1.00 -> 1.12 1.08 -> 1.22 1.08 -> 1.35
openknot 1.00 -> 1.09 1.06 -> 1.15 1.09 -> 1.32
dash 1.00 -> 1.18 1.08 -> 1.28 1.13 -> 1.50
light 1.19 (unchanged) 1.13 (unchanged) 1.48 -> 1.53
openknot-light 1.20 (unchanged) 1.14 (unchanged) 1.49 -> 1.60
dash-light 1.34 (unchanged) 1.20 (unchanged) 1.66 -> 1.93

Light chip surfaces are byte-identical (verified by sampling the rendered pixels: #efebe4 before and after). Only the light border moves, from the composited rgba(0, 0, 0, 0.1) to --border-strong, which is within one or two units per channel on claw-light and openknot-light and slightly firmer on dash-light.

Screenshots come from the mock-gateway Control UI E2E harness with fixture messages, captured headless at 1100x900. Each image is the same rendered line at 2x, before on top and after below.

Claw dark - the chip gains a surface step and a soft edge:

Claw dark inline code, before above and after below

OpenKnot dark:

OpenKnot dark inline code, before above and after below

Dash dark:

Dash dark inline code, before above and after below

Claw light - unchanged:

Claw light inline code, before above and after below, visually identical

Full message frame on Claw dark after the change, showing an inline chip inside a user bubble, inline chips in the flat assistant column, and a fenced block:

Claw dark chat message after the change

Focused tests, all green:

node scripts/run-vitest.mjs ui/src/styles/base-theme-contrast.node.test.ts \
  ui/src/styles/base-theme-tokens.node.test.ts ui/src/styles/theme-contrast.test.ts
Test Files  3 passed (3)     Tests  6 passed (6)

The new guard was verified to actually fail on the pre-fix tokens rather than passing vacuously:

dark: chip --secondary #161920 on --card #161920 = 1.00:1 (< 1.05:1)
dark: chip border --border #1e2028 on --card #161920 = 1.08:1 (< 1.25:1)
openknot: chip --secondary #111113 on --card #111113 = 1.00:1 (< 1.05:1)
dash: chip --secondary #221a16 on --card #221a16 = 1.00:1 (< 1.05:1)

git diff --check clean, stylelint clean on the touched stylesheet, oxfmt clean on the touched test. Production LOC delta is -7 (7 added, 14 removed, 3 of the added lines being the invariant comment); the +59 lines are test-only.

Every dark palette defines --secondary with the same hex as --card, so the
markdown code chip painted with --secondary collapsed into the surface it sat
on (1.00:1 against a user bubble, 1.06-1.08:1 against the flat assistant
column) and --border was too close to the background to draw an edge. Light
mode never showed the bug because it overrode both properties.

Promote the light override into the single canonical rule: code chips and code
blocks paint --bg-muted with a --border-strong edge in every theme, and the
mode-specific overrides (including the raw rgba border) are deleted.

Also fixes the theme-contrast guard, which merged repeated `:root` blocks by
overwriting instead of merging, so the default `dark` theme resolved to an
empty token map and skipped every assertion. A new case reads the chip tokens
out of the shipped rule and asserts surface and border separation from --card
and --bg on all six themes.
@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 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 10, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review August 10, 2026 03:38
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 9, 2026, 11:44 PM ET / August 10, 2026, 03:44 UTC.

ClawSweeper review

What this changes

This PR makes Control UI chat inline code and fenced blocks use the muted surface and strong border in every theme, while adding a contrast regression guard.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still uses the collapsing code-surface tokens; this focused PR replaces them through the shared chat markdown rules and repairs the skipped default-theme guard. No blocking patch defect found; the MEMBER-authored, maintainer-labeled PR needs normal human review and exact-head CI completion.

Priority: P2
Reviewed head: 8dbd9acf04cb0e7eb8a977de9fd782638557985e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-aligned visual repair with a meaningful regression guard and no blocking review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body additionally provides mock-gateway Control UI screenshots and focused test output.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body additionally provides mock-gateway Control UI screenshots and focused test output.
Evidence reviewed 6 items Current-main defect: Current main styles inline code and fenced blocks with --secondary and --border; the default dark palette defines --secondary as the same #161920 value as --card.
Canonical repair on PR head: The branch changes both chat code surfaces to shared --bg-muted and --border-strong tokens and removes the light-only duplicate overrides.
Guard repairs default-theme parsing: The branch merges repeated :root declarations rather than overwriting the palette and reads the live inline-code rule before checking all shipped theme variants.
Findings None None.
Security None None.

How this fits together

Control UI markdown produces inline &lt;code> and &lt;pre> elements inside chat message bubbles. Shared theme palettes supply their surface tokens, and the chat stylesheet plus contrast tests determine whether those code elements remain visually distinct.

flowchart LR
  A[Theme palettes] --> B[Shared color tokens]
  B --> C[Chat markdown styles]
  D[Markdown messages] --> C
  C --> E[Inline code and code blocks]
  B --> F[Theme contrast guard]
  C --> F
  F --> G[Regression protection]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -7, Tests +59. Total +52 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 14 -7
Tests 1 60 1 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 67 15 +52

Review metrics

Metric Value Why it matters
Production vs tests production −7 (7 added, 14 removed); tests +59 (60 added, 1 removed) The visual repair consolidates duplicate mode-specific CSS while the added lines are regression coverage for the shared token invariant.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #121374
Summary: This PR explicitly targets the canonical dark-theme inline-code readability report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one mode-independent chat-code rule using --bg-muted and --border-strong, with the repaired palette parser guarding all built-in themes before landing.

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

Yes, source-reproducible with high confidence: current main paints chat code with --secondary while each shipped dark palette equates it to the card surface; the PR also supplies after-fix Control UI harness screenshots.

Is this the best way to solve the issue?

Yes. Promoting the existing light-mode token choice into the single shared markdown rule avoids dark-only duplication and preserves the established custom-theme token contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The default dark Control UI path has a persistent readability defect, but the repair is localized to chat presentation.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body additionally provides mock-gateway Control UI screenshots and focused test output.

Label justifications:

  • P2: The default dark Control UI path has a persistent readability defect, but the repair is localized to chat presentation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body additionally provides mock-gateway Control UI screenshots and focused test output.

Evidence

What I checked:

Likely related people:

  • synth: Authored the current-main contrast-test introduction that this PR corrects and extends. (role: introduced contrast guard; confidence: high; commits: c0070d70abea; files: ui/src/styles/base-theme-contrast.node.test.ts)
  • Galin Iliev: Authored the prior current-main inline-code handling change in the chat stylesheet. (role: earlier chat-code contributor; confidence: medium; commits: 0cbd2d3b08e3; files: ui/src/styles/chat/text.css)
  • Vyctor H. Brzezowski: Has a recent merged Control UI theme-related commit and is also the proposed patch author. (role: recent adjacent UI contributor; confidence: medium; commits: 32ced3053df2; files: ui/src/styles/base.css)

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.

@vyctorbrzezowski
vyctorbrzezowski merged commit bb02fc5 into main Aug 10, 2026
148 checks passed
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Merged via squash.

@vyctorbrzezowski
vyctorbrzezowski deleted the brzezowski/inline-code-contrast branch August 10, 2026 04:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
Every dark palette defines --secondary with the same hex as --card, so the
markdown code chip painted with --secondary collapsed into the surface it sat
on (1.00:1 against a user bubble, 1.06-1.08:1 against the flat assistant
column) and --border was too close to the background to draw an edge. Light
mode never showed the bug because it overrode both properties.

Promote the light override into the single canonical rule: code chips and code
blocks paint --bg-muted with a --border-strong edge in every theme, and the
mode-specific overrides (including the raw rgba border) are deleted.

Also fixes the theme-contrast guard, which merged repeated `:root` blocks by
overwriting instead of merging, so the default `dark` theme resolved to an
empty token map and skipped every assertion. A new case reads the chip tokens
out of the shipped rule and asserts surface and border separation from --card
and --bg on all six themes.
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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: inline code chips are invisible on dark Control UI themes

1 participant