Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): agent screenshots and clicks work while T3 Code is hidden, minimized or covered #40263

Merged3xcalibur-tech(GitHub profile, opens in a new tab)merged 7 commits intomain fromrefs/pull/40263/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 97 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
97 additions and 0 deletionsapps/desktop/src/preview/DesktopBrowserHost.test.tsModified
View file
@@ -50,6 +50,10 @@
readonly deferFocus?: boolean;
/** The guest is still loading its first page. */
readonly loading?: boolean;
+ /** Like a guest of a hidden window: it answers a capture only once Electron captures it. */
+ readonly drawsOnlyWhenCaptured?: () => boolean;
+ /** Electron's capture of this guest never settles. */
+ readonly capturesStall?: () => boolean;
readonly refuse?: (method: string, sessionId: string | undefined) => boolean;
} = {},
) => {
@@ -90,7 +94,14 @@
}),
});
let destroyed = false;
+ let nativeCaptures = 0;
const webContents = Object.assign(new NodeEvents.EventEmitter(), {
+ capturePage: () => {
+ nativeCaptures += 1;
+ if (options.capturesStall?.()) return new Promise(() => {});
+ if (options.drawsOnlyWhenCaptured?.()) pending.splice(0).forEach((resolve) => resolve());
+ return Promise.resolve({});
+ },
getURL: () => "http://localhost/",
getTitle: () => "Page",
getUserAgent: () => "Electron",
@@ -117,6 +128,7 @@
/** Refuses the pending command the debugger received with this id. */