Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): capture covered preview surfaces without hanging #33719

Closedandrew-metaplanet(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/33719/headopened View on GitHub

Showing 3 changed files with 172 additions and 1 deletion.

x
0 of 3 viewed, 3 left
7 additions and 0 deletionsapps/desktop/src/preview/DesktopBrowserHost.test.tsModified
View file
@@ -96,6 +96,13 @@
getUserAgent: () => "Electron",
isLoadingMainFrame: () => options.loading === true,
isDestroyed: () => destroyed,
+ // A viewport screenshot copies the guest's surface; it waits like a debugger command.
+ capturePage: () =>
+ new Promise((resolve) => {
+ sent.push(undefined);
+ pending.push(() => resolve({ isEmpty: () => false, toPNG: () => Buffer.from("png") }));
+ sendWaiters.shift()?.();
+ }),
});
return {
tab: {
80 additions and 0 deletionsapps/desktop/src/preview/GuestInput.test.tsModified
View file
@@ -264,6 +264,86 @@
​
+ it("screenshots the guest's surface once the app paints it, and leaves clips to Chromium", async () => {
+ vi.useFakeTimers();
+ try {
+ const guest = makeGuest({ focused: false });
+ const painted = { isEmpty: () => false, toPNG: () => Buffer.from("png") };
+ const capturePage = vi
+ .fn()
+ .mockRejectedValueOnce(new Error("UnknownVizError"))