Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): make float/dock a header icon and keep widget actions when floating
Lincoln Stein60e90720465b
diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsxnew file mode 100644index 0000000000..71e21b8caa--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsx@@ -0,0 +1,172 @@+/* oxlint-disable react-perf/jsx-no-new-object-as-prop */+import type { FloatingWidgetState } from '@workbench/layoutContracts';+import type { RegisteredWidget, WidgetImplementation, WidgetManifest } from '@workbench/widgetContracts';++import { ChakraProvider } from '@chakra-ui/react';+import { system } from '@theme/system';+import i18next from 'i18next';+import { MapIcon, TagsIcon } from 'lucide-react';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { I18nextProvider, initReactI18next } from 'react-i18next';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++/**+ * A floated widget renders bare inside this window, so its header controls+ * only exist here — the map's label and selection toggles used to disappear on+ * float. The window mounts the widget's own actions and nothing else: the+ * frame-level chrome (settings, the overflow menu, the float control) is+ * replaced by this bar's shade/maximize/dock buttons.+ */++const windowMocks = vi.hoisted(() => ({+ dockFloating: vi.fn(),+ focusFloating: vi.fn(),+ setFloatingGeometry: vi.fn(),+ setFloatingMode: vi.fn(),+}));++vi.mock('@workbench/WorkbenchContext', () => ({+ useActiveProjectSelector: (selector: (project: unknown) => unknown) =>+ selector({+ id: 'project-1',+ widgetInstances: {+ 'image-map-instance': {+ createdAt: 0,+ id: 'image-map-instance',+ state: { values: {} },+ typeId: 'image-map',+ },+ },+ widgetRegions: { center: { activeInstanceId: null, instanceIds: [] } },+ }),+ useWorkbenchCommands: () => ({ widgets: windowMocks }),+}));++vi.mock('@workbench/WorkbenchWidgetRegistryContext', () => ({+ useWorkbenchWidgetRegistry: () => ({+ getWidgetById: () => registeredWidget,+ getWidgetsForRegion: () => [],+ }),+}));++// The runtime needs the workbench store; the window's chrome is what is under+// test, and neither the stub view nor the stub actions touch the runtime.+vi.mock('./createWidgetRuntime', () => ({ useWidgetRuntime: () => ({}) }));++import { FloatingWidgetWindow } from './FloatingWidgetWindow';++const manifest = {+ allowFloating: true,+ allowedRegions: ['center', 'left', 'right'],+ failurePolicy: { isolateRenderFailure: false, onRegistrationFailure: 'disable' },+ icon: MapIcon,+ id: 'image-map',+ label: () => 'Image Map',+ version: 1,+} as unknown as WidgetManifest;++const implementation: WidgetImplementation = {+ headerActions: () => (+ <button aria-label="Toggle cluster labels" type="button">+ <TagsIcon />+ </button>+ ),+ view: () => <div data-testid="map-body" />,+};++const implementationPromise = Promise.resolve(implementation);+const registeredWidget = {+ implementation: { load: () => implementationPromise, retry: () => {} },+ manifest,+ status: 'enabled',+} as unknown as RegisteredWidget;++const state: FloatingWidgetState = {+ heightPx: 400,+ mode: 'windowed',+ returnRegion: 'right',+ stackOrder: 1,+ widthPx: 500,+ x: 40,+ y: 40,+};++const i18n = i18next.createInstance();+await i18n.use(initReactI18next).init({+ fallbackLng: 'en',+ lng: 'en',+ resources: {+ en: {+ translation: {+ widgets: {+ floating: { dock: 'Dock to panel', maximize: 'Maximize', move: 'Move {{label}} window', shade: 'Shade' },+ labels: { imageMap: 'Image Map' },+ },+ },+ },+ },+});++let host: HTMLDivElement | null = null;+let root: Root | null = null;+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const renderWindow = async (floatingState: FloatingWidgetState = state) => {+ await act(async () => {+ root?.render(+ <I18nextProvider i18n={i18n}>+ <ChakraProvider value={system}>+ <FloatingWidgetWindow instanceId="image-map-instance" stackRank={0} state={floatingState} />+ </ChakraProvider>+ </I18nextProvider>+ );+ await implementationPromise;+ });+ // The chrome slot suspends on the implementation chunk; one more flush lets+ // the resolved actions paint before the assertions run.+ await act(async () => {+ await Promise.resolve();+ });+};++beforeEach(() => {+ windowMocks.dockFloating.mockClear();+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);+});++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('FloatingWidgetWindow chrome', () => {+ it("mounts the widget's own header actions in the title bar", async () => {+ await renderWindow();++ expect(host?.querySelector('button[aria-label="Toggle cluster labels"]')).not.toBeNull();+ expect(host?.querySelector('[data-testid="map-body"]')).not.toBeNull();+ });++ it('keeps the widget actions reachable while the window is shaded', async () => {+ await renderWindow({ ...state, mode: 'shaded' });++ expect(host?.querySelector('button[aria-label="Toggle cluster labels"]')).not.toBeNull();+ expect(host?.querySelector('[data-testid="map-body"]')).toBeNull();+ });++ it('still docks from the title bar with the widget actions alongside', async () => {+ await renderWindow();++ await act(async () => {+ host?.querySelector<HTMLButtonElement>('button[aria-label="Dock to panel"]')?.click();+ await Promise.resolve();+ });++ expect(windowMocks.dockFloating).toHaveBeenCalledWith('image-map-instance');+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsxindex 170af42153..b566ded519 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.tsx@@ -23,6 +23,7 @@ import {TriangleAlertIcon,} from 'lucide-react';import {+ Suspense,useCallback,useEffect,useRef,@@ -33,7 +34,7 @@ import {} from 'react';import { useTranslation } from 'react-i18next';-import { WidgetRendererById } from './WidgetRenderer';+import { WidgetChromeSlotById, WidgetRendererById } from './WidgetRenderer';import { areWidgetRenderInstancesEqual } from './widgetRenderInstance';/** Below Chakra dialogs/popovers/toasts; above the docked shell. */@@ -315,6 +316,14 @@ export const FloatingWidgetWindow = ({</Text></HStack><HStack flexShrink={0} gap="1">+ {/* The widget's own header toggles: floated content renders bare, so+ without this the docked header's controls would simply vanish on+ float. Frame-level actions stay out — this bar carries its own. */}+ {isEnabled && widget ? (+ <Suspense fallback={null}>+ <WidgetChromeSlotById instanceId={instanceId} region="floating" slot="viewActions" widget={widget} />+ </Suspense>+ ) : null}<Tooltip content={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}><IconButtonaria-label={isShaded ? t('widgets.floating.unshade') : t('widgets.floating.shade')}diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsxindex f200df8519..a95f460931 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetActionsMenu.tsx@@ -12,11 +12,8 @@ import { flushWorkbenchDrafts } from '@platform/react/draftRegistry';import { IconButton } from '@platform/ui';import { createGraphBearingSurface } from '@workbench/graphSurfaces';import { resolveWidgetLabel } from '@workbench/widgetLabels';-import { getEnabledCenterViewCount } from '@workbench/widgetPlacementCommands';-import { areWidgetPlacementProjectsEqual, getWidgetPlacementProject } from '@workbench/widgetPlacementMeta';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { useWorkbenchWidgetRegistry } from '@workbench/WorkbenchWidgetRegistryContext';-import { GitBranchIcon, MoreHorizontalIcon, PictureInPicture2Icon, TargetIcon } from 'lucide-react';+import { GitBranchIcon, MoreHorizontalIcon, TargetIcon } from 'lucide-react';import { lazy, Suspense, useCallback, useMemo, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -25,6 +22,10 @@ import { useTranslation } from 'react-i18next';* graph-bearing actions (`Set Source`, `View Graph`) and any extra entries the* widget's manifest contributes via `headerMenu` — one menu per widget, so* widgets extend the frame instead of stacking their own menus and toolbars.+ *+ * Floating is not among them: it is a mode toggle, so it renders as its own+ * header icon ({@link WidgetFloatButton}) opposite the floating window's dock+ * control rather than as a menu item.*/const GraphPreviewHost = lazy(() => import('./GraphPreviewHost'));@@ -86,9 +87,6 @@ export const WidgetActionsMenu = ({runtime: WidgetRuntimeApi;}) => {const { t } = useTranslation();- const placementProject = useActiveProjectSelector(getWidgetPlacementProject, areWidgetPlacementProjectsEqual);- const { getWidgetById } = useWorkbenchWidgetRegistry();- const { widgets } = useWorkbenchCommands();const [isPreviewOpen, setIsPreviewOpen] = useState(false);// Mount outlives `isPreviewOpen`: dropping the host the moment the dialog// closes cancels its exit transition, so the preview blinked out of@@ -100,20 +98,6 @@ export const WidgetActionsMenu = ({manifest.graphBearing?.surfaces.includes(region) ? createGraphBearingSurface(manifest, region, label) : null,[label, manifest, region]);- // Floating is offered only from dockable regions; the floating window's own- // chrome carries the dock control. The last center *view* is not offered it- // either — floating it out would leave the work surface with nothing to- // show, which is why `closeWidgetPlacement` refuses the same removal.- const canFloat =- Boolean(manifest.allowFloating) &&- region !== 'floating' &&- !(region === 'center' && getEnabledCenterViewCount(placementProject, getWidgetById) === 1);- // Floating unmounts the docked subtree; the draft registry's cleanup only- // deregisters the flusher, so an uncommitted edit is lost without this.- const handleFloat = useCallback(() => {- flushWorkbenchDrafts();- widgets.float(instance.id);- }, [instance.id, widgets]);const handlePreview = useCallback(() => {flushWorkbenchDrafts();setIsPreviewMounted(true);@@ -127,7 +111,7 @@ export const WidgetActionsMenu = ({}}, [isPreviewOpen]);- if (!surface && !HeaderMenu && !canFloat) {+ if (!surface && !HeaderMenu) {return null;}@@ -143,14 +127,7 @@ export const WidgetActionsMenu = ({<Menu.Positioner><Menu.Content minW="13rem">{surface ? <GraphSurfaceMenuItems surface={surface} onPreview={handlePreview} /> : null}- {surface && (HeaderMenu || canFloat) ? <Menu.Separator borderColor="border.subtle" /> : null}- {canFloat ? (- <Menu.Item value="float-window" onClick={handleFloat}>- <Icon as={PictureInPicture2Icon} boxSize="3.5" />- <Menu.ItemText>{t('widgets.floating.floatWindow')}</Menu.ItemText>- </Menu.Item>- ) : null}- {canFloat && HeaderMenu ? <Menu.Separator borderColor="border.subtle" /> : null}+ {surface && HeaderMenu ? <Menu.Separator borderColor="border.subtle" /> : null}{HeaderMenu ? (<HeaderMenu instance={instance} manifest={manifest} region={region} runtime={runtime} />) : null}diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFloatButton.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFloatButton.browser.test.tsxnew file mode 100644index 0000000000..39aa57a759--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFloatButton.browser.test.tsx@@ -0,0 +1,145 @@+/* oxlint-disable react-perf/jsx-no-new-object-as-prop */+import type { RegisteredWidget, WidgetManifest, WidgetTypeId, WorkbenchRegion } from '@workbench/widgetContracts';++import { ChakraProvider } from '@chakra-ui/react';+import { system } from '@theme/system';+import i18next from 'i18next';+import { MapIcon } from 'lucide-react';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { I18nextProvider, initReactI18next } from 'react-i18next';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++/**+ * The float control replaced a menu item, so the conditions that used to hide+ * that item now decide whether a button renders at all: a widget that may not+ * float, and the last center view — floating it out would leave the work+ * surface empty. Docking is covered by the floating window's own chrome.+ */++const floatMocks = vi.hoisted(() => ({+ centerInstanceIds: ['image-map-instance'] as string[],+ float: vi.fn(),+ flushWorkbenchDrafts: vi.fn(),+}));++vi.mock('@platform/react/draftRegistry', () => ({+ flushWorkbenchDrafts: floatMocks.flushWorkbenchDrafts,+}));++vi.mock('@workbench/WorkbenchContext', () => ({+ useActiveProjectSelector: (selector: (project: unknown) => unknown) =>+ selector({+ id: 'project-1',+ widgetInstances: Object.fromEntries(+ floatMocks.centerInstanceIds.map((instanceId) => [+ instanceId,+ { createdAt: 0, id: instanceId, state: { values: {} }, typeId: 'image-map' },+ ])+ ),+ widgetRegions: {+ center: { activeInstanceId: floatMocks.centerInstanceIds[0], instanceIds: floatMocks.centerInstanceIds },+ },+ }),+ useWorkbenchCommands: () => ({ widgets: { float: floatMocks.float } }),+}));++vi.mock('@workbench/WorkbenchWidgetRegistryContext', () => ({+ useWorkbenchWidgetRegistry: () => ({+ getWidgetById: (typeId: WidgetTypeId) =>+ ({ manifest: { id: typeId }, status: 'enabled' }) as unknown as RegisteredWidget,+ }),+}));++import { WidgetFloatButton } from './WidgetFrames';++const i18n = i18next.createInstance();+await i18n.use(initReactI18next).init({+ fallbackLng: 'en',+ lng: 'en',+ resources: { en: { translation: { widgets: { floating: { floatWindow: 'Float Window' } } } } },+});++const manifest = (allowFloating: boolean): WidgetManifest =>+ ({+ allowFloating,+ allowedRegions: ['center', 'left', 'right'],+ failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },+ icon: MapIcon,+ id: 'image-map',+ label: () => 'Image Map',+ load: () => Promise.resolve({ view: () => null }),+ version: 1,+ }) as unknown as WidgetManifest;++let host: HTMLDivElement | null = null;+let root: Root | null = null;+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++const renderButton = async (region: WorkbenchRegion, allowFloating = true) => {+ await act(async () => {+ root?.render(+ <I18nextProvider i18n={i18n}>+ <ChakraProvider value={system}>+ <WidgetFloatButton instanceId="image-map-instance" manifest={manifest(allowFloating)} region={region} />+ </ChakraProvider>+ </I18nextProvider>+ );+ await Promise.resolve();+ });++ return host?.querySelector<HTMLButtonElement>('button[aria-label="Float Window"]') ?? null;+};++beforeEach(() => {+ floatMocks.centerInstanceIds = ['image-map-instance'];+ floatMocks.float.mockClear();+ floatMocks.flushWorkbenchDrafts.mockClear();+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);+});++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ host = null;+ root = null;+});++describe('WidgetFloatButton', () => {+ it('floats the instance from a docked panel, flushing drafts first', async () => {+ const button = await renderButton('right');++ expect(button).not.toBeNull();++ await act(async () => {+ button?.click();+ await Promise.resolve();+ });++ expect(floatMocks.flushWorkbenchDrafts).toHaveBeenCalled();+ expect(floatMocks.float).toHaveBeenCalledWith('image-map-instance');+ expect(floatMocks.flushWorkbenchDrafts.mock.invocationCallOrder[0]).toBeLessThan(+ floatMocks.float.mock.invocationCallOrder[0]+ );+ });++ it('renders nothing for a widget its manifest does not allow to float', async () => {+ expect(await renderButton('right', false)).toBeNull();+ });++ it('renders nothing for the last enabled center view', async () => {+ expect(await renderButton('center')).toBeNull();+ });++ it('renders for a center view that is not the last one', async () => {+ floatMocks.centerInstanceIds = ['image-map-instance', 'canvas-instance'];++ expect(await renderButton('center')).not.toBeNull();+ });++ it('renders nothing inside a floating window, which carries the dock control', async () => {+ expect(await renderButton('floating')).toBeNull();+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsxindex e061377d06..d227060242 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx@@ -11,14 +11,18 @@ import type {} from '@workbench/widgetContracts';import { Box, Flex, HStack, Icon, Stack, Text } from '@chakra-ui/react';+import { flushWorkbenchDrafts } from '@platform/react/draftRegistry';import { useMountEffect } from '@platform/react/useMountEffect';import { IconButton, Tooltip } from '@platform/ui';import { useFocusRegionProps } from '@workbench/focusRegions';import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';import { resolveWidgetInstanceLabel } from '@workbench/widgetLabels';+import { getEnabledCenterViewCount } from '@workbench/widgetPlacementCommands';+import { areWidgetPlacementProjectsEqual, getWidgetPlacementProject } from '@workbench/widgetPlacementMeta';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';import { clampPanelSize, getPanelSizeBounds, shouldSnapPanelShut } from '@workbench/workbenchState';-import { SettingsIcon } from 'lucide-react';+import { useWorkbenchWidgetRegistry } from '@workbench/WorkbenchWidgetRegistryContext';+import { PictureInPicture2Icon, SettingsIcon } from 'lucide-react';import {useCallback,useMemo,@@ -249,11 +253,66 @@ export const WidgetPanelFrame = ({);};+/**+ * The docked half of the float/dock pair: one icon in the widget's header+ * actions that detaches it into a floating window. Its opposite — the dock+ * control — sits in the same corner of `FloatingWidgetWindow`'s title bar, so+ * the mode is one click away either way instead of a menu item in one mode and+ * a button in the other.+ */+export const WidgetFloatButton = ({+ instanceId,+ manifest,+ region,+}: {+ instanceId: WidgetInstanceId;+ manifest: WidgetManifest;+ region: WorkbenchRegion;+}) => {+ const { t } = useTranslation();+ const placementProject = useActiveProjectSelector(getWidgetPlacementProject, areWidgetPlacementProjectsEqual);+ const { getWidgetById } = useWorkbenchWidgetRegistry();+ const { widgets } = useWorkbenchCommands();+ // Floating unmounts the docked subtree; the draft registry's cleanup only+ // deregisters the flusher, so an uncommitted edit is lost without this.+ const handleFloat = useCallback(() => {+ flushWorkbenchDrafts();+ widgets.float(instanceId);+ }, [instanceId, widgets]);+ // Floating is offered only from dockable regions; the floating window's own+ // chrome carries the dock control. The last center *view* is not offered it+ // either — floating it out would leave the work surface with nothing to+ // show, which is why `closeWidgetPlacement` refuses the same removal.+ const canFloat =+ Boolean(manifest.allowFloating) &&+ region !== 'floating' &&+ !(region === 'center' && getEnabledCenterViewCount(placementProject, getWidgetById) === 1);++ if (!canFloat) {+ return null;+ }++ return (+ <Tooltip content={t('widgets.floating.floatWindow')}>+ <IconButton+ aria-label={t('widgets.floating.floatWindow')}+ color="fg.muted"+ size="2xs"+ variant="ghost"+ onClick={handleFloat}+ >+ <Icon as={PictureInPicture2Icon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ );+};+/*** The trailing action cluster of a widget's chrome: the manifest's own- * `headerActions`, the settings gear, and the shared overflow menu. Panels- * render it inside {@link WidgetHeader}; the center region renders it on its- * own, floating over the work surface, so it lives apart from the header row.+ * `headerActions`, the settings gear, the float control, and the shared+ * overflow menu. Panels render it inside {@link WidgetHeader}; the center+ * region renders it on its own, floating over the work surface, so it lives+ * apart from the header row.*/export const WidgetHeaderActionsGroup = ({actions,@@ -293,6 +352,7 @@ export const WidgetHeaderActionsGroup = ({</IconButton></Tooltip>) : null}+ <WidgetFloatButton instanceId={instance.id} manifest={manifest} region={region} /><WidgetActionsMenuHeaderMenu={HeaderMenu}instance={instance}diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsxindex 5285fdd112..ada7f19078 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx@@ -5,6 +5,7 @@ import type {WidgetInstanceRuntimeMeta,WidgetRuntimeApi,WidgetViewProps,+ WorkbenchRegion,} from '@workbench/widgetContracts';import { Box, Flex, Text } from '@chakra-ui/react';@@ -32,11 +33,18 @@ interface WidgetRendererByIdProps extends Omit<WidgetViewProps, 'instance' | 'mawidget: RegisteredWidget;}-/** The chrome slots the center region hoists out of the widget frame. */-type WidgetChromeSlotName = 'actions' | 'label';+/**+ * The chrome slots a region can hoist out of the widget frame. `actions` is the+ * full trailing cluster (widget actions, settings, float, overflow menu);+ * `viewActions` is the widget's own `headerActions` alone, for chrome that+ * already carries its own frame controls.+ */+type WidgetChromeSlotName = 'actions' | 'label' | 'viewActions';interface WidgetChromeSlotByIdProps {instanceId: string;+ /** The region the hoisted chrome acts for. Defaults to the center region. */+ region?: WorkbenchRegion;slot: WidgetChromeSlotName;widget: RegisteredWidget;}@@ -52,28 +60,33 @@ export const WidgetRendererById = ({ instanceId, widget, ...props }: WidgetRende/*** Renders one chrome slot of a widget outside its own frame. The center region- * floats its chrome over the work surface, so the label and action slots are- * mounted by `CenterArea` rather than by the widget's frame — this resolves the+ * floats its chrome over the work surface and a floating window owns its title+ * bar, so their label and action slots are mounted by `CenterArea` and+ * `FloatingWidgetWindow` rather than by the widget's frame — this resolves the* same implementation and runtime the view would get.** Suspends on first load of the implementation chunk; callers wrap it in their* own `Suspense` so the rest of the chrome paints immediately.*/-export const WidgetChromeSlotById = ({ instanceId, slot, widget }: WidgetChromeSlotByIdProps) => {+export const WidgetChromeSlotById = ({ instanceId, region = 'center', slot, widget }: WidgetChromeSlotByIdProps) => {const selection = useActiveProjectSelector((project) => ({ instance: project.widgetInstances[instanceId], projectId: project.id }),areProjectWidgetRenderInstancesEqual);- return selection.instance ? <WidgetChromeSlot instance={selection.instance} slot={slot} widget={widget} /> : null;+ return selection.instance ? (+ <WidgetChromeSlot instance={selection.instance} region={region} slot={slot} widget={widget} />+ ) : null;};const WidgetChromeSlot = ({instance,+ region,slot,widget,}: {instance: WidgetInstanceContract;+ region: WorkbenchRegion;slot: WidgetChromeSlotName;widget: RegisteredWidget;}) => {@@ -94,16 +107,16 @@ const WidgetChromeSlot = ({getWidgetsForRegion,instance: instanceMeta,project,- region: 'center',+ region,});const HeaderActions = implementation.headerActions;const HeaderLabel = implementation.headerLabel;const actions = useMemo(() =>HeaderActions ? (- <HeaderActions instance={instanceMeta} manifest={widget.manifest} region="center" runtime={runtime} />+ <HeaderActions instance={instanceMeta} manifest={widget.manifest} region={region} runtime={runtime} />) : null,- [HeaderActions, instanceMeta, runtime, widget.manifest]+ [HeaderActions, instanceMeta, region, runtime, widget.manifest]);if (widget.manifest.chrome?.header === 'hidden') {@@ -113,7 +126,14 @@ const WidgetChromeSlot = ({// A widget-supplied label only replaces the standard title, which the center// view selector already shows — a renamed instance keeps the selector's text.if (slot === 'label') {- return HeaderLabel && !instanceMeta.title ? <HeaderLabel region="center" /> : null;+ return HeaderLabel && !instanceMeta.title ? <HeaderLabel region={region} /> : null;+ }++ // The window chrome around a floating widget already carries the frame's own+ // controls (shade, maximize, dock), so it takes the widget's actions alone —+ // a floated widget keeps the toggles its docked header shows.+ if (slot === 'viewActions') {+ return actions;}return (@@ -122,7 +142,7 @@ const WidgetChromeSlot = ({actions={actions}instance={instanceMeta}manifest={widget.manifest}- region="center"+ region={region}runtime={runtime}/>);