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
fix(webv2): restore a live progress affordance on multi-session preview tiles
joshistoaste008b4b0b651
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 ba59bddff1..9e57a10877 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@@ -14,6 +14,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { PreviewActionStrip } from './PreviewActionStrip';import { PreviewFilmstrip } from './PreviewFilmstrip';import { PreviewFooter } from './PreviewFooter';+import { LivePreviewTile } from './PreviewWidgetView';const sharedImage: GalleryImageItem = {boardId: 'none',@@ -45,6 +46,34 @@ const sharedVideo: GalleryVideoItem = {width: 1920,};+const mocks = vi.hoisted(() => ({+ itemProgress: null as { device: string | null; percentage: number | null } | null,+ progressImage: null,+ deviceLabel: null,+}));++vi.mock('@features/queue/react', () => ({+ useItemProgress: () => mocks.itemProgress,+ useQueueItemProgressImage: () => mocks.progressImage,+ useActiveProgressTargets: () => [],+ useActiveProgressTarget: () => null,+ useProgressImage: () => null,+}));++vi.mock('@features/queue/devices', () => ({+ useDeviceLabel: () => mocks.deviceLabel,+}));++vi.mock('@platform/ui/streaming-image/useStreamingImageSource', () => ({+ useStreamingImageSource: () => ({+ alt: 'preview',+ height: 512,+ kind: 'fallback' as const,+ src: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"/>',+ width: 512,+ }),+}));+const i18n = createInstance();void i18n.use(initReactI18next).init({fallbackLng: 'en',@@ -53,7 +82,7 @@ void i18n.use(initReactI18next).init({resources: {en: {translation: {- common: { countOfTotal: '{{count}} of {{total}}' },+ common: { countOfTotal: '{{count}} of {{total}}', generating: 'Generating' },widgets: {preview: {copyCurrentFrame: 'Copy Current Frame',@@ -65,6 +94,11 @@ void i18n.use(initReactI18next).init({videoDetails: 'Video Details',videoDuration: 'Duration {{duration}}',},+ queue: {+ device: {+ shortLabel: 'GPU {{index}}',+ },+ },},},},@@ -393,3 +427,37 @@ describe('Preview mixed media footer and actions', () => {expect(actions.copyImage).toHaveBeenCalledWith(expect.objectContaining({ imageName: 'shared' }));});});++describe('Multi-session live preview tiles', () => {+ const placeholder = {+ backendItemId: 1,+ boardId: 'none',+ height: 512,+ id: 'queue-1:0',+ itemIndex: 0,+ queueItemId: 'queue-1',+ width: 512,+ };++ it('shows a live badge with percent on session tiles even without a device label', async () => {+ mocks.itemProgress = { device: null, percentage: 0.4 };+ mocks.deviceLabel = null;++ await render(+ <DndContext>+ <LivePreviewTile placeholder={placeholder} shouldAntialiasProgressImage={false} />+ </DndContext>+ );++ const allElements = Array.from(host!.querySelectorAll('*'));+ const badge = allElements.find((el) => {+ const text = el.textContent || '';+ return /Generating · 40%/.test(text);+ });++ expect(badge).not.toBeNull();+ if (badge) {+ expect(badge.textContent || '').toMatch(/Generating · 40%/);+ }+ });+});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex 2b559dabc3..6c30385c66 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -30,6 +30,7 @@ import {} from '@features/gallery/contracts';import { galleryBoardsOptions } from '@features/gallery/queries';import { createGenerateFormValuesSelector } from '@features/generation/react';+import { getDeterminateProgressPercent } from '@features/queue/contracts';import { useDeviceLabel } from '@features/queue/devices';import {useActiveProgressTarget,@@ -878,7 +879,7 @@ const LivePreview = ({* Subscribes to its own slot's progress image rather than receiving it from the* parent, so a frame from one GPU's session re-renders only that tile.*/-const LivePreviewTile = ({+export const LivePreviewTile = ({placeholder,shouldAntialiasProgressImage,}: {@@ -906,12 +907,21 @@ const LivePreviewTile = ({[placeholder.id, previewImage]);+ const percent = getDeterminateProgressPercent(itemProgress?.percentage);+ // Every tile declares itself live: with several sessions racing, a silent+ // tile reads as a stuck one. Device label when known, plain "Generating"+ // otherwise; percent appended once quantified (zero is model-loading).+ const badgeBase = deviceLabel+ ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index })+ : t('common.generating');+ const liveBadgeLabel = percent === null ? badgeBase : `${badgeBase} · ${percent}%`;+return (<PreviewFrameframeHeight={previewImage?.height ?? placeholder.height}frameWidth={previewImage?.width ?? placeholder.width}isLive- liveBadgeLabel={deviceLabel ? t('widgets.queue.device.shortLabel', { index: deviceLabel.index }) : undefined}+ liveBadgeLabel={liveBadgeLabel}shouldAntialiasLiveImage={shouldAntialiasProgressImage}source={source}variant="inset"@@ -926,7 +936,7 @@ const LivePreviewTile = ({* single-frame preview so nothing changes on a single-GPU install. The grid is a* plain auto-fit so two GPUs sit side by side and four wrap to a 2×2.*/-const LivePreviewTiles = ({+export const LivePreviewTiles = ({placeholders,shouldAntialiasProgressImage,}: {