Skip to content

Commit 317bbb9

Browse files
fix(desktop): settle background preview tabs on main's preview shape
Background tabs are streamed, so the server sizes them and counts only panel tabs as visible, pointer-drawn, or measured. isBackground becomes a plain check like isShown, the attached event omits the flag for panel tabs, and the Electron check entry is a knip entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d22c957 commit 317bbb9

4 files changed

Lines changed: 10 additions & 15 deletions

File tree

‎apps/desktop/scripts/verify-background-preview.mjs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// Proves agent preview tabs still paint while the app window is hidden or
2-
// minimized, using the exact window options the preview manager ships.
3-
// Agents open tabs whenever they like; a tab that cannot paint makes every
4-
// screenshot of it time out. Unit tests mock Electron, so only a real one can
5-
// catch this.
1+
// Proves agent preview tabs still paint while the app window is hidden or minimized,
2+
// using the window options the preview manager ships. Unit tests mock Electron.
63
import * as NodeChildProcess from "node:child_process";
74
import * as NodeModule from "node:module";
85
import * as NodePath from "node:path";

‎apps/server/src/preview/DesktopBrowserChannel.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class DesktopBrowserChannel extends Context.Service<
4646
readonly attached: Stream.Stream<DesktopTabKey>;
4747
readonly isAttached: (key: DesktopTabKey) => Effect.Effect<boolean>;
4848
/** The tab lives in a never-shown desktop window, so no panel sizes it. */
49-
readonly isBackground: (key: DesktopTabKey) => Effect.Effect<boolean>;
49+
readonly isBackground: (key: DesktopTabKey) => boolean;
5050
/** Whether a desktop window draws the tab on screen, which no streamed viewer counts. */
5151
readonly isShown: (key: DesktopTabKey) => boolean;
5252
/** A load failure the desktop saw, possibly before the server connected to the tab. */
@@ -94,7 +94,7 @@ const make = Effect.gen(function* () {
9494
pointer: Effect.fn("DesktopBrowserChannel.pointer")(function () {
9595
return Effect.void;
9696
}),
97-
isBackground: () => Effect.succeed(false),
97+
isBackground: () => false,
9898
isShown: () => false,
9999
loadFailure: () => undefined,
100100
});
@@ -256,9 +256,7 @@ const make = Effect.gen(function* () {
256256
isAttached: Effect.fn("DesktopBrowserChannel.isAttached")(function (key) {
257257
return Effect.sync(() => attachedTabs.has(keyOf(key)));
258258
}),
259-
isBackground: Effect.fn("DesktopBrowserChannel.isBackground")(function (key) {
260-
return Effect.sync(() => attachedTabs.get(keyOf(key)) === true);
261-
}),
259+
isBackground: (key) => attachedTabs.get(keyOf(key)) === true,
262260
isShown: (key) => shownTabs.get(keyOf(key)) ?? true,
263261
loadFailure: (key) => loadFailures.get(keyOf(key)),
264262
endpoint,

‎apps/server/src/preview/ServerBrowser.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ const dependencies = Layer.mergeAll(
500500
),
501501
),
502502
isAttached: (key) => Effect.sync(() => desktopRenders(key.tabId)),
503-
isBackground: () => Effect.sync(() => desktopBackground),
503+
isBackground: () => desktopBackground,
504504
isShown: (key) => shownDesktopTabs.has(key.tabId),
505505
loadFailure: (key) => desktopLoadFailures.get(key.tabId),
506506
endpoint: (key) =>

‎apps/server/src/preview/ServerBrowser.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,12 +954,12 @@ const make = Effect.gen(function* () {
954954
.pipe(Scope.provide(scope)),
955955
);
956956
const connected = await contexts.connectDesktopPage(endpoint);
957-
const background = await Effect.runPromise(
958-
desktopChannel.isBackground({ threadId: snapshot.threadId, tabId: snapshot.tabId }),
959-
);
960957
return {
961958
page: connected.page,
962-
background,
959+
background: desktopChannel.isBackground({
960+
threadId: snapshot.threadId,
961+
tabId: snapshot.tabId,
962+
}),
963963
close: async () => {
964964
await connected.browser.close().catch(constVoid);
965965
await runPromise(Scope.close(scope, Exit.void));

0 commit comments

Comments
 (0)