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(gallery): reveal external video generations with gallery:reveal (#9973)

Lincoln Steina0ab6f530183
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index 434381d92d..6b51cf19e5 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -4458,7 +4458,7 @@
"boardVisibility": "Board visibility",
"boardsLoadFailed": "Could not load boards.",
"boardsRefreshFailed": "Could not refresh boards.",
- "externalGenerationRevealed": "Showing an image from another app",
+ "externalGenerationRevealed": "Showing a result from another app",
"destination": "Destination",
"followSelectedBoard": "Send new results to the selected board",
"commands": {
diff --git a/invokeai/frontend/webv2/src/features/gallery/README.md b/invokeai/frontend/webv2/src/features/gallery/README.md
index 645dda294c..3121724222 100644
--- a/invokeai/frontend/webv2/src/features/gallery/README.md
+++ b/invokeai/frontend/webv2/src/features/gallery/README.md
@@ -10,7 +10,7 @@ Uploads, reconnects, and the signed-in user's completed queue items whose origin
An external client asks for its results to be revealed by enqueueing with `POST /api/v1/queue/default/enqueue_batch` and `batch.destination` set to `gallery:reveal`. The request is honored only for the signed-in user's items (any user's on a single-user server) whose origin does not start with `webv2:`. Every other destination only refreshes, `gallery` included: legacy web sends it on every workflow and upscale run.
-The reveal is best effort. Each completed item asks once; a reveal that stands down is dropped, not retried, except in a hidden tab. Every visible tab or device signed in as that user may reveal. The reveal takes the last non-intermediate image the item saved and lands on it as Find in Gallery does: board, page and selection, plus the starred-only filter, the media filter and the images/assets view when the item needs them, after which Preview follows the selection and the grid scrolls to it. With the Gallery widget closed, the selection still changes, unseen. It raises no widget and leaves Canvas, Generate panels and the route untouched. Only while the Gallery widget is mounted is it announced, once, in the Gallery's polite live region; a Gallery mounted later does not repeat it.
+The reveal is best effort. Each completed item asks once; a reveal that stands down is dropped, not retried, except in a hidden tab. Every visible tab or device signed in as that user may reveal. The reveal takes the last non-intermediate image or video the item saved, in the order of its session results and of the outputs within each, and lands on it as Find in Gallery does: board, page and selection, plus the starred-only filter, the media filter and the images/assets view when the item needs them, after which Preview follows the selection and the grid scrolls to it. With the Gallery widget closed, the selection still changes, unseen. It raises no widget and leaves Canvas, Generate panels and the route untouched. Only while the Gallery widget is mounted is it announced, once, in the Gallery's polite live region; a Gallery mounted later does not repeat it.
It never takes the Gallery from the user. These conditions are checked when the completion arrives, before and after its result is read, and immediately before the first Gallery change; the first failure drops the reveal:
@@ -27,7 +27,8 @@ A hidden tab defers instead: the newest request waits until the tab is shown, an
Known limitations:
- The status event does not say whether an item is a workflow-call child, which inherits its parent's destination. A child's completion supersedes a reveal still in flight before its read finds it is a child and reveals nothing; if the parent then fails or is cancelled, the earlier item is not revealed.
-- An image a graph passes through from its inputs counts as an output, so it is picked if it is the last non-intermediate one.
+- An image or video a graph passes through from its inputs counts as an output, so it is picked if it is the last non-intermediate one.
+- Videos are recognized only as a node's top-level video output; a video inside a workflow-call return value is not, so such an item reveals its last saved image instead, if any.
## Board destinations
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
index 00a293a909..0b26dde20f 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.test.ts
@@ -762,7 +762,7 @@ describe('getResultVideoNames', () => {
});
});
-describe('readQueueItemLastSavedImageName', () => {
+describe('readQueueItemLastSavedOutput', () => {
const imageUrl = (imageName: string) => `/api/v1/images/i/${imageName}`;
const serveItem = (
item: Record<string, unknown>,
@@ -774,13 +774,13 @@ describe('readQueueItemLastSavedImageName', () => {
return Promise.resolve({ item_id: 1, status: 'completed', ...item });
}
- const imageName = url.replace('/api/v1/images/i/', '');
+ const [, kind, name] = /^\/api\/v1\/(image|video)s\/i\/(.+)$/.exec(url)!;
- if (missing.includes(imageName)) {
+ if (missing.includes(name!)) {
return Promise.reject(new ApiError('Not found', 404));
}
- return Promise.resolve({ image_name: imageName, is_intermediate: intermediates.includes(imageName) });
+ return Promise.resolve({ [`${kind}_name`]: name, is_intermediate: intermediates.includes(name!) });
});
const session = {
results: {
@@ -800,28 +800,77 @@ describe('readQueueItemLastSavedImageName', () => {
it('walks back from the last output to the first saved image, reading no earlier record', async () => {
serveItem({ session }, ['preview.png'], ['deleted.png']);
- const { readQueueItemLastSavedImageName } = await import('./submissionApi');
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
- await expect(readQueueItemLastSavedImageName(1)).resolves.toBe('saved.png');
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toEqual({ kind: 'image', name: 'saved.png' });
expect(mocks.apiFetchJson.mock.calls.map(([url]) => url)).not.toContain(imageUrl('first.png'));
});
+ it.each([
+ ['a video-only item', { clip: { type: 'video_output', video: { video_name: 'clip.mp4' } } }, [], 'clip.mp4'],
+ [
+ 'an item whose frame extract is intermediate',
+ {
+ frame: { image: { image_name: 'frame.png' }, type: 'image_output' },
+ clip: { type: 'video_output', video: { video_name: 'clip.mp4' } },
+ last_frame: { image: { image_name: 'last_frame.png' }, type: 'image_output' },
+ },
+ ['frame.png', 'last_frame.png'],
+ 'clip.mp4',
+ ],
+ ])('reveals the saved video of %s', async (_, results, intermediates, videoName) => {
+ serveItem({ session: { results } }, intermediates);
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
+
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toEqual({ kind: 'video', name: videoName });
+ });
+
+ it('walks back past a deleted and an intermediate video to an earlier saved image', async () => {
+ const results = {
+ still: { image: { image_name: 'still.png' }, type: 'image_output' },
+ draft: { type: 'video_output', video: { video_name: 'draft.mp4' } },
+ deleted: { type: 'video_output', video: { video_name: 'deleted.mp4' } },
+ };
+ serveItem({ session: { results } }, ['draft.mp4'], ['deleted.mp4']);
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
+
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toEqual({ kind: 'image', name: 'still.png' });
+ expect(mocks.apiFetchJson.mock.calls.map(([url]) => url)).toEqual([
+ '/api/v1/queue/default/i/1',
+ '/api/v1/videos/i/deleted.mp4',
+ '/api/v1/videos/i/draft.mp4',
+ '/api/v1/images/i/still.png',
+ ]);
+ });
+
+ it('takes whichever saved image or video comes last', async () => {
+ const image = { image: { image_name: 'still.png' }, type: 'image_output' };
+ const video = { type: 'video_output', video: { video_name: 'clip.mp4' } };
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
+
+ serveItem({ session: { results: { image, video } } }, []);
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toEqual({ kind: 'video', name: 'clip.mp4' });
+
+ serveItem({ session: { results: { video, image } } }, []);
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toEqual({ kind: 'image', name: 'still.png' });
+ });
+
it('reveals nothing for a workflow-call child or an item without saved images', async () => {
- const { readQueueItemLastSavedImageName } = await import('./submissionApi');
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
serveItem({ parent_item_id: 7, session }, []);
- await expect(readQueueItemLastSavedImageName(1)).resolves.toBeNull();
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toBeNull();
serveItem({ session }, ['first.png', 'saved.png', 'preview.png'], ['deleted.png']);
- await expect(readQueueItemLastSavedImageName(1)).resolves.toBeNull();
+ await expect(readQueueItemLastSavedOutput(1)).resolves.toBeNull();
});
it("passes the caller's abort signal to every read", async () => {
serveItem({ session }, ['preview.png'], ['deleted.png']);
- const { readQueueItemLastSavedImageName } = await import('./submissionApi');
+ const { readQueueItemLastSavedOutput } = await import('./submissionApi');
const controller = new AbortController();
- await readQueueItemLastSavedImageName(1, controller.signal);
+ await readQueueItemLastSavedOutput(1, controller.signal);
controller.abort();
for (const [, init] of mocks.apiFetchJson.mock.calls as [string, { signal: AbortSignal }][]) {
diff --git a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
index ebbe288f77..0d286bcfad 100644
--- a/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
+++ b/invokeai/frontend/webv2/src/features/queue/data/submissionApi.ts
@@ -15,7 +15,7 @@ import {
sanitizeBatchCount,
} from '@features/queue/core/promptBatch';
import { mapWithConcurrency } from '@platform/core/concurrency';
-import { addOutputImageNames } from '@platform/core/outputImages';
+import { addOutputImageNames, getOutputImageNames } from '@platform/core/outputImages';
import { assertAccountScopeCurrent, captureAccountScope } from '@platform/state/accountLifecycle';
import { normalizeServerTimestamp } from '@platform/time/serverTimestamp';
import { absolutizeApiUrl, ApiError, apiFetch, apiFetchJson } from '@platform/transport/http';
@@ -165,12 +165,45 @@ const getResultImageNames = (queueItem: QueueServerItemDTO, options?: QueueResul
return [...imageNames];
};
+/** VideoOutput shape: `{ video: { video_name }, width, height, ... }`. */
+const getOutputVideoName = (result: unknown): string | undefined => {
+ if (!result || typeof result !== 'object') {
+ return undefined;
+ }
+
+ const videoName = (result as { video?: { video_name?: unknown } }).video?.video_name;
+ return typeof videoName === 'string' ? videoName : undefined;
+};
+
+type QueueResultMediaRef = { kind: 'image' | 'video'; name: string };
+
+/** Image and video outputs in session-result order, then output order within a result; first occurrence kept. */
+const getResultMediaRefs = (queueItem: QueueServerItemDTO): QueueResultMediaRef[] => {
+ const refs = new Map<string, QueueResultMediaRef>();
+
+ for (const result of Object.values(queueItem.session?.results ?? {})) {
+ for (const name of getOutputImageNames(result)) {
+ refs.set(`image:${name}`, { kind: 'image', name });
+ }
+
+ const videoName = getOutputVideoName(result);
+ if (videoName !== undefined) {
+ refs.set(`video:${videoName}`, { kind: 'video', name: videoName });
+ }
+ }
+
+ return [...refs.values()];
+};
+
/**
- * The last non-intermediate image a completed backend item saved, by execution order: image records are read from the
- * end until one is not an intermediate. Null when it saved none, and for a workflow-call child, whose outputs reach
- * the user through its parent's results.
+ * The last non-intermediate image or video a completed backend item saved, by execution order: media records are read
+ * from the end until one is not an intermediate. Null when it saved none, and for a workflow-call child, whose outputs
+ * reach the user through its parent's results.
*/
-export const readQueueItemLastSavedImageName = async (itemId: number, signal?: AbortSignal): Promise<string | null> => {
+export const readQueueItemLastSavedOutput = async (
+ itemId: number,
+ signal?: AbortSignal
+): Promise<QueueResultMediaRef | null> => {
const owner = captureAccountScope();
const requestSignal = signal ? AbortSignal.any([signal, owner.signal]) : owner.signal;
const item = await getQueueItem(itemId, requestSignal);
@@ -181,13 +214,14 @@ export const readQueueItemLastSavedImageName = async (itemId: number, signal?: A
return null;
}
- for (const imageName of getResultImageNames(item).reverse()) {
- let image: QueueImageDTO;
+ for (const ref of getResultMediaRefs(item).reverse()) {
+ let record: { is_intermediate: boolean };
try {
- image = await apiFetchJson<QueueImageDTO>(`/api/v1/images/i/${encodeURIComponent(imageName)}`, {
- signal: requestSignal,
- });
+ record = await apiFetchJson<QueueImageDTO | QueueVideoDTO>(
+ `/api/v1/${ref.kind}s/i/${encodeURIComponent(ref.name)}`,
+ { signal: requestSignal }
+ );
} catch (error) {
if (error instanceof ApiError && error.status === 404) {
continue;
@@ -197,8 +231,8 @@ export const readQueueItemLastSavedImageName = async (itemId: number, signal?: A
assertAccountScopeCurrent(owner);
- if (!image.is_intermediate) {
- return image.image_name;
+ if (!record.is_intermediate) {
+ return ref;
}
}
@@ -266,13 +300,8 @@ const collectResultVideoNames = (queueItem: QueueServerItemDTO, options?: QueueR
: Object.values(results);
for (const result of resultValues) {
- if (!result || typeof result !== 'object') {
- continue;
- }
-
- // VideoOutput shape: { video: { video_name }, width, height, ... }.
- const videoName = (result as { video?: { video_name?: unknown } }).video?.video_name;
- if (typeof videoName === 'string') {
+ const videoName = getOutputVideoName(result);
+ if (videoName !== undefined) {
videoNames.add(videoName);
}
}
diff --git a/invokeai/frontend/webv2/src/features/queue/queries.ts b/invokeai/frontend/webv2/src/features/queue/queries.ts
index 000b2541c9..b174d2724a 100644
--- a/invokeai/frontend/webv2/src/features/queue/queries.ts
+++ b/invokeai/frontend/webv2/src/features/queue/queries.ts
@@ -1,4 +1,4 @@
/** Expose shell-facing queue queries while keeping widget data hooks private. */
export { getQueueReadModelOptions } from './publicApi';
export { getQueueQueryScope, type QueueJobsScope } from './ui/queueScope';
-export { readQueueItemLastSavedImageName } from './data/submissionApi';
+export { readQueueItemLastSavedOutput } from './data/submissionApi';
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.test.ts
index 2f516fa6db..4d47fd8b59 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.test.ts
@@ -1,3 +1,4 @@
+import type { GalleryItemRef } from '@features/gallery/contracts';
import type { GalleryItem } from '@features/gallery/core/items';
import type { QueueItem } from '@features/queue/contracts';
import type { QueryClient } from '@tanstack/react-query';
@@ -15,11 +16,11 @@ import { attachExternalGenerationReveal } from './recallParametersBridge';
const mocks = vi.hoisted(() => ({
fetchVerifiedPage: vi.fn(),
- readLastSavedImageName: vi.fn<(itemId: number, signal?: AbortSignal) => Promise<string | null>>(),
+ readLastSavedOutput: vi.fn<(itemId: number, signal?: AbortSignal) => Promise<GalleryItemRef | null>>(),
resolve: vi.fn(),
}));
-vi.mock('@features/queue/queries', () => ({ readQueueItemLastSavedImageName: mocks.readLastSavedImageName }));
+vi.mock('@features/queue/queries', () => ({ readQueueItemLastSavedOutput: mocks.readLastSavedOutput }));
vi.mock('@features/gallery', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
galleryItems: { resolve: mocks.resolve },
@@ -29,22 +30,27 @@ vi.mock('@features/gallery/queries', async (importOriginal) => ({
fetchVerifiedGalleryItemPage: (...args: unknown[]) => mocks.fetchVerifiedPage(...args),
}));
-const createItem = (name: string): GalleryItem => ({
- boardId: 'board-1',
- category: 'general',
- createdAt: '2026-10-15T12:00:00Z',
- fullUrl: `/images/${name}`,
- height: 64,
- isIntermediate: false,
- kind: 'image',
- name,
- starred: false,
- thumbnailUrl: `/thumbs/${name}`,
- width: 64,
-});
+const createItem = ({ kind, name }: GalleryItemRef): GalleryItem => {
+ const base = {
+ boardId: 'board-1',
+ category: 'general',
+ createdAt: '2026-10-15T12:00:00Z',
+ fullUrl: `/${kind}s/${name}`,
+ height: 64,
+ isIntermediate: false,
+ name,
+ starred: false,
+ thumbnailUrl: `/thumbs/${name}`,
+ width: 64,
+ } as const;
+
+ return kind === 'video' ? { ...base, durationSeconds: 4, kind } : { ...base, kind };
+};
+
+const lastImage: GalleryItemRef = { kind: 'image', name: 'last.png' };
-const verifiedPage = (name: string) =>
- Promise.resolve({ index: 0, offset: 0, page: { items: [createItem(name)], total: 1 }, total: 1 });
+const verifiedPage = (ref: GalleryItemRef) =>
+ Promise.resolve({ index: 0, offset: 0, page: { items: [createItem(ref)], total: 1 }, total: 1 });
/** A promise the test settles; lets a test act while the reveal waits on the backend. */
const deferred = <T>() => {
@@ -144,11 +150,11 @@ beforeEach(() => {
gallery: { selectBoard: vi.fn(), selectItem: vi.fn(), setPage: vi.fn(), setView: vi.fn() },
widgets: { patchValues: vi.fn() },
};
- mocks.readLastSavedImageName.mockReset().mockResolvedValue('last.png');
- mocks.resolve.mockReset().mockImplementation(({ name }: { name: string }) => Promise.resolve(createItem(name)));
+ mocks.readLastSavedOutput.mockReset().mockResolvedValue(lastImage);
+ mocks.resolve.mockReset().mockImplementation((ref: GalleryItemRef) => Promise.resolve(createItem(ref)));
mocks.fetchVerifiedPage
.mockReset()
- .mockImplementation((_client: unknown, _filter: unknown, ref: { name: string }) => verifiedPage(ref.name));
+ .mockImplementation((_client: unknown, _filter: unknown, ref: GalleryItemRef) => verifiedPage(ref));
});
afterEach(() => accountLifecycle.invalidate());
@@ -157,7 +163,7 @@ describe('external generation reveal', () => {
it("lands the Gallery on the item's last saved image and its board", async () => {
await reveal(42);
- expect(mocks.readLastSavedImageName).toHaveBeenCalledWith(42, expect.any(AbortSignal));
+ expect(mocks.readLastSavedOutput).toHaveBeenCalledWith(42, expect.any(AbortSignal));
expect(commands.gallery.selectBoard).toHaveBeenCalledWith('board-1');
expect(revealed()).toEqual(['last.png']);
expect(getGalleryRevealRequest()).toMatchObject({
@@ -166,6 +172,20 @@ describe('external generation reveal', () => {
});
});
+ it('lands on a saved video, showing both kinds when the media filter hides videos', async () => {
+ galleryValues = { ...galleryValues, mediaFilter: 'image' };
+ mocks.readLastSavedOutput.mockResolvedValue({ kind: 'video', name: 'clip.mp4' });
+
+ await reveal();
+
+ expect(commands.widgets.patchValues).toHaveBeenCalledWith(
+ 'gallery',
+ expect.objectContaining({ mediaFilter: 'all' })
+ );
+ expect(revealed()).toEqual(['clip.mp4']);
+ expect(getGalleryRevealRequest()).toMatchObject({ itemKey: 'video:clip.mp4' });
+ });
+
it.each([
['the user is typing', () => (editingText = true)],
['a run of their own is open', () => (queueItems = [{ status: 'running' }])],
@@ -184,7 +204,7 @@ describe('external generation reveal', () => {
await reveal();
- expect(mocks.readLastSavedImageName).not.toHaveBeenCalled();
+ expect(mocks.readLastSavedOutput).not.toHaveBeenCalled();
expect(revealed()).toEqual([]);
});
@@ -206,9 +226,9 @@ describe('external generation reveal', () => {
['starts a run of their own', () => (queueItems = [{ status: 'pending' }])],
['switches projects', () => (activeProjectId = 'project-2')],
])('makes no Gallery change when the user %s while the result is read', async (_, act) => {
- mocks.readLastSavedImageName.mockImplementation(() => {
+ mocks.readLastSavedOutput.mockImplementation(() => {
act();
- return Promise.resolve('last.png');
+ return Promise.resolve(lastImage);
});
await reveal();
@@ -223,9 +243,9 @@ describe('external generation reveal', () => {
['starts typing', () => (editingText = true)],
['starts a run of their own', () => (queueItems = [{ status: 'pending' }])],
])('makes no Gallery change when the user %s while the item is located', async (_, act) => {
- mocks.fetchVerifiedPage.mockImplementation((_client: unknown, _filter: unknown, ref: { name: string }) => {
+ mocks.fetchVerifiedPage.mockImplementation((_client: unknown, _filter: unknown, ref: GalleryItemRef) => {
act();
- return verifiedPage(ref.name);
+ return verifiedPage(ref);
});
await reveal();
@@ -237,9 +257,9 @@ describe('external generation reveal', () => {
});
it('does not reveal once the account that received the completion is gone', async () => {
- mocks.readLastSavedImageName.mockImplementation(() => {
+ mocks.readLastSavedOutput.mockImplementation(() => {
accountLifecycle.invalidate();
- return Promise.resolve('last.png');
+ return Promise.resolve(lastImage);
});
await reveal();
@@ -248,7 +268,7 @@ describe('external generation reveal', () => {
});
it('reveals nothing for an item without a saved image, such as a workflow-call child', async () => {
- mocks.readLastSavedImageName.mockResolvedValue(null);
+ mocks.readLastSavedOutput.mockResolvedValue(null);
await reveal();
@@ -257,19 +277,19 @@ describe('external generation reveal', () => {
it('lets only the newest of a burst of completions reveal, even when an older read finishes last', async () => {
const reads = new Map([
- [1, deferred<string | null>()],
- [2, deferred<string | null>()],
+ [1, deferred<GalleryItemRef | null>()],
+ [2, deferred<GalleryItemRef | null>()],
]);
- mocks.readLastSavedImageName.mockImplementation((itemId) => reads.get(itemId)!.promise);
+ mocks.readLastSavedOutput.mockImplementation((itemId) => reads.get(itemId)!.promise);
const { revealer, settle } = attach();
revealer.request(1);
- await vi.waitFor(() => expect(mocks.readLastSavedImageName).toHaveBeenCalledTimes(1));
+ await vi.waitFor(() => expect(mocks.readLastSavedOutput).toHaveBeenCalledTimes(1));
revealer.request(2);
- await vi.waitFor(() => expect(mocks.readLastSavedImageName).toHaveBeenCalledTimes(2));
- reads.get(2)!.resolve('newest.png');
+ await vi.waitFor(() => expect(mocks.readLastSavedOutput).toHaveBeenCalledTimes(2));
+ reads.get(2)!.resolve({ kind: 'image', name: 'newest.png' });
await vi.waitFor(() => expect(revealed()).toEqual(['newest.png']));
- reads.get(1)!.resolve('older.png');
+ reads.get(1)!.resolve({ kind: 'image', name: 'older.png' });
await settle(2);
expect(revealed()).toEqual(['newest.png']);
@@ -283,22 +303,22 @@ describe('external generation reveal', () => {
revealer.request(2);
await settle(2);
- expect(mocks.readLastSavedImageName.mock.calls.map(([itemId]) => itemId)).toEqual([2]);
+ expect(mocks.readLastSavedOutput.mock.calls.map(([itemId]) => itemId)).toEqual([2]);
revealer.dispose();
});
it('drops a reveal still in flight when the runtime is disposed', async () => {
- const read = deferred<string | null>();
- mocks.readLastSavedImageName.mockReturnValue(read.promise);
+ const read = deferred<GalleryItemRef | null>();
+ mocks.readLastSavedOutput.mockReturnValue(read.promise);
const { revealer, settle } = attach();
revealer.request(42);
- await vi.waitFor(() => expect(mocks.readLastSavedImageName).toHaveBeenCalled());
+ await vi.waitFor(() => expect(mocks.readLastSavedOutput).toHaveBeenCalled());
revealer.dispose();
- read.resolve('last.png');
+ read.resolve(lastImage);
await settle(1);
- expect(mocks.readLastSavedImageName.mock.calls[0]![1]!.aborted).toBe(true);
+ expect(mocks.readLastSavedOutput.mock.calls[0]![1]!.aborted).toBe(true);
expect(revealed()).toEqual([]);
});
@@ -323,7 +343,7 @@ describe('external generation reveal', () => {
loading.resolve();
await settle(1);
- expect(mocks.readLastSavedImageName).not.toHaveBeenCalled();
+ expect(mocks.readLastSavedOutput).not.toHaveBeenCalled();
expect(revealed()).toEqual([]);
revealer.dispose();
});
@@ -339,9 +359,9 @@ describe('external generation reveal', () => {
['semanticSearchText', ''],
['starredOnly', true],
])('treats a change to %s after arrival as the user navigating', async (key, value) => {
- mocks.readLastSavedImageName.mockImplementation(() => {
+ mocks.readLastSavedOutput.mockImplementation(() => {
galleryValues = { ...galleryValues, [key]: value };
- return Promise.resolve('last.png');
+ return Promise.resolve(lastImage);
});
await reveal();
@@ -357,7 +377,7 @@ describe('external generation reveal', () => {
revealer.request(42);
await settle(1);
- expect(mocks.readLastSavedImageName).not.toHaveBeenCalled();
+ expect(mocks.readLastSavedOutput).not.toHaveBeenCalled();
setVisible(true);
await settle(2);
@@ -367,9 +387,9 @@ describe('external generation reveal', () => {
});
it('resumes a reveal the tab hid while its item was being located', async () => {
- mocks.fetchVerifiedPage.mockImplementationOnce((_client: unknown, _filter: unknown, ref: { name: string }) => {
+ mocks.fetchVerifiedPage.mockImplementationOnce((_client: unknown, _filter: unknown, ref: GalleryItemRef) => {
visible = false;
- return verifiedPage(ref.name);
+ return verifiedPage(ref);
});
const { revealer, settle } = attach();
@@ -395,7 +415,7 @@ describe('external generation reveal', () => {
setVisible(true);
await settle(3);
- expect(mocks.readLastSavedImageName.mock.calls.map(([itemId]) => itemId)).toEqual([2]);
+ expect(mocks.readLastSavedOutput.mock.calls.map(([itemId]) => itemId)).toEqual([2]);
revealer.dispose();
});
@@ -422,7 +442,7 @@ describe('external generation reveal', () => {
revealer.dispose();
expect(visibilityListeners.size).toBe(0);
- expect(mocks.readLastSavedImageName).not.toHaveBeenCalled();
+ expect(mocks.readLastSavedOutput).not.toHaveBeenCalled();
});
});
});
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.ts b/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.ts
index 4806f65b10..a37326cef6 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/revealExternalGeneration.ts
@@ -10,7 +10,7 @@ import {
isGalleryNavigationStateUnchanged,
} from '@features/gallery/contracts';
import { isOpenQueueItem } from '@features/queue/contracts';
-import { readQueueItemLastSavedImageName } from '@features/queue/queries';
+import { readQueueItemLastSavedOutput } from '@features/queue/queries';
import { getProjectWidgetValues } from '@workbench/widgetState';
import type { GalleryRevealContext } from './revealGalleryItem';
@@ -48,9 +48,9 @@ export type ExternalGenerationRevealOutcome =
const SETTLED: ExternalGenerationRevealOutcome = { kind: 'settled' };
/**
- * Reveal another client's completed generation, as Find in Gallery would: select the board of its last saved image,
- * then the image, and announce it. It never takes the Gallery from the user. It stands down once a newer completion
- * arrives, while the user types in the focused window, while a run of their own in this project is open, while a
+ * Reveal another client's completed generation, as Find in Gallery would: select the board of its last saved image
+ * or video, then the item, and announce it. It never takes the Gallery from the user. It stands down once a newer
+ * completion arrives, while the user types in the focused window, while a run of their own in this project is open, while a
* search or semantic query narrows the listing, while several items are selected, while another reveal is locating
* its item, and once the user navigates the Gallery after arrival; all of these are dropped. A hidden tab only defers
* it: the outcome asks to resume once the tab is visible. Every condition is checked again immediately before the
@@ -95,9 +95,9 @@ export const revealExternalGeneration = async (
return standDown();
}
- const imageName = await readQueueItemLastSavedImageName(queueItemId, signal);
+ const output = await readQueueItemLastSavedOutput(queueItemId, signal);
- if (imageName === null) {
+ if (output === null) {
return SETTLED;
}
if (!isOwned() || !mayApply()) {
@@ -105,11 +105,14 @@ export const revealExternalGeneration = async (
}
owned = claimGalleryNavigationSequence();
- await revealGalleryItem(
- context,
- { kind: 'image', name: imageName },
- { accountScope, announcement: 'external-generation', locatorSignal: signal, mayApply, projectId, sequence: owned }
- );
+ await revealGalleryItem(context, output, {
+ accountScope,
+ announcement: 'external-generation',
+ locatorSignal: signal,
+ mayApply,
+ projectId,
+ sequence: owned,
+ });
// Revealing changes the Gallery's navigation, so only a reveal the tab's hiding stood down can resume.
return standDown();