Repository navigation
fix(browser): render dark-scheme documents on a dark canvas in doc previews - #32975
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
… doc previews The doc preview guest was transparent over a white fill, so dark-scheme documents rendered white text on white. Fixes #11190
65af0e4 to
6db9ca7
Compare
ELI5
In dark theme, opening a
.jsonor.txtfile from an HTML doc preview (the browser tab that shows a workspace.htmlfile in an SSH or paired workspace) gave you a blank white page. The text was there, just white on white. Now it shows on a dark background, the same way a normal browser tab does.What Changed
Before:
<webview>transparent and painted#fffbehind it. Chromium's JSON and text viewers, and any page that declarescolor-scheme: light darkwithout a background, turned their text white in dark theme over that white fill. The preview's own "This file needs permission" message is atext/plainpage too, so it was invisible as well.After:
ORCA_BROWSER_PAGE_GUEST_WEB_PREFERENCES_ATTRIBUTE, i.e.transparent=false). The#ffffill is gone.Why
Root cause. Chromium only swaps the page canvas to its dark colour for a dark-scheme document when the guest's base background is opaque. A transparent guest never gets that canvas, so whatever sits behind it shows through. Browser tabs were made opaque in #18738 (local) and #27749 (client-hosted). The doc preview's factory in
doc-preview-webview-attach.tswas the one left on the transparent preference.Design
#ffffill instead of swapping it forvar(--background). Once the guest is opaque, the fill only shows when the guest has no frame. The loading and unavailable overlays already cover that withbg-editor-surface, which is also the parent's colour.Ruled out
Emulation.setDefaultBackgroundColorOverrideon every guest (community PR fix(browser): give CDP-attached guests an opaque base background #11192). It needs a debugger attached to every guest and has to be re-sent after agent takeovers. The guest preference gets the same result without CDP, and browser tabs already ship it.transparent: falsefor every guest inwill-attach-webview. That would also changeArtifactPreview, which is transparent on purpose so dark artifacts don't flash white. It isn't a browser tab.Open questions for Kelvin
ArtifactPreviewhas the same transparent guest. An unstyled artifact in dark theme shows black text on Orca's dark surface. I left it alone because that choice is deliberate there. Worth a follow-up?orca servestreamed pages skip the controller (registerOffscreenGuestnever callsonGuestRegistered) and have no menu. JSON is readable on both (the serve window is opaque). Follow-up, or leave?Related
Platforms, remote, mobile
transparentis an Electron web preference that behaves the same on macOS, Linux and Windows, and browser tabs already ship it on all three.files.readDocPreviewwithout this webview. Mobile has no per-site Appearance today.Linked Issue
Fixes #11190
Visual Proof
Doc preview in a paired workspace, Orca dark. Clicks through to
data.json,notes.txtand acolor-scheme: light darkpage, then switches Orca to light.Before (main):
(screenshot removed: contained real product data)
After:
(screenshot removed: contained real product data)
Stills (left: before, right: after; top:
data.json, bottom:color-scheme: light darkpage, both in Orca dark):(screenshot removed: contained real product data)
Normal browser tab, same URLs. This PR doesn't change this path; it's here to show light, dark and per-site Dark already work.
Main (columns: Orca light, Orca dark, Orca light + site Dark; rows: JSON,
text/plain):(screenshot removed: contained real product data)
Branch, recorded through the real
...> Appearance > Dark menu:(screenshot removed: contained real product data)
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Hidden dev builds on macOS: one paired as a host runtime with a folder workspace, one as the client. I opened
/tmp/jdm-remote/page.htmlfrom the client's address bar, which routes to the doc preview, and followed its links. On main, the guest reportedprefers-color-scheme: darkwith body colourrgb(255, 255, 255)over the white fill. On the branch, the same pages render on the dark canvas.Regular tab matrix on main (light, dark, light + site Dark, dark + site Dark, dark + site Light) across JSON,
text/plain, an unstyled HTML page, an image and acolor-scheme: light darkpage. All were readable.New unit assertion that the doc preview guest is opaque. It fails on main's code and passes here.
Local checks:
check:code-quality:changed,check:react-doctor:changed,pnpm tc:web, and theworkspace-doc/tests (11 files, 86 tests).This is a draft, so stablyai/orca's PR Checks skip every job except the line-count check. Full CI runs once it's marked ready.
AI Disclosure
Review
Agent skill upstream boundary
Notes
will-attach-webview, which don't readtransparent.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)