Repository navigation
fix: follow DSH shell dark theme for code blocks and Mermaid - #1
Merged
Merged
Conversation
MarkstreamMarkdown never passed isDark to MarkdownRender, so markstream defaulted to its light theme regardless of the page appearance: Shiki code blocks rendered with a white background on dark pages and Mermaid diagrams used light-theme colors. Add useDshIsDark(), which resolves the shell's current color scheme via the computed --dsw-alias-bg-base token luminance (fallbacks: the data-ds-dark-theme attribute, then prefers-color-scheme) and re-renders on theme switches through a debounced MutationObserver. Verified in DSH 0.1.0-rc.6 web profile with a patched bundle before upstreaming.
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 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 |
Owner
|
LGTM |
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.
Problem
MarkstreamMarkdownnever passedisDarktoMarkdownRender, so markstream fell back to its light theme regardless of the page appearance. In a dark-themed DSH web profile:Fix
Adds
useDshIsDark()insrc/client/renderer.tsx:--dsw-alias-bg-basetoken (threshold 140/255). This is always fresh and independent of how DSH's theme system applies tokens.data-ds-dark-themeattribute on<body>, then OS preference viaprefers-color-scheme.MutationObserveron<html>/<body>(data-ds-dark-themeandstyleattributes) re-renders when the user switches themes without reloading.The resolved value is passed as
isDarktoMarkdownRender, which propagates it to Shiki code blocks, the Mermaid renderer (dark SVG theme), math containers, and the root.markstream-react.darkCSS class.Verification
data-ds-dark-themeset → asserts.markstream-react.dark; removes the attribute → asserts the dark class goes away via the observer path. All 6 tests pass (pnpm run check).0.1.0-rc.6web profile: patched bundle served from/plugins/dsh-better-markdown/client.js; code blocks and Mermaid follow the dark page, and theme switches apply live without reload.Notes
src/client/dsh-theme.tsmodule or an explicitisDarkprop onMarkstreamMarkdown, happy to restructure.