Add viewer theme toggle + fix washed-out dark-mode comment highlights#4
Conversation
Add a light/dark/auto control to the viewer chrome bar and persist the choice per viewer in localStorage. A forced mode drives both the chrome palette and the in-iframe highlight treatment via a new jh:setThemeMode message to the overlay, so it also serves as a manual override when the doc's darkness is mis-detected. Strengthen the dark-mode comment highlight: the previous ~16% warm tint was nearly invisible on a dark page. It's now a readable amber wash (~.30-.54 by overlap depth) with a near-opaque warm underline across depth levels, hover, and focus, tuned to keep the doc's light text legible. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 609727d. Configure here.
| () => (mode === "auto" && theme && theme.isDark ? buildChromePalette(theme) : null), | ||
| [theme] | ||
| () => (effectiveTheme ? buildChromePalette(effectiveTheme) : null), | ||
| [effectiveTheme] |
There was a problem hiding this comment.
Theme mode not re-synced
Medium Severity
On a second jh:ready while overlayReady is already true, the shell re-posts anchors and reactions but never sends jh:setThemeMode. The new iframe overlay keeps forcedMode at auto, so saved light/dark highlight treatment can disagree with the chrome until the user toggles theme again.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 609727d. Configure here.


Summary
Makes comments render correctly across light and dark documents. Three fixes:
1. Light/dark/auto theme toggle (saved). The viewer chrome had no theme control — it was inferred from the document's background and never selectable (
CommentsShellhardcodedmode = "auto"). Adds a☀ / ☾ / ◐(auto)segmented control to the chrome bar, persisted per viewer inlocalStorage(global preference), driving the chrome palette via aneffectiveTheme. Default staysauto, so light docs are byte-identical to before.2. Dark-mode highlight legibility. The dark highlight was
rgba(241,196,15,.16)— a16% wash invisible on a dark page. Strengthened to a readable amber wash (.30–.54 by overlap depth) with a near-opaque warm underline, across depth levels, hover, and focus, tuned to keep the doc's light text legible.3. Two rendering bugs found in review:
jh:setThemeModere-post concern). The in-document highlight is painted on the document, so it must contrast with the document's background — not the chrome theme. An earlier iteration tied the highlight treatment to the toggle, so forcing light chrome on a dark doc flipped the highlight toward the light treatment and it stopped reading. Fixed by keying.jh-darkon the doc's sampled darkness only. This removesjh:setThemeModeentirely, so there's no re-post gap on a secondjh:ready.<h3>into an inline<span>whose background never paints — the highlight silently vanished (in light mode too).locateStartbiases a boundary start into the next text node, so we wrap the text, not the block.Presentation-only: no API, DB, or anchoring-model changes.
/d/:slug/rawstays byte-pristine (overlay only under?overlay=1).Verification
tsc --noEmitclean ·vitest108/108 ·next buildcleanKnown limitation (not a bug)
The toggle themes the viewer chrome; it can't repaint the author's document, which renders as byte-pristine HTML in a sandboxed iframe. A doc authored with fixed dark colors stays dark;
autokeeps the chrome matched to it. Forwarding the choice to adaptive (prefers-color-scheme) docs is possible as a follow-up.🤖 Generated with Claude Code