refactor(ui): split pierre diff theme from markdown fence theme (#705) - #708
Conversation
…--diff-del (#705) pierre's OpenCode theme wrote `editor.background = var(--code-surface)` as an inline style on `<pre>`, so every stylesheet attempt to set `--diffs-bg` lost the cascade and the diff viewer rendered a cool half-transparent gray shell. Switch `editor.background` to `var(--bg-base)` and point the add/del row overrides at PawWork's `--diff-add` / `--diff-del` semantic tokens, which already carry the correct light/dark values; this also removes the dark `:host([data-color-scheme='dark'])` branch and the drift it was hiding (rgba 63,179,115,0.18 vs the token's 58,176,107,0.15). Flatten the hunk separator + chevron expand button by overriding `--diffs-bg-{buffer,context,separator}` to transparent, kill the 2 px gutter seam with `--diffs-gap-style: 2px solid transparent`, and switch `diffIndicators` from `bars` (4 px side-stripe banned by DESIGN.md) to `classic` (+/− char markers). Drop the local `[data-column-number] { background-color: var(--bg-base) }` rule that was clobbering pierre's own add/del number-column tint.
📝 WalkthroughWalkthroughThe PR unifies editor and diff styling by updating the OpenCode editor background to use ChangesDiff and Editor Theme Unification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the OpenCode theme background to use var(--bg-base) and refactors Pierre diff styling by replacing internal CSS variables with semantic token overrides. It also changes the diff indicators from 'bars' to 'classic' and adjusts column spacing for better visual consistency. A critical issue was identified where the removal of --diffs-deletion-base and --diffs-addition-base would break word-level diff highlights and selection rules, so these should be restored.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/pierre/index.ts`:
- Line 199: The CSS variable "--diffs-gap-style" in
packages/ui/src/pierre/index.ts is not a recognized pierre variable and has no
effect; either confirm pierre 1.1.0-beta.18 supports it via authoritative docs
or remove it and implement a supported alternative: delete the
"--diffs-gap-style" entry and instead apply a supported visual fix (for example,
add a box-shadow or use background-clip/padding-box on the diff row selector
such as the component/class that renders rows in pierre to hide the seam while
keeping the row tint), or add a custom pierce-through rule if pierre exposes
one; update the relevant styling export in index.ts and any associated
class/selector (the diff row renderer) to use the chosen approach.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: df09889d-b430-4bb1-ad4c-32be063a27da
📒 Files selected for processing (2)
packages/ui/src/context/marked.tsxpackages/ui/src/pierre/index.ts
Perf delta summaryComparator: pass
|
The earlier fix on this branch (1df0105) routed the pierre diff fix through the shared OpenCode shiki theme by changing editor.background to var(--bg-base). That fixed the diff but broke the #642 PR0 contract that pins editor.background to var(--code-surface) for markdown fence-code, because the two surfaces were sharing one theme — and they have different visual jobs: fence-code wants an alpha-overlay card against chat body, the diff viewer wants the surface to recede so add/del row tints carry the signal. Fork a "PawWorkDiff" theme that spreads OpenCode's tokenColors and only overrides editor.background to var(--bg-base); point pierre.createDefaultOptions at it. OpenCode itself returns to var(--code-surface) and the theme-parity guard goes green again. pierre's add/del row overrides remain bound to PawWork's --diff-add / --diff-del semantic tokens (which carry their own light/dark values), so the dark :host([data-color-scheme='dark']) branch that had drifted to rgba(63,179,115,0.18) vs the token's rgba(58,176,107,0.15) stays removed. Net effect: markdown fence-code visuals are unchanged from main; review-panel diff renders on the warm --bg-base shell with PawWork add/del tints; the two code surfaces are now decoupled at the theme layer so future edits to one cannot silently move the other.
Summary
PawWorkDiffshiki theme alongsideOpenCodeinmarked.tsx. PawWorkDiff spreads OpenCode'stokenColorsandsemanticTokenColorsand only overrideseditor.backgroundtovar(--bg-base). OpenCode itself is restored toeditor.background = var(--code-surface), restoring the [Task] Design token system debt log (drift, redundancy, dual systems) #642 PR0 contract.pierre.createDefaultOptionsattheme: "PawWorkDiff". Markdown fence-code keeps usingOpenCode. The two surfaces are now decoupled at the theme layer.--diffs-bg-{addition,deletion}{,-number}-overrideto PawWork's--diff-add/--diff-delsemantic tokens. The dark:host([data-color-scheme='dark'])add/del branch is dropped because the tokens already carry their own light/dark values (and the dropped branch had drifted torgba(63,179,115,0.18)vs the token'srgba(58,176,107,0.15)).--diffs-bg-{buffer,context,separator}-override: transparent) and hide the 2 px gutter seam (--diffs-gap-style: 2px solid transparent) so non-add/non-del rows sit flat on the PawWorkDiff surface.[data-column-number] { background-color: var(--bg-base) }rule that was clobbering pierre's own number-column tint on add/del rows.diffIndicatorsfrombars(4 px side-stripe — banned by DESIGN.md absolute bans) toclassic(+/− char markers).Why
Resolves #705. The issue surfaced as "diff viewer is cool gray, not warm
--bg-base," but the root cause was deeper: pierre serializeseditor.backgroundfrom its shiki theme into a<pre>inline style, and that inline value wins the cascade against every--diffs-bgrule inunsafeCSS. The earlier iteration on this branch (1df0105) routed the fix throughOpenCode.editor.background = var(--bg-base), but that surface is shared with markdown fence-code and is pinned tovar(--code-surface)by the #642 PR0 contract (theme-parity.test.ts:354). CI broke; chat-thread fence-code became visually identical to body in dark.The fence-code surface and the diff surface have different jobs — fence-code is a card-like alpha overlay against chat body, the diff viewer is a flat surface so add/del row tints carry the signal — so coupling them through one theme is the wrong architecture. Forking PawWorkDiff lets each surface declare its own
editor.backgroundwhile sharing all syntax highlighting (tokenColors / semanticTokenColors via spread). Future edits to chat code rendering cannot silently move the review diff, and vice versa.Related Issue
Closes #705.
Adjacent: #709 (rework dark mode color system) will revisit
--bg-base/--code-surface/ etc. holistically; this PR ships independently.Human Review Status
Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.
Review Focus
PawWorkDifftheme is the load-bearing change. It isOpenCodewith one field overridden; both themes sharetokenColorsvia spread so there is no duplicated palette to maintain.OpenCode.editor.backgroundis back tovar(--code-surface). The#642 PR0theme-parity contract (packages/ui/test/theme-parity.test.ts:354) is green again.:host([data-color-scheme='dark'])block under[data-diff], [data-file]now contains only selection-related tokens. Add/del live in the PawWork--diff-add/--diff-deltokens.marked.tsxshows a large diff because the OpenCode theme object was extracted to a top-levelOPENCODE_THEMEconst (indent shift). Use "Hide whitespace changes" orgit diff -wto see the real delta (+29 / -11 lines logical).Risk Notes
dev. The earlier iteration's "unified--bg-basebackground" idea is reverted in this commit; that direction will be revisited under [Feature] Rework dark mode color system #709 if it makes sense at all.diffIndicators: "bars"→"classic"changes the per-row marker style; affects every diff render path.DESIGN.mdL191 + L482 were updated locally to permit the--diff-add/--diff-deltokens and to align the dark alpha to the runtime0.15value;docs/is excluded from this worktree's tracking, so the doc change is not in this PR — flagged here for spec coherence.How To Verify
Screenshots or Recordings
Review-panel + chat-fence screenshots were taken locally via E2E (
docs/debug-screens/i705-{chat,}-{light,dark}.png). Attaching them to the PR body requires the GitHub web UI's drag-and-drop. I will add them as a follow-up comment once the human reviewer is ready.Checklist
bug,enhancement,task, ordocumentation), at least one primary routing label (app,ui,platform,harness, orci), and exactly one priority label (P0toP3), or I requested maintainer labelingdev, and my PR title and commit messages use Conventional Commits in English