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(ui): move focus into docked panels from rail tabs and unavailable widgets
Josh Corbett3dc24a6fe303
diff --git a/invokeai/frontend/webv2/ARCHITECTURE.md b/invokeai/frontend/webv2/ARCHITECTURE.mdindex fd8af11ecf..3ae468bf26 100644--- a/invokeai/frontend/webv2/ARCHITECTURE.md+++ b/invokeai/frontend/webv2/ARCHITECTURE.md@@ -126,7 +126,7 @@ Workbench focus is transient and never persisted. `WorkbenchFocusProvider` (`wor- **Raising.** A press inside a window always asks the reducer to raise it, which is a no-op for the topmost window. Focus raises a window only when it makes that window the active one: focus moving around inside the already-active window, or returning from a closing dialog or popover, writes nothing. Ordinary focus leaves a shaded window shaded; the explicit reveal (marker, center "Show window", recall) expands it.- **Recall is the one reveal that moves no focus.** A recall raises and expands its window but leaves keyboard focus, the outline, and the hotkey target where the user had them; the next press or focus change brings them back into agreement. Because focus inside the active window does not re-raise, it cannot re-bury the window a recall just revealed.- **Keys follow the outline.** A press inside a window moves keyboard focus into it when focus was elsewhere, and a press on a docked region pulls focus out of a floating window. The floating layer renders windows in a fixed DOM order and stacks them by z-index alone: raising a window never moves its node, which would drop the focus that raised it.-- **Focus follows placement:** into the window after Float and after a marker or "Show window" reveal, into the return region after Dock, and after Remove from a marker's menu into the center when it gets its view back, otherwise into the panel the window's own rail is showing — or the center when that rail shows none, emptied by the float or collapsed. Removing a window from a rail's enable menu moves no focus: that menu stays open and keeps it. A focus move targets the region frame that is on screen (side regions keep earlier panels mounted but hidden), waits a bounded time for its widget to mount, and is abandoned if the user presses somewhere else first.+- **Focus follows placement:** into the window after Float and after a marker or "Show window" reveal, into the region a docked rail tab shows in when it is selected, so keys stop going to a window that held them, into the return region after Dock, and after Remove from a marker's menu into the center when it gets its view back, otherwise into the panel the window's own rail is showing — or the center when that rail shows none, emptied by the float or collapsed. Removing a window from a rail's enable menu moves no focus: that menu stays open and keeps it. A focus move targets the region frame that is on screen (side regions keep earlier panels mounted but hidden), waits a bounded time for its widget to mount, and is abandoned if the user presses somewhere else first. Every panel frame carries its instance's identity, including the stand-in for a widget whose view cannot render, so a move into it lands.- **Hotkeys read the same target.** `HotkeyContext.focusedRegion` is `WidgetRegion | 'floating' | null`; the persisted `WidgetRegion` is unchanged. A key press is aimed at the widget under the event target first and, outside any widget's DOM, at the active floating instance or the focused region's active member (`resolveHotkeyTarget`). A region's active pointer counts only while it names a member, so a view that floated out of an emptied center answers as a window, not as the center. A floating command source carries `region: 'floating'` and is never used to index `widgetRegions`. Generic `focused-region` shortcuts match under a window, shortcuts tied to a named docked region do not, and a floating widget's own `focused-region` contribution follows its window at the same priority it has when docked.### Window interactionsdiff --git a/invokeai/frontend/webv2/src/workbench/shell/BottomPanel.tsx b/invokeai/frontend/webv2/src/workbench/shell/BottomPanel.tsxindex affa5b097f..3cb57c278e 100644--- a/invokeai/frontend/webv2/src/workbench/shell/BottomPanel.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/BottomPanel.tsx@@ -29,8 +29,10 @@ export const BottomPanel = () => {if (!instance || !widget) {return (<MissingWidgetFrame+ instanceId={bottomRegion.activeInstanceId}label={widget ? resolveWidgetLabel(widget.manifest, t) : bottomRegion.activeInstanceId}region="bottom"+ typeId={instance?.typeId}/>);}diff --git a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsxindex ff6a4ecf8c..6b282b0d24 100644--- a/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/Panels.tsx@@ -64,7 +64,14 @@ const WidgetPanelInstance = ({ instanceId, region }: { instanceId: WidgetInstancconst widget = instance ? getWidgetById(instance.typeId) : undefined;if (!instance || !widget || widget.status !== 'enabled') {- return <MissingWidgetFrame label={widget ? resolveWidgetLabel(widget.manifest, t) : instanceId} region={region} />;+ return (+ <MissingWidgetFrame+ instanceId={instanceId}+ label={widget ? resolveWidgetLabel(widget.manifest, t) : instanceId}+ region={region}+ typeId={instance?.typeId}+ />+ );}return <WidgetRendererById instanceId={instance.id} widget={widget} region={region} />;diff --git a/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx b/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsxindex 2d19d1804f..20d2458128 100644--- a/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx+++ b/invokeai/frontend/webv2/src/workbench/shell/WorkbenchShell.tsx@@ -190,15 +190,20 @@ export const WorkbenchShell = () => {[placementProject, widgets]);const handleDragCancel = useCallback(() => setActiveDrag(null), []);- // Focus follows each of these: into the window a marker shows, into the region a window docks to, and into a- // center that gets its view back when the window is removed.+ // Focus follows each of these: into the window a marker shows or the region a tab shows in, into the region a+ // window docks to, and into a center that gets its view back when the window is removed. A tab that collapses+ // its region shows nothing, and the move gives up.const handleSelect = useCallback((region: WidgetBarGroup['region'], instanceId: string) => {- if (activateRailPlacement({ instanceId, project: placementProject, region, widgets }) === 'window') {+ const activated = activateRailPlacement({ instanceId, project: placementProject, region, widgets });++ if (activated === 'window') {focusFloating(instanceId);+ } else if (activated === 'tab') {+ focusRegion(region, placementProject.widgetInstances[instanceId]?.typeId);}},- [focusFloating, placementProject, widgets]+ [focusFloating, focusRegion, placementProject, widgets]);const handleDock = useCallback((instanceId: string) => {diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsxindex 8f5d55e13d..665460367f 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/FloatingWidgetWindow.browser.test.tsx@@ -220,7 +220,9 @@ const renderWindow = async (<I18nextProvider i18n={i18n}><ChakraProvider value={system}><FocusRegionProvider controller={controller}>- {showUnavailablePanel ? <MissingWidgetFrame label="Image Map" region="right" /> : null}+ {showUnavailablePanel ? (+ <MissingWidgetFrame instanceId="image-map-instance" label="Image Map" region="right" typeId="image-map" />+ ) : null}<FloatingWidgetWindow instanceId="image-map-instance" stackRank={0} state={floatingState} /></FocusRegionProvider></ChakraProvider>@@ -639,7 +641,7 @@ describe('FloatingWidgetWindow focus', () => {it('moves focus to the unavailable-widget panel when its floating window docks', async () => {windowMocks.useMissingWidget = true;const controller = createTestFocusController();- // MissingWidgetFrame has no data-hotkey-widget-type-id for the focus resolver to match.+ // The panel the window docks into stands in for a widget whose view cannot render.await renderWindow(state, controller, true);const dock = host!.querySelector<HTMLButtonElement>('button[aria-label="Dock to right panel"]')!;diff --git a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsxindex 73d2252c28..96bb1daf5e 100644--- a/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx+++ b/invokeai/frontend/webv2/src/workbench/widget-frame/WidgetRenderer.tsx@@ -3,8 +3,10 @@ import type {RegisteredWidget,WidgetImplementation,WidgetInstanceContract,+ WidgetInstanceId,WidgetInstanceRuntimeMeta,WidgetRuntimeApi,+ WidgetTypeId,WidgetViewProps,WorkbenchRegion,} from '@workbench/widgetContracts';@@ -446,8 +448,23 @@ const FooterSlot = memo(function FooterSlot({);}, areSlotPropsEqual);-export const MissingWidgetFrame = ({ label, region }: { label: string; region: Exclude<WidgetRegion, 'center'> }) => (- <WidgetPanelFrame region={region}>+/**+ * Stands in for a widget whose view cannot render. It carries the instance's identity like any other frame, so focus+ * moves and hotkeys that look for the instance find it here.+ */+export const MissingWidgetFrame = ({+ instanceId,+ label,+ region,+ typeId,+}: {+ instanceId: WidgetInstanceId;+ label: string;+ region: Exclude<WidgetRegion, 'center'>;+ /** Unknown when the instance itself is gone. */+ typeId: WidgetTypeId | undefined;+}) => (+ <WidgetPanelFrame instanceId={instanceId} region={region} typeId={typeId}><Box p="3"><Text fontSize="xs" fontWeight="700">{label}