Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: the in-app browser can float over the chat as a small, resizable window (#16775)
Michael Han4db1f3946dad
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsxindex fdafa0d0726..e5555511e84 100644--- a/studio/frontend/src/components/app-sidebar.tsx+++ b/studio/frontend/src/components/app-sidebar.tsx@@ -5914,7 +5914,8 @@ export function AppSidebar() {? "shrink-0 p-0 pt-[calc(var(--studio-content-top-inset,0px)+var(--studio-chat-header-padding-top,11px))]": usesNativeMacTitlebar? "shrink-0 p-0 pt-[calc(var(--studio-desktop-titlebar-height,34px)+calc(17px*var(--ui-space-scale,1)))]"- : "pl-3 pr-3 pt-[calc(14px*var(--ui-space-scale,1))] pb-[calc(8px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:px-0",+ : // The chat header's top padding, so the two rows line up.+ "pl-3 pr-3 pt-[var(--studio-chat-header-padding-top,11px)] pb-[calc(8px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:px-0",)}>{showSidebarBrand && (@@ -5980,10 +5981,10 @@ export function AppSidebar() {useChatSearchStore.getState().open();closeMobileIfOpen();}}- className="relative top-px inline-flex size-[calc(30px*var(--ui-space-scale,1))] cursor-pointer items-center justify-center rounded-[10px] text-nav-fg transition-colors hover:bg-nav-surface-hover hover:text-black dark:hover:text-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ className="inline-flex size-[calc(30px*var(--ui-space-scale,1))] cursor-pointer items-center justify-center rounded-[10px] text-nav-fg transition-colors hover:bg-nav-surface-hover hover:text-black dark:hover:text-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"aria-label={t("shell.navigation.search")}>- <HugeiconsIcon icon={Search01Icon} strokeWidth={1.75} className="size-4" />+ <HugeiconsIcon icon={Search01Icon} strokeWidth={1.75} className="size-icon" /></button></TooltipPrimitive.Trigger><TooltipContentdiff --git a/studio/frontend/src/features/browser/bookmarks.tsx b/studio/frontend/src/features/browser/bookmarks.tsxindex 3e74da6006c..6be7cb0e05c 100644--- a/studio/frontend/src/features/browser/bookmarks.tsx+++ b/studio/frontend/src/features/browser/bookmarks.tsx@@ -341,7 +341,8 @@ export function BookmarkStar({bookmark && "text-primary hover:text-primary [&_path]:fill-current",)}>- <HugeiconsIcon icon={StarIcon} strokeWidth={1.75} className="size-3.75" />+ {/* Optically centred: the star's points weigh it low. */}+ <HugeiconsIcon icon={StarIcon} strokeWidth={1.75} className="size-3.75 -translate-y-[0.5px]" /></button></PopoverAnchor></TooltipTrigger>diff --git a/studio/frontend/src/features/browser/browser-panel.tsx b/studio/frontend/src/features/browser/browser-panel.tsxindex 3725af5e309..0b1efe720fb 100644--- a/studio/frontend/src/features/browser/browser-panel.tsx+++ b/studio/frontend/src/features/browser/browser-panel.tsx@@ -79,6 +79,9 @@ import {InternetIcon,MinusSignIcon,MoreHorizontalIcon,+ PanelLeftIcon,+ PanelRightIcon,+ PictureInPictureOnIcon,PlusSignIcon,SmartPhone01Icon,SourceCodeIcon,@@ -99,7 +102,9 @@ import {type ReactElement,type ReactNode,type RefObject,+ createContext,memo,+ useContext,useEffect,useRef,useState,@@ -129,6 +134,9 @@ import { useBookmarkFor } from "./bookmarks-store";import { browserTabType, fileBarKind, mediaKind } from "./file-kind";import { canCopyVideoFrame, copyVideoFrame, tabVideo } from "./video-registry";import { CONTEXT_MENU } from "./link-context-menu";+import { FLOATING_SCALE_VAR } from "./floating-events";+import { nudgeFloating, startFloatingGesture } from "./floating-preview";+import { closeOrFloatBrowser } from "./close-browser";import { CONTEXT_TAB_MENU, TabMenuItems, focusRenameField, renameTabTo, setTabMuted } from "./tab-menu";import {CertificateIcon,@@ -230,12 +238,13 @@ const TOOLBAR_BUTTON =const TOOLBAR_ICON_BUTTON ="flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-[10px] text-muted-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:opacity-35 disabled:hover:bg-transparent disabled:hover:text-muted-foreground";const NAV_BUTTON =- "size-8 rounded-[10px] text-foreground disabled:hover:text-foreground disabled:opacity-30";-const NAV_ICON = "size-4.5";-const ANNOTATE_BUTTON = "size-8 shrink-0 rounded-[10px] p-0 text-foreground";+ "size-7 rounded-[9px] text-foreground disabled:hover:text-foreground disabled:opacity-30";+const NAV_ICON = "size-4";+const ANNOTATE_BUTTON = "size-7 shrink-0 rounded-[9px] p-0 text-foreground";// Half a pixel right and down: the frame's whole top-left corner and the pointer aimed back at it// read as up and left of centre, though the strokes are centred.-const ANNOTATE_GLYPH = "size-4.5 translate-x-[0.5px] translate-y-[0.5px]";+// Under the row's 16px: its dashed square fills the box, so at full size it reads larger.+const ANNOTATE_GLYPH = "size-[calc(var(--spacing)*3.84)] translate-x-[0.5px] translate-y-[0.5px]";const NAV_STROKE = 2;const URLBAR ="bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] focus-within:bg-[color-mix(in_oklab,var(--foreground)_calc(9%*var(--contrast-wash-gain,1)),transparent)]";@@ -606,11 +615,15 @@ function useTabDrag(listRef: RefObject<HTMLDivElement | null>, tabCount: number)};}+// The chat header's button size, so the two rows match.+const STRIP_BUTTON = "size-[calc(30px*var(--ui-space-scale,1))]";+function TabStrip({tabs,activeTabId,active,-}: { tabs: BrowserTab[]; activeTabId: string | null; active: boolean }) {+ floatable,+}: { tabs: BrowserTab[]; activeTabId: string | null; active: boolean; floatable: boolean }) {const t = useT();const tabTitle = useTabTitle();const fullView = useBrowserStore((state) => state.fullView);@@ -678,7 +691,7 @@ function TabStrip({activateTab(tab.id);}}className={cn(- "group/tab relative flex h-[calc(34px*var(--ui-space-scale,1))] min-w-[calc(88px*var(--ui-space-scale,1))] max-w-60 flex-1 basis-0 cursor-pointer touch-none select-none items-center gap-1 rounded-[10px] pl-2 pr-1.5 text-ui-13 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",+ "group/tab relative flex h-[calc(32px*var(--ui-space-scale,1))] min-w-[calc(88px*var(--ui-space-scale,1))] max-w-60 flex-1 basis-0 cursor-pointer touch-none select-none items-center gap-1 rounded-[10px] pl-2 pr-1.5 text-ui-13 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",active? "bg-card text-foreground dark:bg-accent": "text-muted-foreground hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground",@@ -735,26 +748,30 @@ function TabStrip({);})}</div>- <IconButton- label={t("browser.newTab")}- icon={PlusSignIcon}- onClick={newTab}- className="size-8"- />+ <IconButton label={t("browser.newTab")} onClick={newTab} className={STRIP_BUTTON}>+ <HugeiconsIcon icon={PlusSignIcon} strokeWidth={1.75} className="size-icon" />+ </IconButton><span aria-hidden={true} className="mx-1 h-4 w-px shrink-0 bg-border" /><IconButtonlabel={t(fullView ? "browser.fullView.exit" : "browser.fullView.enter")}shortcut={fullViewShortcut}- icon={fullView ? ExitFullViewIcon : EnterFullViewIcon}onClick={() => setFullView(!fullView)}- className="size-8"- />+ className={STRIP_BUTTON}+ >+ {/* Its marks sit inside the box, so it is drawn larger to match the plus. */}+ <HugeiconsIcon+ icon={fullView ? ExitFullViewIcon : EnterFullViewIcon}+ strokeWidth={1.75}+ className="size-[calc(var(--icon-size)*1.2)]"+ />+ </IconButton><IconButtonlabel={t("browser.close")}- icon={Cancel01Icon}- onClick={closePanel}- className="size-8"- />+ onClick={floatable ? closeOrFloatBrowser : closePanel}+ className={STRIP_BUTTON}+ >+ <HugeiconsIcon icon={Cancel01Icon} strokeWidth={1.75} className="size-icon" />+ </IconButton></div>);}@@ -806,7 +823,7 @@ function AddressBar({inputRef.current?.blur();}}>- <div className={cn("flex h-9 items-center gap-0.5 rounded-full pl-1 pr-1 transition-colors", URLBAR)}>+ <div className={cn("flex h-8 items-center gap-0.5 rounded-full pl-1 pr-1 transition-colors", URLBAR)}>{/* Icons step aside while typing and come back after. */}{editing ? null : (leading ?? <SiteIdentity address={address} tab={tab} />)}<div className="relative min-w-0 flex-1">@@ -835,7 +852,8 @@ function AddressBar({autoCapitalize="off"autoCorrect="off"className={cn(- "h-9 w-full min-w-0 bg-transparent pe-1 text-ui-13 text-foreground outline-none placeholder:text-muted-foreground",+ // pb-px: the UI font's lowercase sits low in its line box.+ "h-8 w-full min-w-0 bg-transparent pe-1 pb-px text-ui-12p5 text-foreground outline-none placeholder:text-muted-foreground",editing ? "ps-2.5" : "ps-0",// The input keeps the full URL, so focusing never changes its text or selection.!editing && address && "text-transparent",@@ -844,7 +862,7 @@ function AddressBar({{!editing && address ? (<spanaria-hidden={true}- className="pointer-events-none absolute inset-0 flex items-center ps-0 pe-1 text-ui-13 text-foreground"+ className="pointer-events-none absolute inset-0 flex items-center ps-0 pe-1 pb-px text-ui-12p5 text-foreground"><span className="truncate">{displayAddress(address, showFullUrl)}</span></span>@@ -880,7 +898,7 @@ function SiteIdentity({ address, tab }: { address: string; tab: BrowserTab | und}if (!url || !/^https?:$/.test(url.protocol)) {return (- <span className="flex size-[calc(26px*var(--ui-space-scale,1))] shrink-0 items-center justify-center text-muted-foreground">+ <span className="flex size-[calc(24px*var(--ui-space-scale,1))] shrink-0 items-center justify-center text-muted-foreground"><HugeiconsIcon icon={Search01Icon} strokeWidth={1.75} aria-hidden={true} className="size-4" /></span>);@@ -908,7 +926,7 @@ function SiteIdentity({ address, tab }: { address: string; tab: BrowserTab | und<buttontype="button"aria-label={label}- className="flex size-[calc(26px*var(--ui-space-scale,1))] shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(8%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-[color-mix(in_oklab,var(--foreground)_calc(10%*var(--contrast-wash-gain,1)),transparent)] aria-expanded:text-foreground"+ className="flex size-[calc(24px*var(--ui-space-scale,1))] shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(8%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-[color-mix(in_oklab,var(--foreground)_calc(10%*var(--contrast-wash-gain,1)),transparent)] aria-expanded:text-foreground">{secure ? (<HugeiconsIcon icon={SiteInfoIcon} strokeWidth={2.25} className="size-4" />@@ -1237,9 +1255,9 @@ function PanelMenu({ tab, children }: { tab: BrowserTab | undefined; children?:ref={triggerRef}type="button"aria-label={t("browser.more")}- className="flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-[10px] text-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-[color-mix(in_oklab,var(--foreground)_calc(8%*var(--contrast-wash-gain,1)),transparent)]"+ className="flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-[9px] text-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-expanded:bg-[color-mix(in_oklab,var(--foreground)_calc(8%*var(--contrast-wash-gain,1)),transparent)]">- <HugeiconsIcon icon={MoreHorizontalIcon} strokeWidth={1.75} className="size-5" />+ <HugeiconsIcon icon={MoreHorizontalIcon} strokeWidth={1.75} className="size-4.5" /></button></DropdownMenuTrigger></TooltipTrigger>@@ -1252,7 +1270,14 @@ function PanelMenu({ tab, children }: { tab: BrowserTab | undefined; children?:sideOffset={6}className="browser-menu min-w-72 rounded-lg p-1 [&_[data-slot=dropdown-menu-separator]]:mx-3 [&_[data-slot=dropdown-menu-separator]]:my-1.5"onCloseAutoFocus={(event) => {- if (!keepFocus.current) return;+ // A click outside that took focus (the address bar) keeps it.+ const active = document.activeElement;+ const focusedOutside =+ active instanceof HTMLElement &&+ active !== document.body &&+ active !== triggerRef.current &&+ !active.closest('[data-slot="dropdown-menu-content"]');+ if (!keepFocus.current && !focusedOutside) return;keepFocus.current = false;event.preventDefault();}}@@ -1431,23 +1456,135 @@ function AnnotatePageButton({ tab }: { tab: BrowserTab | undefined }) {);}+/** Keyboard focus survives a layout switch that unmounts the pressed button; a mouse press is left alone. */+function focusAfterLayout(selector: string): void {+ if (!document.activeElement?.matches(":focus-visible")) return;+ requestAnimationFrame(() =>+ requestAnimationFrame(() =>+ document.querySelector<HTMLElement>(`[data-slot="browser-panel"] ${selector}`)?.focus({ preventScroll: true }),+ ),+ );+}++const SHOWN_TAB = '[role="tab"][aria-selected="true"]';++function canGoBackIn(tab: BrowserTab | undefined): boolean {+ const native = nativePage(tab);+ return Boolean(+ tab && (tab.index > 0 || tab.pageHistory?.back || (native && (tab.nativeError || tab.nativeHistory?.back))),+ );+}++function goBackIn(tab: BrowserTab | undefined): void {+ if (!tab) return;+ const native = nativePage(tab);+ if (native && tab.nativeError && returnToNativePage(tab.id)) return;+ if (native && tab.nativeHistory?.back) nativeAction(tab.id, "back");+ else if (!tab.pageHistory?.back || !sendFrameCommand(tab.id, { command: "go", delta: -1 })) {+ useBrowserStore.getState().goBack(tab.id);+ }+}++const FLOATING_BUTTON = "size-6 rounded-[7px]";+const FLOATING_GLYPH = "size-3.5";++function FloatingBar({ tab, active }: { tab: BrowserTab | undefined; active: boolean }) {+ const t = useT();+ const tabTitle = useTabTitle();+ const chatOnRight = useBrowserStore((state) => state.chatSide === "right");+ const fullViewShortcut = useShortcutLabel("toggleBrowserFullView");+ const { setFloating, setFullView, closePanel } = useBrowserStore.getState();+ useShortcut(+ "toggleBrowserFullView",+ (event) => {+ event.preventDefault();+ setFullView(true);+ },+ { enabled: active },+ );+ const title = tab ? tabTitle(tab, currentEntry(tab)) : t("browser.title");+ const glyph = (icon: IconSvgElement) => (+ <HugeiconsIcon icon={icon} strokeWidth={1.75} className={FLOATING_GLYPH} />+ );+ return (+ <div+ onPointerDown={(event) => startFloatingGesture(event, "move")}+ onDoubleClick={(event) => {+ if (!(event.target as Element).closest("button:not([data-floating-handle])")) setFloating(false);+ }}+ className="browser-chrome flex h-[calc(30px*var(--ui-space-scale,1))] shrink-0 cursor-grab touch-none select-none items-center gap-px border-b border-border/70 px-1"+ >+ <IconButton label={t("browser.back")} disabled={!canGoBackIn(tab)} onClick={() => goBackIn(tab)} className={FLOATING_BUTTON}>+ <ArrowLeft strokeWidth={NAV_STROKE} className={FLOATING_GLYPH} />+ </IconButton>+ <button+ type="button"+ data-floating-handle=""+ aria-label={t("browser.floating.handle")}+ title={title}+ onKeyDown={nudgeFloating}+ className="flex h-6 min-w-0 flex-1 cursor-grab items-center gap-1.5 rounded-[7px] px-1 text-start text-ui-11 text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&_img]:size-3.5 [&_svg]:size-3"+ >+ {tab ? <TabIcon tab={tab} /> : null}+ <span className="min-w-0 flex-1 truncate">{title}</span>+ </button>+ <IconButton+ label={t("browser.floating.dock")}+ onClick={() => {+ setFloating(false);+ focusAfterLayout(SHOWN_TAB);+ }}+ className={FLOATING_BUTTON}+ >+ {glyph(chatOnRight ? PanelLeftIcon : PanelRightIcon)}+ </IconButton>+ <IconButton+ label={t("browser.fullView.enter")}+ shortcut={fullViewShortcut}+ onClick={() => {+ setFullView(true);+ focusAfterLayout(SHOWN_TAB);+ }}+ className={FLOATING_BUTTON}+ >+ {glyph(EnterFullViewIcon)}+ </IconButton>+ <IconButton label={t("browser.floating.close")} onClick={closePanel} className={FLOATING_BUTTON}>+ {glyph(Cancel01Icon)}+ </IconButton>+ </div>+ );+}++const FloatableContext = createContext(false);++function FloatButton() {+ const t = useT();+ if (!useContext(FloatableContext)) return null;+ return (+ <IconButton+ label={t("browser.floating.enter")}+ onClick={() => {+ useBrowserStore.getState().setFloating(true);+ focusAfterLayout("[data-floating-handle]");+ }}+ className={NAV_BUTTON}+ >+ <HugeiconsIcon icon={PictureInPictureOnIcon} strokeWidth={1.75} className={NAV_ICON} />+ </IconButton>+ );+}+/** `visible`: the panel's chat is shown (BrowserPanel `active`). */function WebToolbar({ tab, visible }: { tab: BrowserTab | undefined; visible: boolean }) {const t = useT();- const { goBack, goForward, reload } = useBrowserStore.getState();+ const { goForward, reload } = useBrowserStore.getState();const native = nativePage(tab);- const canGoBack = Boolean(- tab && (tab.index > 0 || tab.pageHistory?.back || (native && (tab.nativeError || tab.nativeHistory?.back))),- );+ const canGoBack = canGoBackIn(tab);const canGoForward = Boolean(tab && (tab.index < tab.history.length - 1 || tab.pageHistory?.forward || (native && tab.nativeHistory?.forward)),);- const back = () => {- if (!tab) return;- if (native && tab.nativeError && returnToNativePage(tab.id)) return;- if (native && tab.nativeHistory?.back) nativeAction(tab.id, "back");- else if (!tab.pageHistory?.back || !sendFrameCommand(tab.id, { command: "go", delta: -1 })) goBack(tab.id);- };+ const back = () => goBackIn(tab);const forward = () => {if (!tab) return;if (native && tab.nativeHistory?.forward) nativeAction(tab.id, "forward");@@ -1492,6 +1629,7 @@ function WebToolbar({ tab, visible }: { tab: BrowserTab | undefined; visible: bo/><div className="flex shrink-0 items-center gap-0.5"><WebActions tab={tab} visible={visible} />+ <FloatButton /><PanelMenu tab={tab} /></div></>@@ -1701,6 +1839,7 @@ function BrowserFileToolbar({<HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} className="size-4.5" /></IconButton><DownloadsButton className={cn(TOOLBAR_ICON_BUTTON, NAV_BUTTON)} visible={visible} idleHidden={true} />+ <FloatButton /><PanelMenu tab={tab}><div className="flex items-start gap-3 px-3 py-2 text-sm"><KindIcon name={entry.name} contentType={entry.contentType} className="mt-0.5 size-4.5" mono={true} />@@ -1807,7 +1946,7 @@ function FloatingFileToolbar({type="button"className={cn(PILL,- "flex h-9 min-w-24 max-w-[55%] shrink cursor-pointer items-center gap-2 rounded-full pl-3.5 pr-2.5 text-ui-13p5 text-foreground outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",+ "flex h-8 min-w-24 max-w-[55%] shrink cursor-pointer items-center gap-2 rounded-full pl-3.5 pr-2.5 text-ui-13p5 text-foreground outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring",)}>{fileLabel}@@ -1866,7 +2005,7 @@ function FloatingFileToolbar({title={entry.name}className={cn(PILL_SURFACE,- "flex h-9 min-w-24 max-w-[55%] shrink items-center gap-2 rounded-full px-3.5 text-ui-13p5 text-foreground",+ "flex h-8 min-w-24 max-w-[55%] shrink items-center gap-2 rounded-full px-3.5 text-ui-13p5 text-foreground",)}>{fileLabel}@@ -1905,7 +2044,7 @@ function FloatingFileToolbar({<divrole="tablist"aria-label={t("browser.file.viewMode")}- className={cn(PILL_SURFACE, "flex h-9 shrink-0 items-center gap-0.5 rounded-full p-0.5")}+ className={cn(PILL_SURFACE, "flex h-8 shrink-0 items-center gap-0.5 rounded-full p-0.5")}>{(["preview", "source"] as const).map((mode) => (<Tooltip key={mode}>@@ -1917,7 +2056,7 @@ function FloatingFileToolbar({aria-label={t(`browser.file.${mode}`)}onClick={() => setView({ mode })}className={cn(- "flex size-8 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ "flex size-7 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",view.mode === mode? "bg-background text-foreground shadow-sm dark:bg-card": "hover:text-foreground",@@ -1948,7 +2087,7 @@ function FloatingFileToolbar({.getState().setZoom(tab.id, value === "fit" ? 1 : value)}- className={cn(PILL, "mr-0 hidden h-9 pr-2.5 @[28rem]:flex")}+ className={cn(PILL, "mr-0 hidden h-8 pr-2.5 @[28rem]:flex")}/>)}<OpenSplit key={entry.fileId} entry={entry} blob={blob} />@@ -1966,7 +2105,7 @@ function FloatingFileToolbar({const SPLIT_PILL = cn(PILL,- "flex h-9 shrink-0 items-center rounded-full",+ "flex h-8 shrink-0 items-center rounded-full","has-[[data-state=open]]:bg-[color-mix(in_oklab,var(--pill-bg),var(--foreground)_var(--pill-hover))]",);const SPLIT_PART =@@ -2253,6 +2392,15 @@ function DeviceBar() {);}+// Floating keeps the side-pane layout, scaled down, so resizing never reflows the page; native pages zoom instead.+const FLOATING_PAGE_STYLE = {+ width: `calc(100% / var(${FLOATING_SCALE_VAR}, 1))`,+ height: `calc(100% / var(${FLOATING_SCALE_VAR}, 1))`,+ margin: 0,+ transform: `scale(var(${FLOATING_SCALE_VAR}, 1))`,+ transformOrigin: "0 0",+} as const;+const MAX_MOUNTED_TABS = 4;// Hidden pages share the chat's thread; keep only one ordinary page and three drafts.const MAX_HIDDEN_WEB_PAGES = 1;@@ -2304,7 +2452,11 @@ function retainedTabs(mounted: readonly string[], tabs: BrowserTab[], activeTabI}/** The chat's in-app browser, memoized so chat renders skip it. `active`: its chat is shown. */-export const BrowserPanel = memo(function BrowserPanel({ active = true }: { active?: boolean }) {+export const BrowserPanel = memo(function BrowserPanel({+ active = true,+ floating = false,+ floatable = false,+}: { active?: boolean; floating?: boolean; floatable?: boolean }) {const t = useT();const tabs = useBrowserStore(useShallow(chatTabs));const activeTabId = useBrowserStore((state) => state.activeTabId);@@ -2362,6 +2514,8 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acticonst htmlAnnotating = frameAvailable && activeEntry?.kind === "file" &&fileBarKind(activeEntry.name, activeEntry.contentType, activeEntry.plainText) === "html" && fileMode === "preview";const pageAnnotating = activeTab && annotateTabId === activeTab.id ? annotateMode(activeTab, native) : null;+ // Only a page native-view.ts shows (its pageRect) is zoomed instead; files and new tabs are DOM.+ const nativeShown = native && activeEntry?.kind === "web" && !activeTab?.nativeError;return (<section@@ -2383,7 +2537,8 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acti}}}className={cn(- "relative flex h-full min-h-0 flex-col overflow-hidden bg-muted pt-[var(--studio-content-top-inset,0px)]",+ "relative flex h-full min-h-0 flex-col overflow-hidden bg-muted",+ floating ? "rounded-[inherit]" : "pt-[var(--studio-content-top-inset,0px)]",documentShown? "[--browser-surface:color-mix(in_oklab,var(--muted)_55%,var(--card))]": "[--browser-surface:var(--card)]",@@ -2408,17 +2563,24 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acti</AlertDialogFooter></AlertDialogContent></AlertDialog>- <TabStrip tabs={tabs} activeTabId={activeTabId} active={active} />+ <FloatableContext.Provider value={floatable}>+ {floating ? (+ <FloatingBar tab={activeTab} active={active} />+ ) : (+ <TabStrip tabs={tabs} activeTabId={activeTabId} active={active} floatable={floatable} />+ )}{/* Not on the section: before Safari 18.5 container-type makes a stacking context, sinking the strip under the macOS drag strip. */}<div className="browser-panel-body @container/browser relative flex min-h-0 flex-1 flex-col overflow-hidden bg-[var(--browser-surface)]"><divclassName={cn("browser-chrome @container flex shrink-0 items-center gap-2 px-2.5",+ // Kept mounted, so its shortcuts still reach the page.+ floating && "!hidden",(!activeEntry || activeEntry.kind !== "file") && "browser-web-toolbar flex-wrap",floatingFileControls? "browser-file-toolbar pointer-events-none absolute inset-x-0 top-0 z-20 py-2 *:pointer-events-auto": // 1px less at the bottom for the page's top border.- "pt-2 pb-[calc(var(--spacing)*2-1px)]",+ "pt-1.5 pb-[calc(var(--spacing)*1.5-1px)]",)}>{activeTab && activeEntry?.kind === "file" ? (@@ -2431,17 +2593,17 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acti<WebToolbar tab={activeTab} visible={active} />)}</div>- {floatingFileControls ? null : (+ {floatingFileControls || floating ? null : (<BookmarksBar tab={activeTab} />)}- {deviceWidth ? <DeviceBar /> : null}+ {deviceWidth && !floating ? <DeviceBar /> : null}<AgentBar activeTabId={activeTabId} /><divref={setPageElement}data-browser-page=""className={cn("relative min-h-0 flex-1 overflow-hidden",- floatingFileControls ? "browser-file-page" : "border-t border-border/70",+ floatingFileControls ? "browser-file-page" : !floating && "border-t border-border/70",documentShown ? "bg-transparent" : "bg-background",deviceWidth && "bg-muted/60",)}@@ -2462,7 +2624,11 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acti"border-x border-border/70 bg-background shadow-sm",)}style={- deviceWidth ? { width: `min(100%, ${deviceWidth}px)` } : undefined+ floating && !nativeShown+ ? FLOATING_PAGE_STYLE+ : deviceWidth+ ? { width: `min(100%, ${deviceWidth}px)` }+ : undefined}>{tabs.map((tab) =>@@ -2518,6 +2684,7 @@ export const BrowserPanel = memo(function BrowserPanel({ active = true }: { acti) : null}</div></div>+ </FloatableContext.Provider></section>);});diff --git a/studio/frontend/src/features/browser/browser-toggle.tsx b/studio/frontend/src/features/browser/browser-toggle.tsxindex 1be9a52983e..6d8222bfaae 100644--- a/studio/frontend/src/features/browser/browser-toggle.tsx+++ b/studio/frontend/src/features/browser/browser-toggle.tsx@@ -13,7 +13,7 @@ import {useShortcutLabel,} from "@/features/settings/hooks/use-shortcut";import { useT } from "@/i18n";-import { InternetIcon, PlusSignIcon } from "@hugeicons/core-free-icons";+import { InternetIcon, PictureInPictureOnIcon, PlusSignIcon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { useEffect, useRef, useState } from "react";import { EnterFullViewIcon } from "./icons";@@ -23,20 +23,25 @@ import { useBrowserStore } from "./store";const HOVER_OPEN_MS = 150;const HOVER_CLOSE_MS = 200;-function openNewTab(fullView = false) {+type Layout = "split" | "fullView" | "floating";++function openNewTab(layout: Layout) {const state = useBrowserStore.getState();state.newTab();- if (fullView) state.setFullView(true);+ if (layout === "fullView") state.setFullView(true);+ if (layout === "floating") state.setFloating(true);}-/** The chat header's new tab button: a click opens a tab beside the chat, hovering offers full view.+/** The chat header's new tab button: a click opens a tab in the current layout, hovering offers the others.* Hidden while the panel is open, unless `hideWhenOpen` is false: a project's overlay may not be showing it. */export function BrowserToggleButton({active = true,hideWhenOpen = true,+ floatable = false,}: {active?: boolean;hideWhenOpen?: boolean;+ floatable?: boolean;}) {const t = useT();const open = useBrowserStore((state) => state.open);@@ -46,11 +51,11 @@ export function BrowserToggleButton({const timer = useRef<number | null>(null);// Focus given back when the hover menu closes without opening a tab.const restore = useRef<HTMLElement | null>(null);- const openTab = (fullView = false) => {+ const openTab = (layout: Layout = "split") => {clearTimer();restore.current = null;setMenuOpen(false);- openNewTab(fullView);+ openNewTab(layout);};// The chat stays mounted on other pages: its shortcuts only work while it is shown.useShortcut(@@ -65,7 +70,7 @@ export function BrowserToggleButton({"toggleBrowserFullView",(event) => {event.preventDefault();- openTab(true);+ openTab("fullView");},{ enabled: active && !(hideWhenOpen && open) },);@@ -137,7 +142,7 @@ export function BrowserToggleButton({{label}{newTabShortcut ? <DropdownMenuShortcut className="text-ui-11">{newTabShortcut}</DropdownMenuShortcut> : null}</DropdownMenuItem>- <DropdownMenuItem onSelect={() => openTab(true)}>+ <DropdownMenuItem onSelect={() => openTab("fullView")}>{/* Its corner marks sit inside the box, so at the shared size it reads smaller than the plus. */}<HugeiconsIconicon={EnterFullViewIcon}@@ -149,6 +154,12 @@ export function BrowserToggleButton({<DropdownMenuShortcut className="text-ui-11">{fullViewShortcut}</DropdownMenuShortcut>) : null}</DropdownMenuItem>+ {floatable ? (+ <DropdownMenuItem onSelect={() => openTab("floating")}>+ <HugeiconsIcon icon={PictureInPictureOnIcon} strokeWidth={1.75} className="size-icon" />+ {t("browser.newTabFloating")}+ </DropdownMenuItem>+ ) : null}</DropdownMenuContent></DropdownMenu>);diff --git a/studio/frontend/src/features/browser/close-browser.ts b/studio/frontend/src/features/browser/close-browser.tsnew file mode 100644index 00000000000..3f4e5a2e0a3--- /dev/null+++ b/studio/frontend/src/features/browser/close-browser.ts@@ -0,0 +1,27 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import { agentChat } from "./agent/agent-store";+import { useBrowserStore } from "./store";++export function agentUsingBrowser(): boolean {+ const state = useBrowserStore.getState();+ const agent = agentChat(state.chat);+ return (+ agent.runKey !== null &&+ agent.stoppedRun !== agent.runKey &&+ state.tabs.some((tab) => tab.id === agent.tabId && tab.chat === state.chat)+ );+}++/** Mid-run, closing floats the model's tab instead (a web browser keeps its page loaded); closing that closes. */+export function closeOrFloatBrowser(): void {+ const state = useBrowserStore.getState();+ if (state.floating || !agentUsingBrowser()) {+ state.closePanel();+ return;+ }+ const tabId = agentChat(state.chat).tabId;+ if (tabId && tabId !== state.activeTabId) state.activateTab(tabId);+ state.floatForAgent();+}diff --git a/studio/frontend/src/features/browser/downloads-button.tsx b/studio/frontend/src/features/browser/downloads-button.tsxindex 75646d076a9..92c42068682 100644--- a/studio/frontend/src/features/browser/downloads-button.tsx+++ b/studio/frontend/src/features/browser/downloads-button.tsx@@ -385,7 +385,7 @@ export function DownloadsButton({{active ? (<DownloadingIcon />) : (- <HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} className="size-4.5" />+ <HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} className="size-4" />)}</button></TooltipTrigger>diff --git a/studio/frontend/src/features/browser/floating-events.ts b/studio/frontend/src/features/browser/floating-events.tsnew file mode 100644index 00000000000..12f0cff1003--- /dev/null+++ b/studio/frontend/src/features/browser/floating-events.ts@@ -0,0 +1,13 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++export const FLOATING_ATTRIBUTE = "data-browser-floating";+/** Per frame of a move, so a native page follows (native-view.ts). */+export const FLOATING_MOVE_EVENT = "unsloth-browser-floating-move";+export const FLOATING_SCALE_VAR = "--browser-floating-scale";+/** `browser_view_zoom`'s floor (browser_webview.rs): below it the call fails and the tab shows an error. */+export const NATIVE_MIN_ZOOM = 0.25;++export function floatingNativeZoom(zoom: number, scale: number): number {+ return scale < 1 ? Math.max(NATIVE_MIN_ZOOM, zoom * scale) : zoom;+}diff --git a/studio/frontend/src/features/browser/floating-frame.tsx b/studio/frontend/src/features/browser/floating-frame.tsxnew file mode 100644index 00000000000..953c10b6440--- /dev/null+++ b/studio/frontend/src/features/browser/floating-frame.tsx@@ -0,0 +1,34 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import { cn } from "@/lib/utils";+import { type FloatingEdge, startFloatingGesture } from "./floating-preview";++// Straddling the frame, mostly outside it: a native page covers whatever lies over it.+const HANDLES: { edge: FloatingEdge; className: string }[] = [+ { edge: "n", className: "inset-x-3 -top-1.5 h-2.5 cursor-ns-resize" },+ { edge: "s", className: "inset-x-3 -bottom-1.5 h-2.5 cursor-ns-resize" },+ { edge: "w", className: "inset-y-3 -left-1.5 w-2.5 cursor-ew-resize" },+ { edge: "e", className: "inset-y-3 -right-1.5 w-2.5 cursor-ew-resize" },+ { edge: "nw", className: "-left-1.5 -top-1.5 size-4 cursor-nwse-resize" },+ { edge: "ne", className: "-right-1.5 -top-1.5 size-4 cursor-nesw-resize" },+ { edge: "sw", className: "-bottom-1.5 -left-1.5 size-4 cursor-nesw-resize" },+ { edge: "se", className: "-bottom-1.5 -right-1.5 size-4 cursor-nwse-resize" },+];++export function FloatingResizeHandles() {+ return (+ <>+ {HANDLES.map(({ edge, className }) => (+ <div+ key={edge}+ aria-hidden={true}+ data-native-clickable=""+ data-floating-resize={edge}+ onPointerDown={(event) => startFloatingGesture(event, edge)}+ className={cn("absolute z-10 touch-none", className)}+ />+ ))}+ </>+ );+}diff --git a/studio/frontend/src/features/browser/floating-preview.ts b/studio/frontend/src/features/browser/floating-preview.tsnew file mode 100644index 00000000000..113fe7ecedd--- /dev/null+++ b/studio/frontend/src/features/browser/floating-preview.ts@@ -0,0 +1,479 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import {+ isDegenerateBox,+ nudgeDelta,+ placeAxis,+} from "@/hooks/floating-panel-position";+import { Z_LAYER } from "@/lib/z-layers";+import type {+ KeyboardEvent as ReactKeyboardEvent,+ PointerEvent as ReactPointerEvent,+} from "react";+import {+ FLOATING_ATTRIBUTE,+ FLOATING_MOVE_EVENT,+ FLOATING_SCALE_VAR,+} from "./floating-events";++const STORAGE_KEY = "unsloth_browser_floating_preview";+const EDGE_GAP = 12;+const MIN_WIDTH = 260;+const MIN_HEIGHT = 180;+// A drop this close to the right edge stays anchored there as the chat resizes.+const RIGHT_SNAP_PX = 16;+// The page keeps a layout at least this wide however small the preview gets.+const MIN_LAYOUT_WIDTH = 480;+const FRAME_PX = 2;++export type FloatingEdge =+ | "move"+ | "n"+ | "s"+ | "e"+ | "w"+ | "ne"+ | "nw"+ | "se"+ | "sw";+/** `left` null: anchored to the right edge. Lengths are CSS px within the room. */+type Geometry = {+ left: number | null;+ top: number;+ width: number;+ height: number;+};+type Box = { left: number; top: number; width: number; height: number };+type Room = Box & { composer: Box | null };++let geometry: Geometry | null = null;+// The page's side-pane layout width, shown scaled down.+let layoutWidth: number | null = null;++function finite(value: unknown): value is number {+ return typeof value === "number" && Number.isFinite(value);+}++function readGeometry(): Geometry | null {+ try {+ const parsed = JSON.parse(+ localStorage.getItem(STORAGE_KEY) ?? "null",+ ) as Record<string, unknown> | null;+ if (+ !parsed ||+ !finite(parsed.top) ||+ !finite(parsed.width) ||+ !finite(parsed.height)+ )+ return null;+ const left =+ parsed.left === null+ ? null+ : finite(parsed.left)+ ? parsed.left+ : undefined;+ if (left === undefined) return null;+ return {+ left,+ top: parsed.top,+ width: parsed.width,+ height: parsed.height,+ };+ } catch {+ return null;+ }+}++function writeGeometry(next: Geometry): void {+ geometry = next;+ try {+ localStorage.setItem(STORAGE_KEY, JSON.stringify(next));+ } catch {+ // storage unavailable+ }+}++const clamp = (value: number, min: number, max: number) =>+ Math.min(max, Math.max(min, value));++const toBox = (rect: DOMRect): Box => ({+ left: rect.left,+ top: rect.top,+ width: rect.width,+ height: rect.height,+});++function overlaps(a: Box, b: Box): boolean {+ return (+ a.left < b.left + b.width &&+ b.left < a.left + a.width &&+ a.top < b.top + b.height &&+ b.top < a.top + a.height+ );+}++function composerIn(split: HTMLElement): Box | null {+ for (const form of split.querySelectorAll?.<HTMLElement>(+ "form.aui-composer-root",+ ) ?? []) {+ if (+ form.offsetParent === null ||+ form.closest('[aria-hidden="true"], [inert]')+ )+ continue;+ const box = form.getBoundingClientRect();+ if (box.width > 0 && box.height > 0) return toBox(box);+ }+ return null;+}++function roomFor(surface: HTMLElement): Room | null {+ const split = surface.closest<HTMLElement>(".chat-artifact-split");+ if (!split) return null;+ const box = split.getBoundingClientRect();+ if (isDegenerateBox(box)) return null;+ const header = split+ .closest("[data-chat-content-root]")+ ?.querySelector<HTMLElement>(+ ":scope > [data-side-panel-inset]:not(.chat-header-fade)",+ );+ const top =+ Math.max(box.top, header?.getBoundingClientRect().bottom ?? box.top) ++ EDGE_GAP;+ const width = box.width - 2 * EDGE_GAP;+ const height = box.bottom - EDGE_GAP - top;+ return width > 0 && height > 0+ ? {+ left: box.left + EDGE_GAP,+ top,+ width,+ height,+ composer: composerIn(split),+ }+ : null;+}++function clearOfComposer(box: Box, room: Room): Box {+ const composer = room.composer;+ if (!composer || !overlaps(box, composer)) return box;+ const tops = [+ composer.top - EDGE_GAP - box.height,+ composer.top + composer.height + EDGE_GAP,+ ].filter(+ (top) => top >= room.top && top + box.height <= room.top + room.height,+ );+ if (tops.length === 0) return box;+ const top = tops.reduce((best, next) =>+ Math.abs(next - box.top) < Math.abs(best - box.top) ? next : best,+ );+ return { ...box, top };+}++function defaultGeometry(room: Box): Geometry {+ const width = Math.round(clamp(room.width * 0.38, 320, 480));+ return { left: null, top: 0, width, height: Math.round(width * 0.68) };+}++function boxIn(room: Room, intent: Geometry): Box {+ const width = clamp(+ intent.width,+ Math.min(MIN_WIDTH, room.width),+ room.width,+ );+ const height = clamp(+ intent.height,+ Math.min(MIN_HEIGHT, room.height),+ room.height,+ );+ return clearOfComposer(+ {+ left: room.left + placeAxis(intent.left, room.width - width),+ top: room.top + clamp(intent.top, 0, room.height - height),+ width,+ height,+ },+ room,+ );+}++function intentOf(room: Box, box: Box): Geometry {+ const left = box.left - room.left;+ const anchored = room.width - box.width - left <= RIGHT_SNAP_PX;+ return {+ left: anchored ? null : left,+ top: box.top - room.top,+ width: box.width,+ height: box.height,+ };+}++function currentBox(room: Room): Box {+ geometry ??= readGeometry();+ return boxIn(room, geometry ?? defaultGeometry(room));+}++function scaleFor(box: Box): number {+ if (!layoutWidth) return 1;+ const scale = Math.min(+ 1,+ Math.max(0.05, (box.width - FRAME_PX) / layoutWidth),+ );+ // Rounded, so a native page is re-zoomed only on a real size change.+ return Math.round(scale * 1000) / 1000;+}++function paint(surface: HTMLElement, box: Box): void {+ Object.assign(surface.style, {+ position: "fixed",+ left: `${box.left}px`,+ top: `${box.top}px`,+ width: `${box.width}px`,+ height: `${box.height}px`,+ });+ surface.style.setProperty(FLOATING_SCALE_VAR, String(scaleFor(box)));+}++// Not transform: React owns it on the surface, and a drag's own is cleared when it ends.+const PLACED_PROPERTIES = [+ "position",+ "left",+ "top",+ "width",+ "height",+ FLOATING_SCALE_VAR,+] as const;+// Below this a press is a click (a double-click docks), not a drag.+const DRAG_SLOP_PX = 3;++export function floatSurface(surface: HTMLElement): () => void {+ const saved = PLACED_PROPERTIES.map((name) =>+ surface.style.getPropertyValue(name),+ );+ const split = surface.closest<HTMLElement>(".chat-artifact-split");+ // Measured before it floats: still the side pane's width, or about none when it opens floating.+ const docked = surface.getBoundingClientRect().width;+ const splitWidth = split?.getBoundingClientRect().width ?? 0;+ layoutWidth = Math.round(+ Math.max(+ MIN_LAYOUT_WIDTH,+ docked >= MIN_LAYOUT_WIDTH ? docked : (layoutWidth ?? splitWidth / 2),+ ),+ );+ const place = () => {+ if (surface.hasAttribute("data-floating-gesture")) return;+ const room = roomFor(surface);+ if (room) paint(surface, currentBox(room));+ };+ place();+ const observer = new ResizeObserver(place);+ if (split) observer.observe(split);+ const observeComposer = () => {+ const composer = split?.querySelector?.<HTMLElement>(+ "form.aui-composer-root",+ );+ if (composer) observer.observe(composer);+ };+ observeComposer();+ window.addEventListener("resize", place);+ return () => {+ observer.disconnect();+ window.removeEventListener("resize", place);+ PLACED_PROPERTIES.forEach((name, index) => {+ if (saved[index]) surface.style.setProperty(name, saved[index]);+ else surface.style.removeProperty(name);+ });+ };+}++function resized(+ start: Box,+ edge: FloatingEdge,+ dx: number,+ dy: number,+ room: Box,+): Box {+ const minWidth = Math.min(MIN_WIDTH, room.width);+ const minHeight = Math.min(MIN_HEIGHT, room.height);+ const roomRight = room.left + room.width;+ const roomBottom = room.top + room.height;+ if (edge === "move") {+ return {+ ...start,+ left: clamp(start.left + dx, room.left, roomRight - start.width),+ top: clamp(start.top + dy, room.top, roomBottom - start.height),+ };+ }+ let left = start.left;+ let right = start.left + start.width;+ let top = start.top;+ let bottom = start.top + start.height;+ if (edge.includes("w")) left = clamp(left + dx, room.left, right - minWidth);+ if (edge.includes("e")) right = clamp(right + dx, left + minWidth, roomRight);+ if (edge.includes("n")) top = clamp(top + dy, room.top, bottom - minHeight);+ if (edge.includes("s"))+ bottom = clamp(bottom + dy, top + minHeight, roomBottom);+ return { left, top, width: right - left, height: bottom - top };+}++function settled(+ start: Box,+ previous: Box,+ next: Box,+ edge: FloatingEdge,+ room: Room,+): Box {+ if (edge === "move") return clearOfComposer(next, room);+ const composer = room.composer;+ if (!composer || !overlaps(next, composer) || overlaps(start, composer))+ return next;+ let { top, height } = next;+ const bottom = top + height;+ if (edge.includes("s") && start.top + start.height <= composer.top) {+ height = composer.top - EDGE_GAP - top;+ } else if (+ edge.includes("n") &&+ start.top >= composer.top + composer.height+ ) {+ top = composer.top + composer.height + EDGE_GAP;+ height = bottom - top;+ }+ const stopped = { ...next, top, height };+ return height >= Math.min(MIN_HEIGHT, room.height) &&+ !overlaps(stopped, composer)+ ? stopped+ : previous;+}++const CURSORS: Record<FloatingEdge, string> = {+ move: "grabbing",+ n: "ns-resize",+ s: "ns-resize",+ e: "ew-resize",+ w: "ew-resize",+ ne: "nesw-resize",+ sw: "nesw-resize",+ nw: "nwse-resize",+ se: "nwse-resize",+};++const announceMove = () => window.dispatchEvent(new Event(FLOATING_MOVE_EVENT));++/** A move rides a transform and a resize only rescales, once per frame; a sheet keeps the page's frame off the pointer. */+export function startFloatingGesture(+ event: ReactPointerEvent<HTMLElement>,+ edge: FloatingEdge,+): void {+ if (event.button !== 0) return;+ if (+ edge === "move" &&+ (event.target as Element).closest(+ "button:not([data-floating-handle]), a, input",+ )+ )+ return;+ const surface = event.currentTarget.closest<HTMLElement>(+ `[${FLOATING_ATTRIBUTE}]`,+ );+ const room = surface ? roomFor(surface) : null;+ if (!surface || !room) return;+ event.preventDefault();+ const start = currentBox(room);+ const startX = event.clientX;+ const startY = event.clientY;+ let latest = start;+ let frame = 0;+ // Only on the first real move: from the press it would take the double-click.+ // `[data-slot$="-overlay"]`: native-view.ts treats it as covering the page, so input stays here.+ let sheet: HTMLElement | null = null;+ const begin = () => {+ sheet = document.createElement("div");+ sheet.setAttribute("data-slot", "browser-floating-drag-overlay");+ sheet.setAttribute("aria-hidden", "true");+ Object.assign(sheet.style, {+ position: "fixed",+ inset: "0",+ zIndex: String(Z_LAYER.DRAG_CURSOR_OVERLAY),+ cursor: CURSORS[edge],+ userSelect: "none",+ touchAction: "none",+ });+ document.body.appendChild(sheet);+ surface.setAttribute(+ "data-floating-gesture",+ edge === "move" ? "move" : "resize",+ );+ };+ // Docked or closed mid-drag: the surface is no longer the window's.+ const floating = () => surface.hasAttribute(FLOATING_ATTRIBUTE);+ const draw = () => {+ frame = 0;+ if (!floating()) return;+ if (edge === "move") {+ surface.style.transform = `translate3d(${latest.left - start.left}px, ${latest.top - start.top}px, 0)`;+ } else {+ paint(surface, latest);+ }+ announceMove();+ };+ const move = (next: PointerEvent) => {+ if (next.buttons === 0) {+ finish();+ return;+ }+ const dx = next.clientX - startX;+ const dy = next.clientY - startY;+ if (!sheet) {+ if (Math.hypot(dx, dy) < DRAG_SLOP_PX) return;+ begin();+ }+ latest = settled(+ start,+ latest,+ resized(start, edge, dx, dy, room),+ edge,+ room,+ );+ if (!frame) frame = requestAnimationFrame(draw);+ };+ const finish = () => {+ window.removeEventListener("pointermove", move);+ window.removeEventListener("pointerup", finish);+ window.removeEventListener("pointercancel", finish);+ cancelAnimationFrame(frame);+ if (!sheet) return;+ sheet.remove();+ surface.removeAttribute("data-floating-gesture");+ if (edge === "move") surface.style.transform = "none";+ if (!floating()) return;+ paint(surface, latest);+ writeGeometry(intentOf(room, latest));+ announceMove();+ };+ window.addEventListener("pointermove", move);+ window.addEventListener("pointerup", finish);+ window.addEventListener("pointercancel", finish);+}++export function nudgeFloating(event: ReactKeyboardEvent<HTMLElement>): void {+ const delta = nudgeDelta(event.key, false);+ const surface = event.currentTarget.closest<HTMLElement>(+ `[${FLOATING_ATTRIBUTE}]`,+ );+ const room = surface ? roomFor(surface) : null;+ if (!delta || !surface || !room) return;+ event.preventDefault();+ const step = 2;+ const edge = event.shiftKey ? "se" : "move";+ const start = currentBox(room);+ const next = settled(+ start,+ start,+ resized(start, edge, delta.dx * step, delta.dy * step, room),+ edge,+ room,+ );+ paint(surface, next);+ writeGeometry(intentOf(room, next));+ announceMove();+}diff --git a/studio/frontend/src/features/browser/full-view-chat.tsx b/studio/frontend/src/features/browser/full-view-chat.tsxindex c3faa09d0ca..a00b6beda9f 100644--- a/studio/frontend/src/features/browser/full-view-chat.tsx+++ b/studio/frontend/src/features/browser/full-view-chat.tsx@@ -26,6 +26,7 @@ import {} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { useEffect, useRef, useState } from "react";+import { closeOrFloatBrowser } from "./close-browser";import { useBrowserStore } from "./store";const WASH =@@ -34,7 +35,7 @@ const WASH =export function FullViewChatBar({ title }: { title: string | undefined }) {const t = useT();const dock = useBrowserStore((state) => state.chatDock);- const { setChatDock, closePanel, splitWithChatOn } =+ const { setChatDock, splitWithChatOn } =useBrowserStore.getState();const [menuOpen, setMenuOpen] = useState(false);const barRef = useRef<HTMLDivElement | null>(null);@@ -132,7 +133,7 @@ export function FullViewChatBar({ title }: { title: string | undefined }) {sideOffset={8}className="browser-menu min-w-60 rounded-lg p-1">- <DropdownMenuItem onSelect={closePanel}>+ <DropdownMenuItem onSelect={closeOrFloatBrowser}><HugeiconsIconicon={ExpandArrowsIcon}strokeWidth={1.75}diff --git a/studio/frontend/src/features/browser/index.ts b/studio/frontend/src/features/browser/index.tsindex d778b0ce488..0b5fb17bcd8 100644--- a/studio/frontend/src/features/browser/index.ts+++ b/studio/frontend/src/features/browser/index.ts@@ -25,6 +25,9 @@ export { SEARCH_ENGINES, type SearchEngineId } from "./address";export { useBrowserHistoryStore } from "./history-store";export { useNativeBrowser } from "./native-support";export { pinBrowserPage } from "./resize-pin";+export { FloatingResizeHandles } from "./floating-frame";+export { floatSurface } from "./floating-preview";+export { closeOrFloatBrowser } from "./close-browser";export {type AnnotationScreenshots,type BookmarksToolbarMode,diff --git a/studio/frontend/src/features/browser/native-view.ts b/studio/frontend/src/features/browser/native-view.tsindex 73f8fbf7ed3..db6593a3600 100644--- a/studio/frontend/src/features/browser/native-view.ts+++ b/studio/frontend/src/features/browser/native-view.ts@@ -19,6 +19,7 @@ import { abandonDownload, beginDownload, finishDownload, useDownloadActivity } fimport { proxiedFavicon } from "./favicon";import { useBrowserHistoryStore } from "./history-store";import { decideNativeDownload } from "./native-downloads";+import { FLOATING_ATTRIBUTE, FLOATING_MOVE_EVENT, FLOATING_SCALE_VAR, floatingNativeZoom } from "./floating-events";import { outsideThread } from "./outside-thread";import { callNative as call, localOriginGranted, nativeClearing, onNativeViewsClosed, setLocalViewCloser } from "./native-support";import { useBrowserPrefsStore } from "./prefs-store";@@ -612,6 +613,7 @@ function markHole(): boolean {const layers = chain.filter((node) => node.hasAttribute?.("data-wallpaper-workspace") || node.hasAttribute?.("data-chat-content-root")).flatMap((node) => [...(node.children ?? [])].filter((child): child is HTMLElement => child.classList.contains("chat-wallpaper")));+ layers.push(...floatingUnderlay(chain));const signature = `${root.dataset.palette}|${theme}|${chain.map((node) => node.className).join("|")}|${layers.length}`;if (signature === holeSignature && [...holed, ...masked].every((node) => node.isConnected)) return false;unmarkHole();@@ -632,6 +634,20 @@ function markHole(): boolean {return true;}+/** The chat under a floating page is no ancestor of it, so its boxes are masked too. */+function floatingUnderlay(chain: HTMLElement[]): HTMLElement[] {+ const floating = chain.findIndex((node) => node.hasAttribute?.(FLOATING_ATTRIBUTE));+ if (floating < 0) return [];+ const under: HTMLElement[] = [];+ for (const node of chain.slice(floating)) {+ if (node.hasAttribute("data-chat-content-root")) break;+ for (const sibling of node.parentElement?.children ?? []) {+ if (sibling !== node && sibling instanceof HTMLElement && !sibling.classList.contains("chat-wallpaper")) under.push(sibling);+ }+ }+ return under;+}+function unmarkHole(): void {for (const node of holed) {node.removeAttribute(HOLE_ATTRIBUTE);@@ -713,6 +729,12 @@ function insetToasts(rect: DOMRect | null): void {else style.removeProperty(BROWSER_PAGE_INSET_VAR);}+function floatingScale(tabId: string): number {+ const surface = placeholder(tabId)?.closest?.<HTMLElement>(`[${FLOATING_ATTRIBUTE}]`);+ const scale = Number.parseFloat(surface?.style?.getPropertyValue?.(FLOATING_SCALE_VAR) ?? "");+ return scale > 0 && scale <= 1 ? scale : 1;+}+function desiredView(): Desired {const page = pageRect();if (layered) {@@ -727,7 +749,7 @@ function desiredView(): Desired {tabId: tab.id,url: entry.url,entry: entryKey(entry),- zoom: tab.zoom,+ zoom: floatingNativeZoom(tab.zoom, floatingScale(tab.id)),bounds: {x: Math.round(rect.left),y: Math.round(rect.top),@@ -1123,6 +1145,8 @@ export function startNativeViews(): () => void {const sync = () => {frame = 0;if (layered === null) return;+ // A page on top waits out a floating drag under its snapshot, not a capture per frame.+ if (!layered && parkedView !== null && document.querySelector?.("[data-floating-gesture]")) return;markHole();const desired = desiredView();pruneViews(desired?.tabId ?? null);@@ -1172,6 +1196,11 @@ export function startNativeViews(): () => void {document.addEventListener("pointerover", reachedPage, true);// A dragged or resized panel ends where the pointer lets go.document.addEventListener("pointerup", schedule, true);+ // A layered page follows the floating window; one on top waits for the drop (see sync).+ const floatingMoved = () => {+ if (layered || !document.querySelector("[data-floating-gesture]")) schedule();+ };+ window.addEventListener(FLOATING_MOVE_EVENT, floatingMoved);const interval = window.setInterval(schedule, RECHECK_MS);void askLayered().then(schedule);schedule();@@ -1187,6 +1216,7 @@ export function startNativeViews(): () => void {for (const type of MOTION_EVENTS) document.removeEventListener(type, moved, true);document.removeEventListener("pointerover", reachedPage, true);document.removeEventListener("pointerup", schedule, true);+ window.removeEventListener(FLOATING_MOVE_EVENT, floatingMoved);window.clearInterval(interval);panelUp = false;tooltipHold = 0;diff --git a/studio/frontend/src/features/browser/store.ts b/studio/frontend/src/features/browser/store.tsindex 0bc6a0eb0e0..893717a73f3 100644--- a/studio/frontend/src/features/browser/store.ts+++ b/studio/frontend/src/features/browser/store.ts@@ -334,6 +334,10 @@ type BrowserState = {bookmarkSequence: number;device: DeviceMode;fullView: boolean;+ /** The floating window layout, for every chat and kept across closes. */+ floating: boolean;+ /** Floated by a close mid-run (close-browser.ts): its own close restores the chosen layout. */+ floatedForAgent: boolean;chatDock: ChatDock;chatSide: ChatSide;requestEdits: RequestEdits | null;@@ -406,6 +410,8 @@ type BrowserState = {setFullView: (fullView: boolean) => void;setChatDock: (dock: ChatDock) => void;splitWithChatOn: (side: ChatSide) => void;+ setFloating: (floating: boolean) => void;+ floatForAgent: () => void;};const patchTab = (tabs: BrowserTab[], tabId: string, update: (tab: BrowserTab) => BrowserTab) =>@@ -592,6 +598,8 @@ export const useBrowserStore = create<BrowserState>((set, get) => {bookmarkSequence: 0,device: "off",fullView: false,+ floating: false,+ floatedForAgent: false,chatDock: "composer",chatSide: "left",requestEdits: null,@@ -614,7 +622,13 @@ export const useBrowserStore = create<BrowserState>((set, get) => {}set((state) => ({ open: true, openSequence: state.openSequence + 1 }));},- closePanel: () => set({ open: false, fullView: false, annotateTabId: null }),+ closePanel: () =>+ set((state) => ({+ open: false,+ fullView: false,+ annotateTabId: null,+ ...(state.floatedForAgent ? { floating: false, floatedForAgent: false } : {}),+ })),togglePanel: () => (get().open ? get().closePanel() : get().openPanel()),newTab: () => {openTab(createTab({ kind: "newtab" }));@@ -859,9 +873,26 @@ export const useBrowserStore = create<BrowserState>((set, get) => {tabs: patchTab(state.tabs, tabId, (tab) => ({ ...tab, zoom: Math.min(5, Math.max(0.25, zoom)) })),})),setDevice: (device) => set({ device }),- setFullView: (fullView) => set({ fullView, chatDock: "composer" }),+ setFullView: (fullView) =>+ set(+ fullView+ ? { fullView, chatDock: "composer", floating: false, floatedForAgent: false }+ : { fullView, chatDock: "composer" },+ ),setChatDock: (chatDock) => set({ chatDock }),- splitWithChatOn: (chatSide) => set({ fullView: false, chatSide }),+ splitWithChatOn: (chatSide) => set({ fullView: false, floating: false, floatedForAgent: false, chatSide }),+ // Marks would land on the unscaled page.+ setFloating: (floating) =>+ set(+ floating+ ? { floating, floatedForAgent: false, fullView: false, chatDock: "composer", annotateTabId: null }+ : { floating, floatedForAgent: false },+ ),+ floatForAgent: () => {+ if (get().floating) return;+ get().setFloating(true);+ set({ floatedForAgent: true });+ },};});diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex e63abff5919..3b6be0ab124 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -104,7 +104,10 @@ import { cn } from "@/lib/utils";import { setInAppLinkHandler } from "@/lib/open-link";import {BrowserToggleButton,+ FloatingResizeHandles,chatKeyOfThread,+ closeOrFloatBrowser,+ floatSurface,openUrlInBrowser,pinBrowserPage,setBrowserPanelAvailable,@@ -660,11 +663,11 @@ const SingleContent = memo(function SingleContent({if (size == null) return;// Dragged shut means closed.if (size <= 5) {- closeBrowser();+ closeOrFloatBrowser();return;}artifactPanelWidthRef.current = `${size}%`;- }, [closeBrowser]);+ }, []);const hasInitializedArtifactPanelRef = useRef(false);const [isArtifactLayoutAnimating, setIsArtifactLayoutAnimating] =useState(false);@@ -688,10 +691,14 @@ const SingleContent = memo(function SingleContent({}, [browserOpenSequence, browserOpen, browserOverlaid, showResearchPanel, closeResearchPanel]);const browserFullView =useBrowserStore((state) => state.fullView) && showBrowserPanel;+ // Floating stays mounted here, so switching layouts never reloads the page.+ const browserFloating =+ useBrowserStore((state) => state.floating) && showBrowserPanel && !browserFullView;+ const browserDocked = showBrowserPanel && !browserFloating;const chatDock = useBrowserStore((state) => state.chatDock);const chatOnRight =useBrowserStore((state) => state.chatSide === "right") &&- showBrowserPanel &&+ browserDocked &&!browserFullView;const defaultPanelSizeRef = useRef(ARTIFACT_PANEL_DEFAULT_SIZE);useEffect(() => {@@ -699,7 +706,7 @@ const SingleContent = memo(function SingleContent({? BROWSER_PANEL_DEFAULT_SIZE: ARTIFACT_PANEL_DEFAULT_SIZE;});- const showContextPanel = showResearchPanel || showBrowserPanel;+ const showContextPanel = showResearchPanel || browserDocked;const artifactLayoutActive = showContextPanel || isArtifactPanelLayoutActive;const artifactPanelSettledOpen =@@ -793,7 +800,7 @@ const SingleContent = memo(function SingleContent({useEffect(() => {const surface = contextSurfaceRef.current;const root = surface?.closest<HTMLElement>("[data-chat-content-root]");- if (!surface || !root || !showBrowserPanel) return;+ if (!surface || !root || !browserDocked) return;let width = "";const insets = () =>root.querySelectorAll<HTMLElement>(":scope > [data-side-panel-inset]");@@ -826,7 +833,13 @@ const SingleContent = memo(function SingleContent({element.style.removeProperty("--studio-side-panel-left");}};- }, [showBrowserPanel, chatOnRight]);+ }, [browserDocked, chatOnRight]);++ useLayoutEffect(() => {+ const surface = contextSurfaceRef.current;+ if (!surface || !browserFloating) return;+ return floatSurface(surface);+ }, [browserFloating]);// Moving the chat re-sorts panels to default sizes; restore the browser's width (full view fills).const browserLayout = `${browserFullView}:${chatOnRight}`;@@ -835,14 +848,14 @@ const SingleContent = memo(function SingleContent({if (seenBrowserLayoutRef.current === browserLayout) return;seenBrowserLayoutRef.current = browserLayout;const panel = artifactPanelRef.current;- if (!panel || !showBrowserPanel) return;+ if (!panel || !browserDocked) return;const frameId = window.requestAnimationFrame(() => {panel.resize(artifactPanelWidthRef.current ?? defaultPanelSizeRef.current,);});return () => window.cancelAnimationFrame(frameId);- }, [browserLayout, showBrowserPanel]);+ }, [browserLayout, browserDocked]);// With no chat beside it, the chat header would sit over the browser's tabs.useEffect(() => {@@ -998,11 +1011,13 @@ const SingleContent = memo(function SingleContent({data-artifact-surface-visible={isArtifactSurfaceVisible ? "true" : "false"}+ {...{ "data-browser-floating": browserFloating ? "" : undefined }}className={cn("chat-artifact-pop-surface flex h-full min-h-0 min-w-0 flex-col overflow-visible",- (showResearchPanel || showBrowserPanel) &&+ (showResearchPanel || browserDocked) &&(chatOnRight ? "border-r" : "border-l"),- (showResearchPanel || showBrowserPanel) && "border-border/70",+ (showResearchPanel || browserDocked) && "border-border/70",+ browserFloating && "chat-browser-floating",)}style={showBrowserPanel ? { transform: "none" } : undefined}>@@ -1014,7 +1029,8 @@ const SingleContent = memo(function SingleContent({/>) : showBrowserPanel ? (<Suspense fallback={null}>- <BrowserPanel active={chatActive} />+ <BrowserPanel active={chatActive} floating={browserFloating} floatable={true} />+ {browserFloating ? <FloatingResizeHandles /> : null}</Suspense>) : null}</div>@@ -4848,6 +4864,7 @@ export function ChatPage({<BrowserToggleButtonactive={active}hideWhenOpen={view.mode === "single" || showBrowserOverlay}+ floatable={view.mode === "single"}/>) : null}{view.mode === "single" &&diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex ec4178ba4d7..65ad7299a46 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -207,6 +207,7 @@ export const ar = {tabs: "علامات تبويب المتصفح",newTab: "علامة تبويب جديدة",newTabFullView: "علامة تبويب جديدة في العرض الكامل",+ newTabFloating: "علامة تبويب جديدة في نافذة عائمة",closeTab: "إغلاق علامة التبويب",close: "إغلاق المتصفح",show: "إظهار المتصفح",@@ -390,6 +391,12 @@ export const ar = {moveLeft: "نقل إلى اللوحة اليسرى",moveRight: "نقل إلى اللوحة اليمنى",},+ floating: {+ enter: "نافذة عائمة",+ dock: "تثبيت على الجانب",+ close: "إغلاق النافذة العائمة",+ handle: "تحريك النافذة. تحركها مفاتيح الأسهم، ويغيّر Shift مع الأسهم حجمها.",+ },annotate: {countOne: "تعليق توضيحي واحد",countMany: "{count} تعليقات توضيحية",diff --git a/studio/frontend/src/i18n/locales/cs.ts b/studio/frontend/src/i18n/locales/cs.tsindex 61f80cce4b4..4e66d07c720 100644--- a/studio/frontend/src/i18n/locales/cs.ts+++ b/studio/frontend/src/i18n/locales/cs.ts@@ -215,6 +215,7 @@ export const cs = {tabs: "Karty prohlížeče",newTab: "Nová karta",newTabFullView: "Nová karta v plném zobrazení",+ newTabFloating: "Nová karta v plovoucím okně",closeTab: "Zavřít kartu",close: "Zavřít prohlížeč",show: "Zobrazit prohlížeč",@@ -434,6 +435,12 @@ export const cs = {moveLeft: "Přesunout do levého podokna",moveRight: "Přesunout do pravého podokna",},+ floating: {+ enter: "Plovoucí okno",+ dock: "Připnout ke straně",+ close: "Zavřít plovoucí okno",+ handle: "Přesunout okno. Šipky jej posouvají, Shift se šipkami mění jeho velikost.",+ },annotate: {countOne: "1 anotace",countMany: "Anotace: {count}",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 3b832853acf..3f71ba42528 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -207,6 +207,7 @@ export const de = {tabs: "Browser-Tabs",newTab: "Neuer Tab",newTabFullView: "Neuer Tab in Vollansicht",+ newTabFloating: "Neuer Tab in schwebendem Fenster",closeTab: "Tab schließen",close: "Browser schließen",show: "Browser anzeigen",@@ -390,6 +391,12 @@ export const de = {moveLeft: "In linken Bereich verschieben",moveRight: "In rechten Bereich verschieben",},+ floating: {+ enter: "Schwebendes Fenster",+ dock: "Seitlich andocken",+ close: "Schwebendes Fenster schließen",+ handle: "Fenster verschieben. Pfeiltasten verschieben es, Umschalt und Pfeiltasten ändern seine Größe.",+ },annotate: {countOne: "1 Anmerkung",countMany: "{count} Anmerkungen",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 95d01a99a04..41a70c75ff6 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -204,6 +204,7 @@ export const en = {tabs: "Browser tabs",newTab: "New tab",newTabFullView: "New tab in full view",+ newTabFloating: "New tab in floating window",closeTab: "Close tab",close: "Close browser",show: "Show browser",@@ -387,6 +388,12 @@ export const en = {moveLeft: "Move to left pane",moveRight: "Move to right pane",},+ floating: {+ enter: "Floating window",+ dock: "Dock to side",+ close: "Close floating window",+ handle: "Move window. Arrow keys move it; Shift and arrow keys resize it.",+ },annotate: {countOne: "1 annotation",countMany: "{count} annotations",diff --git a/studio/frontend/src/i18n/locales/es-419.ts b/studio/frontend/src/i18n/locales/es-419.tsindex b6629e5bf80..8293d7f862b 100644--- a/studio/frontend/src/i18n/locales/es-419.ts+++ b/studio/frontend/src/i18n/locales/es-419.ts@@ -216,6 +216,7 @@ export const es419 = {tabs: "Pestañas del navegador",newTab: "Nueva pestaña",newTabFullView: "Nueva pestaña en vista completa",+ newTabFloating: "Nueva pestaña en ventana flotante",closeTab: "Cerrar pestaña",close: "Cerrar navegador",show: "Mostrar navegador",@@ -436,6 +437,12 @@ export const es419 = {moveLeft: "Mover al panel izquierdo",moveRight: "Mover al panel derecho",},+ floating: {+ enter: "Ventana flotante",+ dock: "Acoplar al costado",+ close: "Cerrar ventana flotante",+ handle: "Mover la ventana. Las flechas la mueven; Mayús y las flechas cambian su tamaño.",+ },annotate: {countOne: "1 anotación",countMany: "{count} anotaciones",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 4dbe557c88c..bfbe75b2727 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -207,6 +207,7 @@ export const es = {tabs: "Pestañas del navegador",newTab: "Nueva pestaña",newTabFullView: "Nueva pestaña en vista completa",+ newTabFloating: "Nueva pestaña en ventana flotante",closeTab: "Cerrar pestaña",close: "Cerrar navegador",show: "Mostrar navegador",@@ -390,6 +391,12 @@ export const es = {moveLeft: "Mover al panel izquierdo",moveRight: "Mover al panel derecho",},+ floating: {+ enter: "Ventana flotante",+ dock: "Acoplar al lateral",+ close: "Cerrar ventana flotante",+ handle: "Mover la ventana. Las flechas la mueven; Mayús y las flechas cambian su tamaño.",+ },annotate: {countOne: "1 anotación",countMany: "{count} anotaciones",diff --git a/studio/frontend/src/i18n/locales/fa.ts b/studio/frontend/src/i18n/locales/fa.tsindex 78af0171d54..0b1c9ca63f6 100644--- a/studio/frontend/src/i18n/locales/fa.ts+++ b/studio/frontend/src/i18n/locales/fa.ts@@ -215,6 +215,7 @@ export const fa = {tabs: "زبانههای مرورگر",newTab: "زبانهٔ جدید",newTabFullView: "زبانهٔ جدید در نمای کامل",+ newTabFloating: "زبانه جدید در پنجره شناور",closeTab: "بستن زبانه",close: "بستن مرورگر",show: "نمایش مرورگر",@@ -432,6 +433,12 @@ export const fa = {moveLeft: "انتقال به قاب چپ",moveRight: "انتقال به قاب راست",},+ floating: {+ enter: "پنجره شناور",+ dock: "چسباندن به کنار",+ close: "بستن پنجره شناور",+ handle: "جابهجایی پنجره. کلیدهای جهت آن را جابهجا میکنند و Shift همراه کلیدهای جهت اندازهاش را تغییر میدهد.",+ },annotate: {countOne: "1 حاشیهنویسی",countMany: "{count} حاشیهنویسی",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 4838666693f..e2eb68d328d 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -207,6 +207,7 @@ export const fr = {tabs: "Onglets du navigateur",newTab: "Nouvel onglet",newTabFullView: "Nouvel onglet en plein écran",+ newTabFloating: "Nouvel onglet en fenêtre flottante",closeTab: "Fermer l’onglet",close: "Fermer le navigateur",show: "Afficher le navigateur",@@ -390,6 +391,12 @@ export const fr = {moveLeft: "Déplacer vers le volet gauche",moveRight: "Déplacer vers le volet droit",},+ floating: {+ enter: "Fenêtre flottante",+ dock: "Ancrer sur le côté",+ close: "Fermer la fenêtre flottante",+ handle: "Déplacer la fenêtre. Les flèches la déplacent ; Maj et les flèches la redimensionnent.",+ },annotate: {countOne: "1 annotation",countMany: "{count} annotations",diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.tsindex 837c38023cd..c0b54721590 100644--- a/studio/frontend/src/i18n/locales/he.ts+++ b/studio/frontend/src/i18n/locales/he.ts@@ -208,6 +208,7 @@ export const he = {tabs: "כרטיסיות דפדפן",newTab: "כרטיסייה חדשה",newTabFullView: "כרטיסייה חדשה בתצוגה מלאה",+ newTabFloating: "כרטיסייה חדשה בחלון צף",closeTab: "סגור כרטיסייה",close: "סגור דפדפן",show: "הצג דפדפן",@@ -400,6 +401,12 @@ export const he = {moveLeft: "העבר לחלונית השמאלית",moveRight: "העבר לחלונית הימנית",},+ floating: {+ enter: "חלון צף",+ dock: "עגינה לצד",+ close: "סגירת החלון הצף",+ handle: "הזזת החלון. מקשי החצים מזיזים אותו, ו־Shift עם החצים משנה את גודלו.",+ },annotate: {countOne: "הערה אחת",countMany: "{count} הערות",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex ae73530e7f8..be0579568a9 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -207,6 +207,7 @@ export const hi = {tabs: "ब्राउज़र टैब",newTab: "नया टैब",newTabFullView: "पूरे व्यू में नया टैब",+ newTabFloating: "फ़्लोटिंग विंडो में नया टैब",closeTab: "टैब बंद करें",close: "ब्राउज़र बंद करें",show: "ब्राउज़र दिखाएँ",@@ -390,6 +391,12 @@ export const hi = {moveLeft: "बाएँ पैन में ले जाएँ",moveRight: "दाएँ पैन में ले जाएँ",},+ floating: {+ enter: "फ़्लोटिंग विंडो",+ dock: "साइड में डॉक करें",+ close: "फ़्लोटिंग विंडो बंद करें",+ handle: "विंडो खिसकाएँ। ऐरो कुंजियाँ इसे खिसकाती हैं; Shift और ऐरो कुंजियाँ इसका आकार बदलती हैं।",+ },annotate: {countOne: "1 टिप्पणी",countMany: "{count} टिप्पणियाँ",diff --git a/studio/frontend/src/i18n/locales/id.ts b/studio/frontend/src/i18n/locales/id.tsindex 4999483932f..be9dfde4eae 100644--- a/studio/frontend/src/i18n/locales/id.ts+++ b/studio/frontend/src/i18n/locales/id.ts@@ -215,6 +215,7 @@ export const id = {tabs: "Tab browser",newTab: "Tab baru",newTabFullView: "Tab baru dalam tampilan penuh",+ newTabFloating: "Tab baru di jendela mengambang",closeTab: "Tutup tab",close: "Tutup browser",show: "Tampilkan browser",@@ -434,6 +435,12 @@ export const id = {moveLeft: "Pindahkan ke panel kiri",moveRight: "Pindahkan ke panel kanan",},+ floating: {+ enter: "Jendela mengambang",+ dock: "Sematkan ke samping",+ close: "Tutup jendela mengambang",+ handle: "Pindahkan jendela. Tombol panah memindahkannya; Shift dan tombol panah mengubah ukurannya.",+ },annotate: {countOne: "1 anotasi",countMany: "{count} anotasi",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex 89fc0e9cf81..ccd88f03215 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -204,6 +204,7 @@ export const it = {tabs: "Schede del browser",newTab: "Nuova scheda",newTabFullView: "Nuova scheda a schermo intero",+ newTabFloating: "Nuova scheda in finestra mobile",closeTab: "Chiudi scheda",close: "Chiudi browser",show: "Mostra browser",@@ -387,6 +388,12 @@ export const it = {moveLeft: "Sposta nel riquadro sinistro",moveRight: "Sposta nel riquadro destro",},+ floating: {+ enter: "Finestra mobile",+ dock: "Aggancia di lato",+ close: "Chiudi finestra mobile",+ handle: "Sposta la finestra. Le frecce la spostano; Maiusc e le frecce la ridimensionano.",+ },annotate: {countOne: "1 annotazione",countMany: "{count} annotazioni",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex 12f3de44a85..5a8ef699a3d 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -208,6 +208,7 @@ export const ja = {tabs: "ブラウザのタブ",newTab: "新しいタブ",newTabFullView: "全画面表示で新しいタブ",+ newTabFloating: "フローティングウィンドウで新しいタブ",closeTab: "タブを閉じる",close: "ブラウザを閉じる",show: "ブラウザを表示",@@ -391,6 +392,12 @@ export const ja = {moveLeft: "左ペインに移動",moveRight: "右ペインに移動",},+ floating: {+ enter: "フローティングウィンドウ",+ dock: "横にドッキング",+ close: "フローティングウィンドウを閉じる",+ handle: "ウィンドウを移動。矢印キーで移動、Shift と矢印キーでサイズを変更します。",+ },annotate: {countOne: "注釈 1 件",countMany: "注釈 {count} 件",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex 0ba506b2256..20f073ff579 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -207,6 +207,7 @@ export const ko = {tabs: "브라우저 탭",newTab: "새 탭",newTabFullView: "전체 보기로 새 탭",+ newTabFloating: "플로팅 창에서 새 탭",closeTab: "탭 닫기",close: "브라우저 닫기",show: "브라우저 표시",@@ -390,6 +391,12 @@ export const ko = {moveLeft: "왼쪽 창으로 이동",moveRight: "오른쪽 창으로 이동",},+ floating: {+ enter: "플로팅 창",+ dock: "옆에 고정",+ close: "플로팅 창 닫기",+ handle: "창 이동. 화살표 키로 이동하고 Shift와 화살표 키로 크기를 바꿉니다.",+ },annotate: {countOne: "주석 1개",countMany: "주석 {count}개",diff --git a/studio/frontend/src/i18n/locales/nl.ts b/studio/frontend/src/i18n/locales/nl.tsindex 000a23fff49..7bcd015d9b7 100644--- a/studio/frontend/src/i18n/locales/nl.ts+++ b/studio/frontend/src/i18n/locales/nl.ts@@ -215,6 +215,7 @@ export const nl = {tabs: "Browsertabbladen",newTab: "Nieuw tabblad",newTabFullView: "Nieuw tabblad in volledige weergave",+ newTabFloating: "Nieuw tabblad in zwevend venster",closeTab: "Tabblad sluiten",close: "Browser sluiten",show: "Browser weergeven",@@ -435,6 +436,12 @@ export const nl = {moveLeft: "Naar linkerpaneel verplaatsen",moveRight: "Naar rechterpaneel verplaatsen",},+ floating: {+ enter: "Zwevend venster",+ dock: "Aan de zijkant vastzetten",+ close: "Zwevend venster sluiten",+ handle: "Venster verplaatsen. Pijltoetsen verplaatsen het; Shift en pijltoetsen wijzigen de grootte.",+ },annotate: {countOne: "1 annotatie",countMany: "{count} annotaties",diff --git a/studio/frontend/src/i18n/locales/pl.ts b/studio/frontend/src/i18n/locales/pl.tsindex 7491807c72f..e573f47d649 100644--- a/studio/frontend/src/i18n/locales/pl.ts+++ b/studio/frontend/src/i18n/locales/pl.ts@@ -215,6 +215,7 @@ export const pl = {tabs: "Karty przeglądarki",newTab: "Nowa karta",newTabFullView: "Nowa karta w pełnym widoku",+ newTabFloating: "Nowa karta w pływającym oknie",closeTab: "Zamknij kartę",close: "Zamknij przeglądarkę",show: "Pokaż przeglądarkę",@@ -435,6 +436,12 @@ export const pl = {moveLeft: "Przenieś do lewego panelu",moveRight: "Przenieś do prawego panelu",},+ floating: {+ enter: "Pływające okno",+ dock: "Przypnij z boku",+ close: "Zamknij pływające okno",+ handle: "Przesuń okno. Strzałki je przesuwają, Shift ze strzałkami zmienia jego rozmiar.",+ },annotate: {countOne: "1 adnotacja",countMany: "Adnotacje: {count}",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex b1162199abf..103df882fa3 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -207,6 +207,7 @@ export const ptBR = {tabs: "Abas do navegador",newTab: "Nova aba",newTabFullView: "Nova aba em tela cheia",+ newTabFloating: "Nova guia em janela flutuante",closeTab: "Fechar aba",close: "Fechar navegador",show: "Mostrar navegador",@@ -390,6 +391,12 @@ export const ptBR = {moveLeft: "Mover para o painel esquerdo",moveRight: "Mover para o painel direito",},+ floating: {+ enter: "Janela flutuante",+ dock: "Encaixar na lateral",+ close: "Fechar janela flutuante",+ handle: "Mover a janela. As setas a movem; Shift e as setas a redimensionam.",+ },annotate: {countOne: "1 anotação",countMany: "{count} anotações",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex aea9a18fa2a..60db70216b7 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -207,6 +207,7 @@ export const ru = {tabs: "Вкладки браузера",newTab: "Новая вкладка",newTabFullView: "Новая вкладка во весь экран",+ newTabFloating: "Новая вкладка в плавающем окне",closeTab: "Закрыть вкладку",close: "Закрыть браузер",show: "Показать браузер",@@ -390,6 +391,12 @@ export const ru = {moveLeft: "Переместить в левую панель",moveRight: "Переместить в правую панель",},+ floating: {+ enter: "Плавающее окно",+ dock: "Закрепить сбоку",+ close: "Закрыть плавающее окно",+ handle: "Переместить окно. Стрелки перемещают его, Shift со стрелками меняет размер.",+ },annotate: {countOne: "1 пометка",countMany: "Пометок: {count}",diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.tsindex fc097b02ac7..768dfc11f43 100644--- a/studio/frontend/src/i18n/locales/sv.ts+++ b/studio/frontend/src/i18n/locales/sv.ts@@ -205,6 +205,7 @@ export const sv = {tabs: "Webbläsarflikar",newTab: "Ny flik",newTabFullView: "Ny flik i helvy",+ newTabFloating: "Ny flik i flytande fönster",closeTab: "Stäng flik",close: "Stäng webbläsaren",show: "Visa webbläsaren",@@ -402,6 +403,12 @@ export const sv = {moveLeft: "Flytta till vänstra panelen",moveRight: "Flytta till högra panelen",},+ floating: {+ enter: "Flytande fönster",+ dock: "Docka vid sidan",+ close: "Stäng flytande fönster",+ handle: "Flytta fönstret. Piltangenterna flyttar det; Skift och piltangenterna ändrar storleken.",+ },annotate: {countOne: "1 anteckning",countMany: "{count} anteckningar",diff --git a/studio/frontend/src/i18n/locales/th.ts b/studio/frontend/src/i18n/locales/th.tsindex bbd4eb8782f..61ca579b451 100644--- a/studio/frontend/src/i18n/locales/th.ts+++ b/studio/frontend/src/i18n/locales/th.ts@@ -212,6 +212,7 @@ export const th = {tabs: "แท็บเบราว์เซอร์",newTab: "แท็บใหม่",newTabFullView: "แท็บใหม่แบบเต็มหน้าจอ",+ newTabFloating: "แท็บใหม่ในหน้าต่างลอย",closeTab: "ปิดแท็บ",close: "ปิดเบราว์เซอร์",show: "แสดงเบราว์เซอร์",@@ -416,6 +417,12 @@ export const th = {moveLeft: "ย้ายไปบานหน้าต่างซ้าย",moveRight: "ย้ายไปบานหน้าต่างขวา",},+ floating: {+ enter: "หน้าต่างลอย",+ dock: "ปักไว้ด้านข้าง",+ close: "ปิดหน้าต่างลอย",+ handle: "ย้ายหน้าต่าง ปุ่มลูกศรใช้ย้าย และ Shift กับปุ่มลูกศรใช้ปรับขนาด",+ },annotate: {countOne: "คำอธิบายประกอบ 1 รายการ",countMany: "คำอธิบายประกอบ {count} รายการ",diff --git a/studio/frontend/src/i18n/locales/tr.ts b/studio/frontend/src/i18n/locales/tr.tsindex 1c40bb4a450..9e64cb45f6f 100644--- a/studio/frontend/src/i18n/locales/tr.ts+++ b/studio/frontend/src/i18n/locales/tr.ts@@ -215,6 +215,7 @@ export const tr = {tabs: "Tarayıcı sekmeleri",newTab: "Yeni sekme",newTabFullView: "Tam görünümde yeni sekme",+ newTabFloating: "Kayan pencerede yeni sekme",closeTab: "Sekmeyi kapat",close: "Tarayıcıyı kapat",show: "Tarayıcıyı göster",@@ -434,6 +435,12 @@ export const tr = {moveLeft: "Sol bölmeye taşı",moveRight: "Sağ bölmeye taşı",},+ floating: {+ enter: "Kayan pencere",+ dock: "Yana sabitle",+ close: "Kayan pencereyi kapat",+ handle: "Pencereyi taşı. Ok tuşları taşır; Shift ve ok tuşları boyutunu değiştirir.",+ },annotate: {countOne: "1 ek açıklama",countMany: "{count} ek açıklama",diff --git a/studio/frontend/src/i18n/locales/uk.ts b/studio/frontend/src/i18n/locales/uk.tsindex d110131c967..c34faae63d0 100644--- a/studio/frontend/src/i18n/locales/uk.ts+++ b/studio/frontend/src/i18n/locales/uk.ts@@ -215,6 +215,7 @@ export const uk = {tabs: "Вкладки браузера",newTab: "Нова вкладка",newTabFullView: "Нова вкладка на весь екран",+ newTabFloating: "Нова вкладка в плаваючому вікні",closeTab: "Закрити вкладку",close: "Закрити браузер",show: "Показати браузер",@@ -434,6 +435,12 @@ export const uk = {moveLeft: "Перемістити на ліву панель",moveRight: "Перемістити на праву панель",},+ floating: {+ enter: "Плаваюче вікно",+ dock: "Закріпити збоку",+ close: "Закрити плаваюче вікно",+ handle: "Перемістити вікно. Стрілки переміщують його, Shift зі стрілками змінює розмір.",+ },annotate: {countOne: "1 анотація",countMany: "Анотацій: {count}",diff --git a/studio/frontend/src/i18n/locales/vi.ts b/studio/frontend/src/i18n/locales/vi.tsindex 664cd2b8114..f0a8981f298 100644--- a/studio/frontend/src/i18n/locales/vi.ts+++ b/studio/frontend/src/i18n/locales/vi.ts@@ -215,6 +215,7 @@ export const vi = {tabs: "Thẻ trình duyệt",newTab: "Thẻ mới",newTabFullView: "Thẻ mới ở chế độ toàn màn hình",+ newTabFloating: "Tab mới trong cửa sổ nổi",closeTab: "Đóng thẻ",close: "Đóng trình duyệt",show: "Hiển thị trình duyệt",@@ -434,6 +435,12 @@ export const vi = {moveLeft: "Chuyển sang ngăn trái",moveRight: "Chuyển sang ngăn phải",},+ floating: {+ enter: "Cửa sổ nổi",+ dock: "Ghim sang bên",+ close: "Đóng cửa sổ nổi",+ handle: "Di chuyển cửa sổ. Phím mũi tên di chuyển; Shift và phím mũi tên đổi kích thước.",+ },annotate: {countOne: "1 chú thích",countMany: "{count} chú thích",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex 541f56ce6c2..bb1807dac18 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -207,6 +207,7 @@ export const zhCN = {tabs: "浏览器标签页",newTab: "新标签页",newTabFullView: "在全屏视图中新建标签页",+ newTabFloating: "在浮动窗口中新建标签页",closeTab: "关闭标签页",close: "关闭浏览器",show: "显示浏览器",@@ -390,6 +391,12 @@ export const zhCN = {moveLeft: "移到左侧窗格",moveRight: "移到右侧窗格",},+ floating: {+ enter: "浮动窗口",+ dock: "停靠到侧边",+ close: "关闭浮动窗口",+ handle: "移动窗口。方向键移动,Shift 加方向键调整大小。",+ },annotate: {countOne: "1 条批注",countMany: "{count} 条批注",diff --git a/studio/frontend/src/i18n/locales/zh-TW.ts b/studio/frontend/src/i18n/locales/zh-TW.tsindex ceee6bd31c1..82891e3e9ae 100644--- a/studio/frontend/src/i18n/locales/zh-TW.ts+++ b/studio/frontend/src/i18n/locales/zh-TW.ts@@ -211,6 +211,7 @@ export const zhTW = {tabs: "瀏覽器分頁",newTab: "新分頁",newTabFullView: "以完整檢視開啟新分頁",+ newTabFloating: "在浮動視窗中開新分頁",closeTab: "關閉分頁",close: "關閉瀏覽器",show: "顯示瀏覽器",@@ -414,6 +415,12 @@ export const zhTW = {moveLeft: "移到左側窗格",moveRight: "移到右側窗格",},+ floating: {+ enter: "浮動視窗",+ dock: "停駐到側邊",+ close: "關閉浮動視窗",+ handle: "移動視窗。方向鍵移動,Shift 加方向鍵調整大小。",+ },annotate: {countOne: "1 則註解",countMany: "{count} 則註解",diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex 33e4edf322b..f4439691831 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -5682,6 +5682,42 @@ html[data-find-bar-open] [data-sonner-toaster][data-y-position="top"] {}}+/* Placed by floating-preview.ts. No transition: a drag's transform must drop without easing back. */+.chat-artifact-pop-surface.chat-browser-floating {+ z-index: 35;+ opacity: 1;+ pointer-events: auto;+ will-change: auto;+ transition: none;+ border: 1px solid var(--border);+ border-radius: calc(16px * var(--ui-space-scale, 1));+ background: var(--card);+ box-shadow:+ 0 18px 44px -14px rgb(0 0 0 / 0.3),+ 0 4px 12px -4px rgb(0 0 0 / 0.12);+ /* No chat header above it. */+ --studio-content-top-inset: 0px;+ animation: browser-floating-in 140ms var(--ease-out-cubic);+}++.chat-browser-floating[data-floating-gesture] {+ box-shadow:+ 0 26px 60px -16px rgb(0 0 0 / 0.38),+ 0 6px 16px -6px rgb(0 0 0 / 0.16);+}++@keyframes browser-floating-in {+ from {+ opacity: 0;+ }+}++@media (prefers-reduced-motion: reduce) {+ html:not(.force-motion) .chat-browser-floating {+ animation: none;+ }+}+/* Unlayered, so it beats the panel's utilities. */.chat-artifact-split[data-browser-full-view] > #chat-thread {position: absolute;diff --git a/studio/frontend/tests/artifact-panel-reopen.test.ts b/studio/frontend/tests/artifact-panel-reopen.test.tsindex 54eaef467c4..c6674b1bbbd 100644--- a/studio/frontend/tests/artifact-panel-reopen.test.ts+++ b/studio/frontend/tests/artifact-panel-reopen.test.ts@@ -25,11 +25,11 @@ test("a card opens its page in a browser tab keyed by the artifact, so reopeningassert.match(card, /key: artifact\.id,/);});-test("a panel dragged shut closes the browser, not left at no width", () => {+test("a panel dragged shut closes the browser (or floats it while the model works in it), not left at no width", () => {const page = read("../src/features/chat/chat-page.tsx");const remember = page.indexOf("const rememberArtifactPanelWidth");assert.ok(remember > 0);- const closeAt = page.indexOf("closeBrowser();", remember);+ const closeAt = page.indexOf("closeOrFloatBrowser();", remember);const widthAt = page.indexOf("artifactPanelWidthRef.current = `", remember);assert.ok(closeAt > 0 && closeAt < widthAt, "a shut panel still records a width");});diff --git a/studio/frontend/tests/browser-floating-layout.test.ts b/studio/frontend/tests/browser-floating-layout.test.tsnew file mode 100644index 00000000000..5e4872d9b3c--- /dev/null+++ b/studio/frontend/tests/browser-floating-layout.test.ts@@ -0,0 +1,60 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import { register } from "node:module";+import { test } from "node:test";++register("./helpers/browser-store-resolver.mjs", import.meta.url);+const { useBrowserStore } = await import("../src/features/browser/store.ts");++test("floating, full view and the split are one layout at a time, and floating outlasts a close", () => {+ const store = () => useBrowserStore.getState();+ store().openUrl("https://example.com");+ store().setFullView(true);+ store().setFloating(true);+ assert.deepEqual([store().floating, store().fullView], [true, false]);+ store().setFullView(true);+ assert.deepEqual([store().floating, store().fullView], [false, true]);+ store().setFloating(true);+ store().splitWithChatOn("right");+ assert.deepEqual([store().floating, store().fullView, store().chatSide], [false, false, "right"]);+ store().setFloating(true);+ store().closePanel();+ store().openPanel();+ assert.deepEqual([store().open, store().floating], [true, true]);+});++test("closed while the model still works in it, the browser floats on the model's tab; closing the preview closes it", async () => {+ const { patchAgentChat } = await import("../src/features/browser/agent/agent-store.ts");+ const { closeOrFloatBrowser } = await import("../src/features/browser/close-browser.ts");+ const store = () => useBrowserStore.getState();+ store().setFloating(false);+ store().openUrl("https://example.com/agent", { newTab: true });+ const agentTab = store().activeTabId;+ store().openUrl("https://example.com/mine", { newTab: true });+ patchAgentChat(store().chat, { tabId: agentTab, runKey: "run-1", stoppedRun: null });+ closeOrFloatBrowser();+ assert.deepEqual([store().open, store().floating, store().activeTabId], [true, true, agentTab]);+ closeOrFloatBrowser();+ assert.deepEqual([store().open, store().floating], [false, false]);+ store().openPanel();+ patchAgentChat(store().chat, { stoppedRun: "run-1" });+ closeOrFloatBrowser();+ assert.equal(store().open, false);+});++test("a native page zoomed out before floating stays at the native zoom floor instead of failing", async () => {+ const { NATIVE_MIN_ZOOM, floatingNativeZoom } = await import("../src/features/browser/floating-events.ts");+ assert.equal(floatingNativeZoom(1, 0.5), 0.5);+ assert.equal(floatingNativeZoom(0.25, 0.615), NATIVE_MIN_ZOOM);+ assert.equal(floatingNativeZoom(0.4, 0.5), NATIVE_MIN_ZOOM);+ assert.equal(floatingNativeZoom(0.25, 1), 0.25);+});++test("only a page shown natively skips the floating window's scale; files and new tabs scale even with native browsing on", async () => {+ const { readFileSync } = await import("node:fs");+ const panel = readFileSync(new URL("../src/features/browser/browser-panel.tsx", import.meta.url), "utf8");+ assert.match(panel, /const nativeShown = native && activeEntry\?\.kind === "web" && !activeTab\?\.nativeError;/);+ assert.match(panel, /floating && !nativeShown\s*\?\s*FLOATING_PAGE_STYLE/);+});diff --git a/studio/frontend/tests/browser-floating-preview.test.ts b/studio/frontend/tests/browser-floating-preview.test.tsnew file mode 100644index 00000000000..76559bff53c--- /dev/null+++ b/studio/frontend/tests/browser-floating-preview.test.ts@@ -0,0 +1,177 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import { register } from "node:module";+import { test } from "node:test";++register("./helpers/toast-resolver.mjs", import.meta.url);++type Listener = (event: { clientX: number; clientY: number; buttons: number }) => void;+const windowListeners = new Map<string, Set<Listener>>();+const frames: (() => void)[] = [];+const storage = new Map<string, string>();+const rect = (left: number, top: number, width: number, height: number) =>+ ({ left, top, width, height, right: left + width, bottom: top + height }) as DOMRect;++Object.assign(globalThis, {+ window: globalThis,+ localStorage: {+ getItem: (key: string) => storage.get(key) ?? null,+ setItem: (key: string, value: string) => void storage.set(key, value),+ },+ addEventListener: (type: string, listener: Listener) => {+ if (!windowListeners.has(type)) windowListeners.set(type, new Set());+ windowListeners.get(type)?.add(listener);+ },+ removeEventListener: (type: string, listener: Listener) => windowListeners.get(type)?.delete(listener),+ dispatchEvent: () => true,+ requestAnimationFrame: (callback: () => void) => frames.push(callback),+ cancelAnimationFrame: () => undefined,+ ResizeObserver: class {+ observe() {}+ disconnect() {}+ },+ document: {+ createElement: () => ({ style: {}, setAttribute() {}, remove() {} }),+ body: { appendChild() {} },+ },+});++// The chat: x 300..1300, y 0..900, its header 48 tall.+const header = { getBoundingClientRect: () => rect(300, 0, 1000, 48) };+const root = { querySelector: () => header };+let composer: DOMRect | null = null;+const composerForm = {+ offsetParent: {},+ closest: () => null,+ getBoundingClientRect: () => composer ?? rect(0, 0, 0, 0),+};+const split = {+ getBoundingClientRect: () => rect(300, 0, 1000, 900),+ closest: () => root,+ querySelector: () => composerForm,+ querySelectorAll: () => (composer ? [composerForm] : []),+};+let dockedWidth = 600;+const attributes = new Set<string>(["data-browser-floating"]);+const style: Record<string, string> = {};+const surface = {+ style: Object.assign(style, {+ getPropertyValue: (name: string) => style[name] ?? "",+ setProperty: (name: string, value: string) => void (style[name] = value),+ removeProperty: (name: string) => void delete style[name],+ }),+ closest: (selector: string) => (selector === ".chat-artifact-split" ? split : surface),+ getBoundingClientRect: () => rect(700, 0, dockedWidth, 900),+ hasAttribute: (name: string) => attributes.has(name),+ setAttribute: (name: string) => void attributes.add(name),+ removeAttribute: (name: string) => void attributes.delete(name),+};+const placed = () => ["left", "top", "width", "height"].map((key) => Number.parseFloat(style[key] ?? "NaN"));++const { floatSurface, startFloatingGesture } = await import("../src/features/browser/floating-preview.ts");++function drag(edge: Parameters<typeof startFloatingGesture>[1], from: [number, number], to: [number, number]) {+ const target = { closest: () => null };+ startFloatingGesture(+ {+ button: 0,+ clientX: from[0],+ clientY: from[1],+ target,+ currentTarget: { closest: () => surface },+ preventDefault() {},+ } as never,+ edge,+ );+ for (const listener of windowListeners.get("pointermove") ?? []) listener({ clientX: to[0], clientY: to[1], buttons: 1 });+ while (frames.length) frames.shift()?.();+ for (const listener of [...(windowListeners.get("pointerup") ?? [])]) listener({ clientX: to[0], clientY: to[1], buttons: 0 });+}++test("the preview opens at the chat's top right, below its header, and gives the surface back when it docks", () => {+ style.transform = "none";+ const release = floatSurface(surface as never);+ // 38% of the 976px room is 371; 12px in from the right and below the header.+ assert.deepEqual(placed(), [1300 - 12 - 371, 48 + 12, 371, Math.round(371 * 0.68)]);+ assert.equal(style.position, "fixed");+ assert.equal(style["--browser-floating-scale"], String(Math.round(((371 - 2) / 600) * 1000) / 1000));+ release();+ assert.equal(style["--browser-floating-scale"], undefined);+ assert.equal(style.position, undefined);+ assert.equal(style.transform, "none");+});++test("a press without a drag leaves the preview where it is, so a double-click on its header can dock it", () => {+ const release = floatSurface(surface as never);+ const before = placed();+ drag("move", [before[0] + 20, before[1] + 10], [before[0] + 21, before[1] + 11]);+ assert.deepEqual(placed(), before);+ assert.equal(storage.has("unsloth_browser_floating_preview"), false);+ release();+});++test("a drag that outlives the preview leaves the docked panel alone", () => {+ const release = floatSurface(surface as never);+ const target = { closest: () => null };+ startFloatingGesture(+ { button: 0, clientX: 900, clientY: 70, target, currentTarget: { closest: () => surface }, preventDefault() {} } as never,+ "move",+ );+ for (const listener of windowListeners.get("pointermove") ?? []) listener({ clientX: 500, clientY: 300, buttons: 1 });+ release();+ attributes.delete("data-browser-floating");+ for (const listener of [...(windowListeners.get("pointerup") ?? [])]) listener({ clientX: 500, clientY: 300, buttons: 0 });+ while (frames.length) frames.shift()?.();+ assert.equal(style.position, undefined);+ assert.equal(storage.has("unsloth_browser_floating_preview"), false);+ attributes.add("data-browser-floating");+});++test("a move stays in the chat, and one dropped at the right edge stays anchored there", () => {+ const release = floatSurface(surface as never);+ drag("move", [1000, 70], [-500, 2000]);+ const [left, top, width, height] = placed();+ assert.equal(left, 312);+ assert.equal(top + height, 900 - 12);+ assert.equal(width, 371);+ drag("move", [400, 700], [2400, 700]);+ assert.equal(JSON.parse(storage.get("unsloth_browser_floating_preview") ?? "{}").left, null);+ assert.equal(placed()[0] + placed()[2], 1300 - 12);+ release();+});++test("a resize from a corner keeps the opposite corner put and never goes under the minimum", () => {+ const release = floatSurface(surface as never);+ const [left, top, width, height] = placed();+ drag("nw", [left, top], [left - 200, top - 100]);+ const grown = placed();+ assert.equal(grown[0] + grown[2], left + width);+ assert.equal(grown[1] + grown[3], top + height);+ assert.equal(grown[2], width + 200);+ drag("nw", [grown[0], grown[1]], [grown[0] + 5000, grown[1] + 5000]);+ const shrunk = placed();+ assert.deepEqual([shrunk[2], shrunk[3]], [260, 180]);+ assert.equal(shrunk[0] + shrunk[2], left + width);+ release();+});++test("the preview steps over the composer rather than covering it, and a resize stops at it", () => {+ composer = rect(500, 760, 600, 120);+ dockedWidth = 0;+ const release = floatSurface(surface as never);+ const [left, , width, height] = placed();+ drag("move", [left + 10, placed()[1] + 10], [800, 780]);+ assert.equal(placed()[1] + height, 760 - 12);+ assert.equal(placed()[2], width);+ const above = placed();+ drag("s", [above[0] + 10, above[1] + above[3]], [above[0] + 10, above[1] + above[3] + 200]);+ assert.deepEqual(placed(), above);+ drag("sw", [above[0], above[1] + above[3]], [above[0] - 100, above[1] + above[3] + 200]);+ const grown = placed();+ assert.equal(grown[0], above[0] - 100);+ assert.equal(grown[1] + grown[3], 760 - 12);+ release();+ composer = null;+});