Skip to content

fix(browser): render dark-scheme documents on a dark canvas in doc previews - #32975

Merged
AmoabaKelvin merged 2 commits into
mainfrom
doc-preview-dark-scheme-canvas
Oct 24, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
doc-preview-dark-scheme-canvas

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​21 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​10
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2

ELI5

In dark theme, opening a .json or .txt file from an HTML doc preview (the browser tab that shows a workspace .html file 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:

  • Normal browser tabs were already fine on main. JSON and text pages follow the theme there, and so does the per-site Appearance menu (feat(browser): per-site appearance and zoom, from the page menu and Cmd/Ctrl +/-/0 #31621).
  • The HTML doc preview still made its <webview> transparent and painted #fff behind it. Chromium's JSON and text viewers, and any page that declares color-scheme: light dark without a background, turned their text white in dark theme over that white fill. The preview's own "This file needs permission" message is a text/plain page too, so it was invisible as well.

After:

  • The doc preview uses the same opaque guest preference as browser tabs (ORCA_BROWSER_PAGE_GUEST_WEB_PREFERENCES_ATTRIBUTE, i.e. transparent=false). The #fff fill is gone.
  • In dark theme, dark-scheme documents get Chromium's dark canvas, with its Pretty-print bar for JSON. Pages with no styling stay white with black text in both themes. Light theme is unchanged.

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.ts was the one left on the transparent preference.

Design

  • Reuse the opaque page preference that the other two browser guest factories already use. Renderer only: about 1 line changed and 3 removed, with no IPC, saved state or main-process change.
  • Delete the #fff fill instead of swapping it for var(--background). Once the guest is opaque, the fill only shows when the guest has no frame. The loading and unavailable overlays already cover that with bg-editor-surface, which is also the parent's colour.
  • No Orca JSON viewer. Chromium's built-in viewer already does Pretty-print and follows dark mode once the canvas is opaque, which matches Chrome.

Ruled out

  • CDP Emulation.setDefaultBackgroundColorOverride on 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.
  • Forcing transparent: false for every guest in will-attach-webview. That would also change ArtifactPreview, which is transparent on purpose so dark artifacts don't flash white. It isn't a browser tab.

Open questions for Kelvin

  • ArtifactPreview has 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?
  • Per-site Appearance doesn't reach two surfaces, and neither is specific to JSON. Doc previews have no site, so they follow Orca's theme. Headless orca serve streamed pages skip the controller (registerOffscreenGuest never calls onGuestRegistered) and have no menu. JSON is readable on both (the serve window is opaque). Follow-up, or leave?
  • fix(browser): give CDP-attached guests an opaque base background #11192 can be closed as superseded. I haven't touched it.

Related

Platforms, remote, mobile

  • transparent is an Electron web preference that behaves the same on macOS, Linux and Windows, and browser tabs already ship it on all three.
  • The doc preview is rendered by the desktop client. The host only serves bytes, so mixed client/host versions behave the same.
  • Mobile needs nothing: its browser draws frames streamed from desktop/server guests, and its doc preview reads through files.readDocPreview without 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.txt and a color-scheme: light dark page, 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 dark page, 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.html from the client's address bar, which routes to the doc preview, and followed its links. On main, the guest reported prefers-color-scheme: dark with body colour rgb(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 a color-scheme: light dark page. 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 the workspace-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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: none. The guest keeps the same partition, preload pin and admission checks in will-attach-webview, which don't read transparent.
  • Performance: none. An opaque guest layer needs no alpha blending, so it's slightly cheaper to composite.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e728dea7-a1aa-4139-b9d7-7d659ac60b93
Commits

Reviewing files that changed from the base of the PR and between 65af0e4 and 6db9ca7.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 98f0c8aa-260e-4fc7-9013-cef15b92acda
Commits

Reviewing files that changed from the base of the PR and between 4687e90 and 65af0e4.

Files selected for processing: 2
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-webview-attach.test.ts
  • src/renderer/src/components/browser-pane/workspace-doc/doc-preview-webview-attach.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The document preview now uses ORCA_BROWSER_PAGE_GUEST_WEB_PREFERENCES_ATTRIBUTE instead of ORCA_BROWSER_GUEST_WEB_PREFERENCES_ATTRIBUTE. The attachment no longer assigns a white webview background. Tests use a shared attachment helper and check that webpreferences includes transparent=false.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 65af0

The change is limited to preview rendering preferences and has no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: rendering dark-scheme documents on a dark canvas in document previews.
Description check Passed The description follows the required template and provides a clear user-facing summary, implementation details, rationale, linked issue, visual proof, testing evidence, and compatibility notes. The em…
Linked Issues check Passed Issue [#11190] requires readable dark-theme rendering for JSON content in an embedded browser. The production change applies ORCA_BROWSER_PAGE_GUEST_WEB_PREFERENCES_ATTRIBUTE to the document-preview…
Out of Scope Changes check Passed The changes stay within issue [#11190]. The production change fixes document-preview canvas rendering. The test helper refactor supports the existing drag test, and the new assertion verifies the opaq…
Full details: Description check

Explanation

The description follows the required template and provides a clear user-facing summary, implementation details, rationale, linked issue, visual proof, testing evidence, and compatibility notes. The empty Review section and unchecked full CI checklist are non-critical because the PR is a draft and the author documents the checks that were run.

Full details: Linked Issues check

Explanation

Issue [#11190] requires readable dark-theme rendering for JSON content in an embedded browser. The production change applies ORCA_BROWSER_PAGE_GUEST_WEB_PREFERENCES_ATTRIBUTE to the document-preview webview, which sets transparent=false, and removes the white background fill. The added test verifies the opaque guest preference. The PR description also reports that the existing browser-tab path already provides the requested behavior.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue [#11190]. The production change fixes document-preview canvas rendering. The test helper refactor supports the existing drag test, and the new assertion verifies the opaque guest requirement. No unrelated production behavior, IPC, state, or main-process code changed.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

… doc previews

The doc preview guest was transparent over a white fill, so dark-scheme
documents rendered white text on white.

Fixes #11190
@AmoabaKelvin
AmoabaKelvin force-pushed the doc-preview-dark-scheme-canvas branch from 65af0e4 to 6db9ca7 Compare October 24, 2026 03:26
@AmoabaKelvin
AmoabaKelvin merged commit 1753f03 into main Oct 24, 2026
33 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the doc-preview-dark-scheme-canvas branch October 24, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: JSON responses show up as a blank white page in the embedded browser (dark theme)

1 participant