Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions apps/web/src/components/preview/ThreadPreviewMiniPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ interface Props {
readonly bottomInset: number;
}

const PREVIEW_MINI_PLAYER_CORNER_RADIUS = 12;

// Invisible grab zones straddling each edge; the cursor is the only affordance.
const RESIZE_HANDLES: ReadonlyArray<{
readonly direction: BrowserViewportResizeDirection;
Expand All @@ -59,6 +61,10 @@ const RESIZE_HANDLES: ReadonlyArray<{
{ direction: "southeast", className: "-bottom-2 -right-2 size-4 cursor-nwse-resize" },
];

/**
* Floats the thread's browser surface over chat. Native clipping and the DOM
* frame use the same radius so their separately composited edges stay aligned.
*/
export function ThreadPreviewMiniPlayer({ threadRef, tabId, bottomInset }: Props) {
const containerRef = useRef<HTMLDivElement | null>(null);
const gestureRef = useRef<PointerGesture | null>(null);
Expand Down Expand Up @@ -193,7 +199,13 @@ export function ThreadPreviewMiniPlayer({ threadRef, tabId, bottomInset }: Props
aria-label="Floating browser preview"
data-preview-mini-player={tabId}
className="pointer-events-none absolute select-none"
style={{ left: frame.x, top: frame.y, width: frame.width, height: frame.height }}
style={{
left: frame.x,
top: frame.y,
width: frame.width,
height: frame.height,
borderRadius: PREVIEW_MINI_PLAYER_CORNER_RADIUS,
}}
>
<div className="group pointer-events-auto absolute right-2 top-2 z-[49] size-3">
<div
Expand Down Expand Up @@ -267,19 +279,19 @@ export function ThreadPreviewMiniPlayer({ threadRef, tabId, bottomInset }: Props
</div>
</div>

<div className="absolute inset-0 z-[47] rounded-xl bg-muted shadow-2xl/35" />
<div className="absolute inset-0 z-[47] rounded-[inherit] bg-muted shadow-2xl/35" />
<BrowserSurfaceSlot
tabId={runtimeTabId}
visible={Boolean(desktopOverlay?.hasWebContents)}
cornerRadius={12}
cornerRadius={PREVIEW_MINI_PLAYER_CORNER_RADIUS}
zIndex={PREVIEW_MINI_PLAYER_WEBVIEW_Z_INDEX}
fitSourceContent
layoutVersion={`${frame.x}:${frame.y}`}
className="absolute inset-0"
/>
<div className="pointer-events-none absolute inset-0 z-[49] rounded-xl ring-1 ring-inset ring-border/80" />
<div className="pointer-events-none absolute inset-0 z-[49] rounded-[inherit] ring-1 ring-inset ring-border/80" />
{!desktopOverlay?.hasWebContents ? (
<div className="pointer-events-none absolute inset-0 z-[49] flex items-center justify-center rounded-xl bg-muted text-xs text-muted-foreground">
<div className="pointer-events-none absolute inset-0 z-[49] flex items-center justify-center rounded-[inherit] bg-muted text-xs text-muted-foreground">
Reconnecting preview…
</div>
) : null}
Expand Down
Loading