fix(chat): invert syntax highlighting in user message code blocks#1191
fix(chat): invert syntax highlighting in user message code blocks#1191fbricon wants to merge 2 commits intokortex-hub:mainfrom
Conversation
📝 WalkthroughWalkthroughAdd overflow clipping to chat message text containers; make Markdown code blocks wrap and break long words; refactor Highlight.js CSS to define light/dark palettes and add user-scoped variable overrides that invert syntax colors for user message code blocks. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
15bc17a to
9f0f3b1
Compare
| --hljs-comment: #6a737d; | ||
| --hljs-keyword: #d73a49; | ||
| --hljs-string: #032f62; | ||
| --hljs-title: #6f42c1; | ||
| --hljs-function: #6f42c1; | ||
| --hljs-number: #005cc5; | ||
| --hljs-literal: #005cc5; | ||
| --hljs-built-in: #005cc5; | ||
| --hljs-type: #d73a49; | ||
| --hljs-variable: #e36209; | ||
| --hljs-attribute: #e36209; | ||
| --hljs-meta: #6a737d; | ||
| --hljs-tag: #22863a; | ||
| --hljs-name: #22863a; | ||
| --hljs-operator: #d73a49; | ||
| --hljs-fg: #24292e; |
There was a problem hiding this comment.
do you think it can use css variables defined
usually we don't hardcode any color in the code, colors are coming from color-registry (defining variables) that rely on tailwind-color-palette stuff
There was a problem hiding this comment.
I've tweaked the css variables a bit, but moving to the color registry doesn't seem to be a good idea according to claude:
me: could we add the hljs values in tailwind-color-palette.json and then benefit from the color
registry?claude Opus: Not cleanly, because of the user message inversion requirement.
The ColorRegistry provides one value per color based on the active theme — e.g., --pd-hljs-comment
would be #6a737d in light mode or #8b949e in dark mode. But for user messages, we need both light
and dark values available simultaneously so we can swap them. The registry doesn't expose the
"other theme's" values.To work around it, we'd have to register each color twice:
this.registerColor('hljs-light-comment', { dark: '#6a737d', light: '#6a737d' });
this.registerColor('hljs-dark-comment', { dark: '#8b949e', light: '#8b949e' });That misuses the registry — the light/dark fields would have identical values since we're
registering palette entries, not themed colors. We'd still need the CSS inversion logic in
syntax-highlighting.css to swap them for [data-role='user'].So the current approach (self-contained CSS variables) is the better fit here.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fred Bricon <fbricon@gmail.com>
…rtex-hub#1190) User message bubbles use bg-primary which inverts the app theme, so code snippet highlighting colors need to be swapped accordingly to remain readable in both light and dark modes. Hex values are defined once as --hljs-light-* / --hljs-dark-* palette variables and referenced via var() in all theme blocks. These colors follow the GitHub syntax highlighting scheme and don't map to the project's tailwind color palette, so they are kept self-contained in syntax-highlighting.css rather than registered in the ColorRegistry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fred Bricon <fbricon@gmail.com>
9f0f3b1 to
9df5628
Compare
User message bubbles use bg-primary which inverts the app theme, so
code snippet highlighting colors need to be swapped accordingly to
remain readable in both light and dark modes.
Hex values are defined once as --hljs-light-* / --hljs-dark-* palette
variables and referenced via var() in all theme blocks. These colors
follow the GitHub syntax highlighting scheme and don't map to the
project's tailwind color palette, so they are kept self-contained in
syntax-highlighting.css rather than registered in the ColorRegistry.
Fixes #1190