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
refactor(workbench): fold the right-rail docks into Layers editor panes
Josh Corbett30de9290eb36
diff --git a/invokeai/frontend/webv2/performance/architecture-baseline.json b/invokeai/frontend/webv2/performance/architecture-baseline.jsonindex 286da05cd0..0db5f5e687 100644--- a/invokeai/frontend/webv2/performance/architecture-baseline.json+++ b/invokeai/frontend/webv2/performance/architecture-baseline.json@@ -2,10 +2,10 @@"build": {"launchpad": {"baseline": {- "brotliBytes": 839840,+ "brotliBytes": 839827,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 838513,+ "gzipBytes": 838510,"imageRawBytes": 156376,"initialRawBytes": 1954215,"largestAssetRawBytes": 746355,@@ -290,10 +290,10 @@]},"limits": {- "brotliBytes": 848239,+ "brotliBytes": 848226,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 846899,+ "gzipBytes": 846896,"imageRawBytes": 157940,"initialRawBytes": 1973758,"largestAssetRawBytes": 753819,@@ -308,15 +308,15 @@},"editor": {"baseline": {- "brotliBytes": 1102507,+ "brotliBytes": 1098011,"cssRawBytes": 2159,"fontRawBytes": 219480,- "gzipBytes": 1098109,+ "gzipBytes": 1093193,"imageRawBytes": 156376,- "initialRawBytes": 2752961,+ "initialRawBytes": 2738573,"largestAssetRawBytes": 746355,"otherAssetRawBytes": 0,- "ownedRawBytes": 124705,+ "ownedRawBytes": 114600,"requestCount": 97,"scriptRequestCount": 81,"sourceOwners": [@@ -843,7 +843,6 @@"source:src/workbench/shell/CenterArea.tsx","source:src/workbench/shell/DocumentTitleProgress.tsx","source:src/workbench/shell/Panels.tsx",- "source:src/workbench/shell/RightRail.tsx","source:src/workbench/shell/StatusBar.tsx","source:src/workbench/shell/WorkbenchShell.tsx","source:src/workbench/shell/documentTitle.ts",@@ -916,14 +915,13 @@"source:src/workbench/widgets/generate/manifest.ts","source:src/workbench/widgets/image-map/manifest.ts","source:src/workbench/widgets/layers/manifest.ts",+ "source:src/workbench/widgets/layers/panes/editorPaneLayout.ts","source:src/workbench/widgets/notifications/manifest.ts","source:src/workbench/widgets/preview/manifest.ts","source:src/workbench/widgets/project/manifest.ts",- "source:src/workbench/widgets/properties/manifest.ts","source:src/workbench/widgets/queue-status/manifest.ts","source:src/workbench/widgets/queue/manifest.ts","source:src/workbench/widgets/server-status/manifest.ts",- "source:src/workbench/widgets/transform/manifest.ts","source:src/workbench/widgets/upscale/manifest.ts","source:src/workbench/widgets/version-status/manifest.ts","source:src/workbench/widgets/video/manifest.ts",@@ -933,15 +931,15 @@]},"limits": {- "brotliBytes": 1113533,+ "brotliBytes": 1108992,"cssRawBytes": 2181,"fontRawBytes": 221675,- "gzipBytes": 1109091,+ "gzipBytes": 1104125,"imageRawBytes": 157940,- "initialRawBytes": 2780491,+ "initialRawBytes": 2765959,"largestAssetRawBytes": 753819,"otherAssetRawBytes": 0,- "ownedRawBytes": 124705,+ "ownedRawBytes": 114600,"requestCount": 97,"scriptRequestCount": 81},@@ -950,7 +948,7 @@"source": "src/app/WorkbenchApp.tsx"}},- "capturedAt": "2026-08-29",+ "capturedAt": "2026-08-31","developmentInvalidation": {"platformUiBarrel": {"specifier": "@platform/ui",diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 6fcc3ba935..f7b52595f8 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1516,17 +1516,6 @@"session": "Transform in progress","title": "Transform"},- "dock": {- "collapse": "Collapse {{dock}}",- "expand": "Expand {{dock}}",- "resize": "Resize {{dock}}",- "tabs": "{{dock}} widgets",- "names": {- "rightTop": "top dock",- "right": "middle dock",- "rightBottom": "bottom dock"- }- },"labels": {"autosaveStatus": "Autosave","canvas": "Canvas",@@ -2987,7 +2976,13 @@"large": "Large"}},- "dropRefused": "Can't drop here: {{reason}}"+ "dropRefused": "Can't drop here: {{reason}}",+ "panes": {+ "collapse": "Collapse editor panes",+ "expand": "Expand editor panes",+ "resize": "Resize editor panes",+ "tabs": "Layer editor panes"+ }},"gallery": {"alwaysShowDimensions": "Always show dimensions",diff --git a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjsindex b4d7159992..1e51913109 100644--- a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs+++ b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs@@ -179,7 +179,7 @@ const surfaces = [ready: async (page) => {await waitForWorkbench(page);await selectLayoutPreset(page, 'Edit', 'Canvas');- // The bottom dock's Properties tab is the canvas's settings surface; the journey must scan it, not a fallback.+ // The Layers panel's Properties pane is the canvas's settings surface; the journey must scan it, not a fallback.await page.getByRole('tab', { exact: true, name: 'Properties', selected: true }).waitFor();await page.getByRole('tabpanel').getByText('Tool', { exact: true }).waitFor();},diff --git a/invokeai/frontend/webv2/scripts/widget-sources.mjs b/invokeai/frontend/webv2/scripts/widget-sources.mjsindex 725c2069b7..50b451242a 100644--- a/invokeai/frontend/webv2/scripts/widget-sources.mjs+++ b/invokeai/frontend/webv2/scripts/widget-sources.mjs@@ -16,8 +16,6 @@ export const WIDGET_SOURCES = new Map([['src/workbench/widgets/notifications/implementation.ts', 'notifications'],['src/workbench/widgets/preview/implementation.ts', 'preview'],['src/workbench/widgets/project/implementation.ts', 'project'],- ['src/workbench/widgets/properties/implementation.ts', 'properties'],- ['src/workbench/widgets/transform/implementation.ts', 'transform'],['src/workbench/widgets/queue-status/implementation.ts', 'queue-status'],['src/workbench/widgets/server-status/implementation.ts', 'server-status'],['src/workbench/widgets/version-status/implementation.ts', 'version-status'],diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsxindex c94a138a77..deb754ede8 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx+++ b/invokeai/frontend/webv2/src/features/gallery/ui/GalleryUiContext.tsx@@ -76,7 +76,7 @@ export interface GalleryWidgetRuntime {export interface GalleryWidgetProps {presentation?: 'compact' | 'expanded' | 'tooltip';- region: 'bottom' | 'center' | 'dialog' | 'floating' | 'left' | 'popover' | 'right' | 'rightTop' | 'rightBottom';+ region: 'bottom' | 'center' | 'dialog' | 'floating' | 'left' | 'popover' | 'right';runtime: GalleryWidgetRuntime;}diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDensity.ts b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDensity.tsindex f87db9846e..cfff72cf38 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/galleryDensity.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/galleryDensity.ts@@ -9,9 +9,7 @@ type GalleryRegion = GalleryWidgetProps['region'];* components read it: every slot renders one way, so a size-dependent* difference must be expressible as "which shell puts this where".*/-/** A side rail: the left panel or any dock of the right rail. */-const isRailRegion = (region: string): boolean =>- region === 'left' || region === 'right' || region === 'rightTop' || region === 'rightBottom';+const isRailRegion = (region: string): boolean => region === 'left' || region === 'right';export type GalleryLayoutMode = 'stacked' | 'wide';diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsxindex 968759b022..97ed294033 100644--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueWidgetView.tsx@@ -25,7 +25,7 @@ export const QueueWidgetView = ({region,}: {presentation?: 'compact' | 'expanded' | 'tooltip';- region: 'bottom' | 'center' | 'dialog' | 'floating' | 'left' | 'popover' | 'right' | 'rightTop' | 'rightBottom';+ region: 'bottom' | 'center' | 'dialog' | 'floating' | 'left' | 'popover' | 'right';}) => {const { t } = useTranslation();const counts = useQueueCounts();diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts b/invokeai/frontend/webv2/src/features/workflow/ui/contracts.tsindex 40655bccb7..17545d7886 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts+++ b/invokeai/frontend/webv2/src/features/workflow/ui/contracts.ts@@ -1,16 +1,7 @@import type { ProjectGraphAction } from '@features/workflow/core/document';import type { ProjectGraphState, XYPosition } from '@features/workflow/core/types';-export type WorkflowRegion =- | 'left'- | 'right'- | 'rightTop'- | 'rightBottom'- | 'bottom'- | 'center'- | 'dialog'- | 'popover'- | 'floating';+export type WorkflowRegion = 'left' | 'right' | 'bottom' | 'center' | 'dialog' | 'popover' | 'floating';/*** Panel regions workflow surfaces may open/select widgets in. Structural@@ -18,7 +9,7 @@ export type WorkflowRegion =* the feature may not import workbench, so drift is caught as a tsc error at* the check site: the `widgets` wiring in `app/WorkflowUiAdapter.tsx`.*/-export type WorkflowWidgetPanelRegion = 'left' | 'right' | 'rightTop' | 'rightBottom' | 'bottom' | 'center';+export type WorkflowWidgetPanelRegion = 'left' | 'right' | 'bottom' | 'center';/*** Invocation sources the graph preview can route. Structural mirror ofdiff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md b/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.mdindex ca66f53ada..d531cd0fe6 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/ARCHITECTURE.md@@ -41,7 +41,7 @@ The document mirror diffs forests by leaf identity and ancestor-effective state:### Properties and Transform-Tool and operation settings live off the surface, in the right rail's bottom dock. `widgets/properties` renders the running operation first (its inputs, secondary controls and status with Apply / Cancel) and then the active tool's settings as labelled rows; `widgets/transform` edits the selected layer's transform without a tool — each field commits one undoable `patch`, and while the Transform tool holds a session the same fields drive its preview and Apply / Cancel land or drop it. Both read the engine's option stores and document transactions through one `ToolPresentationAdapter` per tool and one `OperationPresentationAdapter` per operation (`widgets/canvas/tool-presentation`): a component per settings region, no state mirror. Staging and generation lock the tool rows in place (`inert`) while an operation keeps its own controls live and Cancel always reachable. The right rail itself is three docks (`rightTop`, `right`, `rightBottom`), each an ordinary widget region with a tab strip; `shell/RightRail.tsx` owns the docks and `RightRail.browser.test.tsx` pins their layout, keyboard and resize behaviour.+Tool and operation settings live off the surface, as editor panes of the Layers panel (`widgets/layers/panes`). The Properties pane renders the running operation first (its inputs, secondary controls and status with Apply / Cancel) and then the active tool's settings as labelled rows; the Transform pane edits the selected layer's transform without a tool — each field commits one undoable `patch`, and while the Transform tool holds a session the same fields drive its preview and Apply / Cancel land or drop it. Both read the engine's option stores and document transactions through one `ToolPresentationAdapter` per tool and one `OperationPresentationAdapter` per operation (`widgets/canvas/tool-presentation`): a component per settings region, no state mirror. Staging and generation lock the tool rows in place (`inert`) while an operation keeps its own controls live and Cancel always reachable. The panes are fixed parts of the panel — `LayerEditorPanes` owns their tabs, preferred height and collapse, persisted through the Layers widget's project state — not movable widgets.## Package and capability boundariesdiff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/extensionHotkeys.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/extensionHotkeys.tsindex 5882aecadf..76983df6fa 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/extensionHotkeys.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/extensionHotkeys.ts@@ -6,7 +6,7 @@ import { useMemo, useSyncExternalStore } from 'react';import type { HotkeyDefinition } from './types';-const widgetRegions = new Set<WorkbenchRegion>(['bottom', 'center', 'left', 'right', 'rightTop', 'rightBottom']);+const widgetRegions = new Set<WorkbenchRegion>(['bottom', 'center', 'left', 'right']);const NO_EXTENSION_HOTKEYS: WidgetHotkeyContribution[] = [];const subscribeToNothing = (): (() => void) => () => {};const getNoExtensionHotkeys = (): WidgetHotkeyContribution[] => NO_EXTENSION_HOTKEYS;diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.tsindex 7cf3b32712..421ab4f9cf 100644--- a/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/firstPartyCommands.ts@@ -19,7 +19,6 @@ import {} from '@platform/state/accountLifecycle';import { useQueryClient } from '@tanstack/react-query';import { submitActiveInvocation } from '@workbench/activeInvocationSubmission';-import { RIGHT_RAIL_DOCKS, WIDGET_REGIONS } from '@workbench/layoutContracts';import { builtInLayoutPresetDescriptors } from '@workbench/layoutPresets';import { toggleCommandPalette } from '@workbench/palette/paletteStore';import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';@@ -321,19 +320,21 @@ export const useRegisterFirstPartyCommands = () => {}),commandApi.register({handler: () => {- const region = queries.getSnapshot().activeProject.widgetRegions.left;+ const toggle = resolvePanelToggle(queries.getSnapshot().activeProject.widgetRegions, ['left']);- layout.setRegionCollapsed('left', !region.isCollapsed);+ for (const region of toggle.regions) {+ layout.setRegionCollapsed(region, toggle.shouldCollapse);+ }},id: 'app.toggleLeftPanel',title: 'Toggle left panel',}),commandApi.register({handler: () => {- const toggle = resolvePanelToggle(queries.getSnapshot().activeProject.widgetRegions, RIGHT_RAIL_DOCKS);+ const toggle = resolvePanelToggle(queries.getSnapshot().activeProject.widgetRegions, ['right']);- for (const dock of toggle.regions) {- layout.setRegionCollapsed(dock, toggle.shouldCollapse);+ for (const region of toggle.regions) {+ layout.setRegionCollapsed(region, toggle.shouldCollapse);}},id: 'app.toggleRightPanel',@@ -346,10 +347,11 @@ export const useRegisterFirstPartyCommands = () => {}),commandApi.register({handler: () => {- const toggle = resolvePanelToggle(- queries.getSnapshot().activeProject.widgetRegions,- WIDGET_REGIONS.filter((region) => region !== 'center')- );+ const toggle = resolvePanelToggle(queries.getSnapshot().activeProject.widgetRegions, [+ 'left',+ 'right',+ 'bottom',+ ]);for (const region of toggle.regions) {layout.setRegionCollapsed(region, toggle.shouldCollapse);diff --git a/invokeai/frontend/webv2/src/workbench/layoutContracts.ts b/invokeai/frontend/webv2/src/workbench/layoutContracts.tsindex bc932b966b..dc56db1fb2 100644--- a/invokeai/frontend/webv2/src/workbench/layoutContracts.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutContracts.ts@@ -19,27 +19,9 @@ export interface PanelState {isBottomOpen: boolean;}-/**- * The right rail is three docks stacked vertically, each its own tab group:- * `rightTop`, `right` (the flexible middle) and `rightBottom`. A widget that- * may dock on the right may dock in any of the three.- */-export type RightRailDock = 'rightTop' | 'right' | 'rightBottom';--export type WidgetRegion = 'left' | RightRailDock | 'bottom' | 'center';--/** The four rails a widget manifest addresses; the right rail's docks share one. */-export type WidgetRail = 'left' | 'right' | 'bottom' | 'center';--export const WIDGET_REGIONS: readonly WidgetRegion[] = ['left', 'rightTop', 'right', 'rightBottom', 'bottom', 'center'];--/** Top to bottom. */-export const RIGHT_RAIL_DOCKS: readonly RightRailDock[] = ['rightTop', 'right', 'rightBottom'];--export const isRightRailDock = (region: WidgetRegion): region is RightRailDock =>- region === 'rightTop' || region === 'right' || region === 'rightBottom';+export type WidgetRegion = 'left' | 'right' | 'bottom' | 'center';-export const getWidgetRail = (region: WidgetRegion): WidgetRail => (isRightRailDock(region) ? 'right' : region);+export const WIDGET_REGIONS: readonly WidgetRegion[] = ['left', 'right', 'bottom', 'center'];export const isWidgetRegion = (value: unknown): value is WidgetRegion =>typeof value === 'string' && (WIDGET_REGIONS as readonly string[]).includes(value);diff --git a/invokeai/frontend/webv2/src/workbench/layoutPresetRouting.ts b/invokeai/frontend/webv2/src/workbench/layoutPresetRouting.tsindex 9c467b4990..3952148725 100644--- a/invokeai/frontend/webv2/src/workbench/layoutPresetRouting.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutPresetRouting.ts@@ -3,9 +3,8 @@ import type { LayoutPreset, LayoutPresetRoute, WidgetRegion } from './layoutContimport { getNaturalDestination, getSourceIdForWidgetTypeId, graphWidgetSources } from './graphWidgets';import { isInvocationSourceAvailable } from './invocation';-import { getSnapshotRegion } from './layoutPresetSnapshots';-const activeSourceRegionPriority: WidgetRegion[] = ['center', 'left', 'right', 'rightTop', 'rightBottom', 'bottom'];+const activeSourceRegionPriority: WidgetRegion[] = ['center', 'left', 'right', 'bottom'];const getPresetSourceIds = (preset: LayoutPreset): Set<InvocationSourceId> => {const sourceIds = new Set<InvocationSourceId>();@@ -33,7 +32,7 @@ export const getLayoutPresetSourceOptions = (preset: LayoutPreset) => {const getActivePresetSource = (preset: LayoutPreset): InvocationSourceId | null => {for (const regionId of activeSourceRegionPriority) {- const region = getSnapshotRegion(preset.snapshot.widgetRegions, regionId);+ const region = preset.snapshot.widgetRegions[regionId];const typeId = preset.snapshot.widgetInstances[region.activeInstanceId]?.typeId;const sourceId = typeId ? getSourceIdForWidgetTypeId(typeId) : null;diff --git a/invokeai/frontend/webv2/src/workbench/layoutPresetSnapshots.ts b/invokeai/frontend/webv2/src/workbench/layoutPresetSnapshots.tsindex 0b5450d243..763ed24f11 100644--- a/invokeai/frontend/webv2/src/workbench/layoutPresetSnapshots.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutPresetSnapshots.ts@@ -10,7 +10,6 @@ import type {import type { AccountState, Project } from '@workbench/projectContracts';import type { WidgetInstanceId } from '@workbench/widgetContracts';-import { isRightRailDock, WIDGET_REGIONS } from '@workbench/layoutContracts';import {builtInLayoutPresetDescriptors,getLayoutPreset,@@ -31,22 +30,7 @@ export const getLayoutPresetCommandTitleOverrides = (}));-const widgetRegions: readonly WidgetRegion[] = WIDGET_REGIONS;--/** What a dock holds until a widget lands in it; also what a snapshot saved before docks existed meant. */-export const EMPTY_DOCK_REGION: WidgetRegionState = {- activeInstanceId: '',- instanceIds: [],- isCollapsed: true,- sizePx: 280,-};--/** Reads a region from a snapshot that may predate the right-rail docks. */-export const getSnapshotRegion = (- widgetRegionState: Partial<Record<WidgetRegion, WidgetRegionState>>,- region: WidgetRegion-): WidgetRegionState =>- widgetRegionState[region] ?? (isRightRailDock(region) ? EMPTY_DOCK_REGION : widgetRegionState[region]!);+const widgetRegions: WidgetRegion[] = ['left', 'right', 'bottom', 'center'];/*** The preset as saved *for this account*: a custom preset, or a built-in with@@ -81,14 +65,13 @@ export const cloneFloatingWidgets = (Object.fromEntries(Object.entries(floatingWidgets).map(([instanceId, state]) => [instanceId, { ...state }]));export const cloneLayoutPresetWidgetRegions = (- widgetRegionState: Partial<Record<WidgetRegion, WidgetRegionState>>-): Record<WidgetRegion, WidgetRegionState> =>- Object.fromEntries(- WIDGET_REGIONS.map((region) => {- const state = getSnapshotRegion(widgetRegionState, region);- return [region, { ...state, instanceIds: [...state.instanceIds] }];- })- ) as Record<WidgetRegion, WidgetRegionState>;+ widgetRegionState: Record<WidgetRegion, WidgetRegionState>+): Record<WidgetRegion, WidgetRegionState> => ({+ bottom: { ...widgetRegionState.bottom, instanceIds: [...widgetRegionState.bottom.instanceIds] },+ center: { ...widgetRegionState.center, instanceIds: [...widgetRegionState.center.instanceIds] },+ left: { ...widgetRegionState.left, instanceIds: [...widgetRegionState.left.instanceIds] },+ right: { ...widgetRegionState.right, instanceIds: [...widgetRegionState.right.instanceIds] },+});export const createLayoutPresetSnapshot = (project: Project): LayoutPresetSnapshot => {const referencedInstanceIds = new Set<WidgetInstanceId>();@@ -184,9 +167,7 @@ export const areLayoutPresetSnapshotsEqual = (left: LayoutPresetSnapshot, right:left.layout.panels.isBottomOpen === right.layout.panels.isBottomOpen &&left.layout.panels.isLeftOpen === right.layout.panels.isLeftOpen &&left.layout.panels.isRightOpen === right.layout.panels.isRightOpen &&- widgetRegions.every((region) =>- areWidgetRegionsEqual(getSnapshotRegion(left.widgetRegions, region), getSnapshotRegion(right.widgetRegions, region))- ) &&+ widgetRegions.every((region) => areWidgetRegionsEqual(left.widgetRegions[region], right.widgetRegions[region])) &&areFloatingWidgetsEqual(left.floatingWidgets, right.floatingWidgets) &&areWidgetInstanceSnapshotsEqual(left.widgetInstances, right.widgetInstances);diff --git a/invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts b/invokeai/frontend/webv2/src/workbench/layoutPresets.test.tsindex df7656ba37..f9b41d8bbc 100644--- a/invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutPresets.test.ts@@ -62,16 +62,12 @@ describe('built-in layout preset descriptors', () => {center: snapshot.widgetRegions.center.activeInstanceId,left: snapshot.widgetRegions.left.activeInstanceId,right: snapshot.widgetRegions.right.activeInstanceId,- rightBottom: snapshot.widgetRegions.rightBottom.activeInstanceId,- rightTop: snapshot.widgetRegions.rightTop.activeInstanceId,},bottom: snapshot.widgetRegions.bottom.instanceIds,center: snapshot.widgetRegions.center.instanceIds,left: snapshot.widgetRegions.left.instanceIds,panels: snapshot.layout.panels,right: snapshot.widgetRegions.right.instanceIds,- rightBottom: snapshot.widgetRegions.rightBottom.instanceIds,- rightTop: snapshot.widgetRegions.rightTop.instanceIds,},]));@@ -83,16 +79,12 @@ describe('built-in layout preset descriptors', () => {center: 'workflow:center',left: 'workflow',right: 'queue',- rightBottom: '',- rightTop: '',},bottom: ['server-status', 'queue-status', 'gallery:bottom', 'notifications', 'autosave-status'],center: ['workflow:center', 'preview'],left: ['workflow'],panels: { isBottomOpen: false, isLeftOpen: true, isRightOpen: true },right: ['queue', 'preview', 'gallery', 'image-map'],- rightBottom: [],- rightTop: [],},compose: {active: {@@ -100,8 +92,6 @@ describe('built-in layout preset descriptors', () => {center: 'preview',left: 'generate',right: 'gallery',- rightBottom: '',- rightTop: '',},bottom: ['server-status', 'queue-status', 'gallery:bottom', 'notifications', 'autosave-status'],// Compose keeps Gallery as a center view: the retired `gallery` preset@@ -112,8 +102,6 @@ describe('built-in layout preset descriptors', () => {left: ['generate', 'upscale', 'video'],panels: { isBottomOpen: false, isLeftOpen: true, isRightOpen: true },right: ['gallery', 'image-map', 'queue'],- rightBottom: [],- rightTop: [],},edit: {active: {@@ -121,17 +109,13 @@ describe('built-in layout preset descriptors', () => {center: 'canvas',left: 'generate',right: 'layers',- rightBottom: 'properties',- rightTop: '',},bottom: ['server-status', 'queue-status', 'gallery:bottom', 'notifications', 'autosave-status'],center: ['canvas', 'preview'],left: ['generate', 'upscale', 'video'],panels: { isBottomOpen: false, isLeftOpen: true, isRightOpen: true },- right: ['layers', 'preview', 'gallery', 'image-map', 'queue'],- // The rail is three tab groups: Layers in the middle, the editors below it.- rightBottom: ['properties', 'transform'],- rightTop: [],+ // The Edit rail is the Layers panel alone; its editors are panes inside it.+ right: ['layers'],},});});diff --git a/invokeai/frontend/webv2/src/workbench/layoutPresets.ts b/invokeai/frontend/webv2/src/workbench/layoutPresets.tsindex eb2ae38f37..c68874f30d 100644--- a/invokeai/frontend/webv2/src/workbench/layoutPresets.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutPresets.ts@@ -37,11 +37,9 @@ const defaultInstanceTypes: Record<WidgetInstanceId, WidgetTypeId> = {notifications: 'notifications',preview: 'preview',project: 'project',- properties: 'properties',queue: 'queue','queue-status': 'queue-status','server-status': 'server-status',- transform: 'transform','version-status': 'version-status',workflow: 'workflow','workflow:bottom': 'workflow',@@ -60,10 +58,6 @@ const createRegion = ({sizePx: number;}): WidgetRegionState => ({ activeInstanceId, instanceIds, isCollapsed, sizePx });-/** A right-rail dock with nothing in it stays collapsed to nothing until a widget lands there. */-const createEmptyDock = (): WidgetRegionState =>- createRegion({ activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 280 });-const createWidgetInstances = (widgetRegions: Record<WidgetRegion, WidgetRegionState>): Record<WidgetInstanceId, LayoutPresetWidgetInstanceSnapshot> => {@@ -188,8 +182,6 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [instanceIds: ['gallery', 'image-map', 'queue'],sizePx: 450,}),- rightBottom: createEmptyDock(),- rightTop: createEmptyDock(),},}),createPresetDescriptor({@@ -220,15 +212,9 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [}),right: createRegion({activeInstanceId: 'layers',- instanceIds: ['layers', 'preview', 'gallery', 'image-map', 'queue'],+ instanceIds: ['layers'],sizePx: 450,}),- rightBottom: createRegion({- activeInstanceId: 'properties',- instanceIds: ['properties', 'transform'],- sizePx: 300,- }),- rightTop: createEmptyDock(),},}),createPresetDescriptor({@@ -262,8 +248,6 @@ export const builtInLayoutPresetDescriptors: BuiltInLayoutPresetDescriptor[] = [instanceIds: ['queue', 'preview', 'gallery', 'image-map'],sizePx: 450,}),- rightBottom: createEmptyDock(),- rightTop: createEmptyDock(),},}),];diff --git a/invokeai/frontend/webv2/src/workbench/layoutWidgetSet.ts b/invokeai/frontend/webv2/src/workbench/layoutWidgetSet.tsindex 6494e73948..3787ed13cf 100644--- a/invokeai/frontend/webv2/src/workbench/layoutWidgetSet.ts+++ b/invokeai/frontend/webv2/src/workbench/layoutWidgetSet.ts@@ -14,7 +14,7 @@ export interface LayoutWidgetSource {* Regions in the order a boot reveals them, so callers that care about* priority get it for free and callers that do not are unaffected.*/-const REGION_ORDER = ['center', 'left', 'right', 'rightTop', 'rightBottom', 'bottom'];+const REGION_ORDER = ['center', 'left', 'right', 'bottom'];/*** Every widget type a layout renders: each region's active instance, plus everydiff --git a/invokeai/frontend/webv2/src/workbench/rightRailDocks.test.ts b/invokeai/frontend/webv2/src/workbench/rightRailDocks.test.tsdeleted file mode 100644index 92b765dd52..0000000000--- a/invokeai/frontend/webv2/src/workbench/rightRailDocks.test.ts+++ /dev/null@@ -1,210 +0,0 @@-import { describe, expect, it } from 'vitest';--import type { LayoutPreset, LayoutPresetSnapshot, WidgetRegionState } from './layoutContracts';-import type { Project, WorkbenchState } from './projectContracts';--import { getLayoutPreset } from './layoutPresets';-import { areLayoutPresetSnapshotsEqual, doesProjectMatchLayoutPreset } from './layoutPresetSnapshots';-import { createInitialWorkbenchState, normalizeWorkbenchAccount, resolvePanelToggle } from './workbenchState';-import { workbenchReducer } from './workbenchState.testing';--const activeProject = (state: WorkbenchState): Project =>- state.projects.find((project) => project.id === state.activeProjectId)!;--const editState = (): WorkbenchState =>- workbenchReducer(createInitialWorkbenchState(), { presetId: 'edit', type: 'applyPreset' });--/** The Edit preset as an account saved it before the rail had docks. */-const preDockEditSnapshot = (): LayoutPresetSnapshot => {- const { rightBottom: _bottom, rightTop: _top, ...regions } = getLayoutPreset('edit').snapshot.widgetRegions;- const right: WidgetRegionState = {- ...regions.right,- instanceIds: ['layers', 'preview', 'gallery', 'image-map', 'queue'],- };- const snapshot = getLayoutPreset('edit').snapshot;- const widgetRegions = { ...regions, right } as LayoutPresetSnapshot['widgetRegions'];- const referenced = new Set(Object.values(widgetRegions).flatMap((region) => region.instanceIds));- return {- layout: { ...snapshot.layout, panels: { ...snapshot.layout.panels } },- widgetInstances: Object.fromEntries(- Object.entries(snapshot.widgetInstances).filter(([instanceId]) => referenced.has(instanceId))- ),- widgetRegions,- };-};--describe('right rail docks', () => {- it('loads an account whose custom preset and override predate the docks, and treats them as empty docks', () => {- const custom: LayoutPreset = { id: 'custom-old', label: 'Old', snapshot: preDockEditSnapshot() };- const account = normalizeWorkbenchAccount({- customLayoutPresets: [custom],- layoutPresetOverrides: { edit: preDockEditSnapshot() },- });-- expect(account.customLayoutPresets?.map((preset) => preset.id)).toEqual(['custom-old']);- expect(account.customLayoutPresets?.[0]?.snapshot.widgetRegions.rightTop).toMatchObject({- activeInstanceId: '',- instanceIds: [],- isCollapsed: true,- });- expect(account.layoutPresetOverrides?.edit?.widgetRegions.rightBottom).toMatchObject({ instanceIds: [] });-- const initial = createInitialWorkbenchState();- const hydrated = workbenchReducer(initial, {- state: { ...initial, account: { ...initial.account, customLayoutPresets: [custom] } },- type: 'hydrateWorkbench',- });- const applied = workbenchReducer(hydrated, { presetId: 'custom-old', type: 'applyPreset' });- expect(activeProject(applied).widgetRegions.right.instanceIds).toContain('image-map');- expect(activeProject(applied).widgetRegions.rightBottom.instanceIds).toEqual([]);- // Drift compares a dock-less snapshot as if it carried empty docks.- expect(- areLayoutPresetSnapshotsEqual(- custom.snapshot,- activeProject(applied).widgetRegions ? { ...custom.snapshot } : custom.snapshot- )- ).toBe(true);- expect(doesProjectMatchLayoutPreset(activeProject(applied), custom)).toBe(true);- });-- it('keeps a saved preset whose docks are empty', () => {- const preset: LayoutPreset = { id: 'custom-new', label: 'New', snapshot: getLayoutPreset('compose').snapshot };- expect(preset.snapshot.widgetRegions.rightTop.activeInstanceId).toBe('');- expect(normalizeWorkbenchAccount({ customLayoutPresets: [preset] }).customLayoutPresets?.length).toBe(1);- });-- it('leaves an emptied dock naming no instance, so moving widgets out and back matches the preset again', () => {- let state = editState();- const move = (instanceId: string, fromRegion: 'rightTop' | 'rightBottom', toRegion: 'rightTop' | 'rightBottom') =>- workbenchReducer(state, { fromRegion, instanceId, toIndex: 99, toRegion, type: 'moveWidgetInstance' });- state = move('properties', 'rightBottom', 'rightTop');- state = move('transform', 'rightBottom', 'rightTop');- expect(activeProject(state).widgetRegions.rightBottom).toMatchObject({- activeInstanceId: '',- instanceIds: [],- isCollapsed: true,- });- expect(activeProject(state).widgetRegions.rightTop).toMatchObject({- activeInstanceId: 'transform',- instanceIds: ['properties', 'transform'],- isCollapsed: false,- });-- state = move('properties', 'rightTop', 'rightBottom');- state = move('transform', 'rightTop', 'rightBottom');- state = workbenchReducer(state, { region: 'rightBottom', type: 'selectRegionWidget', widgetId: 'properties' });- expect(doesProjectMatchLayoutPreset(activeProject(state), getLayoutPreset('edit'))).toBe(true);-- const closed = workbenchReducer(- workbenchReducer(state, { region: 'rightBottom', type: 'toggleRegionWidget', widgetId: 'transform' }),- { region: 'rightBottom', type: 'toggleRegionWidget', widgetId: 'properties' }- );- expect(activeProject(closed).widgetRegions.rightBottom.activeInstanceId).toBe('');-- const floated = workbenchReducer(state, { instanceId: 'properties', type: 'floatWidget' });- expect(activeProject(floated).widgetRegions.rightBottom).toMatchObject({ activeInstanceId: 'transform' });- expect(activeProject(floated).floatingWidgets?.properties?.returnRegion).toBe('rightBottom');- });-- it('reveals an instance already docked elsewhere on the rail instead of placing it twice', () => {- let state = editState();- state = workbenchReducer(state, { region: 'rightBottom', type: 'setRegionWidgetCollapsed', isCollapsed: true });- state = workbenchReducer(state, { region: 'right', type: 'openRegionWidget', widgetId: 'transform' });- const { right, rightBottom } = activeProject(state).widgetRegions;- expect(right.instanceIds).not.toContain('transform');- expect(rightBottom).toMatchObject({ activeInstanceId: 'transform', isCollapsed: false });- });-- it('migrates a pre-dock Edit rail keeping the rail shut if it was, and leaves a floated Image Map in the middle', () => {- const initial = createInitialWorkbenchState();- const preDock = (mutate: (project: Project) => Project): WorkbenchState => ({- ...initial,- projects: initial.projects.map((project) => {- const { rightBottom: _b, rightTop: _t, ...regions } = project.widgetRegions;- return mutate({- ...project,- widgetRegions: {- ...regions,- right: {- ...project.widgetRegions.right,- instanceIds: ['layers', 'preview', 'gallery', 'image-map', 'queue'],- isCollapsed: true,- },- } as Project['widgetRegions'],- });- }),- });-- const shut = activeProject(workbenchReducer(initial, { state: preDock((p) => p), type: 'hydrateWorkbench' }));- expect(shut.widgetRegions.rightBottom).toMatchObject({- instanceIds: ['properties', 'transform'],- isCollapsed: true,- });-- const floated = activeProject(- workbenchReducer(initial, {- state: preDock((project) => ({- ...project,- floatingWidgets: {- 'image-map': {- heightPx: 300,- mode: 'windowed',- returnRegion: 'right',- stackOrder: 1,- widthPx: 300,- x: 0,- y: 0,- },- },- widgetRegions: {- ...project.widgetRegions,- right: { ...project.widgetRegions.right, isCollapsed: false },- },- })),- type: 'hydrateWorkbench',- })- );- expect(floated.floatingWidgets?.['image-map']?.returnRegion).toBe('right');- expect(floated.widgetRegions.rightBottom).toMatchObject({ instanceIds: ['properties', 'transform'] });- expect(floated.widgetRegions.right.instanceIds).toEqual(['layers', 'preview', 'gallery', 'queue']);- });-- it('upgrades the interim rail that docked Image Map alone at the bottom to the shipped docks', () => {- const initial = createInitialWorkbenchState();- const interim: WorkbenchState = {- ...initial,- projects: initial.projects.map((project) => ({- ...project,- widgetRegions: {- ...project.widgetRegions,- right: { ...project.widgetRegions.right, instanceIds: ['layers', 'preview', 'gallery', 'queue'] },- rightBottom: { activeInstanceId: 'image-map', instanceIds: ['image-map'], isCollapsed: false, sizePx: 280 },- rightTop: { activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 280 },- },- })),- };- const project = activeProject(workbenchReducer(initial, { state: interim, type: 'hydrateWorkbench' }));- expect(project.widgetRegions.right.instanceIds).toEqual(['layers', 'preview', 'gallery', 'image-map', 'queue']);- expect(project.widgetRegions.rightBottom.instanceIds).toEqual(['properties', 'transform']);- expect(project.widgetInstances.transform?.typeId).toBe('transform');- expect(project.widgetRegions.rightBottom).toMatchObject({ activeInstanceId: 'properties', isCollapsed: false });- });-- it('toggles only the docks that hold something', () => {- const regions = activeProject(editState()).widgetRegions;- expect(resolvePanelToggle(regions, ['rightTop', 'right', 'rightBottom'])).toEqual({- regions: ['right', 'rightBottom'],- shouldCollapse: true,- });- const collapsed = {- ...regions,- right: { ...regions.right, isCollapsed: true },- rightBottom: { ...regions.rightBottom, isCollapsed: true },- rightTop: { ...regions.rightTop, isCollapsed: false },- };- expect(resolvePanelToggle(collapsed, ['rightTop', 'right', 'rightBottom'])).toEqual({- regions: ['right', 'rightBottom'],- shouldCollapse: false,- });- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsxindex 4566abd973..9b60c9e3bf 100644--- a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx@@ -23,6 +23,11 @@ export const LeftPanel = ({ instanceId }: { instanceId: WidgetInstanceId }) => (<WidgetPanelSlot instanceId={instanceId} region="left" />);+/** Right panel — hosts the active registered widget panel view. */+export const RightPanel = ({ instanceId }: { instanceId: WidgetInstanceId }) => (+ <WidgetPanelSlot instanceId={instanceId} region="right" />+);+/*** Keeps the panel widgets this session has already shown mounted behind the* active one, so switching a layout preset hides them rather than destroyingdiff --git a/invokeai/frontend/webv2/src/workbench/shell/RightRail.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/RightRail.browser.test.tsxdeleted file mode 100644index 80e2cdb428..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/RightRail.browser.test.tsx+++ /dev/null@@ -1,304 +0,0 @@-/* oxlint-disable react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-array-as-prop */-import type { RightRailDock } from '@workbench/layoutContracts';-import type { WorkbenchInternalStore } from '@workbench/workbenchStore';--import { ChakraProvider } from '@chakra-ui/react';-import { DndContext } from '@dnd-kit/core';-import { system } from '@theme/system';-import { FocusRegionProvider } from '@workbench/focusRegions';-import { RIGHT_RAIL_DOCKS } from '@workbench/layoutContracts';-import { createWorkbenchStore } from '@workbench/workbenchStore';-import { createInstance } from 'i18next';-import { act, useSyncExternalStore } from 'react';-import { createRoot, type Root } from 'react-dom/client';-import { I18nextProvider } from 'react-i18next';-import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';-import { page, userEvent } from 'vitest/browser';--const storeRef = vi.hoisted(() => ({ current: null as WorkbenchInternalStore | null }));--vi.mock('@workbench/WorkbenchContext', () => ({- shallowEqual: Object.is,- useActiveProjectId: () => {- const store = storeRef.current!;- return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot).activeProject.id;- },- useActiveProjectSelector: (selector: (project: never) => unknown) => {- const store = storeRef.current!;- const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);- return selector(snapshot.activeProject as never);- },- useWorkbenchCommands: () => storeRef.current!.commands,-}));-vi.mock('./Panels', () => ({- WidgetPanelSlot: ({ instanceId, region }: { instanceId: string; region: string }) => (- <div data-dock-body={region} data-instance={instanceId} style={{ height: '100%' }} />- ),-}));-vi.mock('@workbench/widget-frame', async () => {- const frames = await import('@workbench/widget-frame/WidgetFrames');- const strip = await import('@workbench/widget-frame/WidgetStrip');- const menu = await import('@workbench/widget-frame/WidgetInstanceContextMenu');-- return {- WidgetChromeSlotById: ({ instanceId }: { instanceId: string }) => <span data-chrome-actions={instanceId} />,- WidgetInstanceContextMenu: menu.WidgetInstanceContextMenu,- WidgetPanelFrame: frames.WidgetPanelFrame,- WidgetStrip: strip.WidgetStrip,- };-});--import { resolveFlexDock, RightRailPanel, type RightRailDockModel, type RightRailItem } from './RightRail';--const i18n = createInstance();-beforeAll(async () => {- const translation = (await (await fetch('/locales/en.json')).json()) as Record<string, unknown>;- await i18n.init({ initAsync: false, lng: 'en', resources: { en: { translation } } });-});--(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;--let host: HTMLDivElement | null = null;-let root: Root | null = null;--const interact = (run: () => void): Promise<void> =>- act(async () => {- run();- await Promise.resolve();- });--const item = (id: string): RightRailItem => ({- allowMultiple: false,- icon: () => null,- id,- instance: { id, typeId: id },- isEnabled: true,- label: id,- status: 'enabled',- typeId: id,- widget: { manifest: { icon: () => null, id } } as never,-});--const noDrop = { helperText: '', isActive: false, isAllowed: false };--/** The rail as the shell would build it from the store: one dock model per region. */-const Rail = () => {- const store = storeRef.current!;- const project = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot).activeProject;- const docks = RIGHT_RAIL_DOCKS.map((region): RightRailDockModel => {- const state = project.widgetRegions[region];- return {- activeId: state.instanceIds.includes(state.activeInstanceId) ? state.activeInstanceId : null,- dropState: noDrop,- items: state.instanceIds.map(item),- region,- state,- };- });- return (- <RightRailPanel- docks={docks}- onRemove={(region, removed) =>- store.commands.widgets.toggle({ projectId: project.id, region, widgetId: removed.id })- }- onSelect={(region, instanceId) =>- store.commands.widgets.select({ projectId: project.id, region, widgetId: instanceId })- }- />- );-};--const region = (dock: RightRailDock) => storeRef.current!.getSnapshot().activeProject.widgetRegions[dock];-const dockElement = (dock: RightRailDock) => host!.querySelector<HTMLElement>(`[data-rail-dock="${dock}"]`);-const tabsOf = (dock: RightRailDock) =>- [...(dockElement(dock)?.querySelectorAll<HTMLElement>('[role="tab"]') ?? [])].map((tab) => ({- label: tab.textContent,- selected: tab.getAttribute('aria-selected') === 'true',- }));-const bodyOf = (dock: RightRailDock) =>- dockElement(dock)?.querySelector<HTMLElement>('[data-dock-body]')?.dataset.instance;--beforeEach(async () => {- storeRef.current = createWorkbenchStore();- storeRef.current.commands.layout.applyPreset('edit');- host = document.createElement('div');- host.style.cssText = 'display:flex;height:1000px;width:1000px;';- document.body.append(host);- root = createRoot(host);- await interact(() =>- root?.render(- <I18nextProvider i18n={i18n}>- <ChakraProvider value={system}>- <FocusRegionProvider>- <DndContext>- <Rail />- </DndContext>- </FocusRegionProvider>- </ChakraProvider>- </I18nextProvider>- )- );-});--afterEach(async () => {- await interact(() => root?.unmount());- host?.remove();- host = null;- root = null;- storeRef.current = null;-});--describe('right rail docks', () => {- it('shows the Edit preset as two docks — Layers and its siblings in the middle, Image Map below — and hides the empty top dock', () => {- expect(dockElement('rightTop')).toBeNull();- expect(tabsOf('right')).toEqual([- { label: 'layers', selected: true },- { label: 'preview', selected: false },- { label: 'gallery', selected: false },- { label: 'image-map', selected: false },- { label: 'queue', selected: false },- ]);- expect(tabsOf('rightBottom')).toEqual([- { label: 'properties', selected: true },- { label: 'transform', selected: false },- ]);- const tab = page.getByRole('tab', { exact: true, name: 'layers' }).element();- expect(tab.getAttribute('aria-controls')).toBe('rail-dock-right-panel');- expect(host!.querySelector('#rail-dock-right-panel')?.getAttribute('role')).toBe('tabpanel');- expect(tab.getAttribute('aria-roledescription')).toBeNull();- expect(bodyOf('right')).toBe('layers');- expect(bodyOf('rightBottom')).toBe('properties');- expect(Math.round(dockElement('rightBottom')!.getBoundingClientRect().height)).toBe(region('rightBottom').sizePx);- expect(dockElement('right')!.getBoundingClientRect().height).toBeGreaterThan(400);- expect(host!.querySelector('[data-chrome-actions="layers"]')).not.toBeNull();- });-- it('switches the dock body from its tabs, by pointer and by arrow keys, without collapsing on the active tab', async () => {- await interact(() =>- page- .getByRole('tab', { exact: true, name: 'preview' })- .element()- .dispatchEvent(new MouseEvent('click', { bubbles: true }))- );- expect(region('right').activeInstanceId).toBe('preview');- expect(bodyOf('right')).toBe('preview');-- await interact(() =>- page- .getByRole('tab', { exact: true, name: 'preview' })- .element()- .dispatchEvent(new MouseEvent('click', { bubbles: true }))- );- expect(region('right').isCollapsed).toBe(false);-- (page.getByRole('tab', { exact: true, name: 'preview' }).element() as HTMLElement).focus();- await act(() => userEvent.keyboard('{ArrowRight}'));- expect(document.activeElement?.textContent).toBe('gallery');- await act(() => userEvent.keyboard('{End}'));- expect(document.activeElement?.textContent).toBe('queue');- await act(() => userEvent.keyboard('{ArrowRight}'));- expect(document.activeElement?.textContent).toBe('layers');- });-- it('collapses a dock to its tab strip and expands it again', async () => {- await interact(() =>- page- .getByRole('button', { exact: true, name: 'Collapse bottom dock' })- .element()- .dispatchEvent(new MouseEvent('click', { bubbles: true }))- );- expect(region('rightBottom').isCollapsed).toBe(true);- expect(bodyOf('rightBottom')).toBeUndefined();- expect(dockElement('rightBottom')!.getBoundingClientRect().height).toBeLessThan(48);- expect(tabsOf('rightBottom').map((tab) => tab.label)).toEqual(['properties', 'transform']);-- await interact(() =>- page- .getByRole('button', { exact: true, name: 'Expand bottom dock' })- .element()- .dispatchEvent(new MouseEvent('click', { bubbles: true }))- );- expect(region('rightBottom').isCollapsed).toBe(false);- expect(bodyOf('rightBottom')).toBe('properties');- });-- it('resizes the bottom dock from its handle by keyboard and collapses it below the floor', async () => {- const handle = page.getByRole('separator', { exact: true, name: 'Resize bottom dock' });- const start = region('rightBottom').sizePx;- (handle.element() as HTMLElement).focus();- await act(() => userEvent.keyboard('{ArrowUp}'));- expect(region('rightBottom').sizePx).toBe(start + 16);- await act(() => userEvent.keyboard('{Shift>}{ArrowDown}{/Shift}'));- expect(region('rightBottom').sizePx).toBe(start - 16);- await act(() => userEvent.keyboard('{Home}'));- expect(region('rightBottom').sizePx).toBe(120);- await act(() => userEvent.keyboard('{ArrowDown}'));- expect(region('rightBottom').isCollapsed).toBe(true);- });-- it('resizes the bottom dock by dragging its top edge, previewing live and committing once on release', async () => {- const handle = page.getByRole('separator', { exact: true, name: 'Resize bottom dock' }).element();- const start = region('rightBottom').sizePx;- await interact(() => handle.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, clientY: 700 })));- await interact(() => window.dispatchEvent(new PointerEvent('pointermove', { clientY: 600 })));- expect(region('rightBottom').sizePx).toBe(start);- expect(Math.round(dockElement('rightBottom')!.getBoundingClientRect().height)).toBe(start + 100);- await interact(() => window.dispatchEvent(new PointerEvent('pointerup', { clientY: 600 })));- expect(region('rightBottom').sizePx).toBe(start + 100);-- await interact(() => handle.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, clientY: 600 })));- await interact(() => window.dispatchEvent(new PointerEvent('pointermove', { clientY: 650 })));- await interact(() => window.dispatchEvent(new PointerEvent('pointercancel', { clientY: 650 })));- expect(region('rightBottom').sizePx).toBe(start + 100);- });-- it('follows a widget between docks: the top dock appears when it gains a widget and a dock with nothing left disappears', async () => {- const store = storeRef.current!;- for (const instanceId of ['properties', 'transform']) {- await interact(() =>- store.commands.widgets.move({ fromRegion: 'rightBottom', instanceId, toIndex: 9, toRegion: 'rightTop' })- );- }- expect(dockElement('rightBottom')).toBeNull();- expect(tabsOf('rightTop').map((tab) => tab.label)).toEqual(['properties', 'transform']);- expect([...host!.querySelectorAll<HTMLElement>('[data-rail-dock]')].map((el) => el.dataset.railDock)).toEqual([- 'rightTop',- 'right',- ]);- expect(page.getByRole('separator', { exact: true, name: 'Resize top dock' }).element()).not.toBeNull();- });-- it('shuts every dock when the rail panel is dragged closed', async () => {- const handle = page.getByRole('separator', { exact: true, name: 'Resize right widget panel' }).element();- const start = region('right').sizePx;- await interact(() => handle.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, clientX: 0 })));- await interact(() => window.dispatchEvent(new PointerEvent('pointermove', { clientX: start - 260 })));- await interact(() => window.dispatchEvent(new PointerEvent('pointerup', { clientX: start - 260 })));- expect(region('right').isCollapsed).toBe(true);- expect(region('rightBottom').isCollapsed).toBe(true);- });-- it('gives the spare height to the middle dock, or to the last dock with a widget', () => {- expect(- resolveFlexDock([- { items: [1], region: 'rightTop' },- { items: [], region: 'right' },- { items: [1], region: 'rightBottom' },- ])- ).toBe('rightBottom');- expect(- resolveFlexDock([- { items: [1], region: 'rightTop' },- { items: [1], region: 'right' },- { items: [], region: 'rightBottom' },- ])- ).toBe('right');- expect(- resolveFlexDock([- { items: [], region: 'rightTop' },- { items: [], region: 'right' },- { items: [], region: 'rightBottom' },- ])- ).toBeNull();- });-});diff --git a/invokeai/frontend/webv2/src/workbench/shell/RightRail.tsx b/invokeai/frontend/webv2/src/workbench/shell/RightRail.tsxdeleted file mode 100644index 8c509043a1..0000000000--- a/invokeai/frontend/webv2/src/workbench/shell/RightRail.tsx+++ /dev/null@@ -1,497 +0,0 @@-/* oxlint-disable react-perf/jsx-no-new-function-as-prop */-import type { RightRailDock, WidgetRegionState } from '@workbench/layoutContracts';-import type { WidgetInstanceId } from '@workbench/widgetContracts';-import type { WidgetRegionDropState } from '@workbench/widgetDnd';-import type { PlacedWidgetRegionItem, WidgetPlacementInstanceMeta } from '@workbench/widgetRegionViewModel';--import { Box, chakra, Flex, HStack, Icon, Text } from '@chakra-ui/react';-import { useDndContext } from '@dnd-kit/core';-import { horizontalListSortingStrategy } from '@dnd-kit/sortable';-import { useMountEffect } from '@platform/react/useMountEffect';-import { IconButton } from '@platform/ui/Button';-import { Tooltip } from '@platform/ui/Tooltip';-import { useFocusRegionProps } from '@workbench/focusRegions';-import { RIGHT_RAIL_DOCKS } from '@workbench/layoutContracts';-import {- WidgetChromeSlotById,- WidgetInstanceContextMenu,- WidgetPanelFrame,- WidgetStrip,- type WidgetInstanceContextMenuTarget,-} from '@workbench/widget-frame';-import { useWidgetSortable } from '@workbench/widget-frame/useWidgetSortable';-import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { clampPanelSize, getPanelSizeBounds } from '@workbench/workbenchState';-import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react';-import {- Suspense,- useCallback,- useMemo,- useRef,- useState,- type KeyboardEvent as ReactKeyboardEvent,- type MouseEvent,- type PointerEvent as ReactPointerEvent,-} from 'react';-import { useTranslation } from 'react-i18next';--import { WidgetPanelSlot } from './Panels';--export type RightRailItem = PlacedWidgetRegionItem<WidgetPlacementInstanceMeta>;--export interface RightRailDockModel {- activeId: WidgetInstanceId | null;- dropState: WidgetRegionDropState;- items: RightRailItem[];- region: RightRailDock;- state: WidgetRegionState;-}--/** The tab strip's height; a collapsed dock is exactly this tall, and no dock shrinks below it. */-export const DOCK_STRIP_HEIGHT_PX = 40;-const DOCK_SIZE_STEP_PX = 16;-const TAB_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };-const HANDLE_HOVER_PROPS = { bg: 'accent.solid', opacity: 0.45 };-const HANDLE_FOCUS_PROPS = { bg: 'accent.solid', opacity: 0.65, outline: '2px solid {colors.accent.solid}' };--interface DockShape {- items: readonly unknown[];- region: RightRailDock;- state?: Pick<WidgetRegionState, 'isCollapsed'>;-}--/**- * The dock that takes the rail's spare height: the middle one while it shows- * something, else the last expanded dock; a collapsed dock never takes it.- */-export const resolveFlexDock = (docks: readonly DockShape[]): RightRailDock | null => {- const expanded = docks.filter((dock) => dock.items.length > 0 && !dock.state?.isCollapsed);- return expanded.some((dock) => dock.region === 'right') ? 'right' : (expanded.at(-1)?.region ?? null);-};--/**- * The right rail's panel: up to three docks stacked top to bottom, each a tab- * group over one widget region. The panel owns the rail's width; each outer- * dock owns a preferred height, the flex dock takes what is left, and a dock- * with nothing placed in it takes no space at all.- */-export const RightRailPanel = ({- docks,- onSelect,- onRemove,-}: {- docks: readonly RightRailDockModel[];- onSelect: (region: RightRailDock, instanceId: WidgetInstanceId) => void;- onRemove: (region: RightRailDock, item: RightRailItem) => void;-}) => {- const flexDock = resolveFlexDock(docks);- const visible = docks.filter((dock) => dock.items.length > 0);- // A drag previews the size locally; the store hears about it on release.- const [preview, setPreview] = useState<{ region: RightRailDock; sizePx: number } | null>(null);-- return (- <WidgetPanelFrame region="right">- {visible.map((dock, index) => {- const previous = visible[index - 1];- // The divider above a dock sizes whichever of the pair is fixed; a pair of fixed docks sizes the lower one.- const sized = dock.region === flexDock ? previous?.region : dock.region;- const edge = sized === dock.region ? 'top' : 'bottom';- return (- <Flex key={dock.region} direction="column" display="contents">- {previous && sized && !dock.state.isCollapsed && !previous.state.isCollapsed ? (- <DockDivider edge={edge} region={sized} onPreview={setPreview} />- ) : null}- <RailDock- dock={dock}- isFlex={dock.region === flexDock}- previewSizePx={preview?.region === dock.region ? preview.sizePx : null}- onRemove={onRemove}- onSelect={onSelect}- />- </Flex>- );- })}- </WidgetPanelFrame>- );-};--const RailDock = ({- dock,- isFlex,- onRemove,- onSelect,- previewSizePx,-}: {- dock: RightRailDockModel;- isFlex: boolean;- onRemove: (region: RightRailDock, item: RightRailItem) => void;- onSelect: (region: RightRailDock, instanceId: WidgetInstanceId) => void;- previewSizePx: number | null;-}) => {- const { t } = useTranslation();- const { layout } = useWorkbenchCommands();- const { region, state } = dock;- const expanded = !state.isCollapsed;- const dockName = t(`widgets.dock.names.${region}`);- const active = dock.items.find((item) => item.id === dock.activeId) ?? dock.items[0];- const focusRegionProps = useFocusRegionProps(region);- const panelId = `rail-dock-${region}-panel`;- // Collapsed docks are their strip; the flex dock takes the rest; a fixed dock- // keeps its preferred height but yields, down to its strip, when the rail is short.- const sizeProps = !expanded- ? { flex: '0 0 auto' as const }- : isFlex- ? { flex: '1 1 0' as const, minH: `${DOCK_STRIP_HEIGHT_PX}px` }- : {- flex: `0 1 ${clampPanelSize(region, previewSizePx ?? state.sizePx)}px`,- minH: `${DOCK_STRIP_HEIGHT_PX}px`,- };- const toggle = useCallback(() => layout.setRegionCollapsed(region, expanded), [expanded, layout, region]);-- return (- <Flex- aria-label={t('widgets.panelLabel', { region: dockName })}- borderColor="border.subtle"- borderTopWidth={region === 'rightTop' ? '0' : '1px'}- data-rail-dock={region}- data-rail-dock-collapsed={expanded ? undefined : ''}- direction="column"- overflow="hidden"- role="group"- {...focusRegionProps}- {...sizeProps}- >- <DockTabStrip- active={active}- dock={dock}- expanded={expanded}- panelId={panelId}- onRemove={onRemove}- onSelect={onSelect}- onToggle={toggle}- />- {expanded && active ? (- <Box- aria-labelledby={`rail-dock-tab-${active.id}`}- flex="1"- id={panelId}- minH="0"- overflow="hidden"- role="tabpanel"- >- <WidgetPanelSlot instanceId={active.id} region={region} />- </Box>- ) : null}- </Flex>- );-};--const DockTabStrip = ({- active,- dock,- expanded,- onRemove,- onSelect,- onToggle,- panelId,-}: {- active: RightRailItem | undefined;- dock: RightRailDockModel;- expanded: boolean;- onRemove: (region: RightRailDock, item: RightRailItem) => void;- onSelect: (region: RightRailDock, instanceId: WidgetInstanceId) => void;- onToggle: () => void;- panelId: string;-}) => {- const { t } = useTranslation();- const { active: activeDrag } = useDndContext();- const { region } = dock;- const dockName = t(`widgets.dock.names.${region}`);- const sortableInstanceIds = useMemo(() => dock.items.map((item) => item.id), [dock.items]);- const [menuTarget, setMenuTarget] = useState<WidgetInstanceContextMenuTarget | null>(null);- const remove = useCallback(- (item: { id: string }) => {- const railItem = dock.items.find((candidate) => candidate.id === item.id);- if (railItem) {- onRemove(region, railItem);- }- },- [dock.items, onRemove, region]- );- const isDragging = activeDrag !== null;- const focusSibling = useCallback(- (event: ReactKeyboardEvent<HTMLElement>) => {- // A keyboard drag owns the arrow keys until it drops.- if (isDragging) {- return;- }- if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight' && event.key !== 'Home' && event.key !== 'End') {- return;- }- const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')];- const current = tabs.indexOf(document.activeElement as HTMLElement);- if (current === -1) {- return;- }- event.preventDefault();- const next =- event.key === 'Home'- ? 0- : event.key === 'End'- ? tabs.length - 1- : (current + (event.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length;- tabs[next]?.focus();- },- [isDragging]- );- const collapseLabel = expanded- ? t('widgets.dock.collapse', { dock: dockName })- : t('widgets.dock.expand', { dock: dockName });-- return (- <WidgetStrip- align="center"- direction="row"- dropState={dock.dropState}- flexShrink={0}- gap="0.5"- h={`${DOCK_STRIP_HEIGHT_PX}px`}- minW="0"- px="1.5"- region={region}- sortableInstanceIds={sortableInstanceIds}- strategy={horizontalListSortingStrategy}- surface="dock"- >- <HStack- aria-label={t('widgets.dock.tabs', { dock: dockName })}- aria-orientation="horizontal"- flex="1"- gap="0.5"- minW="0"- overflow="hidden"- role="tablist"- onKeyDown={focusSibling}- >- {dock.items.map((item) => (- <DockTab- key={item.id}- isActive={item.id === active?.id}- item={item}- panelId={panelId}- region={region}- onContextMenu={(event) => {- event.preventDefault();- setMenuTarget({ item, x: event.clientX, y: event.clientY });- }}- onSelect={onSelect}- />- ))}- </HStack>- {active && expanded ? (- <Suspense fallback={null}>- <WidgetChromeSlotById instanceId={active.id} region={region} slot="actions" widget={active.widget} />- </Suspense>- ) : null}- <Tooltip content={collapseLabel}>- <IconButton- aria-expanded={expanded}- aria-label={collapseLabel}- color="fg.muted"- size="2xs"- variant="ghost"- onClick={onToggle}- >- <Icon as={expanded ? ChevronDownIcon : ChevronUpIcon} boxSize="3.5" />- </IconButton>- </Tooltip>- <WidgetInstanceContextMenu target={menuTarget} onClose={() => setMenuTarget(null)} onRemove={remove} />- </WidgetStrip>- );-};--const DockTab = ({- isActive,- item,- onContextMenu,- onSelect,- panelId,- region,-}: {- isActive: boolean;- item: RightRailItem;- onContextMenu: (event: MouseEvent<HTMLElement>) => void;- onSelect: (region: RightRailDock, instanceId: WidgetInstanceId) => void;- panelId: string;- region: RightRailDock;-}) => {- const isDisabled = item.status === 'disabled';- // Space picks the tab up for a keyboard reorder; Enter and clicks select it.- const { semanticDragHandleProps, setNodeRef, style } = useWidgetSortable({- disabled: isDisabled,- instanceId: item.id,- region,- surface: 'dock',- typeId: item.typeId,- });- const select = useCallback(() => {- if (!isDisabled && !isActive) {- onSelect(region, item.id);- }- }, [isActive, isDisabled, item.id, onSelect, region]);-- return (- <chakra.button- ref={setNodeRef}- {...semanticDragHandleProps}- aria-controls={isActive ? panelId : undefined}- aria-selected={isActive}- bg={isActive ? 'bg.emphasized' : 'transparent'}- color={isActive ? 'fg' : 'fg.muted'}- cursor={isDisabled ? 'not-allowed' : 'pointer'}- data-widget-dock-tab={item.id}- flexShrink={0}- fontSize="xs"- fontWeight="600"- h="7"- id={`rail-dock-tab-${item.id}`}- opacity={isDisabled ? 0.4 : 1}- px="2.5"- role="tab"- rounded="md"- style={style}- tabIndex={isActive ? 0 : -1}- title={item.failureMessage ? `${item.label}: ${item.failureMessage}` : item.label}- type="button"- _hover={isActive || isDisabled ? undefined : TAB_HOVER_PROPS}- onClick={select}- onContextMenu={onContextMenu}- >- <Text as="span" truncate>- {item.label}- </Text>- </chakra.button>- );-};--/**- * The line between two docks, carrying the handle that sizes the fixed one of- * the pair: dragging its top edge up or its bottom edge down grows it, the- * store hears the size on release, an interrupted drag keeps the old size, and- * dropping below the floor collapses the dock.- */-const DockDivider = ({- edge,- onPreview,- region,-}: {- /** Which edge of the sized dock this divider is. */- edge: 'top' | 'bottom';- onPreview: (preview: { region: RightRailDock; sizePx: number } | null) => void;- region: RightRailDock;-}) => {- const { t } = useTranslation();- const { layout } = useWorkbenchCommands();- const sizePx = useActiveProjectSelector((project) => project.widgetRegions[region].sizePx);- const { max, min } = getPanelSizeBounds(region);- const session = useRef<AbortController | null>(null);- const dockName = t(`widgets.dock.names.${region}`);-- useMountEffect(() => () => session.current?.abort());-- const commit = useCallback(- (next: number) => {- if (next < min) {- layout.setRegionCollapsed(region, true);- return;- }- const clamped = clampPanelSize(region, next);- if (clamped !== sizePx) {- layout.setRegionSize(region, clamped);- }- },- [layout, min, region, sizePx]- );- const onPointerDown = useCallback(- (event: ReactPointerEvent<HTMLDivElement>) => {- event.preventDefault();- const startY = event.clientY;- const direction = edge === 'top' ? -1 : 1;- const controller = new AbortController();- session.current?.abort();- session.current = controller;- let latest = sizePx;- try {- event.currentTarget.setPointerCapture(event.pointerId);- } catch {- // The window listeners carry the drag without capture.- }- const move = (moveEvent: PointerEvent) => {- latest = sizePx + (moveEvent.clientY - startY) * direction;- onPreview({ region, sizePx: clampPanelSize(region, latest) });- };- const finish = (apply: boolean) => () => {- controller.abort();- onPreview(null);- if (apply) {- commit(latest);- }- };- window.addEventListener('pointermove', move, { signal: controller.signal });- window.addEventListener('pointerup', finish(true), { signal: controller.signal });- window.addEventListener('pointercancel', finish(false), { signal: controller.signal });- },- [commit, edge, onPreview, region, sizePx]- );- const onKeyDown = useCallback(- (event: ReactKeyboardEvent<HTMLDivElement>) => {- const step = event.shiftKey ? DOCK_SIZE_STEP_PX * 2 : DOCK_SIZE_STEP_PX;- const grow = edge === 'top' ? 'ArrowUp' : 'ArrowDown';- const shrink = edge === 'top' ? 'ArrowDown' : 'ArrowUp';- const change =- event.key === grow- ? step- : event.key === shrink- ? -step- : event.key === 'End'- ? max - sizePx- : event.key === 'Home'- ? min - sizePx- : undefined;- if (change === undefined) {- return;- }- event.preventDefault();- commit(change < 0 && sizePx <= min ? min - 1 : sizePx + change);- },- [commit, edge, max, min, sizePx]- );-- return (- <Box flexShrink={0} h="1px" position="relative" zIndex="1">- <Box- aria-label={t('widgets.dock.resize', { dock: dockName })}- aria-orientation="horizontal"- aria-valuemax={max}- aria-valuemin={min}- aria-valuenow={sizePx}- cursor="ns-resize"- h="2"- left="0"- opacity="0"- position="absolute"- right="0"- role="separator"- tabIndex={0}- top="-4px"- transition="opacity var(--wb-motion-duration-fast) ease"- _focusVisible={HANDLE_FOCUS_PROPS}- _hover={HANDLE_HOVER_PROPS}- onKeyDown={onKeyDown}- onPointerDown={onPointerDown}- />- </Box>- );-};--export { RIGHT_RAIL_DOCKS };diff --git a/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx b/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsxindex d247f5b4d2..fe8158e70e 100644--- a/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx@@ -15,7 +15,6 @@ import { GalleryDragCursor } from '@features/gallery/utility';import { useMountEffect } from '@platform/react/useMountEffect';import { FocusRegionProvider } from '@workbench/focusRegions';import { WidgetIcon } from '@workbench/iconResolver';-import { RIGHT_RAIL_DOCKS, type RightRailDock } from '@workbench/layoutContracts';import { PROJECT_CONTENT_PANEL_ID } from '@workbench/projects/projectTabsA11y';import { WidgetBar, type WidgetBarGroup } from '@workbench/widget-frame';import { FloatingWidgetLayer } from '@workbench/widget-frame/FloatingWidgetLayer';@@ -35,11 +34,7 @@ import {revealWidgetPlacement,} from '@workbench/widgetPlacementCommands';import { areWidgetPlacementProjectsEqual, getWidgetPlacementProject } from '@workbench/widgetPlacementMeta';-import {- createWidgetRegionViewModel,- createWidgetRegionViewModelFromState,- getWidgetRegionItems,-} from '@workbench/widgetRegionViewModel';+import { createWidgetRegionViewModelFromState, getWidgetRegionItems } from '@workbench/widgetRegionViewModel';import { getWidgetById, getWidgetsForRegion, widgetRegistrationFailures } from '@workbench/widgetRegistry';import { useActiveProjectSelector, useWorkbenchCommands } from '@workbench/WorkbenchContext';import { useCallback, useMemo, useState } from 'react';@@ -49,8 +44,7 @@ import { BottomPanel } from './BottomPanel';import { CenterArea } from './CenterArea';import { DocumentTitleProgress } from './DocumentTitleProgress';import { WorkbenchNotificationToaster } from './notifications';-import { LeftPanel } from './Panels';-import { RightRailPanel, type RightRailDockModel, type RightRailItem } from './RightRail';+import { LeftPanel, RightPanel } from './Panels';import { StatusBar } from './StatusBar';import { TopBar } from './topbar';@@ -74,13 +68,7 @@ export const WorkbenchShell = () => {const panels = useActiveProjectSelector((project) => project.layout.panels);const projectName = useActiveProjectSelector((project) => project.name);const leftRegion = useActiveProjectSelector((project) => project.widgetRegions.left);- const rightTopRegion = useActiveProjectSelector((project) => project.widgetRegions.rightTop);const rightRegion = useActiveProjectSelector((project) => project.widgetRegions.right);- const rightBottomRegion = useActiveProjectSelector((project) => project.widgetRegions.rightBottom);- const rightDockRegions = useMemo(- () => ({ right: rightRegion, rightBottom: rightBottomRegion, rightTop: rightTopRegion }),- [rightBottomRegion, rightRegion, rightTopRegion]- );const placementProject = useActiveProjectSelector(getWidgetPlacementProject, areWidgetPlacementProjectsEqual);const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),@@ -102,70 +90,37 @@ export const WorkbenchShell = () => {}),[getWidgetLabel, leftRegion, placementProject.widgetInstances]);- // One view model per dock for the rail groups and the docks themselves, plus- // a rail-wide one so the menu counts a widget placed in any dock as placed.- const rightDockViewModels = useMemo(+ const rightRegionViewModel = useMemo(() =>- RIGHT_RAIL_DOCKS.map((dock) =>- createWidgetRegionViewModelFromState({- region: dock,- regionState: rightDockRegions[dock],- widgetInstances: placementProject.widgetInstances,- widgets: getWidgetsForRegion('right'),- getWidgetLabel,- })- ),- [getWidgetLabel, placementProject.widgetInstances, rightDockRegions]- );- const rightRailViewModel = useMemo(- () =>- createWidgetRegionViewModel({- activeInstanceId: rightRegion.activeInstanceId,- instanceIds: RIGHT_RAIL_DOCKS.flatMap((dock) => rightDockRegions[dock].instanceIds),+ createWidgetRegionViewModelFromState({region: 'right',+ regionState: rightRegion,widgetInstances: placementProject.widgetInstances,widgets: getWidgetsForRegion('right'),getWidgetLabel,}),- [getWidgetLabel, placementProject.widgetInstances, rightDockRegions, rightRegion.activeInstanceId]+ [getWidgetLabel, placementProject.widgetInstances, rightRegion]);const leftMenuItems = useMemo(() => getWidgetRegionItems(leftRegionViewModel), [leftRegionViewModel]);- const rightMenuItems = useMemo(() => getWidgetRegionItems(rightRailViewModel), [rightRailViewModel]);+ const rightMenuItems = useMemo(() => getWidgetRegionItems(rightRegionViewModel), [rightRegionViewModel]);const leftRailItems = useMemo(() => leftRegionViewModel.placedItems.filter((item) => item.status !== 'disabled'),[leftRegionViewModel]);+ const rightRailItems = useMemo(+ () => rightRegionViewModel.placedItems.filter((item) => item.status !== 'disabled'),+ [rightRegionViewModel]+ );const canShowLeftPanel = leftRailItems.some((item) => item.id === leftRegion.activeInstanceId);+ const canShowRightPanel = rightRailItems.some((item) => item.id === rightRegion.activeInstanceId);const leftDropState = useMemo(() => getRegionDropState(placementProject, activeDrag, 'left', getWidgetById),[activeDrag, placementProject]);- const rightDocks = useMemo(- () =>- RIGHT_RAIL_DOCKS.map((dock, index): RightRailDockModel => {- const state = rightDockRegions[dock];- const items = rightDockViewModels[index]!.placedItems.filter((item) => item.status !== 'disabled');- return {- activeId: items.some((item) => item.id === state.activeInstanceId) ? state.activeInstanceId : null,- dropState: getRegionDropState(placementProject, activeDrag, dock, getWidgetById),- items,- region: dock,- state,- };- }),- [activeDrag, placementProject, rightDockRegions, rightDockViewModels]- );- const rightRailGroups = useMemo(- () =>- rightDocks.map((dock) => ({- activeId: panels.isRightOpen && !dock.state.isCollapsed ? dock.activeId : null,- dropState: dock.dropState,- railItems: dock.items,- region: dock.region,- })),- [panels.isRightOpen, rightDocks]+ const rightDropState = useMemo(+ () => getRegionDropState(placementProject, activeDrag, 'right', getWidgetById),+ [activeDrag, placementProject]);- const canShowRightPanel = rightDocks.some((dock) => dock.items.length > 0 && !dock.state.isCollapsed);const bottomDropState = useMemo(() => getRegionDropState(placementProject, activeDrag, 'bottom', getWidgetById),[activeDrag, placementProject]@@ -248,31 +203,22 @@ export const WorkbenchShell = () => {}),[placementProject, widgets]);- // Closing finds the dock that holds the instance; opening lands in the dock the manifest prefers.const handleToggleRight = useCallback(- (item: (typeof rightMenuItems)[number]) => {- if (item.isEnabled) {- const region = RIGHT_RAIL_DOCKS.find((dock) => rightDockRegions[dock].instanceIds.includes(item.id));- return region- ? closeWidgetPlacement({ widgets, getWidgetById, instanceId: item.id, project: placementProject, region })- : { ok: false as const, reason: 'not-found' as const };- }- const preferred = item.widget.manifest.rightDock ?? 'right';- return openWidgetPlacement({- widgets,- getWidgetsForRegion,- options: {- createNew: item.allowMultiple,- preferredRegions: [preferred, ...RIGHT_RAIL_DOCKS.filter((dock) => dock !== preferred)],- },- typeId: item.typeId,- });- },- [placementProject, rightDockRegions, widgets]- );- const handleRemoveFromDock = useCallback(- (region: RightRailDock, item: RightRailItem) =>- closeWidgetPlacement({ widgets, getWidgetById, instanceId: item.id, project: placementProject, region }),+ (item: (typeof rightMenuItems)[number]) =>+ item.isEnabled+ ? closeWidgetPlacement({+ widgets,+ getWidgetById,+ instanceId: item.id,+ project: placementProject,+ region: 'right',+ })+ : openWidgetPlacement({+ widgets,+ getWidgetsForRegion,+ options: { createNew: item.allowMultiple, preferredRegions: ['right'] },+ typeId: item.typeId,+ }),[placementProject, widgets]);const leftRailGroups = useMemo(@@ -286,6 +232,17 @@ export const WorkbenchShell = () => {],[leftDropState, leftRailItems, leftRegion.activeInstanceId, leftRegion.isCollapsed, panels.isLeftOpen]);+ const rightRailGroups = useMemo(+ () => [+ {+ activeId: panels.isRightOpen && !rightRegion.isCollapsed ? rightRegion.activeInstanceId : null,+ dropState: rightDropState,+ railItems: rightRailItems,+ region: 'right' as const,+ },+ ],+ [panels.isRightOpen, rightDropState, rightRailItems, rightRegion.activeInstanceId, rightRegion.isCollapsed]+ );return (<FocusRegionProvider>@@ -329,8 +286,8 @@ export const WorkbenchShell = () => {<LeftPanel instanceId={leftRegion.activeInstanceId} />) : null}<CenterArea />- {panels.isRightOpen && canShowRightPanel ? (- <RightRailPanel docks={rightDocks} onRemove={handleRemoveFromDock} onSelect={handleSelect} />+ {panels.isRightOpen && !rightRegion.isCollapsed && canShowRightPanel ? (+ <RightPanel instanceId={rightRegion.activeInstanceId} />) : null}<WidgetBargroups={rightRailGroups}diff --git a/invokeai/frontend/webv2/src/workbench/shell/index.ts b/invokeai/frontend/webv2/src/workbench/shell/index.tsindex 227f599a13..6793a6b4f7 100644--- a/invokeai/frontend/webv2/src/workbench/shell/index.ts+++ b/invokeai/frontend/webv2/src/workbench/shell/index.ts@@ -1,7 +1,7 @@export { WorkbenchShell } from './WorkbenchShell';export { BottomPanel } from './BottomPanel';export { CenterArea } from './CenterArea';-export { LeftPanel } from './Panels';+export { LeftPanel, RightPanel } from './Panels';export { StatusBar } from './StatusBar';export { TopBar } from './topbar';export { WorkbenchNotificationToaster } from './notifications';diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsxindex 377fec4f09..01a8c04289 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFailureBoundary.tsx@@ -13,7 +13,7 @@ import { TriangleAlertIcon } from 'lucide-react';import { Component, type ErrorInfo, type ReactNode } from 'react';import { useTranslation } from 'react-i18next';-import { WidgetDockFrame, WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';+import { WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';interface WidgetFailureBoundaryProps {children: ReactNode;@@ -161,32 +161,18 @@ const WidgetFailureFallback = ({);}- const isDock = region === 'rightTop' || region === 'right' || region === 'rightBottom';- const isPanel = region === 'left' || region === 'bottom';+ const isPanel = region === 'left' || region === 'right' || region === 'bottom';- if (!isDock && !isPanel && region !== 'center') {+ if (!isPanel && region !== 'center') {return <WidgetFailureCard details={details} label={label} onCopy={onCopy} onRetry={onRetry} />;}- const card = (- <Box flex="1" minH="0" overflow="auto" p="2">- <WidgetFailureCard details={details} label={label} onCopy={onCopy} onRetry={onRetry} />- </Box>- );-- // A dock's tab strip carries the identity, so only the card is framed there.- if (isDock) {- return (- <WidgetDockFrame instanceId={instance?.id} region={region} typeId={instance?.typeId}>- {card}- </WidgetDockFrame>- );- }-const framed = (<>{widget?.manifest.chrome?.header === 'hidden' ? null : <WidgetFailureHeader label={label} region={region} />}- {card}+ <Box flex="1" minH="0" overflow="auto" p="2">+ <WidgetFailureCard details={details} label={label} onCopy={onCopy} onRetry={onRetry} />+ </Box></>);diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsxindex 244aaa282a..c76191fcc2 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetFrames.tsx@@ -1,4 +1,4 @@-import type { RightRailDock, WidgetRegion } from '@workbench/layoutContracts';+import type { WidgetRegion } from '@workbench/layoutContracts';import type {WidgetInstanceId,WidgetInstanceRuntimeMeta,@@ -16,7 +16,6 @@ import { useMountEffect } from '@platform/react/useMountEffect';import { IconButton } from '@platform/ui/Button';import { Tooltip } from '@platform/ui/Tooltip';import { useFocusRegionProps } from '@workbench/focusRegions';-import { RIGHT_RAIL_DOCKS } from '@workbench/layoutContracts';import { openWorkbenchSettings } from '@workbench/settings/settingsDialogStore';import { resolveWidgetInstanceLabel } from '@workbench/widgetLabels';import { getEnabledCenterViewCount } from '@workbench/widgetPlacementCommands';@@ -93,13 +92,6 @@ export const WidgetPanelFrame = ({},[layout, region, regionState.sizePx]);- // The right panel frames every dock of its rail, so shutting it shuts them all.- const collapse = useCallback(() => {- for (const target of region === 'right' ? RIGHT_RAIL_DOCKS : [region]) {- layout.setRegionCollapsed(target, true);- }- }, [layout, region]);-const handlePointerDown = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {event.preventDefault();@@ -141,7 +133,7 @@ export const WidgetPanelFrame = ({if (nextDrag.isSnappedShut) {// Visibility change, not a resize — `sizePx` keeps the width the user// chose so the rail button reopens the panel where they left it.- collapse();+ layout.setRegionCollapsed(region, true);return;}@@ -160,7 +152,7 @@ export const WidgetPanelFrame = ({window.addEventListener('pointerup', handlePointerUp, { signal: pointerSession.signal });window.addEventListener('pointercancel', handlePointerCancel, { signal: pointerSession.signal });},- [collapse, commitSize, isBottom, isLeft, region, regionState.sizePx]+ [commitSize, isBottom, isLeft, layout, region, regionState.sizePx]);const handleKeyDown = useCallback(@@ -190,14 +182,14 @@ export const WidgetPanelFrame = ({// Keyboard parity with the drag: a further collapse-ward step at the// floor collapses, instead of silently clamping forever.if (sizeChange < 0 && displaySizePx <= minPanelSizePx) {- collapse();+ layout.setRegionCollapsed(region, true);return;}commitSize(displaySizePx + sizeChange);},- [collapse, commitSize, displaySizePx, isBottom, isLeft, maxPanelSizePx, minPanelSizePx]+ [commitSize, displaySizePx, isBottom, isLeft, layout, maxPanelSizePx, minPanelSizePx, region]);const panelSizeProps = useMemo(() => (isBottom ? { h: `${renderSizePx}px`, w: 'full' } : { h: 'full', w: `${renderSizePx}px` }),@@ -261,42 +253,6 @@ export const WidgetPanelFrame = ({);};-/**- * A widget's box inside a right-rail dock. The dock's tab strip is the header- * and the rail panel owns width and resizing, so this frame carries only the- * hotkey and focus-region identity of the instance it shows.- */-export const WidgetDockFrame = ({- children,- instanceId,- region,- typeId,-}: {- children: ReactNode;- instanceId?: WidgetInstanceId;- region: RightRailDock;- typeId?: WidgetTypeId;-}) => {- const focusRegionProps = useFocusRegionProps(region);-- return (- <Flex- bg="bg.subtle"- data-hotkey-widget-instance-id={instanceId}- data-hotkey-widget-region={region}- data-hotkey-widget-type-id={typeId}- direction="column"- h="full"- minH="0"- overflow="hidden"- w="full"- {...focusRegionProps}- >- {children}- </Flex>- );-};-/*** 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 dockdiff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetLoadingFallback.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetLoadingFallback.tsxindex 30034325bc..ab44007f36 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetLoadingFallback.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetLoadingFallback.tsx@@ -5,7 +5,7 @@ import { chipRecipe } from '@theme/recipes';import { resolveWidgetInstanceLabel } from '@workbench/widgetLabels';import { useTranslation } from 'react-i18next';-import { WidgetDockFrame, WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';+import { WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';import { WidgetIdentityIcon } from './WidgetIdentityIcon';interface WidgetLoadingFallbackProps {@@ -133,16 +133,7 @@ export const WidgetLoadingFallback = ({ instance, presentation, region, widget }return <TooltipWidgetLoadingFallback label={label} loadingLabel={loadingLabel} widget={widget} />;}- // A dock's tab strip already names the widget; the loading body is all a dock paints.- if (region === 'rightTop' || region === 'right' || region === 'rightBottom') {- return (- <WidgetDockFrame instanceId={instance.id} region={region} typeId={instance.typeId}>- <WidgetLoadingSurface bg="bg.subtle" label={loadingLabel} />- </WidgetDockFrame>- );- }-- if (region === 'left' || region === 'bottom') {+ if (region === 'left' || region === 'right' || region === 'bottom') {return (<WidgetPanelFrame instanceId={instance.id} region={region} typeId={instance.typeId}>{widget.manifest.chrome?.header === 'hidden' ? null : <WidgetLoadingHeader label={label} widget={widget} />}diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsxindex 1b81fc512c..91ee80c341 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetPanelFrame.browser.test.tsx@@ -237,12 +237,7 @@ describe('WidgetPanelFrame resize', () => {await interact(() => window.dispatchEvent(new PointerEvent('pointermove', { clientX: 190 })));await interact(() => window.dispatchEvent(new PointerEvent('pointerup', { clientX: 190 })));- // The right panel frames the whole rail, so shutting it shuts every dock.- expect(frameMocks.setRegionCollapsed.mock.calls).toEqual([- ['rightTop', true],- ['right', true],- ['rightBottom', true],- ]);+ expect(frameMocks.setRegionCollapsed).toHaveBeenCalledExactlyOnceWith('right', true);});it('measures the bottom strip vertically against its own floor', async () => {diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsxindex 9dcb68896b..e6653974b4 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx@@ -20,13 +20,7 @@ import { memo, Suspense, use, useMemo } from 'react';import { useWidgetRuntime } from './createWidgetRuntime';import { WidgetFailureBoundary } from './WidgetFailureBoundary';-import {- WidgetDockFrame,- WidgetHeader,- WidgetHeaderActionsGroup,- WidgetPanelFrame,- WidgetTooltipFrame,-} from './WidgetFrames';+import { WidgetHeader, WidgetHeaderActionsGroup, WidgetPanelFrame, WidgetTooltipFrame } from './WidgetFrames';import { WidgetLoadingFallback } from './WidgetLoadingFallback';import { areProjectWidgetRenderInstancesEqual } from './widgetRenderInstance';@@ -268,25 +262,7 @@ const WidgetShellFrame = ({return safeContent;}- // A right-rail dock hoists the header into its tab strip (`RightRail`), the- // way the center region floats its chrome; the body and footer run here.- if (region === 'rightTop' || region === 'right' || region === 'rightBottom') {- return (- <WidgetDockFrame instanceId={instance.id} region={region} typeId={instance.typeId}>- <PanelBodySlot>{safeContent}</PanelBodySlot>- <FooterSlot- implementation={implementation}- instance={instance}- presentation={presentation}- region={region}- runtime={runtime}- widget={widget}- />- </WidgetDockFrame>- );- }-- if (region === 'left' || region === 'bottom') {+ if (region === 'left' || region === 'right' || region === 'bottom') {return (<WidgetPanelFrame instanceId={instance.id} region={region} typeId={instance.typeId}><HeaderSlot@@ -470,24 +446,15 @@ const FooterSlot = memo(function FooterSlot({);}, areSlotPropsEqual);-const MissingWidgetNotice = ({ label }: { label: string }) => (- <Box p="3">- <Text fontSize="xs" fontWeight="700">- {label}- </Text>- <Text color="fg.subtle" fontSize="2xs">- Widget view unavailable.- </Text>- </Box>+export const MissingWidgetFrame = ({ label, region }: { label: string; region: Exclude<WidgetRegion, 'center'> }) => (+ <WidgetPanelFrame region={region}>+ <Box p="3">+ <Text fontSize="xs" fontWeight="700">+ {label}+ </Text>+ <Text color="fg.subtle" fontSize="2xs">+ Widget view unavailable.+ </Text>+ </Box>+ </WidgetPanelFrame>);--export const MissingWidgetFrame = ({ label, region }: { label: string; region: Exclude<WidgetRegion, 'center'> }) =>- region === 'rightTop' || region === 'right' || region === 'rightBottom' ? (- <WidgetDockFrame region={region}>- <MissingWidgetNotice label={label} />- </WidgetDockFrame>- ) : (- <WidgetPanelFrame region={region}>- <MissingWidgetNotice label={label} />- </WidgetPanelFrame>- );diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsxindex a10b321e77..b8b9aee266 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetStrip.tsx@@ -1,6 +1,6 @@import type { WidgetRegion } from '@workbench/layoutContracts';import type { WidgetInstanceId } from '@workbench/widgetContracts';-import type { WidgetDndSurface, WidgetRegionDropState } from '@workbench/widgetDnd';+import type { WidgetRegionDropState } from '@workbench/widgetDnd';import { Flex, type FlexProps } from '@chakra-ui/react';import { useDroppable } from '@dnd-kit/core';@@ -16,7 +16,6 @@ interface WidgetStripProps extends FlexProps {region: WidgetRegion;sortableInstanceIds: WidgetInstanceId[];strategy: SortingStrategy;- surface?: WidgetDndSurface;}export const WidgetStrip = ({@@ -25,17 +24,16 @@ export const WidgetStrip = ({region,sortableInstanceIds,strategy,- surface = 'rail',...props}: WidgetStripProps) => {const { isOver, setNodeRef } = useDroppable({data: getWidgetRegionDropData(region),disabled: !dropState.isActive || !dropState.isAllowed,- id: getWidgetRegionDropId(region, surface),+ id: getWidgetRegionDropId(region),});const sortableItems = useMemo(- () => sortableInstanceIds.map((id) => getWidgetInstanceDragId(region, id, surface)),- [region, sortableInstanceIds, surface]+ () => sortableInstanceIds.map((id) => getWidgetInstanceDragId(region, id)),+ [region, sortableInstanceIds]);return (diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/createWidgetRuntime.test.ts b/invokeai/frontend/webv2/src/workbench/widget-frame/createWidgetRuntime.test.tsindex 5ad49f3b63..1c2e7feeb9 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/createWidgetRuntime.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/createWidgetRuntime.test.ts@@ -100,8 +100,6 @@ const createPlacementProject = (center: { activeInstanceId: 'alpha', instanceIds: [], isCollapsed: false, sizePx: 240 },left: { activeInstanceId: 'alpha', instanceIds: [], isCollapsed: false, sizePx: 240 },right: { activeInstanceId: 'alpha', instanceIds: ['alpha'], isCollapsed: false, sizePx: 240 },- rightBottom: { activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 240 },- rightTop: { activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 240 },...overrides.widgetRegions,},});@@ -253,8 +251,6 @@ describe('createWidgetRuntime', () => {center: { activeInstanceId: 'alpha', instanceIds: [], isCollapsed: false, sizePx: 240 },left: { activeInstanceId: 'alpha', instanceIds: [], isCollapsed: false, sizePx: 240 },right: { activeInstanceId: 'alpha', instanceIds: [], isCollapsed: false, sizePx: 240 },- rightBottom: { activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 240 },- rightTop: { activeInstanceId: '', instanceIds: [], isCollapsed: true, sizePx: 240 },},}),region: 'bottom',diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/useWidgetSortable.ts b/invokeai/frontend/webv2/src/workbench/widget-frame/useWidgetSortable.tsindex f4bdc80c67..e34503b33f 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/useWidgetSortable.ts+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/useWidgetSortable.ts@@ -4,21 +4,19 @@ import type { CSSProperties, KeyboardEvent as ReactKeyboardEvent } from 'react';import { useSortable } from '@dnd-kit/sortable';import { CSS } from '@dnd-kit/utilities';-import { getWidgetInstanceDragData, getWidgetInstanceDragId, type WidgetDndSurface } from '@workbench/widgetDnd';+import { getWidgetInstanceDragData, getWidgetInstanceDragId } from '@workbench/widgetDnd';import { useCallback } from 'react';export const useWidgetSortable = ({disabled,instanceId,region,- surface = 'rail',typeId,}: {region: WidgetRegion;instanceId: WidgetInstanceId;typeId: WidgetTypeId;disabled?: boolean;- surface?: WidgetDndSurface;}): {setNodeRef: ReturnType<typeof useSortable>['setNodeRef'];style: CSSProperties;@@ -29,7 +27,7 @@ export const useWidgetSortable = ({const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition } = useSortable({data: getWidgetInstanceDragData(region, instanceId, typeId),disabled,- id: getWidgetInstanceDragId(region, instanceId, surface),+ id: getWidgetInstanceDragId(region, instanceId),});const setSortableNodeRef = useCallback((node: HTMLElement | null) => {diff --git a/invokeai/frontend/webv2/src/workbench/widgetContracts.ts b/invokeai/frontend/webv2/src/workbench/widgetContracts.tsindex 910ea15262..191eac006f 100644--- a/invokeai/frontend/webv2/src/workbench/widgetContracts.ts+++ b/invokeai/frontend/webv2/src/workbench/widgetContracts.ts@@ -5,7 +5,7 @@ import type { DeferredResource, DeferredResourceStatus } from './deferredResourcimport type { DeveloperLogNamespace } from './diagnostics/contracts';import type { GraphId } from './graphContracts';import type { InvocationSourceId } from './invocationContracts';-import type { RightRailDock, WidgetRegion } from './layoutContracts';+import type { WidgetRegion } from './layoutContracts';export type FirstPartyWidgetTypeId =| 'autosave-status'@@ -34,16 +34,7 @@ export type WidgetInstanceId = string;export type WidgetId = WidgetTypeId;-export type WorkbenchRegion =- | 'left'- | 'right'- | 'rightTop'- | 'rightBottom'- | 'center'- | 'bottom'- | 'dialog'- | 'popover'- | 'floating';+export type WorkbenchRegion = 'left' | 'right' | 'center' | 'bottom' | 'dialog' | 'popover' | 'floating';export interface WidgetStateContract {id: WidgetTypeId;@@ -302,10 +293,7 @@ export interface WidgetManifest {label: WidgetLabel;headerLabel?: WidgetHeaderLabel;version: 1;- /** Rails the widget may dock in; `right` covers every dock of the right rail. */allowedRegions: WidgetRegion[];- /** The right-rail dock a newly opened instance prefers; `right` (the middle) unless said otherwise. */- rightDock?: RightRailDock;allowMultiple: boolean;icon: WidgetIconComponent;bottomPanel?: 'expandable' | 'tooltip';diff --git a/invokeai/frontend/webv2/src/workbench/widgetDnd.ts b/invokeai/frontend/webv2/src/workbench/widgetDnd.tsindex 5b5fd6beb1..36ce43f1d3 100644--- a/invokeai/frontend/webv2/src/workbench/widgetDnd.ts+++ b/invokeai/frontend/webv2/src/workbench/widgetDnd.ts@@ -111,18 +111,10 @@ export type WidgetDragEndResolution =type: 'move';};-/** The rail lists a region and a dock strip shows the same region; each surface registers its own dnd ids. */-export type WidgetDndSurface = 'rail' | 'dock';+export const getWidgetInstanceDragId = (region: WidgetRegion, instanceId: WidgetInstanceId): string =>+ `widget-instance:${region}:${instanceId}`;-export const getWidgetInstanceDragId = (- region: WidgetRegion,- instanceId: WidgetInstanceId,- surface: WidgetDndSurface = 'rail'-): string =>- surface === 'rail' ? `widget-instance:${region}:${instanceId}` : `widget-instance:dock:${region}:${instanceId}`;--export const getWidgetRegionDropId = (region: WidgetRegion, surface: WidgetDndSurface = 'rail'): string =>- surface === 'rail' ? `widget-region:${region}` : `widget-region:dock:${region}`;+export const getWidgetRegionDropId = (region: WidgetRegion): string => `widget-region:${region}`;export const getWidgetInstanceDragData = (region: WidgetRegion,diff --git a/invokeai/frontend/webv2/src/workbench/widgetPlacementCommands.ts b/invokeai/frontend/webv2/src/workbench/widgetPlacementCommands.tsindex db698b43fb..279ffdbec3 100644--- a/invokeai/frontend/webv2/src/workbench/widgetPlacementCommands.ts+++ b/invokeai/frontend/webv2/src/workbench/widgetPlacementCommands.ts@@ -19,14 +19,7 @@ export interface WidgetPlacementProject {widgetRegions: Record<WidgetRegion, Pick<WidgetRegionState, 'activeInstanceId' | 'instanceIds'>>;}-const DEFAULT_OPEN_REGIONS: ReadonlyArray<WidgetRegion> = [- 'center',- 'right',- 'rightTop',- 'rightBottom',- 'left',- 'bottom',-];+const DEFAULT_OPEN_REGIONS: ReadonlyArray<WidgetRegion> = ['center', 'right', 'left', 'bottom'];export type WidgetPlacementCommandResult = WidgetWorkbenchApiResult;diff --git a/invokeai/frontend/webv2/src/workbench/widgetRegistry.test.ts b/invokeai/frontend/webv2/src/workbench/widgetRegistry.test.tsindex 6c930e3fd0..c2ce0d9f39 100644--- a/invokeai/frontend/webv2/src/workbench/widgetRegistry.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgetRegistry.test.ts@@ -32,10 +32,8 @@ describe('widget registry', () => {it('registers first-party widget manifests without icon validation failures', () => {const widgets = registerFirstPartyWidgets();- expect(widgets).toHaveLength(19);- expect(widgets.map((widget) => widget.manifest.id)).toEqual(- expect.arrayContaining(['layers', 'properties', 'transform', 'image-map'])- );+ expect(widgets).toHaveLength(17);+ expect(widgets.map((widget) => widget.manifest.id)).toEqual(expect.arrayContaining(['layers', 'image-map']));expect(widgets.flatMap((widget) => widget.failure ?? [])).toEqual([]);expect(widgets.every((widget) => widget.status === 'enabled')).toBe(true);});diff --git a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts b/invokeai/frontend/webv2/src/workbench/widgetRegistry.tsindex daa9c1786f..18973281dd 100644--- a/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts+++ b/invokeai/frontend/webv2/src/workbench/widgetRegistry.ts@@ -8,7 +8,6 @@ import type {} from '@workbench/widgetContracts';import { getAuthSession } from '@features/identity';-import { RIGHT_RAIL_DOCKS } from '@workbench/layoutContracts';import { createDeferredResource } from './deferredResource';import { createWidgetImplementationResource } from './widgetImplementationResource';@@ -22,11 +21,9 @@ import { layersWidgetManifest } from './widgets/layers/manifest';import { notificationsWidgetManifest } from './widgets/notifications/manifest';import { previewWidgetManifest } from './widgets/preview/manifest';import { projectWidgetManifest } from './widgets/project/manifest';-import { propertiesWidgetManifest } from './widgets/properties/manifest';import { queueStatusWidgetManifest } from './widgets/queue-status/manifest';import { queueWidgetManifest } from './widgets/queue/manifest';import { serverStatusWidgetManifest } from './widgets/server-status/manifest';-import { transformWidgetManifest } from './widgets/transform/manifest';import { upscaleWidgetManifest } from './widgets/upscale/manifest';import { versionStatusWidgetManifest } from './widgets/version-status/manifest';import { videoWidgetManifest } from './widgets/video/manifest';@@ -44,8 +41,6 @@ export const firstPartyWidgetManifests: WidgetManifest[] = [previewWidgetManifest,projectWidgetManifest,layersWidgetManifest,- propertiesWidgetManifest,- transformWidgetManifest,queueWidgetManifest,notificationsWidgetManifest,serverStatusWidgetManifest,@@ -61,7 +56,7 @@ const createFailure = (widgetId: WidgetTypeId, error: unknown): WidgetFailure =>widgetId,});-const renderableRegions = new Set<WidgetRegion>(['bottom', 'center', 'left', 'right', 'rightTop', 'rightBottom']);+const renderableRegions = new Set<WidgetRegion>(['bottom', 'center', 'left', 'right']);const isWidgetIconComponent = (value: WidgetManifest['icon']): boolean =>typeof value === 'function' || (typeof value === 'object' && value !== null && '$$typeof' in value);@@ -94,15 +89,8 @@ const validateManifest = (manifest: NormalizedWidgetManifest): void => {}};-/** `right` in a manifest means the whole rail: every dock of it accepts the widget. */-const expandRightRail = (allowedRegions: WidgetRegion[]): WidgetRegion[] =>- allowedRegions.includes('right')- ? [...new Set<WidgetRegion>([...allowedRegions, ...RIGHT_RAIL_DOCKS])]- : allowedRegions;-export const normalizeWidgetManifest = (manifest: WidgetManifest): NormalizedWidgetManifest => ({...manifest,- allowedRegions: expandRightRail(manifest.allowedRegions),apiVersion: manifest.apiVersion ?? 1,state: manifest.state ?? { createInitial: () => ({}), persistence: 'project', version: 1 },});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/image-map/manifest.ts b/invokeai/frontend/webv2/src/workbench/widgets/image-map/manifest.tsindex d3f3ad3f36..22648c4d12 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/image-map/manifest.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/image-map/manifest.ts@@ -9,7 +9,6 @@ export const imageMapWidgetManifest: WidgetManifest = {failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },icon: MapIcon,id: 'image-map',- rightDock: 'rightBottom',label: (t) => t('widgets.labels.imageMap'),load: () => import('./implementation').then((module) => module.widgetImplementation),loadHost: () => import('./ImageMapDataRuntime').then((module) => module.ImageMapDataRuntime),diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsxindex 81048b0f07..28c5e4e5eb 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersWidgetView.tsx@@ -1,4 +1,5 @@import type { LayerPanelDensity } from '@workbench/layerPanelState';+import type { WidgetViewProps } from '@workbench/widgetContracts';import { Flex, Icon, Stack, Text } from '@chakra-ui/react';import { getDocumentIndex } from '@workbench/canvas-engine/api';@@ -11,20 +12,25 @@ import { LayersIcon } from 'lucide-react';import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';+import type { LayerEditorPaneLayout } from './panes/editorPaneLayout';+import { LayerMultiSelectionActions } from './LayerMultiSelectionActions';import { LAYER_PANEL_DEGRADE_THRESHOLD } from './layerPanelRows';import { LayersPanelFooter } from './LayersPanelFooter';import { LayersPanelHeader } from './LayersPanelHeader';import { LayersTree } from './LayersTree';import { buildLayerStackRows } from './layerTreeRows';+import { areLayerEditorPaneLayoutsEqual, readLayerEditorPaneLayout } from './panes/editorPaneLayout';+import { LayerEditorPanes } from './panes/LayerEditorPanes';/*** The layers panel: a fixed header (selected layer's opacity + blend mode, global denoising* strength), a fixed selection toolbar, the virtualized tree of the four stacks, and a fixed- * footer (summary, filter, density). Regions keep their geometry; their controls disable instead- * of appearing and disappearing.+ * footer (summary, filter, density), and the editor panes (Properties, Transform) docked at the+ * bottom. Regions keep their geometry; their controls disable instead of appearing and+ * disappearing.*/-export const LayersWidgetView = () => {+export const LayersWidgetView = ({ runtime }: WidgetViewProps) => {const { t } = useTranslation();const engine = useCanvasEngine();const projectId = useActiveProjectId();@@ -59,6 +65,14 @@ export const LayersWidgetView = () => {(filter: string) => setLayerPanelFilter(projectId, selectedLayerId, filter),[projectId, selectedLayerId]);+ const paneLayout = useActiveProjectSelector(+ (project) => readLayerEditorPaneLayout(project.widgetInstances[runtime.instanceId]?.state.values ?? {}),+ areLayerEditorPaneLayoutsEqual+ );+ const handlePaneLayout = useCallback(+ (next: LayerEditorPaneLayout) => runtime.state.patch({ editorPanes: next }),+ [runtime.state]+ );return (<Stack gap="1" h="full" minH="0">@@ -92,16 +106,18 @@ export const LayersWidgetView = () => {</Text></Flex>) : (- <LayersTree- degraded={degraded}- dispatch={dispatch}- document={document}- editingLocked={editingLocked}- engine={engine}- panel={panel}- projectId={projectId}- stacks={stacks}- />+ <Flex direction="column" flex="1" minH="8rem">+ <LayersTree+ degraded={degraded}+ dispatch={dispatch}+ document={document}+ editingLocked={editingLocked}+ engine={engine}+ panel={panel}+ projectId={projectId}+ stacks={stacks}+ />+ </Flex>)}<LayersPanelFooterdegraded={degraded}@@ -113,6 +129,7 @@ export const LayersWidgetView = () => {onDensityChange={handleDensity}onFilterChange={handleFilter}/>+ <LayerEditorPanes layout={paneLayout} onLayoutChange={handlePaneLayout} /></Stack>);};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/manifest.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/manifest.tsindex 06bf4e8702..edcdb7e213 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/manifest.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/manifest.ts@@ -2,6 +2,8 @@ import type { WidgetManifest } from '@workbench/widgetContracts';import { LayersIcon } from 'lucide-react';+import { LAYER_EDITOR_PANE_DEFAULTS } from './panes/editorPaneLayout';+export const layersWidgetManifest: WidgetManifest = {allowMultiple: false,allowedRegions: ['right'],@@ -10,5 +12,10 @@ export const layersWidgetManifest: WidgetManifest = {id: 'layers',label: (t) => t('widgets.labels.layers'),load: () => import('./implementation').then((module) => module.widgetImplementation),+ state: {+ createInitial: () => ({ editorPanes: { ...LAYER_EDITOR_PANE_DEFAULTS } }),+ persistence: 'project',+ version: 1,+ },version: 1,};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/GroupSelectedNotice.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsxsimilarity index 100%rename from invokeai/frontend/webv2/src/workbench/widgets/properties/GroupSelectedNotice.tsxrename to invokeai/frontend/webv2/src/workbench/widgets/layers/panes/GroupSelectedNotice.tsxdiff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgets.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsxsimilarity index 81%rename from invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgets.browser.test.tsxrename to invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsxindex abb91ccac8..f00ae2de8d 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgets.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx@@ -4,7 +4,6 @@ import type { CanvasEngine } from '@workbench/canvas-operations/createCanvasEngiimport type { FilterOperationSessionState } from '@workbench/canvas-operations/filterOperationSession';import type { CanvasProjectMutationPort } from '@workbench/canvasProjectMutationPort';import type { Project } from '@workbench/projectContracts';-import type { WidgetViewProps } from '@workbench/widgetContracts';import { ChakraProvider } from '@chakra-ui/react';import { system } from '@theme/system';@@ -23,7 +22,7 @@ import { createEmptyCanvasDocument, createEmptyCanvasState } from '@workbench/caimport { applyCanvasProjectMutation } from '@workbench/canvasProjectMutations';import { createInitialWorkbenchState } from '@workbench/workbenchState';import { createInstance } from 'i18next';-import { act } from 'react';+import { act, useState } from 'react';import { createRoot, type Root } from 'react-dom/client';import { I18nextProvider } from 'react-i18next';import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest';@@ -40,9 +39,12 @@ vi.mock('@workbench/useCanvasProjectMutationDispatch', () => ({}));vi.mock('@workbench/widgets/canvas/useCanvasEngine', () => ({ useCanvasEngine: () => harness.engine }));-import { TransformWidgetView } from '@workbench/widgets/transform/TransformWidgetView';+import type { LayerEditorPaneLayout } from './editorPaneLayout';-import { PropertiesWidgetView } from './PropertiesWidgetView';+import { LAYER_EDITOR_PANE_DEFAULTS } from './editorPaneLayout';+import { LayerEditorPanes } from './LayerEditorPanes';+import { PropertiesPane } from './PropertiesPane';+import { TransformPane } from './TransformPane';const i18n = createInstance();beforeAll(async () => {@@ -130,12 +132,11 @@ const settle = () =>}));-const viewProps = {} as WidgetViewProps;const IDENTITY = { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 };type Selection = 'none' | 'layer' | 'group';-const mount = async (View: typeof PropertiesWidgetView, selection: Selection = 'none') => {+const mount = async (View: typeof PropertiesPane, selection: Selection = 'none') => {const base = { ...createInitialWorkbenchState().projects[0]!, id: 'p' };const nodes =selection === 'none'@@ -164,7 +165,7 @@ const mount = async (View: typeof PropertiesWidgetView, selection: Selection = 'root?.render(<I18nextProvider i18n={i18n}><ChakraProvider value={system}>- <View {...viewProps} />+ <View /></ChakraProvider></I18nextProvider>);@@ -183,9 +184,15 @@ afterEach(async () => {harness.engine = null;});-describe('Properties widget', () => {+let paneHarnessLayout: LayerEditorPaneLayout = { ...LAYER_EDITOR_PANE_DEFAULTS };+const LayerEditorPanesHarness = () => {+ const [layout, setLayout] = useState(paneHarnessLayout);+ return <LayerEditorPanes layout={layout} onLayoutChange={setLayout} />;+};++describe('Properties pane', () => {it('shows the active tool as labelled rows and swaps them with the tool', async () => {- await mount(PropertiesWidgetView);+ await mount(PropertiesPane);await act(() => engine!.tools.setTool('brush'));await settle();expect(host!.textContent).toContain('Brush');@@ -201,7 +208,7 @@ describe('Properties widget', () => {});it('puts a running operation first with Cancel, locks the tool rows in place and hands them focus over', async () => {- await mount(PropertiesWidgetView);+ await mount(PropertiesPane);await act(() => engine!.tools.setTool('brush'));await settle();await act(() => page.getByRole('slider', { exact: true, name: 'Brush size' }).element().focus());@@ -219,16 +226,16 @@ describe('Properties widget', () => {});});-describe('Transform widget', () => {+describe('Transform pane', () => {it('disables its fields with nothing selected and commits one patch per field for a selected layer', async () => {- await mount(TransformWidgetView);+ await mount(TransformPane);expect(host!.textContent).toContain('No layer selected');await expect.element(page.getByRole('spinbutton', { exact: true, name: 'X' })).toBeDisabled();await act(() => root?.unmount());host?.remove();registry?.releaseEngine('p');- await mount(TransformWidgetView, 'layer');+ await mount(TransformPane, 'layer');const commit = vi.spyOn(engine!.layers, 'commitPrepared');const x = page.getByRole('spinbutton', { exact: true, name: 'X' });await expect.element(x).toBeEnabled();@@ -250,7 +257,7 @@ describe('Transform widget', () => {});it('wraps rotation into a half turn and names a selected group instead of editing it', async () => {- await mount(TransformWidgetView, 'layer');+ await mount(TransformPane, 'layer');const commit = vi.spyOn(engine!.layers, 'commitPrepared');const rotation = page.getByRole('spinbutton', { exact: true, name: 'Rotation' });await expect.element(rotation).toHaveValue('28.65');@@ -264,14 +271,14 @@ describe('Transform widget', () => {await act(() => root?.unmount());host?.remove();registry?.releaseEngine('p');- await mount(TransformWidgetView, 'group');+ await mount(TransformPane, 'group');expect(host!.textContent).toContain('Folder');expect(host!.textContent).toContain('Select a layer inside this group to transform.');await expect.element(page.getByRole('spinbutton', { exact: true, name: 'X' })).toBeDisabled();});it('scrubs a field from its label and commits the result once when the mouse button lifts', async () => {- await mount(TransformWidgetView, 'layer');+ await mount(TransformPane, 'layer');// The scrubber locks the pointer once a real click has activated the page; the harness lock steals focus.vi.spyOn(Element.prototype, 'requestPointerLock').mockImplementation(() => Promise.resolve());const commit = vi.spyOn(engine!.layers, 'commitPrepared');@@ -295,3 +302,35 @@ describe('Transform widget', () => {expect(commit).toHaveBeenCalledTimes(1);});});++describe('Layer editor panes host', () => {+ it('keeps the collapsed strip reachable and expands from tab selection', async () => {+ paneHarnessLayout = { ...LAYER_EDITOR_PANE_DEFAULTS };+ await mount(LayerEditorPanesHarness);+ await act(async () => {+ await userEvent.click(page.getByRole('button', { exact: true, name: 'Collapse editor panes' }));+ });+ await settle();+ const propertiesTab = page.getByRole('tab', { exact: true, name: 'Properties' });+ await expect.element(propertiesTab).toHaveAttribute('aria-selected', 'true');+ expect((propertiesTab.element() as HTMLElement).tabIndex).toBe(0);+ expect(host!.querySelector('[role="tabpanel"]')).toBeNull();+ await act(async () => {+ await userEvent.click(propertiesTab);+ });+ await settle();+ expect(host!.querySelector('[role="tabpanel"]')).not.toBeNull();+ });++ it('collapses from the separator keyboard floor and hands focus to the expand button', async () => {+ paneHarnessLayout = { ...LAYER_EDITOR_PANE_DEFAULTS, sizePx: 140 };+ await mount(LayerEditorPanesHarness);+ const separator = host!.querySelector<HTMLElement>('[role="separator"]')!;+ await act(() => separator.focus());+ await act(() => separator.dispatchEvent(new KeyboardEvent('keydown', { bubbles: true, key: 'ArrowDown' })));+ await settle();+ const expand = page.getByRole('button', { exact: true, name: 'Expand editor panes' });+ await expect.element(expand).toBeVisible();+ expect(document.activeElement).toBe(expand.element());+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsxnew file mode 100644index 0000000000..5cb77de4be--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.tsx@@ -0,0 +1,295 @@+import type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from 'react';++import { Box, chakra, Flex, HStack, Icon, Text } from '@chakra-ui/react';+import { useMountEffect } from '@platform/react/useMountEffect';+import { IconButton } from '@platform/ui/Button';+import { Tooltip } from '@platform/ui/Tooltip';+import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react';+import { useCallback, useRef, useState } from 'react';+import { useTranslation } from 'react-i18next';++import type { LayerEditorPaneId, LayerEditorPaneLayout } from './editorPaneLayout';++import {+ clampLayerEditorPaneSize,+ LAYER_EDITOR_PANE_MAX_SIZE_PX,+ LAYER_EDITOR_PANE_MIN_SIZE_PX,+} from './editorPaneLayout';+import { PropertiesPane } from './PropertiesPane';+import { TransformPane } from './TransformPane';++/** The tab strip's height; the collapsed pane block is exactly this tall. */+const STRIP_HEIGHT_PX = 40;+const RESIZE_STEP_PX = 16;+/** Parity with the shell panels: releasing at the floor stops there; collapse asks for a real push past it. */+const COLLAPSE_OVERSHOOT_PX = 80;+const PANEL_ID = 'layer-editor-pane-panel';+const TAB_HOVER_PROPS = { bg: 'bg.muted', color: 'fg' };+const HANDLE_HOVER_PROPS = { bg: 'accent.solid', opacity: 0.45 };+const HANDLE_FOCUS_PROPS = { bg: 'accent.solid', opacity: 0.65, outline: '2px solid {colors.accent.solid}' };++const PANES: ReadonlyArray<{ id: LayerEditorPaneId; labelKey: string }> = [+ { id: 'properties', labelKey: 'widgets.labels.properties' },+ { id: 'transform', labelKey: 'widgets.labels.transform' },+];++/**+ * The Layers widget's editor panes: a fixed block under the tree with one tab+ * per pane — the active tool's Properties and the selected layer's Transform.+ * The panes are part of the panel, not movable widgets; the block keeps a+ * preferred height, collapses to its strip, and persists through the widget's+ * project state.+ */+export const LayerEditorPanes = ({+ layout,+ onLayoutChange,+}: {+ layout: LayerEditorPaneLayout;+ onLayoutChange: (next: LayerEditorPaneLayout) => void;+}) => {+ const { t } = useTranslation();+ const { activePane, isCollapsed, sizePx } = layout;+ // A drag previews the size locally; the store hears about it on release.+ const [previewSizePx, setPreviewSizePx] = useState<number | null>(null);+ const drag = useRef<AbortController | null>(null);+ const toggleRef = useRef<HTMLButtonElement>(null);++ useMountEffect(() => () => drag.current?.abort());++ const patch = useCallback(+ (next: Partial<LayerEditorPaneLayout>) => onLayoutChange({ ...layout, ...next }),+ [layout, onLayoutChange]+ );+ const toggle = useCallback(() => patch({ isCollapsed: !isCollapsed }), [isCollapsed, patch]);+ const selectPane = useCallback(+ (pane: LayerEditorPaneId) =>+ patch(pane === activePane ? { isCollapsed: !isCollapsed } : { activePane: pane, isCollapsed: false }),+ [activePane, isCollapsed, patch]+ );+ const commitSize = useCallback(+ (next: number) => {+ const clamped = clampLayerEditorPaneSize(next);+ if (clamped !== sizePx) {+ patch({ sizePx: clamped });+ }+ },+ [patch, sizePx]+ );+ const onSeparatorPointerDown = useCallback(+ (event: ReactPointerEvent<HTMLDivElement>) => {+ event.preventDefault();+ const startY = event.clientY;+ const controller = new AbortController();+ drag.current?.abort();+ drag.current = controller;+ let latest = sizePx;+ try {+ event.currentTarget.setPointerCapture(event.pointerId);+ } catch {+ // The window listeners carry the drag without capture.+ }+ const move = (moveEvent: PointerEvent) => {+ latest = sizePx + (startY - moveEvent.clientY);+ // Past the overshoot the preview snaps to the strip, so the release's collapse is never a surprise.+ setPreviewSizePx(+ latest <= LAYER_EDITOR_PANE_MIN_SIZE_PX - COLLAPSE_OVERSHOOT_PX+ ? STRIP_HEIGHT_PX+ : clampLayerEditorPaneSize(latest)+ );+ };+ const finish = (apply: boolean) => () => {+ controller.abort();+ setPreviewSizePx(null);+ if (!apply) {+ return;+ }+ if (latest <= LAYER_EDITOR_PANE_MIN_SIZE_PX - COLLAPSE_OVERSHOOT_PX) {+ patch({ isCollapsed: true });+ return;+ }+ commitSize(latest);+ };+ window.addEventListener('pointermove', move, { signal: controller.signal });+ window.addEventListener('pointerup', finish(true), { signal: controller.signal });+ window.addEventListener('pointercancel', finish(false), { signal: controller.signal });+ },+ [commitSize, patch, sizePx]+ );+ const onSeparatorKeyDown = useCallback(+ (event: ReactKeyboardEvent<HTMLDivElement>) => {+ const step = event.shiftKey ? RESIZE_STEP_PX * 2 : RESIZE_STEP_PX;+ const change =+ event.key === 'ArrowUp'+ ? step+ : event.key === 'ArrowDown'+ ? -step+ : event.key === 'End'+ ? LAYER_EDITOR_PANE_MAX_SIZE_PX - sizePx+ : event.key === 'Home'+ ? LAYER_EDITOR_PANE_MIN_SIZE_PX - sizePx+ : undefined;+ if (change === undefined) {+ return;+ }+ event.preventDefault();+ // A further collapse-ward step at the floor collapses; the separator unmounts, so focus moves to the strip first.+ if (change < 0 && sizePx <= LAYER_EDITOR_PANE_MIN_SIZE_PX) {+ toggleRef.current?.focus();+ patch({ isCollapsed: true });+ return;+ }+ commitSize(sizePx + change);+ },+ [commitSize, patch, sizePx]+ );+ const focusSibling = useCallback((event: ReactKeyboardEvent<HTMLElement>) => {+ if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight' && event.key !== 'Home' && event.key !== 'End') {+ return;+ }+ const tabs = [...event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]')];+ const current = tabs.indexOf(document.activeElement as HTMLElement);+ if (current === -1) {+ return;+ }+ event.preventDefault();+ const next =+ event.key === 'Home'+ ? 0+ : event.key === 'End'+ ? tabs.length - 1+ : (current + (event.key === 'ArrowRight' ? 1 : tabs.length - 1)) % tabs.length;+ tabs[next]?.focus();+ }, []);++ const collapseLabel = isCollapsed ? t('widgets.layers.panes.expand') : t('widgets.layers.panes.collapse');++ return (+ <Flex+ borderColor="border.subtle"+ borderTopWidth="1px"+ data-layer-editor-panes={isCollapsed ? 'collapsed' : 'expanded'}+ direction="column"+ flex={isCollapsed ? '0 0 auto' : `0 1 ${previewSizePx ?? sizePx}px`}+ minH={`${STRIP_HEIGHT_PX}px`}+ overflow="hidden"+ >+ {!isCollapsed ? (+ <Box flexShrink={0} h="1px" position="relative" zIndex="1">+ <Box+ aria-label={t('widgets.layers.panes.resize')}+ aria-orientation="horizontal"+ aria-valuemax={LAYER_EDITOR_PANE_MAX_SIZE_PX}+ aria-valuemin={LAYER_EDITOR_PANE_MIN_SIZE_PX}+ aria-valuenow={sizePx}+ cursor="ns-resize"+ h="2"+ left="0"+ opacity="0"+ position="absolute"+ right="0"+ role="separator"+ tabIndex={0}+ top="-4px"+ transition="opacity var(--wb-motion-duration-fast) ease"+ _focusVisible={HANDLE_FOCUS_PROPS}+ _hover={HANDLE_HOVER_PROPS}+ onKeyDown={onSeparatorKeyDown}+ onPointerDown={onSeparatorPointerDown}+ />+ </Box>+ ) : null}+ <HStack align="center" flexShrink={0} gap="0.5" h={`${STRIP_HEIGHT_PX}px`} minW="0" px="1.5">+ <HStack+ aria-label={t('widgets.layers.panes.tabs')}+ aria-orientation="horizontal"+ flex="1"+ gap="0.5"+ minW="0"+ overflow="hidden"+ role="tablist"+ onKeyDown={focusSibling}+ >+ {PANES.map((pane) => (+ <PaneTab+ key={pane.id}+ id={pane.id}+ isExpanded={!isCollapsed}+ isSelected={pane.id === activePane}+ label={t(pane.labelKey)}+ onSelect={selectPane}+ />+ ))}+ </HStack>+ <Tooltip content={collapseLabel}>+ <IconButton+ ref={toggleRef}+ aria-expanded={!isCollapsed}+ aria-label={collapseLabel}+ color="fg.muted"+ size="2xs"+ variant="ghost"+ onClick={toggle}+ >+ <Icon as={isCollapsed ? ChevronUpIcon : ChevronDownIcon} boxSize="3.5" />+ </IconButton>+ </Tooltip>+ </HStack>+ {!isCollapsed ? (+ <Box+ aria-labelledby={`layer-editor-pane-tab-${activePane}`}+ flex="1"+ id={PANEL_ID}+ minH="0"+ overflow="hidden"+ role="tabpanel"+ >+ {activePane === 'transform' ? <TransformPane /> : <PropertiesPane />}+ </Box>+ ) : null}+ </Flex>+ );+};++const PaneTab = ({+ id,+ isExpanded,+ isSelected,+ label,+ onSelect,+}: {+ id: LayerEditorPaneId;+ /** Collapsed keeps the selected tab focusable and selected; only the shown look changes. */+ isExpanded: boolean;+ isSelected: boolean;+ label: string;+ onSelect: (pane: LayerEditorPaneId) => void;+}) => {+ const select = useCallback(() => onSelect(id), [id, onSelect]);+ const isShown = isSelected && isExpanded;++ return (+ <chakra.button+ aria-controls={isShown ? PANEL_ID : undefined}+ aria-selected={isSelected}+ bg={isShown ? 'bg.emphasized' : 'transparent'}+ color={isShown ? 'fg' : 'fg.muted'}+ cursor="pointer"+ flexShrink={0}+ fontSize="xs"+ fontWeight="600"+ h="7"+ id={`layer-editor-pane-tab-${id}`}+ px="2.5"+ role="tab"+ rounded="md"+ tabIndex={isSelected ? 0 : -1}+ type="button"+ _hover={isShown ? undefined : TAB_HOVER_PROPS}+ onClick={select}+ >+ <Text as="span" truncate>+ {label}+ </Text>+ </chakra.button>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsxsimilarity index 97%rename from invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgetView.tsxrename to invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsxindex 6a00da3f55..8a789bc9e7 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx@@ -1,5 +1,3 @@-import type { WidgetViewProps } from '@workbench/widgetContracts';-import { Flex, Stack, Text } from '@chakra-ui/react';import { Scrollable } from '@platform/ui/Scrollable';import { isCanvasInteractionLocked } from '@workbench/widgets/canvas/canvasInteractionLock';@@ -31,7 +29,7 @@ const REGION_LABEL_KEYS = {* document transactions through the same adapters the canvas registers; it* mirrors no state of its own.*/-export const PropertiesWidgetView = (_props: WidgetViewProps) => {+export const PropertiesPane = () => {const { t } = useTranslation();const engine = useCanvasEngine();const isSurfaceInteractionLocked = useActiveProjectSelector((project) =>diff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsxsimilarity index 92%rename from invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesSection.tsxrename to invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsxindex 116abbb036..e7e129de82 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/properties/PropertiesSection.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx@@ -3,7 +3,7 @@ import type { ReactNode, Ref } from 'react';import { Flex, Stack, Text } from '@chakra-ui/react';import { FieldLabel } from '@platform/ui/Field';-/** A headed group of rows in the Properties widget: Operation, Tool, Layer. */+/** A headed group of rows in an editor pane: Operation, Tool, Layer. */export const PropertiesSection = ({children,disabled = false,@@ -44,7 +44,7 @@ export const PropertiesSection = ({);};-/** One labelled row: a fixed label column and the controls packed after it, wrapping when the dock is narrow. */+/** One labelled row: a fixed label column and the controls packed after it, wrapping when the pane is narrow. */export const PropertiesRow = ({ children, label }: { children: ReactNode; label: string }) => (<Flex align="flex-start" gap="2" minW="0"><Flex align="center" flexShrink={0} minH="8" w="20">diff --git a/invokeai/frontend/webv2/src/workbench/widgets/transform/TransformWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsxsimilarity index 95%rename from invokeai/frontend/webv2/src/workbench/widgets/transform/TransformWidgetView.tsxrename to invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsxindex bbc6489bad..64e313865b 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/transform/TransformWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx@@ -1,19 +1,20 @@import type { LayerTransform } from '@workbench/canvas-engine/api';-import type { WidgetViewProps } from '@workbench/widgetContracts';import { Flex, Stack, Text } from '@chakra-ui/react';import { Button } from '@platform/ui/Button';+import { Scrollable } from '@platform/ui/Scrollable';import { getDocumentNode, lookupDocumentLeaf } from '@workbench/canvas-engine/api';import { useCanvasHasFloatingSelection, useTransformSession } from '@workbench/widgets/canvas/engineStoreHooks';import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useCanvasEngine, type CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';-import { GroupSelectedNotice } from '@workbench/widgets/properties/GroupSelectedNotice';-import { PropertiesRow, PropertiesSection } from '@workbench/widgets/properties/PropertiesSection';import { useActiveProjectSelector } from '@workbench/WorkbenchContext';import { useCallback } from 'react';import { useTranslation } from 'react-i18next';+import { GroupSelectedNotice } from './GroupSelectedNotice';+import { PropertiesRow, PropertiesSection } from './PropertiesSection';+const RAD_TO_DEG = 180 / Math.PI;const DEG_TO_RAD = Math.PI / 180;const MIN_SCALE_PERCENT = 1;@@ -42,7 +43,7 @@ interface SelectedNode {* it; a floating selection offers Apply / Cancel alone, since its transform is* layer-local rather than document space.*/-export const TransformWidgetView = (_props: WidgetViewProps) => {+export const TransformPane = () => {const { t } = useTranslation();const engine = useCanvasEngine();@@ -53,7 +54,11 @@ export const TransformWidgetView = (_props: WidgetViewProps) => {</Flex>);}- return <ConnectedTransform engine={engine} />;+ return (+ <Scrollable h="full">+ <ConnectedTransform engine={engine} />+ </Scrollable>+ );};const ConnectedTransform = ({ engine }: { engine: CanvasEngineHandle }) => {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/editorPaneLayout.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/editorPaneLayout.tsnew file mode 100644index 0000000000..64d909a96f--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/editorPaneLayout.ts@@ -0,0 +1,40 @@+/** Pure layout contract for the Layers widget's editor panes; the manifest seeds it, so no React here. */++export type LayerEditorPaneId = 'properties' | 'transform';++export interface LayerEditorPaneLayout {+ activePane: LayerEditorPaneId;+ isCollapsed: boolean;+ sizePx: number;+}++export const LAYER_EDITOR_PANE_MIN_SIZE_PX = 140;+export const LAYER_EDITOR_PANE_MAX_SIZE_PX = 560;++export const LAYER_EDITOR_PANE_DEFAULTS: LayerEditorPaneLayout = {+ activePane: 'properties',+ isCollapsed: false,+ sizePx: 300,+};++export const clampLayerEditorPaneSize = (sizePx: number): number =>+ Math.min(LAYER_EDITOR_PANE_MAX_SIZE_PX, Math.max(LAYER_EDITOR_PANE_MIN_SIZE_PX, Math.round(sizePx)));++const isPaneId = (value: unknown): value is LayerEditorPaneId => value === 'properties' || value === 'transform';++/** The persisted widget values are untyped; anything malformed falls back per field. */+export const readLayerEditorPaneLayout = (values: Record<string, unknown>): LayerEditorPaneLayout => {+ const raw = values.editorPanes;+ const layout = typeof raw === 'object' && raw !== null ? (raw as Partial<LayerEditorPaneLayout>) : {};+ return {+ activePane: isPaneId(layout.activePane) ? layout.activePane : LAYER_EDITOR_PANE_DEFAULTS.activePane,+ isCollapsed: typeof layout.isCollapsed === 'boolean' ? layout.isCollapsed : LAYER_EDITOR_PANE_DEFAULTS.isCollapsed,+ sizePx:+ typeof layout.sizePx === 'number' && Number.isFinite(layout.sizePx)+ ? clampLayerEditorPaneSize(layout.sizePx)+ : LAYER_EDITOR_PANE_DEFAULTS.sizePx,+ };+};++export const areLayerEditorPaneLayoutsEqual = (a: LayerEditorPaneLayout, b: LayerEditorPaneLayout): boolean =>+ a.activePane === b.activePane && a.isCollapsed === b.isCollapsed && a.sizePx === b.sizePx;diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewDensity.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewDensity.tsindex 5774176fae..88689a7ed9 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewDensity.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewDensity.ts@@ -13,9 +13,7 @@ import { useCallback, useLayoutEffect, useRef, useState, type Ref } from 'react'* one-line summaries, no footer message line.* - `minimal` — very narrow: frame + hairline progress + prev/next only.*/-/** A side rail: the left panel or any dock of the right rail. */-const isRailRegion = (region: string): boolean =>- region === 'left' || region === 'right' || region === 'rightTop' || region === 'rightBottom';+const isRailRegion = (region: string): boolean => region === 'left' || region === 'right';export type PreviewDensity = 'full' | 'compact' | 'minimal';diff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/implementation.ts b/invokeai/frontend/webv2/src/workbench/widgets/properties/implementation.tsdeleted file mode 100644index a5b2b5baca..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/properties/implementation.ts+++ /dev/null@@ -1,7 +0,0 @@-import type { WidgetImplementation } from '@workbench/widgetContracts';--import { PropertiesWidgetView } from './PropertiesWidgetView';--export const widgetImplementation = {- view: PropertiesWidgetView,-} satisfies WidgetImplementation;diff --git a/invokeai/frontend/webv2/src/workbench/widgets/properties/manifest.ts b/invokeai/frontend/webv2/src/workbench/widgets/properties/manifest.tsdeleted file mode 100644index 02dbfb2012..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/properties/manifest.ts+++ /dev/null@@ -1,15 +0,0 @@-import type { WidgetManifest } from '@workbench/widgetContracts';--import { SlidersHorizontalIcon } from 'lucide-react';--export const propertiesWidgetManifest: WidgetManifest = {- allowMultiple: false,- allowedRegions: ['right'],- failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },- icon: SlidersHorizontalIcon,- id: 'properties',- label: (t) => t('widgets.labels.properties'),- load: () => import('./implementation').then((module) => module.widgetImplementation),- rightDock: 'rightBottom',- version: 1,-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/transform/implementation.ts b/invokeai/frontend/webv2/src/workbench/widgets/transform/implementation.tsdeleted file mode 100644index ffb8dda430..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/transform/implementation.ts+++ /dev/null@@ -1,7 +0,0 @@-import type { WidgetImplementation } from '@workbench/widgetContracts';--import { TransformWidgetView } from './TransformWidgetView';--export const widgetImplementation = {- view: TransformWidgetView,-} satisfies WidgetImplementation;diff --git a/invokeai/frontend/webv2/src/workbench/widgets/transform/manifest.ts b/invokeai/frontend/webv2/src/workbench/widgets/transform/manifest.tsdeleted file mode 100644index b94d334fdd..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/transform/manifest.ts+++ /dev/null@@ -1,15 +0,0 @@-import type { WidgetManifest } from '@workbench/widgetContracts';--import { Rotate3dIcon } from 'lucide-react';--export const transformWidgetManifest: WidgetManifest = {- allowMultiple: false,- allowedRegions: ['right'],- failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },- icon: Rotate3dIcon,- id: 'transform',- label: (t) => t('widgets.labels.transform'),- load: () => import('./implementation').then((module) => module.widgetImplementation),- rightDock: 'rightBottom',- version: 1,-};diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.test.tsindex 7b70780cfe..f6acf2f301 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.test.ts@@ -550,49 +550,38 @@ describe('workbench widget region defaults', () => {'queue',]);for (const preset of layoutPresets) {- const { right, rightBottom } = preset.snapshot.widgetRegions;- expect([...right.instanceIds, ...rightBottom.instanceIds]).toContain('image-map');+ if (preset.id !== 'edit') {+ expect(preset.snapshot.widgetRegions.right.instanceIds).toContain('image-map');+ }}});- it('adds the bottom dock to an untouched pre-dock Edit rail and leaves other rails alone', () => {+ it('adopts the Layers-only Edit rail for untouched legacy rails and leaves customized rails alone', () => {const initial = createInitialWorkbenchState();- const preDock = (instanceIds: Project['widgetRegions']['right']['instanceIds']): WorkbenchState => ({+ const withRight = (instanceIds: Project['widgetRegions']['right']['instanceIds']): WorkbenchState => ({...initial,- projects: initial.projects.map((project) => {- const { rightBottom: _b, rightTop: _t, ...regions } = project.widgetRegions;- return {- ...project,- widgetRegions: {- ...regions,- right: { ...project.widgetRegions.right, instanceIds },- } as Project['widgetRegions'],- };- }),+ projects: initial.projects.map((project) => ({+ ...project,+ widgetRegions: {+ ...project.widgetRegions,+ right: { ...project.widgetRegions.right, activeInstanceId: 'gallery', instanceIds },+ },+ })),});- const editRail = preDock(['layers', 'preview', 'gallery', 'image-map', 'queue']);- const custom = preDock(['image-map', 'layers']);+ const legacyEditRail = withRight(['layers', 'preview', 'gallery', 'image-map', 'queue']);+ const custom = withRight(['image-map', 'layers']);- const hydratedEdit = getActiveProject(workbenchReducer(initial, { state: editRail, type: 'hydrateWorkbench' }));- expect(hydratedEdit.widgetRegions.right.instanceIds).toEqual([- 'layers',- 'preview',- 'gallery',- 'image-map',- 'queue',- ]);- expect(hydratedEdit.widgetRegions.rightBottom).toMatchObject({- activeInstanceId: 'properties',- instanceIds: ['properties', 'transform'],- isCollapsed: false,+ const hydratedLegacy = getActiveProject(+ workbenchReducer(initial, { state: legacyEditRail, type: 'hydrateWorkbench' })+ );+ expect(hydratedLegacy.widgetRegions.right).toMatchObject({+ activeInstanceId: 'layers',+ instanceIds: ['layers'],});- expect(hydratedEdit.widgetInstances.properties?.typeId).toBe('properties');- expect(hydratedEdit.widgetInstances.transform?.typeId).toBe('transform');- expect(hydratedEdit.widgetRegions.rightTop).toMatchObject({ instanceIds: [], isCollapsed: true });const hydratedCustom = getActiveProject(workbenchReducer(initial, { state: custom, type: 'hydrateWorkbench' }));expect(hydratedCustom.widgetRegions.right.instanceIds).toEqual(['image-map', 'layers']);- expect(hydratedCustom.widgetRegions.rightBottom).toMatchObject({ instanceIds: [], isCollapsed: true });+ expect(hydratedCustom.widgetRegions.right.activeInstanceId).toBe('gallery');});it('adds Upscale to untouched legacy left rails while preserving customized rails', () => {diff --git a/invokeai/frontend/webv2/src/workbench/workbenchState.ts b/invokeai/frontend/webv2/src/workbench/workbenchState.tsindex ca61c4b43d..5775279ee8 100644--- a/invokeai/frontend/webv2/src/workbench/workbenchState.ts+++ b/invokeai/frontend/webv2/src/workbench/workbenchState.ts@@ -69,8 +69,7 @@ import {type GallerySettings,type GeneratedImageContract,} from '@features/gallery/contracts';-import { getWidgetRail, RIGHT_RAIL_DOCKS, WIDGET_REGIONS } from '@workbench/layoutContracts';-import { EMPTY_DOCK_REGION } from '@workbench/layoutPresetSnapshots';+import { WIDGET_REGIONS } from '@workbench/layoutContracts';import type { WorkbenchQueueItem as QueueItem } from './queueHistoryContracts';@@ -427,8 +426,6 @@ const MIN_PANEL_SIZE_PX = 350;const MAX_PANEL_SIZE_PX = 720;const MIN_STATUS_PANEL_SIZE_PX = 96;const MAX_STATUS_PANEL_SIZE_PX = 420;-const MIN_DOCK_SIZE_PX = 120;-const MAX_DOCK_SIZE_PX = 720;/*** How far a resize drag must push past a region's floor before releasing means@@ -438,14 +435,11 @@ const MAX_DOCK_SIZE_PX = 720;*/const PANEL_COLLAPSE_OVERSHOOT_PX = 80;-/** The resize bounds for a widget region — shared with the resize handles; the outer docks size their height. */+/** The resize bounds for a widget region — shared with the resize handles. */export const getPanelSizeBounds = (region: WidgetRegion): { max: number; min: number } => {if (region === 'bottom') {return { max: MAX_STATUS_PANEL_SIZE_PX, min: MIN_STATUS_PANEL_SIZE_PX };}- if (region === 'rightTop' || region === 'rightBottom') {- return { max: MAX_DOCK_SIZE_PX, min: MIN_DOCK_SIZE_PX };- }return { max: MAX_PANEL_SIZE_PX, min: MIN_PANEL_SIZE_PX };};@@ -1437,64 +1431,45 @@ const ensureRightRegion = (rightRegion: WidgetRegionState | undefined): WidgetRereturn rightRegion;};-/** The Edit rail as it shipped before the right rail had docks; the bottom dock (Properties, Transform) joins it. */-const PRE_DOCK_EDIT_RIGHT_REGION_WIDGET_IDS: readonly WidgetInstanceId[] = [- 'layers',- 'preview',- 'gallery',- 'image-map',- 'queue',+/**+ * Every Edit rail this app shipped as a default while the canvas editors were+ * separate widgets: the tabbed rail, and one unreleased build's variant+ * without Image Map. Those editors are panes of the Layers panel now, so an+ * untouched rail of either shape adopts the shipped Layers-only rail; a+ * customized rail stays the user's.+ */+const LEGACY_EDIT_RIGHT_REGION_WIDGET_IDS: ReadonlyArray<readonly WidgetInstanceId[]> = [+ ['layers', 'preview', 'gallery', 'image-map', 'queue'],+ ['layers', 'preview', 'gallery', 'queue'],];-/** One unreleased build docked Image Map alone at the bottom; that rail becomes the shipped one too. */-const INTERIM_EDIT_RIGHT_REGION_WIDGET_IDS: readonly WidgetInstanceId[] = ['layers', 'preview', 'gallery', 'queue'];-const sameInstanceIds = (region: WidgetRegionState, ids: readonly WidgetInstanceId[]): boolean =>region.instanceIds.length === ids.length && region.instanceIds.every((id, index) => id === ids[index]);-const isDockShape = (value: unknown): value is WidgetRegionState =>- !!value &&- typeof value === 'object' &&- Array.isArray((value as WidgetRegionState).instanceIds) &&- typeof (value as WidgetRegionState).activeInstanceId === 'string' &&- typeof (value as WidgetRegionState).isCollapsed === 'boolean' &&- typeof (value as WidgetRegionState).sizePx === 'number';--/**- * Projects persisted before the right rail had docks carry none, and one- * unreleased build docked Image Map alone. An untouched rail of either shape- * adopts the shipped Edit docks; anything else gets empty, collapsed docks for- * the ones it lacks and keeps its rail as is.- */-const ensureRightRailDocks = (- regions: Partial<Record<WidgetRegion, WidgetRegionState>> | undefined,- right: WidgetRegionState-): Pick<Record<WidgetRegion, WidgetRegionState>, 'right' | 'rightTop' | 'rightBottom'> => {- const dock = (name: 'rightTop' | 'rightBottom'): WidgetRegionState =>- isDockShape(regions?.[name]) ? regions[name] : { ...EMPTY_DOCK_REGION, sizePx: createWidgetRegions()[name].sizePx };- const top = dock('rightTop');- const bottom = dock('rightBottom');- const isPreDock = regions?.rightTop === undefined && regions?.rightBottom === undefined;- const isInterim =- top.instanceIds.length === 0 &&- sameInstanceIds(bottom, ['image-map']) &&- sameInstanceIds(right, INTERIM_EDIT_RIGHT_REGION_WIDGET_IDS);-- if ((isPreDock && sameInstanceIds(right, PRE_DOCK_EDIT_RIGHT_REGION_WIDGET_IDS)) || isInterim) {- const edit = getLayoutPreset('edit').snapshot.widgetRegions;- return {- right: { ...right, instanceIds: [...edit.right.instanceIds] },- // A rail the user had shut stays shut; the new dock opens with it.- rightBottom: {- ...edit.rightBottom,- instanceIds: [...edit.rightBottom.instanceIds],- isCollapsed: right.isCollapsed,- },- rightTop: top,- };+const ensureEditRightRegion = (right: WidgetRegionState): WidgetRegionState => {+ if (!LEGACY_EDIT_RIGHT_REGION_WIDGET_IDS.some((ids) => sameInstanceIds(right, ids))) {+ return right;}+ const edit = getLayoutPreset('edit').snapshot.widgetRegions.right;+ return { ...right, activeInstanceId: edit.activeInstanceId, instanceIds: [...edit.instanceIds] };+};++/** The canvas editors that folded into the Layers panel; anything persisted about them drops on load. */+const RETIRED_WIDGET_TYPE_IDS: ReadonlySet<string> = new Set(['properties', 'transform']);- return { right, rightBottom: bottom, rightTop: top };+const withoutRetiredInstances = (+ region: WidgetRegionState,+ retired: ReadonlySet<WidgetInstanceId>+): WidgetRegionState => {+ if (!region.instanceIds.some((instanceId) => retired.has(instanceId))) {+ return region;+ }+ const instanceIds = region.instanceIds.filter((instanceId) => !retired.has(instanceId));+ return {+ ...region,+ activeInstanceId: retired.has(region.activeInstanceId) ? (instanceIds[0] ?? '') : region.activeInstanceId,+ instanceIds,+ };};// The shipped bottom-region default before 'queue-status' was added — a@@ -1627,6 +1602,10 @@ const normalizeFloatingWidgets = (}const state = entry as Partial<FloatingWidgetState>;+ // The right rail's docks folded back into one region; a window floated out of one returns to the rail.+ const rawReturnRegion: unknown = state.returnRegion;+ const returnRegion =+ rawReturnRegion === 'rightTop' || rawReturnRegion === 'rightBottom' ? 'right' : state.returnRegion;if (!isFiniteNumber(state.x) ||@@ -1635,7 +1614,7 @@ const normalizeFloatingWidgets = (!isFiniteNumber(state.heightPx) ||!isFiniteNumber(state.stackOrder) ||!isFloatingWidgetMode(state.mode) ||- !isWidgetRegionId(state.returnRegion)+ !isWidgetRegionId(returnRegion)) {continue;}@@ -1649,7 +1628,7 @@ const normalizeFloatingWidgets = (...(isFiniteNumber(state.returnIndex) && state.returnIndex >= 0? { returnIndex: Math.floor(state.returnIndex) }: {}),- returnRegion: state.returnRegion,+ returnRegion,stackOrder: state.stackOrder,};}@@ -1813,23 +1792,26 @@ const assembleWorkbenchProject = (project: Project, canvas: CanvasStateContractV};}- const rail = ensureRightRailDocks(- legacyWidgetRegions,- ensureRightRegion(legacyWidgetRegions?.right ?? legacyWidgetRegions?.['right-panel'])+ // The canvas editors folded into the Layers panel; an instance of the retired widgets has nothing to render.+ const retiredInstanceIds = new Set(+ Object.values(widgetInstances)+ .filter((instance) => RETIRED_WIDGET_TYPE_IDS.has(instance.typeId))+ .map((instance) => instance.id));- // The bottom dock's widgets are new to a migrated project; every dock member needs an instance to render.- const editInstances = getLayoutPreset('edit').snapshot.widgetInstances;- for (const instanceId of rail.rightBottom.instanceIds) {- const typeId = editInstances[instanceId]?.typeId;- if (!widgetInstances[instanceId] && typeId) {- widgetInstances[instanceId] = createWidgetInstance(typeId, instanceId);- }+ for (const instanceId of retiredInstanceIds) {+ delete widgetInstances[instanceId];}+ const rightRegion = ensureEditRightRegion(+ withoutRetiredInstances(+ ensureRightRegion(legacyWidgetRegions?.right ?? legacyWidgetRegions?.['right-panel']),+ retiredInstanceIds+ )+ );const placement = reconcileFloatingWidgets({left: leftRegion,- ...rail,+ right: rightRegion,bottom: bottomRegion,center: ensureCenterRegion(legacyWidgetRegions?.center, project.layout.centerViewId),},@@ -1979,8 +1961,8 @@ const updateActiveProject = (state: WorkbenchState, getProject: (project: Projec/*** Which of `regions` a panel toggle should collapse or expand: empty ones are- * left alone, so toggling never opens a dock with nothing in it (and never- * writes drift into a preset that ships the dock collapsed).+ * left alone, so toggling never opens a panel with nothing in it (and never+ * writes drift into a preset that ships a region collapsed).*/export const resolvePanelToggle = (widgetRegions: Record<WidgetRegion, Pick<WidgetRegionState, 'instanceIds' | 'isCollapsed'>>,@@ -2042,20 +2024,35 @@ const openPanelForRegion = (layout: ProjectLayoutState, region: WidgetRegion): P...layout.panels,isBottomOpen: region === 'bottom' ? true : layout.panels.isBottomOpen,isLeftOpen: region === 'left' ? true : layout.panels.isLeftOpen,- isRightOpen: getWidgetRail(region) === 'right' ? true : layout.panels.isRightOpen,+ isRightOpen: region === 'right' ? true : layout.panels.isRightOpen,},});-const cloneLayoutPresetSnapshot = (snapshot: LayoutPresetSnapshot): LayoutPresetSnapshot => ({+const cloneLayoutPresetSnapshot = (snapshot: LayoutPresetSnapshot): LayoutPresetSnapshot => {// Every account preset is rebuilt through here on load, so a field missing// from this clone is a field the preset silently loses on the next reload.- ...(snapshot.floatingWidgets ? { floatingWidgets: cloneFloatingWidgets(snapshot.floatingWidgets) } : {}),- layout: { ...snapshot.layout, panels: { ...snapshot.layout.panels } },- widgetInstances: Object.fromEntries(- Object.entries(snapshot.widgetInstances).map(([instanceId, instance]) => [instanceId, { ...instance }])- ),- widgetRegions: cloneLayoutPresetWidgetRegions(snapshot.widgetRegions),-});+ // A preset saved while the retired canvas editors were widgets still carries+ // their instances; shedding them here keeps an applied preset drift-free.+ const retired = new Set(+ Object.values(snapshot.widgetInstances)+ .filter((instance) => RETIRED_WIDGET_TYPE_IDS.has(instance.typeId))+ .map((instance) => instance.id)+ );+ const widgetRegions = cloneLayoutPresetWidgetRegions(snapshot.widgetRegions);+ for (const region of Object.keys(widgetRegions) as WidgetRegion[]) {+ widgetRegions[region] = withoutRetiredInstances(widgetRegions[region], retired);+ }+ return {+ ...(snapshot.floatingWidgets ? { floatingWidgets: cloneFloatingWidgets(snapshot.floatingWidgets) } : {}),+ layout: { ...snapshot.layout, panels: { ...snapshot.layout.panels } },+ widgetInstances: Object.fromEntries(+ Object.entries(snapshot.widgetInstances)+ .filter(([, instance]) => !retired.has(instance.id))+ .map(([instanceId, instance]) => [instanceId, { ...instance }])+ ),+ widgetRegions,+ };+};const centerViewIds = new Set<CenterViewId>(['canvas', 'gallery', 'preview', 'workflow']);@@ -2136,14 +2133,7 @@ const isLayoutPresetSnapshot = (value: unknown): value is LayoutPresetSnapshot =isWidgetRegionState(snapshot.widgetRegions.left, widgetInstances) &&isWidgetRegionState(snapshot.widgetRegions.right, widgetInstances) &&isWidgetRegionState(snapshot.widgetRegions.bottom, widgetInstances) &&- isWidgetRegionState(snapshot.widgetRegions.center, widgetInstances) &&- // Docks are absent from snapshots saved before the right rail had them; present ones must be well-formed.- RIGHT_RAIL_DOCKS.every(- (dock) =>- dock === 'right' ||- snapshot.widgetRegions?.[dock] === undefined ||- isWidgetRegionState(snapshot.widgetRegions[dock], widgetInstances)- )+ isWidgetRegionState(snapshot.widgetRegions.center, widgetInstances));};@@ -3638,27 +3628,6 @@ export const __workbenchReducerInternal = (Object.values(project.widgetInstances).find((instance) => instance.typeId === action.widgetId);const instanceId =action.createNew || !existingInstance ? createId(`widget-${action.widgetId}`) : existingInstance.id;- // An instance already docked elsewhere on the same rail is revealed there, never placed twice.- const siblingDock = WIDGET_REGION_IDS.find(- (candidate) =>- candidate !== action.region &&- getWidgetRail(candidate) === getWidgetRail(action.region) &&- project.widgetRegions[candidate].instanceIds.includes(instanceId)- );- if (siblingDock) {- return {- ...project,- layout: openPanelForRegion(project.layout, siblingDock),- widgetRegions: {- ...project.widgetRegions,- [siblingDock]: {- ...project.widgetRegions[siblingDock],- activeInstanceId: instanceId,- isCollapsed: false,- },- },- };- }const instanceIds = region.instanceIds.includes(instanceId)? region.instanceIds: [...region.instanceIds, instanceId];