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(layers): stack-header hints as informational popovers

Josh Corbetta341427275a6
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 31742be7d0..cc9b11efa2 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -767,6 +767,34 @@
"Can boost local detail, but may affect global coherence."
]
},
+ "layerStackControl": {
+ "heading": "Control Layers",
+ "paragraphs": [
+ "Layers that guide generation with structural hints such as edges, depth, or pose maps.",
+ "Each control layer pairs its image with a control model and a weight that sets how strongly it steers the result."
+ ]
+ },
+ "layerStackInpaintMask": {
+ "heading": "Inpaint Masks",
+ "paragraphs": [
+ "Masks that mark regions of the image for regeneration.",
+ "Painted areas are regenerated on the next invoke; noise and denoise-limit modifiers tune how strongly the area may change."
+ ]
+ },
+ "layerStackRaster": {
+ "heading": "Raster Layers",
+ "paragraphs": [
+ "The pixel layers that compose your image and feed generation.",
+ "Layers apply top to bottom, and each can carry a stack of non-destructive adjustments such as levels, curves, or hue."
+ ]
+ },
+ "layerStackRegionalGuidance": {
+ "heading": "Regional Guidance",
+ "paragraphs": [
+ "Regions that apply prompts and reference images to part of the image.",
+ "Painted regions scope their prompts and reference images to just that area of the canvas."
+ ]
+ },
"model": {
"heading": "Model",
"paragraphs": [
@@ -3045,12 +3073,6 @@
"reorderAdjustment": "Reorder adjustment",
"moveReferenceImage": "Move reference image",
"moveToLayer": "Move to “{{name}}”"
- },
- "groupHints": {
- "control": "Layers that guide generation with structural hints like edges, depth, or pose.",
- "inpaint_mask": "Masks that mark regions of the image for regeneration.",
- "raster": "The pixel layers that compose your image and feed generation.",
- "regional_guidance": "Regions that apply prompts and reference images to part of the image."
}
},
"gallery": {
diff --git a/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts b/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts
index 1bb2a9af8e..da628ac754 100644
--- a/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts
@@ -44,6 +44,10 @@ export const FEATURE_HINTS = {
imageInfluence: {
href: 'https://support.invoke.ai/support/solutions/articles/151000094998-image-to-image',
},
+ layerStackControl: {},
+ layerStackInpaintMask: {},
+ layerStackRaster: {},
+ layerStackRegionalGuidance: {},
model: {
href: 'https://support.invoke.ai/support/solutions/articles/151000096601-what-is-a-model-which-should-i-use-',
},
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.browser.test.tsx
new file mode 100644
index 0000000000..a24733ea05
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.browser.test.tsx
@@ -0,0 +1,125 @@
+import { ChakraProvider } from '@chakra-ui/react';
+import { FeatureHintsProvider, type FeatureHintsAdapter } from '@platform/ui/hints/hintsContext';
+import { applyThemeToRoot } from '@theme/applyTheme';
+import { system } from '@theme/system';
+import { createEmptyCanvasDocument } from '@workbench/canvasMigration';
+import { createInstance } from 'i18next';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { userEvent } from 'vitest/browser';
+
+import type { LayerRowCommands } from './layerRowCommands';
+
+import { LayerStackHeader } from './LayerStackHeader';
+
+vi.mock('./useLayerStackActions', () => ({ useLayerStackActions: () => [] }));
+
+const HEADING = 'Raster Layers';
+const GIST = 'The pixel layers that compose your image and feed generation.';
+
+const i18n = createInstance();
+void i18n.use(initReactI18next).init({
+ fallbackLng: 'en',
+ initAsync: false,
+ lng: 'en',
+ resources: {
+ en: {
+ translation: {
+ hints: {
+ layerStackRaster: { heading: HEADING, paragraphs: [GIST, 'Layers apply top to bottom.'] },
+ },
+ widgets: {
+ layers: {
+ groupActions: { collapse: 'Collapse', expand: 'Expand', new: 'New layer' },
+ groups: { raster: 'Raster Layers' },
+ },
+ },
+ },
+ },
+ },
+});
+
+const commands = {
+ focus: () => undefined,
+ keyDown: () => undefined,
+ openStackMenu: () => undefined,
+ toggleCollapse: () => undefined,
+} as unknown as LayerRowCommands;
+
+const hintsAdapter: FeatureHintsAdapter = { enabled: true, onDisable: null };
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const settle = (action: () => void): Promise<void> =>
+ act(async () => {
+ action();
+ await new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 30);
+ });
+ });
+
+const render = async () => {
+ applyThemeToRoot('classic');
+ host = document.createElement('div');
+ host.style.width = '320px';
+ document.body.append(host);
+ root = createRoot(host);
+ await settle(() => {
+ root?.render(
+ <I18nextProvider i18n={i18n}>
+ <ChakraProvider value={system}>
+ <FeatureHintsProvider adapter={hintsAdapter}>
+ <LayerStackHeader
+ collapsed={false}
+ commands={commands}
+ document={createEmptyCanvasDocument()}
+ editingLocked={false}
+ engine={null}
+ focused
+ leafCount={0}
+ posInSet={1}
+ rowKey="header:raster"
+ setSize={4}
+ stack="raster"
+ />
+ </FeatureHintsProvider>
+ </ChakraProvider>
+ </I18nextProvider>
+ );
+ });
+};
+
+afterEach(async () => {
+ await settle(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+describe('LayerStackHeader hint', () => {
+ it('describes the tree item persistently and opens the informational popover on keyboard focus', async () => {
+ await render();
+ const header = host!.querySelector<HTMLElement>('[role="treeitem"]')!;
+ const description = document.getElementById(header.getAttribute('aria-describedby')!);
+ expect(header.contains(description)).toBe(true);
+ expect(description!.textContent).toBe(GIST);
+
+ await act(async () => {
+ await userEvent.tab();
+ });
+ expect(document.activeElement).toBe(header);
+ await act(
+ () =>
+ new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 900);
+ })
+ );
+ const card = document.querySelector('[data-scope="hover-card"][data-part="content"]');
+ expect(card?.textContent).toContain(HEADING);
+ expect(card?.textContent).toContain(GIST);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx
index 53a12027ac..51afae85b1 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerStackHeader.tsx
@@ -1,8 +1,10 @@
+import type { FeatureHintId } from '@platform/ui/hints/hintRegistry';
import type { CanvasDocumentContractV3, LayerStackKind } from '@workbench/canvas-engine/api';
import type { KeyboardEvent, MouseEvent } from 'react';
-import { Box, HStack, Icon, Text } from '@chakra-ui/react';
+import { Box, HStack, Icon, Text, VisuallyHidden } from '@chakra-ui/react';
import { IconButton, Tooltip } from '@platform/ui';
+import { FeatureHint } from '@platform/ui/hints/FeatureHint';
import { ChevronDownIcon } from 'lucide-react';
import { memo, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
@@ -14,6 +16,13 @@ import { useLayerStackActions, type LayerStackActionsEngine } from './useLayerSt
const HEADER_FOCUS = { outline: '2px solid', outlineColor: 'accent.solid', outlineOffset: '-2px' };
+const STACK_HINTS: Record<LayerStackKind, FeatureHintId> = {
+ control: 'layerStackControl',
+ inpaint_mask: 'layerStackInpaintMask',
+ raster: 'layerStackRaster',
+ regional_guidance: 'layerStackRegionalGuidance',
+};
+
interface LayerStackHeaderProps {
collapsed: boolean;
commands: LayerRowCommands;
@@ -84,46 +93,53 @@ const LayerStackHeaderComponent = ({
},
[commands, stack]
);
+ const hintId = STACK_HINTS[stack];
+ const descriptionId = `layer-stack-hint-${stack}`;
return (
- <Box
- ref={element}
- aria-expanded={!collapsed}
- aria-hidden={pinned || undefined}
- aria-label={t(`widgets.layers.groups.${stack}`)}
- aria-level={1}
- aria-posinset={posInSet}
- aria-setsize={setSize}
- bg={pinned ? 'bg.panel' : 'transparent'}
- data-layer-row-id={pinned ? undefined : rowKey}
- h="full"
- role={pinned ? undefined : 'treeitem'}
- rounded="sm"
- tabIndex={pinned ? undefined : focused ? 0 : -1}
- _focusVisible={HEADER_FOCUS}
- onClick={handleClick}
- onContextMenu={handleContextMenu}
- onFocus={pinned ? undefined : handleFocus}
- onKeyDown={pinned ? undefined : handleKeyDown}
- >
- <HStack gap="1" h="full" pe="1.5" ps="0">
- <IconButton
- aria-label={t(collapsed ? 'widgets.layers.groupActions.expand' : 'widgets.layers.groupActions.collapse')}
- color="fg.muted"
- size="2xs"
- tabIndex={-1}
- variant="ghost"
- onClick={handleToggle}
- onMouseDown={keepFocus}
- >
- <Icon
- as={ChevronDownIcon}
- boxSize="3.5"
- transform={collapsed ? 'rotate(-90deg)' : undefined}
- transitionDuration="fast"
- transitionProperty="transform"
- />
- </IconButton>
- <Tooltip content={t(`widgets.layers.groupHints.${stack}`)} openDelay={600}>
+ // The informational popover triggers on the whole tree item, so it opens
+ // for the roving keyboard focus as well as hover; the persistent
+ // described-by span announces the gist without the card.
+ <FeatureHint hint={hintId}>
+ <Box
+ ref={element}
+ aria-describedby={pinned ? undefined : descriptionId}
+ aria-expanded={!collapsed}
+ aria-hidden={pinned || undefined}
+ aria-label={t(`widgets.layers.groups.${stack}`)}
+ aria-level={1}
+ aria-posinset={posInSet}
+ aria-setsize={setSize}
+ bg={pinned ? 'bg.panel' : 'transparent'}
+ data-layer-row-id={pinned ? undefined : rowKey}
+ h="full"
+ role={pinned ? undefined : 'treeitem'}
+ rounded="sm"
+ tabIndex={pinned ? undefined : focused ? 0 : -1}
+ _focusVisible={HEADER_FOCUS}
+ onClick={handleClick}
+ onContextMenu={handleContextMenu}
+ onFocus={pinned ? undefined : handleFocus}
+ onKeyDown={pinned ? undefined : handleKeyDown}
+ >
+ {pinned ? null : <VisuallyHidden id={descriptionId}>{t(`hints.${hintId}.paragraphs.0`)}</VisuallyHidden>}
+ <HStack gap="1" h="full" pe="1.5" ps="0">
+ <IconButton
+ aria-label={t(collapsed ? 'widgets.layers.groupActions.expand' : 'widgets.layers.groupActions.collapse')}
+ color="fg.muted"
+ size="2xs"
+ tabIndex={-1}
+ variant="ghost"
+ onClick={handleToggle}
+ onMouseDown={keepFocus}
+ >
+ <Icon
+ as={ChevronDownIcon}
+ boxSize="3.5"
+ transform={collapsed ? 'rotate(-90deg)' : undefined}
+ transitionDuration="fast"
+ transitionProperty="transform"
+ />
+ </IconButton>
<Text
color="fg.muted"
cursor="pointer"
@@ -136,26 +152,26 @@ const LayerStackHeaderComponent = ({
>
{t(`widgets.layers.groups.${stack}`)} ({leafCount})
</Text>
- </Tooltip>
- <HStack gap="0.5" onClick={stopPropagation} onMouseDown={keepFocus}>
- {actions.map((action) => (
- <Tooltip key={action.id} content={action.label}>
- <IconButton
- aria-label={action.label}
- color="fg.muted"
- disabled={action.disabled}
- size="2xs"
- tabIndex={-1}
- variant="ghost"
- onClick={action.run}
- >
- <Icon as={action.icon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- ))}
+ <HStack gap="0.5" onClick={stopPropagation} onMouseDown={keepFocus}>
+ {actions.map((action) => (
+ <Tooltip key={action.id} content={action.label}>
+ <IconButton
+ aria-label={action.label}
+ color="fg.muted"
+ disabled={action.disabled}
+ size="2xs"
+ tabIndex={-1}
+ variant="ghost"
+ onClick={action.run}
+ >
+ <Icon as={action.icon} boxSize="3.5" />
+ </IconButton>
+ </Tooltip>
+ ))}
+ </HStack>
</HStack>
- </HStack>
- </Box>
+ </Box>
+ </FeatureHint>
);
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
index ba3b6d2425..89b3d749ae 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
@@ -675,8 +675,12 @@ export const LayersTree = ({
// Focus repair: the browser drops focus to the body when a focused row unmounts, so the tree
// remembers whether it owned focus and puts it back on the item that now holds the tab stop.
- const handleFocusCapture = useCallback(() => {
- treeOwnsFocus.current = true;
+ // Portaled children (the stack hint card) route focus through this capture
+ // handler while their DOM lives outside the host; only real host focus counts.
+ const handleFocusCapture = useCallback((event: FocusEvent<HTMLElement>) => {
+ if (event.currentTarget.contains(event.target as Node)) {
+ treeOwnsFocus.current = true;
+ }
}, []);
const handleBlurCapture = useCallback((event: FocusEvent<HTMLElement>) => {
if (event.relatedTarget && !event.currentTarget.contains(event.relatedTarget as Node)) {