GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(desktop): the browser panel keeps the theme background while a pa… · pingdotgg/t3code@53fdf49

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/browser
    • HostedBrowserWebview.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/browser/HostedBrowserWebview.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/browser/HostedBrowserWebview.tsx
+12-8Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export function HostedBrowserWebview(props: {
135135

136136
const [webviewGeneration, setWebviewGeneration] = useState(0);
137137
const [recoverySrc, setRecoverySrc] = useState(initialSrc);
138+
// A guest with no document is transparent, so the host paints the panel until the first commit.
139+
const [committedGeneration, setCommittedGeneration] = useState<number | null>(null);
138140
const active = presentation.visible && presentation.rect !== null;
139141
const shown = active || pictureInPicture;
140142
const reportedShown = useEffectEvent(() => serverDriven && shown);
@@ -186,8 +188,13 @@ export function HostedBrowserWebview(props: {
186188
new PointerEvent("pointerdown", { bubbles: true, pointerType: "mouse" }),
187189
);
188190
};
191+
const markCommitted = (event: Event) => {
192+
if ((event as Event & { url?: string }).url === "about:blank") return;
193+
setCommittedGeneration(webviewGeneration);
194+
};
189195
webview.addEventListener("did-attach", register);
190196
webview.addEventListener("dom-ready", register);
197+
webview.addEventListener("did-navigate", markCommitted);
191198
webview.addEventListener("render-process-gone", recoverGuest);
192199
webview.addEventListener("focus", dismissHostPopups);
193200
register();
@@ -196,16 +203,11 @@ export function HostedBrowserWebview(props: {
196203
if (recoveryTimeout !== null) clearTimeout(recoveryTimeout);
197204
webview.removeEventListener("did-attach", register);
198205
webview.removeEventListener("dom-ready", register);
206+
webview.removeEventListener("did-navigate", markCommitted);
199207
webview.removeEventListener("render-process-gone", recoverGuest);
200208
webview.removeEventListener("focus", dismissHostPopups);
201209
};
202-
}, [
203-
clientSettingsHydrated,
204-
config,
205-
runtimeTabId,
206-
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- A crash recovery remounts the webview under a new key, so the listeners attach to the new element.
207-
webviewGeneration,
208-
]);
210+
}, [clientSettingsHydrated, config, runtimeTabId, webviewGeneration]);
209211

210212
const lastRect = presentation.rect;
211213
const layoutZoomFactor = useBrowserLayoutZoomFactor(zoomFactor);
@@ -362,7 +364,9 @@ export function HostedBrowserWebview(props: {
362364
}
363365
aria-hidden={active ? undefined : true}
364366
className={cn(
365-
"absolute flex overflow-hidden bg-white",
367+
"absolute flex overflow-hidden",
368+
// White is the browser canvas behind transparent pages once a document exists.
369+
committedGeneration === webviewGeneration ? "bg-white" : "bg-background",
366370
active && !layout.fillsPanel && "ring-1 ring-border/70 shadow-sm",
367371
)}
368372
style={{

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.