Pin color-scheme on rich-part surface frames (fix white canvas in dark mode)#191
Merged
Conversation
…n dark mode) markdown/code/diff/mermaid surfaces render in sandboxed, opaque-origin iframes. Those default to `color-scheme: normal` (light), so in dark mode the UA painted a WHITE canvas behind the transparent body and the dark-mode text (--text) washed out over it — a markdown caption looked like a near-blank white box on a dark board. renderSandboxedPart/renderMermaidPage now emit colorSchemeCss(mode), the same pin html surfaces already use, so the frame's UA canvas tracks the card in both schemes. A prior comment claimed omitting the property kept the frame transparent; it doesn't — it just leaves the canvas light. That note is corrected, and the regression test now asserts the pin (it previously asserted the buggy "must NOT force color-scheme"). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…g the bug) The e2e theme spec encoded the old buggy behavior — that a transparent markdown frame keeps no forced color-scheme. With the canvas now pinned to the resolved scheme, it must be `dark` in dark mode. Invert the assertion and its comment to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
A markdown (or code/diff/mermaid) surface renders as a near-blank white box with washed-out text on a dark board:
…rendered as faint light-gray text on solid white, inside an otherwise-dark card.
Root cause
Rich-part surfaces (
renderSandboxedPart,renderMermaidPage) are sandboxed, opaque-origin iframes loaded by URL. Such a frame defaults tocolor-scheme: normal(i.e. light). Its body isbackground: transparent— the design intends the dark card to show through — but with a lightcolor-schemethe UA paints the iframe canvas white, and the dark-mode text (--text: #e6edf3) washes out over it.A comment in
renderSandboxedPartexplicitly omittedcolor-scheme, reasoning that forcing it "would paint an opaque UA canvas." That's backwards: omitting it is what leaves the canvas light/white; html surfaces (renderHtmlPage) already pin it viacolorSchemeCss(mode)and render correctly.Verified by reproduction (Playwright, real engine + cloud embed, dark mode): the markdown frame's computed values are all "dark + transparent," yet it visibly paints white — and adding
colorSchemeCss(doc.mode)makes it render correctly and seamlessly against the card.Change
renderSandboxedPartandrenderMermaidPagenow emitcolorSchemeCss(doc.mode)— the exact pin html surfaces already use — so the UA canvas tracks the resolved scheme (dark→dark, light→light). No mode → left to the OS, unchanged.:root{color-scheme:dark}, light→light, no-mode→unpinned).Tests
npm test(400),npm run typecheck,npm run lint,npm run format:checkall green.🤖 Generated with Claude Code