Skip to content

Commit 24f745f

Browse files
PR Batch Testerclaude
andcommitted
fix(server): a page load measures a desktop tab again
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 76d3f97 commit 24f745f

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,21 +1219,29 @@ it.effect(
12191219
result: { value: { width, height } },
12201220
});
12211221
const resized = () => cdp.emitAsync("Page.frameResized");
1222-
// An alert open on attach blocks the first read, which gives up with no size to send.
1222+
// The read on attach never answers and gives up with no size to send.
12231223
const blocked = yield* Queue.take(reads);
12241224
yield* TestClock.adjust("1 second");
1225-
// While it stays open nothing reads again; the host closing it clears it.
1225+
// The next page load measures again.
1226+
desktopSizeAnswer = null;
1227+
yield* Effect.promise(() => cdp.emitAsync("Page.loadEventFired"));
1228+
expect(viewportSizes(yield* Queue.takeAll(viewer.output))).toEqual(["1920x1080"]);
1229+
// While a dialog is open nothing reads. The host closing it clears it, and since
1230+
// closing resizes nothing, the close itself remeasures.
1231+
deferReads();
12261232
context.page.emit("dialog", {
12271233
type: () => "alert",
12281234
message: () => "",
12291235
defaultValue: () => "",
12301236
});
12311237
yield* Effect.promise(resized);
12321238
expect(yield* Queue.size(reads)).toBe(0);
1233-
// Closing it resizes nothing, so the close itself remeasures.
12341239
desktopSizeAnswer = null;
12351240
yield* Effect.promise(() => cdp.emitAsync("Page.javascriptDialogClosed"));
1236-
expect(viewportSizes(yield* Queue.takeAll(viewer.output))).toEqual(["1920x1080"]);
1241+
expect(viewportSizes(yield* Queue.takeAll(viewer.output))).toEqual([
1242+
"1920x1080",
1243+
"1920x1080",
1244+
]);
12371245
// The late answer, a read a navigation breaks and a hidden webview keep the last size.
12381246
blocked.resolve(answer(100, 100));
12391247
deferReads();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,8 @@ const make = Effect.gen(function* () {
858858
if (tab.viewers.size > 0) return broadcastViewport(tab).catch(constVoid);
859859
};
860860
cdp.on("Page.frameResized", remeasure);
861+
// A read a navigation broke has a fresh page to measure.
862+
cdp.on("Page.loadEventFired", remeasure);
861863
// Closing a dialog resizes nothing, and the host can close it without us.
862864
cdp.on("Page.javascriptDialogClosed", () => {
863865
tab.dialog = null;

0 commit comments

Comments
 (0)