fix(app): render code blocks with theme-aware Shiki palette#2447
Open
magic-peach wants to merge 1 commit into
Open
fix(app): render code blocks with theme-aware Shiki palette#2447magic-peach wants to merge 1 commit into
magic-peach wants to merge 1 commit into
Conversation
Code blocks in assistant messages were highlighted with a hardcoded github-light theme, making tokens unreadable in dark mode. Emit both palettes via Shiki's dual-theme CSS variables and switch to github-dark when the app theme is dark. Fixes different-ai#2440
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@magic-peach is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@benjaminshafii could you please review my pr? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
github-lighttheme, so tokens were unreadable in dark mode.codeToHtmlto dual themes (themes: { light: "github-light", dark: "github-dark" },defaultColor: "light"), which emits the dark palette as--shiki-dark*CSS variables alongside the unchanged light colors.src/app/index.cssthat activates the dark variables under.dark/[data-theme="dark"](matching the app's existing dark variant selectors).Why
data-themeon the root, not adarkclass, so the snippet suggested in the issue would not have matched).Issue
Scope
apps/app/src/components/markdown/markdown.tsx(chat message renderer, the file cited in the issue)apps/app/src/react-app/domains/session/surface/markdown.tsx(artifact preview / extension detail renderer — identical hardcoded theme, same 2-line fix)apps/app/src/app/index.css(one CSS rule to activate the dark palette)Out of scope
src/components/ui/code-block.tsx(already takesthemeas a prop; callers can opt in separately)Testing
Ran
pnpm installpnpm --filter @openwork/app typecheckResult
CI status
Manual verification
shiki@4with the new options and confirmed the HTML contains both the inline light colors and--shiki-dark/--shiki-dark-bgvariables.Evidence
Left: light theme after the fix (unchanged). Right top: current dark-mode bug (light palette on dark background). Right bottom: dark theme after the fix.
I was not able to capture an in-app video for this one — the verification above was done against the real Shiki pipeline and CSS outside Electron; the 3-step in-app repro is listed for the reviewer.
Risk
.shikielements under the dark theme selectors.Rollback