Skip to content

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.

feat(webv2): reveal Properties for layer operations and title the pane

Lincoln Stein4bc6b72243e2
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index dad61ac8c9..7b1977e099 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -2109,6 +2109,11 @@
"drag": "Draw or adjust the search box."
}
},
+ "title": {
+ "group": "Group: {{name}}",
+ "layer": "Layer: {{name}}",
+ "operation": "Operation: {{name}}"
+ },
"target": {
"defaults": "Defaults",
"editing": "Editing: {{name}}",
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx
new file mode 100644
index 0000000000..6d06b595cb
--- /dev/null
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/ToastContrast.browser.test.tsx
@@ -0,0 +1,47 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { AppToaster, toaster } from '@platform/ui/toaster';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import { getContrastRatio } from './contrastRatio.testing';
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+afterEach(async () => {
+ await act(() => toaster.remove());
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+describe('toast contrast', () => {
+ // Success and warning fills (green/orange 600) stay below AA even for full-strength white text.
+ it.each(['error', 'info'] as const)('renders a %s description at AA contrast', async (type) => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ await act(() => {
+ root?.render(
+ <ChakraProvider value={system}>
+ <AppToaster />
+ </ChakraProvider>
+ );
+ });
+ await act(() => {
+ toaster.create({ description: 'Layer thumbnail rasterization failed.', title: 'Error', type });
+ });
+ await expect.poll(() => document.querySelector('[data-part="description"]')).not.toBeNull();
+ const description = document.querySelector<HTMLElement>('[data-part="description"]')!;
+ const toastRoot = description.closest<HTMLElement>('[data-part="root"]')!;
+ const style = getComputedStyle(description);
+
+ const ratio = getContrastRatio(style.color, getComputedStyle(toastRoot).backgroundColor, Number(style.opacity));
+
+ expect(ratio).toBeGreaterThanOrEqual(4.5);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index b88252b042..997d7845e5 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -69,6 +69,15 @@ export const popoverSlotRecipe = defineSlotRecipe({
},
});
+/** Chakra dims descriptions to 80%, which drops them below AA on the solid status fills. */
+export const toastSlotRecipe = defineSlotRecipe({
+ ...chakraSlotRecipes.toast,
+ base: {
+ ...chakraSlotRecipes.toast.base,
+ description: { ...chakraSlotRecipes.toast.base?.description, opacity: 1 },
+ },
+});
+
export const tabsSlotRecipe = defineSlotRecipe({
...chakraSlotRecipes.tabs,
base: {
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
index 3761f09550..816ad755ad 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
@@ -18,6 +18,7 @@ import {
skeletonRecipe,
sliderSlotRecipe,
tabsSlotRecipe,
+ toastSlotRecipe,
textareaRecipe,
tooltipSlotRecipe,
} from './recipes';
@@ -371,6 +372,7 @@ const config = defineConfig({
select: selectSlotRecipe,
slider: sliderSlotRecipe,
tabs: tabsSlotRecipe,
+ toast: toastSlotRecipe,
tooltip: tooltipSlotRecipe,
},
},
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/CanvasWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/CanvasWidgetView.tsx
index 07dea3a8b7..257730af4b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/CanvasWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/CanvasWidgetView.tsx
@@ -14,7 +14,6 @@ import { useWorkbenchSettingsSelector } from '@workbench/settings/store';
import { useCanvasProjectMutationDispatch } from '@workbench/useCanvasProjectMutationDispatch';
import { useNotify } from '@workbench/useNotify';
import { CanvasLayerContextMenu } from '@workbench/widgets/layers/LayerContextMenu';
-import { clearLayerPropertiesRequest } from '@workbench/widgets/layers/layerPropertiesRequestStore';
import { getProjectWidgetValues } from '@workbench/widgetState';
import {
useActiveProjectId,
@@ -85,12 +84,6 @@ export const CanvasWidgetView = ({ runtime }: WidgetViewProps) => {
const fontReferences = useMemo(() => engine?.fonts.collectReferences(document) ?? [], [document, engine]);
const operation = useCanvasOperation(engine);
const operationKind = operation?.status === 'active' ? operation.identity.kind : null;
- // An operation's panel supersedes any pending layer-properties request.
- useEffect(() => {
- if (operationKind) {
- clearLayerPropertiesRequest();
- }
- }, [operationKind]);
const { isSaving, save: saveToGallery } = useCanvasGallerySave(engine);
const { createFromBbox, isCreating } = useCreateFromBbox(engine);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
index 583bd6059e..7753f8377a 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
@@ -515,6 +515,14 @@ const LayerMenu = ({
const openRename = useCallback(() => setDialogKind('rename'), [setDialogKind]);
const closeDialog = useCallback(() => setDialogKind(null), [setDialogKind]);
const openRunWorkflow = useCallback(() => setDialogKind('run-workflow'), [setDialogKind]);
+ // Operations present their controls in the Properties pane, so starting one must bring that pane into view.
+ const revealProperties = useCallback(
+ (layerId: string) => {
+ widgets.open({ region: 'right', widgetId: 'layers' });
+ requestLayerProperties(layerId);
+ },
+ [widgets]
+ );
const startSelectObject = useCallback(
(layerId: string) => {
if (!engine) {
@@ -524,8 +532,9 @@ const LayerMenu = ({
if (result !== 'started') {
throw makeStatusError(result);
}
+ revealProperties(layerId);
},
- [engine, makeStatusError]
+ [engine, makeStatusError, revealProperties]
);
const startFilter = useCallback(
(layerId: string) => {
@@ -536,8 +545,9 @@ const LayerMenu = ({
if (result !== 'started') {
throw makeStatusError(result);
}
+ revealProperties(layerId);
},
- [engine, makeStatusError]
+ [engine, makeStatusError, revealProperties]
);
const submitRename = useCallback(
(name: string) => {
@@ -620,10 +630,9 @@ const LayerMenu = ({
}, [engine, layer.id, makeStatusError]);
const handleOpenProperties = useCallback(() => {
- widgets.open({ region: 'right', widgetId: 'layers' });
+ revealProperties(layer.id);
focusOpenedWidget('right', 'layers');
- requestLayerProperties(layer.id);
- }, [layer.id, widgets]);
+ }, [layer.id, revealProperties]);
const handleBooleanRaster = useCallback(
async (operation: BooleanRasterOperation) => {
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
index 3207a148f5..45a9029ce8 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.browser.test.tsx
@@ -1,5 +1,6 @@
/* oxlint-disable react-perf/jsx-no-new-function-as-prop */
import type { CanvasNodeContract, PreparedDocumentEdit } from '@workbench/canvas-engine/api';
+import type { CanvasOperationState } from '@workbench/canvas-operations/api';
import type { CanvasProjectMutation } from '@workbench/canvasProjectMutations';
import type { Project } from '@workbench/projectContracts';
@@ -11,6 +12,7 @@ import {
layerContract,
stacksFrom,
} from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
+import { attachCanvasOperations } from '@workbench/canvas-operations/operationAccess';
import { createEmptyCanvasDocument } from '@workbench/canvasMigration';
import { applyCanvasProjectMutation } from '@workbench/canvasProjectMutations';
import {
@@ -23,7 +25,7 @@ import {
} from '@workbench/layerPanelState';
import { createInitialWorkbenchState } from '@workbench/workbenchState';
import { createInstance } from 'i18next';
-import { act, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
+import { act, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
import { createRoot, type Root } from 'react-dom/client';
import { I18nextProvider, initReactI18next } from 'react-i18next';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -32,6 +34,7 @@ import { userEvent } from 'vitest/browser';
import { clearLayerChildSelection, getLayerChildSelection } from './layerChildSelection';
import { getLayerRowCommits, resetLayerRowCommits } from './layerPanelDiagnostics';
import { LAYER_PANEL_DEGRADE_THRESHOLD, LAYER_ROW_HEIGHT_PX } from './layerPanelRows';
+import { clearLayerPropertiesRequest, requestLayerProperties } from './layerPropertiesRequestStore';
import { LayersTree, type LayersTreeEngine } from './LayersTree';
import { buildLayerStackRows } from './layerTreeRows';
@@ -143,6 +146,64 @@ const exportBakedLayerBlob = vi.fn(() =>
const refusalChecks = vi.fn();
const revealRequests = vi.fn();
+/** The one operation-state seam the tree reads; tests publish through `setOperation`. */
+const operationHarness = (() => {
+ const listeners = new Set<() => void>();
+ let state: CanvasOperationState = { status: 'idle' };
+ return {
+ getOperationState: () => state,
+ set: (next: CanvasOperationState) => {
+ state = next;
+ listeners.forEach((listener) => listener());
+ },
+ subscribeOperation: (listener: () => void) => {
+ listeners.add(listener);
+ return () => listeners.delete(listener);
+ },
+ };
+})();
+const withOperations = (engine: LayersTreeEngine): LayersTreeEngine => {
+ attachCanvasOperations(engine, operationHarness as never);
+ return engine;
+};
+// The real engine handle is stable across document changes; this one reads the harness's latest document.
+let harnessDocument = createEmptyCanvasDocument();
+const engine = withOperations({
+ document: {
+ model: () => {
+ const model = createDocumentModel(harnessDocument, { editRevision: 0, projectId: PROJECT_ID });
+ return {
+ ...model,
+ refusalFor: (command: Parameters<typeof model.refusalFor>[0]) => {
+ refusalChecks(command);
+ return model.refusalFor(command);
+ },
+ };
+ },
+ },
+ exports: { exportBakedLayerBlob: exportBakedLayerBlob, hasExportableLayerContent: () => false },
+ interaction: { get: () => false },
+ layers: {
+ commitPrepared: (_label: string, edit: PreparedDocumentEdit) => {
+ dispatchExternal(edit.forward);
+ return { status: 'committed' as const };
+ },
+ },
+ previews: { drawLayerThumbnail: () => false, requestLayerThumbnail: thumbnailRequests },
+ projectId: PROJECT_ID,
+} as unknown as LayersTreeEngine);
+const setOperation = (layerId: string | null) =>
+ operationHarness.set(
+ layerId === null
+ ? { status: 'idle' }
+ : {
+ error: null,
+ identity: { kind: 'select-object', layerId, projectId: PROJECT_ID },
+ phase: 'ready',
+ status: 'active',
+ }
+ );
+
const Harness = ({ initialNodes }: { initialNodes: CanvasNodeContract[] }) => {
const [project, setProject] = useState<Project>(() => {
const initial = { ...createInitialWorkbenchState().projects[0]!, id: PROJECT_ID };
@@ -162,39 +223,9 @@ const Harness = ({ initialNodes }: { initialNodes: CanvasNodeContract[] }) => {
useEffect(() => {
dispatchExternal = dispatch;
}, [dispatch]);
- // The real engine handle is stable across document changes; the harness reads the document through a ref.
- const documentRef = useRef(document);
- useEffect(() => {
- documentRef.current = document;
+ useLayoutEffect(() => {
+ harnessDocument = document;
}, [document]);
- const engine = useMemo(
- () =>
- ({
- document: {
- model: () => {
- const model = createDocumentModel(documentRef.current, { editRevision: 0, projectId: PROJECT_ID });
- return {
- ...model,
- refusalFor: (command: Parameters<typeof model.refusalFor>[0]) => {
- refusalChecks(command);
- return model.refusalFor(command);
- },
- };
- },
- },
- exports: { exportBakedLayerBlob: exportBakedLayerBlob, hasExportableLayerContent: () => false },
- interaction: { get: () => false },
- layers: {
- commitPrepared: (_label: string, edit: PreparedDocumentEdit) => {
- dispatch(edit.forward);
- return { status: 'committed' as const };
- },
- },
- previews: { drawLayerThumbnail: () => false, requestLayerThumbnail: thumbnailRequests },
- projectId: PROJECT_ID,
- }) as unknown as LayersTreeEngine,
- [dispatch]
- );
const expanded = useMemo(() => new Set(panel.expandedGroupIds), [panel.expandedGroupIds]);
const stacks = useMemo(
() => buildLayerStackRows(document.stacks, expanded, panel.filter),
@@ -315,6 +346,8 @@ beforeEach(() => {
thumbnailRequests.mockClear();
refusalChecks.mockClear();
revealRequests.mockClear();
+ clearLayerPropertiesRequest();
+ setOperation(null);
});
afterEach(async () => {
@@ -663,6 +696,23 @@ describe('LayersTree selection, surfaces and structure', () => {
expect(readLayerPanelState(PROJECT_ID, null).expandedGroupIds).toContain('g');
expect(treeitem('Third')).toHaveAttribute('aria-level', '3');
});
+
+ it("reveals Properties for a running operation's layer but drops requests for any other layer", async () => {
+ await renderTree(trio());
+ // An operation started from a menu and its reveal request land in the same batch.
+ await act(() => {
+ setOperation('second');
+ requestLayerProperties('second');
+ });
+ await settle();
+ expect(revealRequests).toHaveBeenCalledWith('second');
+
+ revealRequests.mockClear();
+ await act(() => requestLayerProperties('third'));
+ await settle();
+ expect(revealRequests).not.toHaveBeenCalled();
+ expect(output('selected-layer')).not.toBe('third');
+ });
});
describe('LayersTree projected child rows', () => {
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
index a989ec554b..6d9ed37808 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
@@ -20,6 +20,7 @@ import {
setLayerPanelFocus,
toggleLayerStackCollapsed,
} from '@workbench/layerPanelState';
+import { useCanvasOperation } from '@workbench/widgets/canvas/engineStoreHooks';
import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';
import { useCallback, useEffectEvent, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { defaultRangeExtractor, useVirtualizer, type Range } from 'react-hook-tanstack-virtual';
@@ -175,6 +176,8 @@ export const LayersTree = ({
const { t } = useTranslation();
const commitPrepared = usePreparedCommit(engine);
const propertiesRequest = useCurrentLayerPropertiesRequest();
+ const operation = useCanvasOperation(engine);
+ const operationLayerId = operation.status === 'active' ? operation.identity.layerId : null;
const scrollRef = useRef<HTMLDivElement | null>(null);
const [scrollTop, setScrollTop] = useState(0);
const [surface, setSurface] = useState<LayerSurfaceRequest | null>(null);
@@ -687,13 +690,17 @@ export const LayersTree = ({
}
}, [primaryId, rowIndexByKey]);
- // Reveal external Properties requests, scroll after render, and open once; discard requests for removed nodes.
+ // Reveal external Properties requests, scroll after render, and open once; discard requests for removed nodes
+ // and, while an operation runs, for any layer but its target: the operation's panel supersedes them.
useLayoutEffect(() => {
if (!propertiesRequest) {
pendingProperties.current = null;
return;
}
- if (!getDocumentNode(document, propertiesRequest.layerId)) {
+ if (
+ !getDocumentNode(document, propertiesRequest.layerId) ||
+ (operationLayerId !== null && operationLayerId !== propertiesRequest.layerId)
+ ) {
clearLayerPropertiesRequest(propertiesRequest.token);
pendingProperties.current = null;
return;
@@ -712,7 +719,7 @@ export const LayersTree = ({
pendingProperties.current = { ...pending, scrolled: true };
virtualizerRef.current.scrollToIndex(index);
}
- }, [document, primaryId, projectId, propertiesRequest, rowIndexByKey]);
+ }, [document, operationLayerId, primaryId, projectId, propertiesRequest, rowIndexByKey]);
useLayoutEffect(() => {
const host = scrollRef.current;
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
index 04bc380032..224d822758 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
@@ -505,6 +505,33 @@ describe('Properties pane', () => {
}
});
+ it('titles the pane with the running operation, else the selected layer or group', async () => {
+ const title = () => page.getByRole('heading', { level: 2 });
+ await mount(PropertiesPane);
+ await expect.element(title()).toHaveTextContent('No layer selected');
+
+ await act(() => root?.unmount());
+ host?.remove();
+ registry?.releaseEngine('p');
+ await mount(PropertiesPane, 'group');
+ await expect.element(title()).toHaveTextContent('Group: Folder');
+
+ await act(() => root?.unmount());
+ host?.remove();
+ registry?.releaseEngine('p');
+ await mount(PropertiesPane, 'mask');
+ await expect.element(title()).toHaveTextContent('Layer: Mask');
+ await act(() => operations!.start(true));
+ await settle();
+ await expect.element(title()).toHaveTextContent('Operation: Filter');
+ // The title replaces the operation section's own header; the group keeps its accessible name.
+ const section = host!.querySelector<HTMLElement>('[role="group"][aria-label="Operation"]')!;
+ expect(section.textContent).not.toContain('Operation');
+ await act(() => operations!.start(false));
+ await settle();
+ await expect.element(title()).toHaveTextContent('Layer: Mask');
+ });
+
it('puts a running operation first with Cancel, locks the tool rows in place and hands them focus over', async () => {
await mount(PropertiesPane);
await act(() => engine!.tools.setTool('brush'));
@@ -512,7 +539,9 @@ describe('Properties pane', () => {
await act(() => page.getByRole('slider', { exact: true, name: 'Brush size' }).element().focus());
await act(() => operations!.start(true));
await settle();
- expect(host!.textContent?.indexOf('Operation')).toBeLessThan(host!.textContent?.indexOf('Tool') ?? -1);
+ const operationSection = host!.querySelector('[role="group"][aria-label="Operation"]')!;
+ const toolSection = host!.querySelector('[role="group"][aria-label="Tool"]')!;
+ expect(operationSection.compareDocumentPosition(toolSection) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
const cancel = page.getByRole('button', { exact: true, name: 'Cancel' });
await expect.element(cancel).toBeEnabled();
await expect.element(page.getByRole('button', { exact: true, name: 'Apply' })).toBeDisabled();
@@ -627,7 +656,7 @@ describe('Layer editor panes host', () => {
await act(() => operations!.start(true));
await settle();
const draft = operations!.getFilterSessionState()!.draft;
- expect(host!.textContent).toContain('Operation');
+ expect(host!.querySelector('[role="group"][aria-label="Operation"]')).not.toBeNull();
await act(async () => {
await userEvent.click(page.getByRole('tab', { exact: true, name: 'Overview' }));
@@ -644,7 +673,7 @@ describe('Layer editor panes host', () => {
expect(operations!.resetFilterOperation).not.toHaveBeenCalled();
expect(operations!.cancelFilterOperation).not.toHaveBeenCalled();
expect(operations!.commitFilterOperation).not.toHaveBeenCalled();
- expect(host!.textContent).toContain('Operation');
+ expect(host!.querySelector('[role="group"][aria-label="Operation"]')).not.toBeNull();
await expect.element(page.getByRole('button', { exact: true, name: 'Cancel' })).toBeEnabled();
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
index d1e22961e9..36026fe8be 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
@@ -37,7 +37,7 @@ type LayerSectionEngine = Pick<
// Reference equality is exact: the document index hands back the same node
// object until the node itself changes, and the section renders the whole
// node, so a narrower comparison would serve stale views of it.
-const selectSelectedNode = (project: {
+export const selectSelectedNode = (project: {
canvas: { document: Pick<CanvasDocumentContractV3, 'stacks' | 'selectedLayerId'> };
}): CanvasNodeContract | null => getDocumentNode(project.canvas.document, project.canvas.document.selectedLayerId);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx
index 8b266264b5..dd075724e9 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx
@@ -1,4 +1,4 @@
-import { Flex, Stack } from '@chakra-ui/react';
+import { Flex, Heading, Stack } from '@chakra-ui/react';
import { Scrollable } from '@platform/ui/Scrollable';
import { isCanvasInteractionLocked } from '@workbench/widgets/canvas/canvasInteractionLock';
import { useCanvasActiveTool, useCanvasOperation } from '@workbench/widgets/canvas/engineStoreHooks';
@@ -13,9 +13,45 @@ import { useLayoutEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { GroupSelectedNotice } from './GroupSelectedNotice';
-import { LayerSection } from './LayerSection';
+import { LayerSection, selectSelectedNode } from './LayerSection';
import { PropertiesSection } from './PropertiesSection';
+const OPERATION_TITLE_KEYS = {
+ filter: 'widgets.layers.rasterFilter.title',
+ 'select-object': 'widgets.layers.selectObject.title',
+} as const;
+
+/** Name what the pane is editing: the running operation, else the selected layer or group. */
+const PropertiesTitle = ({ operationName }: { operationName: string | null }) => {
+ const { t } = useTranslation();
+ const node = useActiveProjectSelector(selectSelectedNode);
+ const title =
+ operationName !== null
+ ? t('widgets.properties.title.operation', { name: operationName })
+ : node
+ ? t(node.type === 'group' ? 'widgets.properties.title.group' : 'widgets.properties.title.layer', {
+ name: node.name,
+ })
+ : t('widgets.transform.noSelection');
+ return (
+ <Flex
+ bg="bg.panel"
+ borderBottomWidth="1px"
+ borderColor="border.subtle"
+ minW="0"
+ position="sticky"
+ px="3"
+ py="2"
+ top="0"
+ zIndex="1"
+ >
+ <Heading as="h2" fontSize="sm" fontWeight="semibold" lineClamp={2} minW="0" wordBreak="break-word">
+ {title}
+ </Heading>
+ </Flex>
+ );
+};
+
/** Show active operation before tool forms; use existing engine stores/transactions without mirrored state. */
export const PropertiesPane = () => {
const { t } = useTranslation();
@@ -69,13 +105,9 @@ const ConnectedProperties = ({
return (
<Stack ref={root} gap="0">
+ <PropertiesTitle operationName={running ? t(OPERATION_TITLE_KEYS[running.kind]) : null} />
{running ? (
- <PropertiesSection
- subtitle={t(
- running.kind === 'filter' ? 'widgets.layers.rasterFilter.title' : 'widgets.layers.selectObject.title'
- )}
- title={t('widgets.properties.sections.operation')}
- >
+ <PropertiesSection headerHidden title={t('widgets.properties.sections.operation')}>
{running.groups.map((group) => (
<PropertyGroup key={group.id} collapsible={group.collapsible} id={group.id} label={t(group.labelKey)}>
<group.body {...regionProps} />
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
index 3d9b1ab8c3..7e76181aad 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
@@ -7,6 +7,7 @@ import { FieldLabel } from '@platform/ui/Field';
export const PropertiesSection = ({
children,
disabled = false,
+ headerHidden = false,
ref,
subtitle,
title,
@@ -14,6 +15,8 @@ export const PropertiesSection = ({
children: ReactNode;
/** The surface is busy elsewhere (staging, generation, an operation): the rows stay in place but cannot act. */
disabled?: boolean;
+ /** The pane title already names this section; `title` still labels the group for assistive technology. */
+ headerHidden?: boolean;
ref?: Ref<HTMLDivElement>;
subtitle?: string;
title: string;
@@ -31,14 +34,16 @@ export const PropertiesSection = ({
py="2.5"
role="group"
>
- <Flex align="baseline" gap="2" minW="0">
- <FieldLabel>{title}</FieldLabel>
- {subtitle ? (
- <Text color="fg.muted" fontSize="xs" minW="0" truncate>
- {subtitle}
- </Text>
- ) : null}
- </Flex>
+ {headerHidden ? null : (
+ <Flex align="baseline" gap="2" minW="0">
+ <FieldLabel>{title}</FieldLabel>
+ {subtitle ? (
+ <Text color="fg.muted" fontSize="xs" minW="0" truncate>
+ {subtitle}
+ </Text>
+ ) : null}
+ </Flex>
+ )}
{children}
</Stack>
);