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
feat(preview): show board/image name in widget header label
joshistoaste0cb53586ec4
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsxnew file mode 100644index 0000000000..2c399141c2--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsx@@ -0,0 +1,38 @@+import type { WidgetLabelProps } from '@workbench/types';++import { HStack, Text } from '@chakra-ui/react';+import { useTranslation } from 'react-i18next';++import { usePreviewHeaderContext } from './previewHeaderStore';++/**+ * The preview widget's header label: `[board] / [image]` for the current+ * selection (published by the view via `previewHeaderStore`), falling back to+ * the static "Preview" title when nothing is selected.+ */+export const PreviewWidgetLabel = (_props: WidgetLabelProps) => {+ const { t } = useTranslation();+ const { boardName, imageName } = usePreviewHeaderContext();++ if (!imageName || !boardName) {+ return (+ <Text fontSize="xs" fontWeight="700">+ {t('widgets.labels.preview')}+ </Text>+ );+ }++ return (+ <HStack flex="1" gap="1" minW="0">+ <Text flexShrink={0} fontSize="xs" fontWeight="700">+ {boardName}+ </Text>+ <Text color="fg.subtle" flexShrink={0} fontSize="xs">+ /+ </Text>+ <Text color="fg.subtle" fontSize="xs" truncate>+ {imageName}+ </Text>+ </HStack>+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex ed07e40b9e..31b61de17d 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -35,6 +35,7 @@ import { PreviewCompare } from './PreviewCompare';import { usePreviewDensity, type PreviewDensity } from './previewDensity';import { PreviewFooter } from './PreviewFooter';import { PreviewFrame } from './PreviewFrame';+import { previewHeaderStore } from './previewHeaderStore';import { getPreviewComparisonMode, type PreviewComparisonMode } from './previewSettings';type PreviewImage = GeneratedImageContract & Partial<Pick<GalleryImage, 'boardId' | 'imageCategory' | 'starred'>>;@@ -355,6 +356,19 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {const selectNextImage = useCallback(() => selectByOffset(1), [selectByOffset]);const selectPreviousImage = useCallback(() => selectByOffset(-1), [selectByOffset]);const closeContextMenu = useCallback(() => setContextMenuTarget(null), []);+ const selectedImageName = selectedImage?.imageName ?? null;++ // Publish the header label context ("[board] / [image]") for the widget+ // frame; the frame chrome renders outside this view, so an external store is+ // the sync channel. Cleared on unmount so a stale title never outlives us.+ useEffect(() => {+ previewHeaderStore.set({+ boardName: selectedImageName === null ? null : boardName,+ imageName: selectedImageName,+ });+ }, [boardName, selectedImageName]);++ useEffect(() => () => previewHeaderStore.clear(), []);const executeViewerHotkey = useEffectEvent((commandId: string) => {if (commandId === 'viewer.toggleViewer') {runtime.workbench.closeWidgetInstance(runtime.instanceId);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/index.tsindex 6a5ce78602..ea84aef991 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/index.ts@@ -3,6 +3,7 @@ import type { WidgetManifest } from '@workbench/types';import { EyeIcon } from 'lucide-react';import { PreviewHeaderActions } from './PreviewHeaderActions';+import { PreviewWidgetLabel } from './PreviewWidgetChrome';import { PreviewWidgetView } from './PreviewWidgetView';export const previewWidgetManifest: WidgetManifest = {@@ -10,6 +11,7 @@ export const previewWidgetManifest: WidgetManifest = {allowedRegions: ['center', 'right'],failurePolicy: { isolateRenderFailure: true, onRegistrationFailure: 'disable' },headerActions: PreviewHeaderActions,+ headerLabel: PreviewWidgetLabel,icon: EyeIcon,id: 'preview',label: (t) => t('widgets.labels.preview'),diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/previewHeaderStore.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewHeaderStore.tsnew file mode 100644index 0000000000..9517f81fff--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/previewHeaderStore.ts@@ -0,0 +1,28 @@+import { createExternalStore } from '@workbench/externalStore';++/**+ * Header context published by the preview view so the widget frame's label can+ * show "[board] / [image]" without refetching boards. The preview is a+ * singleton widget (`allowMultiple: false`), so one module-level store is safe.+ * Cleared when the view unmounts or nothing is selected; the label falls back+ * to the static widget title.+ */+export interface PreviewHeaderContext {+ boardName: string | null;+ imageName: string | null;+}++const emptyContext: PreviewHeaderContext = { boardName: null, imageName: null };++const store = createExternalStore<PreviewHeaderContext>(emptyContext);++export const previewHeaderStore = {+ clear(): void {+ store.patchSnapshot(emptyContext);+ },+ set(context: PreviewHeaderContext): void {+ store.patchSnapshot(context);+ },+};++export const usePreviewHeaderContext = (): PreviewHeaderContext => store.useSelector((snapshot) => snapshot);