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.

chore(canvas): close out the context toolbar and Properties proposal

Josh Corbett304bb2d6ddcb
diff --git a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
index 1e51913109..2ce36b2d83 100644
--- a/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
+++ b/invokeai/frontend/webv2/scripts/run-accessibility-journeys.mjs
@@ -816,6 +816,71 @@ const runKeepAliveStateJourney = async (browser) => {
}
};
+/**
+ * The layers panel's fixed panes: every pane block switches by pointer and by
+ * keyboard (arrows rove, Enter selects — SegmentTabs is manual-activation),
+ * tool switches reshape the Properties pane without losing it, and axe passes
+ * with the non-default panes (Swatches/History/Overview) active — states the
+ * static canvas surface never reaches.
+ */
+const LAYERS_PANEL_SCOPE = { include: ['[data-hotkey-widget-type-id="layers"]'] };
+
+const runLayersPanesJourney = async (browser) => {
+ const { context, page, pageErrors } = await openRepresentativePage(browser, representativeProjectPath);
+
+ try {
+ await waitForWorkbench(page);
+ await selectLayoutPreset(page, 'Edit', 'Canvas');
+ const propertiesTab = page.getByRole('tab', { exact: true, name: 'Properties' });
+ await propertiesTab.waitFor();
+
+ // Tool switching swaps the Tool section's rows in place.
+ const tools = page.getByRole('toolbar', { exact: true, name: 'Tools' });
+ await tools.getByRole('button', { exact: true, name: 'Brush' }).click();
+ await page.getByRole('tabpanel', { exact: true, name: 'Properties' }).getByText('Size', { exact: true }).waitFor();
+ await tools.getByRole('button', { exact: true, name: 'View' }).click();
+ await page.getByRole('tabpanel', { exact: true, name: 'Properties' }).waitFor();
+
+ // Pointer: activate every non-default pane across the three blocks.
+ await page.getByRole('tab', { exact: true, name: 'Overview' }).click();
+ await page.getByRole('button', { exact: true, name: 'Pan the canvas view' }).waitFor();
+ await page.getByRole('tab', { exact: true, name: 'History' }).click();
+ await page.getByRole('tabpanel', { exact: true, name: 'History' }).waitFor();
+ await page.getByRole('tab', { exact: true, name: 'Swatches' }).click();
+ await page.getByRole('tabpanel', { exact: true, name: 'Swatches' }).waitFor();
+
+ await waitForSettledDocument(page);
+ // Scoped to the layers widget: this journey certifies the panel's states;
+ // the page-wide sweep belongs to the canvas surface scan, and the left
+ // rail's lazily mounted generation sections would otherwise leak into the
+ // result nondeterministically depending on load timing.
+ await assertNoAxeViolations(page, 'workbench-layers-panes', LAYERS_PANEL_SCOPE);
+
+ // Keyboard: arrows rove within the block's tablist, Enter activates.
+ const overviewTab = page.getByRole('tab', { exact: true, name: 'Overview' });
+ await overviewTab.focus();
+ await overviewTab.press('ArrowLeft');
+ const transformTab = page.getByRole('tab', { exact: true, name: 'Transform' });
+ await expectFocused(transformTab, 'ArrowLeft should move focus from Overview to Transform.');
+ await transformTab.press('Enter');
+ await page.getByRole('tabpanel', { exact: true, name: 'Transform' }).waitFor();
+ assert.equal(await transformTab.getAttribute('aria-selected'), 'true');
+
+ // Second scan: the Transform pane's states are distinct from the first
+ // scan's Swatches/History/Overview set and must pass on their own.
+ await waitForSettledDocument(page);
+ await assertNoAxeViolations(page, 'workbench-layers-panes:transform', LAYERS_PANEL_SCOPE);
+
+ if (pageErrors.length > 0) {
+ throw new AggregateError(pageErrors, 'workbench-layers-panes raised uncaught browser errors.');
+ }
+
+ return { id: 'workbench-layers-panes', status: 'passed' };
+ } finally {
+ await context.close();
+ }
+};
+
const mockBackend = await startMockBackend(backendPort, { profile: 'representative' });
const preview = spawn(
'pnpm',
@@ -858,6 +923,9 @@ try {
if (!requestedJourney || requestedJourney === 'workbench-keep-alive-state') {
reports.push(await runKeepAliveStateJourney(browser));
}
+ if (!requestedJourney || requestedJourney === 'workbench-layers-panes') {
+ reports.push(await runLayersPanesJourney(browser));
+ }
if (reports.length === 0) {
throw new Error(`Unknown accessibility journey ${JSON.stringify(requestedJourney)}.`);
}
diff --git a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
index 7b7b9db9c4..c15b22e4ab 100644
--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
@@ -1,5 +1,38 @@
import type { HotkeyCategory, HotkeyDefinition } from './types';
+/**
+ * Intentional browser-default interception
+ *
+ * Every registered hotkey prevents default, but only entries with handlers
+ * actually shadow a browser chord. Handlers come from two registries sharing
+ * the same scope resolution: this catalog's `implemented` set, and the
+ * extension-hotkey path (`CanvasWidgetView` registers the canvas's runtime
+ * chords there with `allowInEditable: false`; several ids — X/D color pair,
+ * undo/redo, delete, entity nav, mergeDown, transformSelected — exist in BOTH,
+ * resolving at equal widget-scope priority). A catalog entry with no handler
+ * anywhere (the mod+0…4 zoom chords) intercepts nothing.
+ *
+ * Chords that deliberately override a browser default, outside editable
+ * fields (hotkeys skip editables unless listed in `editableAppHotkeys`):
+ *
+ * - mod+p (`app.openProjectSwitcher`) — print dialog;
+ * - mod+k (`app.openCommandPalette`) — address-bar search;
+ * - mod+, (`app.openSettings`) — browser settings, where the browser
+ * delivers the event to the page at all;
+ * - mod+z / mod+shift+z / mod+y (canvas and workflow undo/redo) — native
+ * text undo;
+ * - mod+a / mod+c / mod+v (canvas, workflow, gallery select/copy/paste) —
+ * the app's own selection/clipboard semantics replace the page's;
+ * - canvas mod+e (merge down) — macOS "use selection for find" / address-bar
+ * search; mod+d (deselect) — bookmark; mod+shift+i (invert selection) —
+ * devtools where delivered; mod+t (transform) — browser-reserved in most
+ * builds, fires only where forwarded.
+ *
+ * Scoping bounds the blast radius: `app.*` chords are global, everything
+ * else fires only while its widget owns focus (`categoryScopes`). Bare keys
+ * ([ ] tool width, X/D, tool mnemonics) conflict with no browser default.
+ */
+
const categoryScopes = {
app: { kind: 'global' },
canvas: { kind: 'widget', typeId: 'canvas' },
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/HistoryPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/HistoryPane.tsx
index d06b2f72e5..74312d168f 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/HistoryPane.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/HistoryPane.tsx
@@ -67,12 +67,12 @@ const ConnectedHistory = ({ engine }: { engine: CanvasEngineHandle }) => {
<Icon as={Redo2Icon} boxSize="3.5" />
</IconButton>
</Tooltip>
- <Text color="fg.subtle" fontSize="2xs" fontVariantNumeric="tabular-nums">
+ <Text color="fg.muted" fontSize="2xs" fontVariantNumeric="tabular-nums">
{t('widgets.layers.historyPane.count', { count: past.length })}
</Text>
</HStack>
{past.length === 0 && future.length === 0 ? (
- <Flex align="center" color="fg.subtle" flex="1" fontSize="xs" justify="center" p="4">
+ <Flex align="center" color="fg.muted" flex="1" fontSize="xs" justify="center" p="4">
{t('widgets.layers.historyPane.empty')}
</Flex>
) : (
@@ -130,7 +130,10 @@ const HistoryStep = ({
<chakra.button
aria-current={isCurrent ? 'step' : undefined}
bg={isCurrent ? 'bg.emphasized' : 'transparent'}
- color={isCurrent ? 'fg' : isFuture ? 'fg.subtle' : 'fg.muted'}
+ // Future (redoable) steps read as dimmed via italics; fg.subtle fails
+ // WCAG contrast at this size, so color stays at fg.muted for both.
+ color={isCurrent ? 'fg' : 'fg.muted'}
+ fontStyle={isFuture ? 'italic' : undefined}
cursor="pointer"
flex="1"
fontSize="xs"
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 d0504309e8..703258c7cc 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
@@ -253,6 +253,24 @@ describe('Properties pane', () => {
expect(host!.textContent).toContain('Drag to pan and scroll to zoom.');
});
+ it('keeps the Tool section mounted with stable geometry across every tool switch', async () => {
+ await mount(PropertiesPane);
+ await act(() => engine!.tools.setTool('brush'));
+ await settle();
+ const section = host!.querySelector<HTMLElement>('[role="group"][aria-label="Tool"]')!;
+ const { left, top } = section.getBoundingClientRect();
+ for (const tool of ['eraser', 'view', 'move', 'shape'] as const) {
+ await act(() => engine!.tools.setTool(tool));
+ await settle();
+ // Same node, same anchor: switching tools swaps rows inside the
+ // section but never unmounts or repositions the section itself.
+ expect(host!.querySelector('[role="group"][aria-label="Tool"]')).toBe(section);
+ const rect = section.getBoundingClientRect();
+ expect(rect.left).toBe(left);
+ expect(rect.top).toBe(top);
+ }
+ });
+
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'));
@@ -368,6 +386,34 @@ describe('Layer editor panes host', () => {
expect(host!.querySelector('[role="tabpanel"]')).not.toBeNull();
});
+ it('preserves a running operation draft across pane tab switches', async () => {
+ paneHarnessLayout = { ...LAYER_EDITOR_PANE_DEFAULTS };
+ await mount(LayerEditorPanesHarness);
+ await act(() => engine!.tools.setTool('brush'));
+ await act(() => operations!.start(true));
+ await settle();
+ const draft = operations!.getFilterSessionState()!.draft;
+ expect(host!.textContent).toContain('Operation');
+
+ await act(async () => {
+ await userEvent.click(page.getByRole('tab', { exact: true, name: 'Overview' }));
+ });
+ await settle();
+ await act(async () => {
+ await userEvent.click(page.getByRole('tab', { exact: true, name: 'Properties' }));
+ });
+ await settle();
+
+ // Drafts live engine-side; remounting the pane reads the same one back
+ // and the unmount must not cancel, reset, or commit the session.
+ expect(operations!.getFilterSessionState()!.draft).toBe(draft);
+ expect(operations!.resetFilterOperation).not.toHaveBeenCalled();
+ expect(operations!.cancelFilterOperation).not.toHaveBeenCalled();
+ expect(operations!.commitFilterOperation).not.toHaveBeenCalled();
+ expect(host!.textContent).toContain('Operation');
+ await expect.element(page.getByRole('button', { exact: true, name: 'Cancel' })).toBeEnabled();
+ });
+
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);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx
index 64e313865b..245e038a12 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx
@@ -179,7 +179,7 @@ const ConnectedTransform = ({ engine }: { engine: CanvasEngineHandle }) => {
</Button>
</Flex>
) : (
- <Text color="fg.subtle" fontSize="2xs">
+ <Text color="fg.muted" fontSize="2xs">
{t('widgets.transform.hint')}
</Text>
)}