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): trade the copy and download buttons for Edit on Canvas
joshistoast7a69690222eb
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex 445276a087..f16e86bf45 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1933,6 +1933,7 @@},"compare": "Compare","copyCurrentFrame": "Copy Current Frame",+ "editOnCanvas": "Edit on Canvas","copyCurrentFrameDrawFailed": "Could not read the current video frame","copyCurrentFrameEncodeFailed": "Could not encode the current video frame","copyCurrentFrameNotReady": "The video does not have a current frame yet",diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewActionStrip.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewActionStrip.tsxindex 211c86f2ff..db605ea7ef 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewActionStrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewActionStrip.tsx@@ -6,10 +6,10 @@ import { galleryImageItemToGalleryImage, isGalleryImageItem, toGalleryItemRef }import { IconButton, Tooltip } from '@platform/ui';import {CopyIcon,- DownloadIcon,EllipsisVerticalIcon,FileJsonIcon,ImagesIcon,+ PencilIcon,StarIcon,type LucideIcon,} from 'lucide-react';@@ -24,6 +24,12 @@ import type { PreviewDensity } from './previewDensity';* (anchored under the button) — one source of truth for every image verb,* mirroring the legacy viewer's menu button. Compact densities collapse to* star + the dropdown.+ *+ * The strip earns its space by holding what the dropdown cannot reach in one+ * click. Copy and Download sat here *and* in the dropdown's quick row, so they+ * cost a slot each to save nothing; editing on canvas — the one verb that+ * moves the image into actual work — had no button at all. Copy and Download+ * stay one click away in the dropdown.*/export const PreviewActionStrip = ({actions,@@ -50,10 +56,9 @@ export const PreviewActionStrip = ({[actions, item]);const selectForCompare = useCallback(() => image && actions.selectForCompare(image), [actions, image]);- const copyImage = useCallback(() => image && void actions.copyImage(image), [actions, image]);+ const editOnCanvas = useCallback(() => image && void actions.sendToCanvas([image], 'raster'), [actions, image]);const copyCurrentFrame = useCallback(() => onCopyCurrentFrame?.(), [onCopyCurrentFrame]);const openDetails = useCallback(() => onOpenDetails?.(), [onOpenDetails]);- const downloadItem = useCallback(() => void actions.downloadItem(item), [actions, item]);const openMenu = useCallback((event: MouseEvent<HTMLButtonElement>) => {const rect = event.currentTarget.getBoundingClientRect();@@ -92,7 +97,11 @@ export const PreviewActionStrip = ({<HStack flexShrink={0} gap="0.5">{starButton}{image ? <StripIconButton icon={ImagesIcon} label="Select for Compare" onClick={selectForCompare} /> : null}- {image ? <StripIconButton icon={CopyIcon} label="Copy to clipboard" onClick={copyImage} /> : null}+ {/* Videos have no canvas destination, so the verb simply is not offered+ for them — the same guard the context menu's image-only branch uses. */}+ {image ? (+ <StripIconButton icon={PencilIcon} label={t('widgets.preview.editOnCanvas')} onClick={editOnCanvas} />+ ) : null}{item.kind === 'video' && onCopyCurrentFrame ? (<StripIconButtondisabled={!isVideoFrameCopyAvailable}@@ -104,7 +113,6 @@ export const PreviewActionStrip = ({{item.kind === 'video' && onOpenDetails ? (<StripIconButton icon={FileJsonIcon} label={t('widgets.preview.videoDetails')} onClick={openDetails} />) : null}- <StripIconButton icon={DownloadIcon} label={`Download ${itemKindLabel}`} onClick={downloadItem} />{menuButton}</HStack>);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsxindex 206bc97661..775dc06ba8 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewMediaChrome.browser.test.tsx@@ -92,6 +92,7 @@ void i18n.use(initReactI18next).init({widgets: {preview: {copyCurrentFrame: 'Copy Current Frame',+ editOnCanvas: 'Edit on Canvas',framesPerSecond: '{{count}} fps',itemCount_one: '{{count}} item',itemCount_other: '{{count}} items',@@ -404,27 +405,25 @@ describe('Preview mixed media footer and actions', () => {/>);+ // Image-only verbs: a video has no compare partner and no canvas+ // destination.expect(host?.querySelector('[aria-label="Select for Compare"]')).toBeNull();- expect(host?.querySelector('[aria-label="Copy to clipboard"]')).toBeNull();+ expect(host?.querySelector('[aria-label="Edit on Canvas"]')).toBeNull();const copyFrame = host?.querySelector<HTMLButtonElement>('[aria-label="Copy Current Frame"]');const details = host?.querySelector<HTMLButtonElement>('[aria-label="Video Details"]');const star = host?.querySelector<HTMLButtonElement>('[aria-label="Unstar video"]');- const download = host?.querySelector<HTMLButtonElement>('[aria-label="Download video"]');expect(copyFrame).not.toBeNull();expect(copyFrame?.disabled).toBe(true);expect(details).not.toBeNull();expect(star).not.toBeNull();- expect(download).not.toBeNull();await interact(() => details?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));await interact(() => star?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));- await interact(() => download?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));expect(onOpenDetails).toHaveBeenCalledOnce();expect(onCopyCurrentFrame).not.toHaveBeenCalled();expect(actions.setItemsStarred).toHaveBeenCalledWith([{ kind: 'video', name: 'shared' }], false);- expect(actions.downloadItem).toHaveBeenCalledWith(sharedVideo);await render(<PreviewActionStrip@@ -444,23 +443,44 @@ describe('Preview mixed media footer and actions', () => {expect(onCopyCurrentFrame).toHaveBeenCalledOnce();});- it('keeps the existing image clipboard action unchanged', async () => {+ it('sends an image to the canvas as a raster layer', async () => {const actions = {copyImage: vi.fn(() => Promise.resolve()),downloadItem: vi.fn(() => Promise.resolve()),selectForCompare: vi.fn(),+ sendToCanvas: vi.fn(() => Promise.resolve()),setItemsStarred: vi.fn(() => Promise.resolve()),} as unknown as ImageActions;await render(<PreviewActionStrip actions={actions} density="full" item={sharedImage} onOpenMenu={() => undefined} />);- const copyImage = host?.querySelector<HTMLButtonElement>('[aria-label="Copy to clipboard"]');+ const editOnCanvas = host?.querySelector<HTMLButtonElement>('[aria-label="Edit on Canvas"]');- expect(copyImage).not.toBeNull();+ expect(editOnCanvas).not.toBeNull();expect(host?.querySelector('[aria-label="Copy Current Frame"]')).toBeNull();- await interact(() => copyImage?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));- expect(actions.copyImage).toHaveBeenCalledWith(expect.objectContaining({ imageName: 'shared' }));+ await interact(() => editOnCanvas?.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true })));+ expect(actions.sendToCanvas).toHaveBeenCalledWith([expect.objectContaining({ imageName: 'shared' })], 'raster');+ });++ // Both remain one click away in the dropdown's quick row, which is why they+ // left the strip.+ it('leaves copy and download to the image-actions dropdown', async () => {+ const actions = {+ copyImage: vi.fn(() => Promise.resolve()),+ downloadItem: vi.fn(() => Promise.resolve()),+ selectForCompare: vi.fn(),+ sendToCanvas: vi.fn(() => Promise.resolve()),+ setItemsStarred: vi.fn(() => Promise.resolve()),+ } as unknown as ImageActions;++ await render(+ <PreviewActionStrip actions={actions} density="full" item={sharedImage} onOpenMenu={() => undefined} />+ );++ expect(host?.querySelector('[aria-label="Copy to clipboard"]')).toBeNull();+ expect(host?.querySelector('[aria-label="Download image"]')).toBeNull();+ expect(host?.querySelector('[aria-label="Image actions"]')).not.toBeNull();});});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsxindex d7a1cfad0f..27238a8aaf 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetChrome.tsx@@ -23,8 +23,11 @@ export const PreviewWidgetLabel = (_props: WidgetLabelProps) => {);}+ // `pe` because the frame's header row only pads to `2` and the label sits+ // against the action cluster; a middle-truncated name otherwise ends flush+ // with the first button.return (- <HStack flex="1" gap="1" minW="0">+ <HStack flex="1" gap="1" minW="0" pe="2"><Text flexShrink={0} fontSize="xs" fontWeight="700">{boardName}</Text>