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
fix(webv2): keep floated widgets out of hidden mounts
joshistoast934fbe44d453
diff --git a/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx b/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsxindex 799f926b61..ab26404128 100644--- a/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/CenterArea.tsx@@ -85,7 +85,7 @@ export const CenterArea = () => {const activeItem = centerViewItems.find((item) => item.id === activeCenterViewId);const projectId = useActiveProjectId();const activeIdsElsewhere = useActiveProjectSelector(- (project) => getActiveInstanceIdsOutside(project.widgetRegions, 'center'),+ (project) => getActiveInstanceIdsOutside(project.widgetRegions, 'center', project.floatingWidgets),areInstanceIdListsEqual);const mountedCenterIds = withoutInstancesShownElsewhere(diff --git a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsxindex 1437bd704b..0cc1ffbdbc 100644--- a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx@@ -39,7 +39,7 @@ const panelRegions = {const WidgetPanelSlot = ({ instanceId, panel }: { instanceId: WidgetInstanceId; panel: keyof typeof panelRegions }) => {const projectId = useActiveProjectId();const activeIdsElsewhere = useActiveProjectSelector(- (project) => getActiveInstanceIdsOutside(project.widgetRegions, panelRegions[panel]),+ (project) => getActiveInstanceIdsOutside(project.widgetRegions, panelRegions[panel], project.floatingWidgets),areInstanceIdListsEqual);const mountedIds = withoutInstancesShownElsewhere(diff --git a/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.browser.test.tsxindex af011f599c..4074112c07 100644--- a/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.browser.test.tsx@@ -147,4 +147,17 @@ describe('instances shown elsewhere', () => {// stays available for the centre to keep.expect(getActiveInstanceIdsOutside(widgetRegions, 'center')).toEqual(['gallery:bottom', 'generate', 'layers']);});++ it('includes floating instance ids, since a float removes an instance from its region entirely', () => {+ const widgetRegions = {+ center: { activeInstanceId: 'canvas', instanceIds: ['canvas'] },+ right: { activeInstanceId: 'layers', instanceIds: ['layers'] },+ };++ // `floatWidget` hands the region off to a fallback, so `image-map` no+ // longer appears as any region's active — only the floating map catches+ // it, which is what keeps the region's kept copy from shadowing the+ // floating window.+ expect(getActiveInstanceIdsOutside(widgetRegions, 'right', { 'image-map': {} })).toEqual(['canvas', 'image-map']);+ });});diff --git a/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.ts b/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.tsindex 366c532ff8..4f22feaf5f 100644--- a/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.ts+++ b/invokeai/frontend/webv2/src/workbench/shell/useMountedInstanceIds.ts@@ -62,12 +62,18 @@ export const useMountedInstanceIds = (* One instance can be placed in more than one region — `preview` is Compose's* centre view and also sits in Edit's and Automate's right rails — so a kept* hidden copy can end up shadowing a live one: the same instance mounted twice,- * one of them a ghost the user can neither see nor dismiss.+ * one of them a ghost the user can neither see nor dismiss. A floated instance+ * is the same hazard: `floatWidget` hands its region off to a fallback but+ * does not touch this hook's remembered set, so the region's kept copy would+ * otherwise stay mounted hidden while `FloatingWidgetWindow` mounts the same+ * instance visible — and re-docking would make the stale hidden copy visible+ * again, silently discarding whatever happened in the floating window.*- * Only the regions' `activeInstanceId` values are consulted. Region membership- * (`instanceIds`) is the thing a preset replaces wholesale, and deriving- * anything here from it would reintroduce the very filtering bug this mechanism- * exists to avoid. Actives are a small, stable signal that cannot.+ * Only the regions' `activeInstanceId` values and the floating instance ids+ * are consulted. Region membership (`instanceIds`) is the thing a preset+ * replaces wholesale, and deriving anything here from it would reintroduce+ * the very filtering bug this mechanism exists to avoid. Actives and floating+ * ids are a small, stable signal that cannot.*/export const withoutInstancesShownElsewhere = (mountedIds: string[],@@ -79,14 +85,17 @@ export const withoutInstancesShownElsewhere = (return kept.length === mountedIds.length ? mountedIds : kept;};-/** The `activeInstanceId` of every region except `region`. */+/** The `activeInstanceId` of every region except `region`, plus every floating instance id. */export const getActiveInstanceIdsOutside = (widgetRegions: Record<string, { activeInstanceId: string }>,- region: string-): string[] =>- Object.entries(widgetRegions)+ region: string,+ floatingWidgets?: Record<string, unknown>+): string[] => [+ ...Object.entries(widgetRegions).filter(([name]) => name !== region)- .map(([, regionState]) => regionState.activeInstanceId);+ .map(([, regionState]) => regionState.activeInstanceId),+ ...Object.keys(floatingWidgets ?? {}),+];export const areInstanceIdListsEqual = (left: readonly string[], right: readonly string[]): boolean =>left.length === right.length && left.every((id, index) => id === right[index]);