Skip to content

Commit 0b8e794

Browse files
fix(web): streamed device toolbar starts at the panel size
ServerBrowserSurface never publishes a rect to the browser surface store, so turning on the device toolbar for a streamed tab fell back to 1024x768. Measure the streamed surface's own box instead. AI-assisted; verified with the tests and tools listed above.
1 parent 2b7813b commit 0b8e794

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎apps/web/src/components/preview/PreviewView.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ export function PreviewView({
213213
const isServerTab = snapshot?.runtime === "server" && !nativeServerTab;
214214
const serverOwnsRendering = snapshot?.runtime === "server";
215215
const serverSurfaceRef = useRef<ServerBrowserHandle | null>(null);
216+
const serverSurfaceBoxRef = useRef<HTMLDivElement | null>(null);
216217
const [serverAspectRatioLocked, setServerAspectRatioLocked] = useState(false);
217218
const [serverToolbarWidth, setServerToolbarWidth] = useState(0);
218219
const serverToolbarShown =
@@ -414,7 +415,10 @@ export function PreviewView({
414415
target,
415416
browserResponsiveViewportForToggle({
416417
defaults: browserDefaults,
417-
panelRect,
418+
// Only BrowserSurfaceSlot publishes a store rect; streamed tabs measure their own box.
419+
panelRect: isServerTab
420+
? (serverSurfaceBoxRef.current?.getBoundingClientRect() ?? null)
421+
: panelRect,
418422
zoomFactor: isServerTab ? serverZoomFactor : layoutZoomFactor,
419423
}),
420424
).catch(() => undefined);
@@ -1056,6 +1060,7 @@ export function PreviewView({
10561060
</div>
10571061
) : null}
10581062
<div
1063+
ref={serverSurfaceBoxRef}
10591064
className={cn(
10601065
"absolute inset-x-0 bottom-0",
10611066
(showEmptyState || isUnreachable) && "invisible",

0 commit comments

Comments
 (0)