fix(desktop): markdown pages no longer render invisible in the dark-mode browser (#14601)

Co-authored-by: PR Batch Tester <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-10-02 10:34:17 +05:30
1 parent 2731929610
commit 3e60fecf39
2 files changed
+28 -1

No files matched your search

+15 -1
View File
@@ -1601,7 +1601,7 @@ describe("PreviewManager", () => {
),
);
effectIt.effect("emulates prefers-color-scheme and re-applies it across webview swaps", () =>
effectIt.effect("re-applies opaque base and color scheme across webview swaps", () =>
withManager((manager) =>
Effect.gen(function* () {
const makeWebContents = (id: number) => {
@@ -1650,6 +1650,16 @@ describe("PreviewManager", () => {
yield* manager.registerWebview("tab_scheme", 42);
yield* Effect.yieldNow;
// Guests start with a transparent base; dark-scheme pages need an opaque
// one or Chromium skips their dark canvas.
const opaqueBase = {
color: { r: 255, g: 255, b: 255, a: 1 },
};
expect(first.sendCommand).toHaveBeenCalledWith(
"Emulation.setDefaultBackgroundColorOverride",
opaqueBase,
);
yield* manager.setColorScheme("tab_scheme", "dark");
expect(first.sendCommand).toHaveBeenCalledWith("Emulation.setEmulatedMedia", {
@@ -1662,6 +1672,10 @@ describe("PreviewManager", () => {
yield* manager.registerWebview("tab_scheme", 43);
yield* Effect.yieldNow;
expect(replacement.sendCommand).toHaveBeenCalledWith(
"Emulation.setDefaultBackgroundColorOverride",
opaqueBase,
);
expect(replacement.sendCommand).toHaveBeenCalledWith("Emulation.setEmulatedMedia", {
features: [{ name: "prefers-color-scheme", value: "dark" }],
});
+13
View File
@@ -1418,6 +1418,19 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
),
{ concurrency: "unbounded", discard: true },
);
// Electron gives `<webview>` guests a transparent base background, and
// Chromium only paints a dark canvas for dark color-scheme pages over an
// opaque base. Without this, dark-scheme pages with no background of
// their own (text/plain, e.g. .md files) render white text on white.
// White matches the webview's existing white backing, so light pages look
// the same; Chromium still swaps in its dark canvas for dark-scheme pages.
yield* attemptPromise(
{ operation: "initializeDebugger.defaultBackground", webContentsId: wc.id },
() =>
wcDebugger.sendCommand("Emulation.setDefaultBackgroundColorOverride", {
color: { r: 255, g: 255, b: 255, a: 1 },
}),
);
return [
control,
replaceMap(sessions, (copy) => {