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(preview): address mixed media review findings
joshistoaste5c5ccf004f6
diff --git a/invokeai/frontend/webv2/src/features/gallery/contracts.ts b/invokeai/frontend/webv2/src/features/gallery/contracts.tsindex f423d038ad..23b9db8f79 100644--- a/invokeai/frontend/webv2/src/features/gallery/contracts.ts+++ b/invokeai/frontend/webv2/src/features/gallery/contracts.ts@@ -13,6 +13,7 @@ export type {export { normalizeGalleryImage } from './core/image';export {assertNeverGalleryItem,+ compareGalleryItems,formatGalleryVideoDuration,galleryImageItemToGalleryImage,isGalleryImageItem,diff --git a/invokeai/frontend/webv2/src/features/gallery/core/items.ts b/invokeai/frontend/webv2/src/features/gallery/core/items.tsindex b2ef8a253b..2b94ed0383 100644--- a/invokeai/frontend/webv2/src/features/gallery/core/items.ts+++ b/invokeai/frontend/webv2/src/features/gallery/core/items.ts@@ -1,4 +1,4 @@-import type { GalleryImage, GeneratedImageContract } from './types';+import type { GalleryImage, GalleryOrderDir, GeneratedImageContract } from './types';export type GalleryItemKind = 'image' | 'video';@@ -71,6 +71,34 @@ export const assertNeverGalleryItem = (item: never): never => {throw new Error(`Unexpected gallery item: ${String(item)}`);};+const compareSqliteBinaryText = (a: string, b: string): number => (a === b ? 0 : a < b ? -1 : 1);++/** Mirrors the backend's starred/time/kind/name order for mixed gallery items. */+export const compareGalleryItems = (+ a: GalleryItem,+ b: GalleryItem,+ { orderDir = 'DESC', starredFirst = false }: { orderDir?: GalleryOrderDir; starredFirst?: boolean }+): number => {+ if (starredFirst && a.starred !== b.starred) {+ return a.starred ? -1 : 1;+ }++ const direction = orderDir === 'ASC' ? 1 : -1;+ const chronologicalOrder = compareSqliteBinaryText(a.createdAt, b.createdAt);++ if (chronologicalOrder !== 0) {+ return direction * chronologicalOrder;+ }++ const kindOrder = compareSqliteBinaryText(a.kind, b.kind);++ if (kindOrder !== 0) {+ return direction * kindOrder;+ }++ return direction * compareSqliteBinaryText(a.name, b.name);+};+type LegacyGalleryImage = GeneratedImageContract & Partial<Pick<GalleryImage, 'boardId' | 'imageCategory' | 'starred'>>;export const legacyGeneratedImageToGalleryItem = (image: LegacyGalleryImage): GalleryImageItem => ({diff --git a/invokeai/frontend/webv2/src/features/gallery/index.ts b/invokeai/frontend/webv2/src/features/gallery/index.tsindex 65459a1b9d..043eba1d7d 100644--- a/invokeai/frontend/webv2/src/features/gallery/index.ts+++ b/invokeai/frontend/webv2/src/features/gallery/index.ts@@ -12,6 +12,7 @@ export type {} from './core/types';export {assertNeverGalleryItem,+ compareGalleryItems,formatGalleryVideoDuration,galleryImageItemToGalleryImage,isGalleryImageItem,diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.tsindex 441634ab75..ff08aa3cb7 100644--- a/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts+++ b/invokeai/frontend/webv2/src/features/gallery/ui/useGalleryData.ts@@ -2,7 +2,7 @@ import type { GalleryItem } from '@features/gallery/core/items';import type { GallerySettings } from '@features/gallery/core/settings';import type { GalleryBoard, GalleryView, GeneratedImageContract } from '@features/gallery/core/types';-import { legacyGeneratedImageToGalleryItem, toGalleryItemKey } from '@features/gallery/core/items';+import { compareGalleryItems, legacyGeneratedImageToGalleryItem, toGalleryItemKey } from '@features/gallery/core/items';import { GALLERY_RECENT_IMAGE_LIMIT } from '@features/gallery/core/recentImages';import { ALL_READABLE_BOARDS_ID, isDateBoardId } from '@features/gallery/data/backend';import {@@ -67,33 +67,6 @@ const isRecentItemVisible = (item: GalleryItem, filter: GalleryItemsFilter): booreturn hasMatchingBoard && hasMatchingCategory;};-const compareSqliteBinaryText = (a: string, b: string): number => (a === b ? 0 : a < b ? -1 : 1);--const compareGalleryItems = (- a: GalleryItem,- b: GalleryItem,- { orderDir = 'DESC', starredFirst = false }: GalleryItemsFilter-): number => {- if (starredFirst && a.starred !== b.starred) {- return a.starred ? -1 : 1;- }-- const direction = orderDir === 'ASC' ? 1 : -1;- const chronologicalOrder = compareSqliteBinaryText(a.createdAt, b.createdAt);-- if (chronologicalOrder !== 0) {- return direction * chronologicalOrder;- }-- const kindOrder = compareSqliteBinaryText(a.kind, b.kind);-- if (kindOrder !== 0) {- return direction * kindOrder;- }-- return direction * compareSqliteBinaryText(a.name, b.name);-};-export const mergeGalleryItemWindow = ({backendItems,filter,diff --git a/invokeai/frontend/webv2/src/features/identity/session.test.ts b/invokeai/frontend/webv2/src/features/identity/session.test.tsindex 058a62dd03..c1a53268ae 100644--- a/invokeai/frontend/webv2/src/features/identity/session.test.ts+++ b/invokeai/frontend/webv2/src/features/identity/session.test.ts@@ -96,19 +96,21 @@ const createObservedLifecycle = (): {},name: 'test-account-cache',});+ const port = {+ activate: (accountId: string, storageSuffix?: string) => {+ testState.events.push(`lifecycle.activate:${accountId}`);+ return lifecycle.activate(accountId, storageSuffix);+ },+ capture: () => lifecycle.capture(),+ invalidate: () => {+ testState.events.push('lifecycle.invalidate');+ return lifecycle.invalidate();+ },+ };return {lifecycle,- port: {- activate: (accountId, storageSuffix) => {- testState.events.push(`lifecycle.activate:${accountId}`);- return lifecycle.activate(accountId, storageSuffix);- },- invalidate: () => {- testState.events.push('lifecycle.invalidate');- return lifecycle.invalidate();- },- },+ port,};};@@ -271,6 +273,7 @@ describe('identity account transitions', () => {const { lifecycle } = createObservedLifecycle();session.configureIdentityAccountLifecycle({activate: (accountId, storageSuffix) => lifecycle.activate(accountId, storageSuffix),+ capture: () => lifecycle.capture(),invalidate: () => lifecycle.invalidate(),});@@ -480,20 +483,49 @@ describe('protected media cookie recovery', () => {await expect(Promise.all([first, second])).resolves.toEqual([true, true]);});- it('starts a separate refresh for a new account epoch and rejects the stale completion', async () => {+ it('aborts the old cookie request before a new account transport starts and gives the new epoch a fresh flight', async () => {await resolveSignedOutMultiuserSession();await session.loginWithCredentials(user.email, 'password', true);const oldRefresh = createDeferred<{ success: boolean }>();const newRefresh = createDeferred<{ success: boolean }>();- api.refreshMediaCookie.mockReturnValueOnce(oldRefresh.promise).mockReturnValueOnce(newRefresh.promise);+ let oldSignal: AbortSignal | undefined;+ let newSignal: AbortSignal | undefined;+ api.refreshMediaCookie+ .mockImplementationOnce((signal?: AbortSignal) => {+ oldSignal = signal;+ signal?.addEventListener(+ 'abort',+ () => {+ testState.events.push('refresh.abort');+ },+ { once: true }+ );+ return oldRefresh.promise;+ })+ .mockImplementationOnce((signal?: AbortSignal) => {+ newSignal = signal;+ return newRefresh.promise;+ });const staleOutcome = session.refreshProtectedMediaCookie();+ expect(oldSignal?.aborted).toBe(false);- api.login.mockResolvedValueOnce({ expires_in: 3600, token: 'token-b', user: userB });+ testState.events.length = 0;+ api.login.mockImplementationOnce(() => {+ testState.events.push('api.login:new-account');+ return Promise.resolve({ expires_in: 3600, token: 'token-b', user: userB });+ });await session.loginWithCredentials(userB.email, 'password', true);++ expect(oldSignal?.aborted).toBe(true);+ expect(testState.events.indexOf('refresh.abort')).toBeGreaterThanOrEqual(0);+ expect(testState.events.indexOf('refresh.abort')).toBeLessThan(testState.events.indexOf('api.login:new-account'));+const currentOutcome = session.refreshProtectedMediaCookie();expect(api.refreshMediaCookie).toHaveBeenCalledTimes(2);+ expect(newSignal?.aborted).toBe(false);+ expect(newSignal).not.toBe(oldSignal);newRefresh.resolve({ success: true });await expect(currentOutcome).resolves.toBe(true);diff --git a/invokeai/frontend/webv2/src/features/identity/session.ts b/invokeai/frontend/webv2/src/features/identity/session.tsindex b682225741..c3fd2ea0e8 100644--- a/invokeai/frontend/webv2/src/features/identity/session.ts+++ b/invokeai/frontend/webv2/src/features/identity/session.ts@@ -46,6 +46,7 @@ const store = createExternalStore<AuthSession>({export interface IdentityAccountLifecycle {activate(accountId: string, storageSuffix?: string): { readonly epoch: number };+ capture(): { readonly epoch: number; readonly signal: AbortSignal };invalidate(): { readonly epoch: number };}@@ -256,7 +257,7 @@ export const ensureAuthSession = (): Promise<AuthSession> => {};interface ProtectedMediaCookieRefresh {- accountEpoch: number;+ scope: ReturnType<IdentityAccountLifecycle['capture']>;promise: Promise<boolean>;}@@ -273,13 +274,25 @@ export const refreshProtectedMediaCookie = (): Promise<boolean> => {return Promise.resolve(false);}- if (pendingProtectedMediaCookieRefresh?.accountEpoch === session.accountEpoch) {+ const lifecycle = getAccountLifecycle();+ const scope = lifecycle.capture();++ if (scope.signal.aborted || scope.epoch !== session.accountEpoch) {+ return Promise.resolve(false);+ }++ if (pendingProtectedMediaCookieRefresh?.scope === scope) {return pendingProtectedMediaCookieRefresh.promise;}- const accountEpoch = session.accountEpoch;- const promise = refreshMediaCookie()- .then((result) => result.success && store.getSnapshot().accountEpoch === accountEpoch)+ const promise = refreshMediaCookie(scope.signal)+ .then(+ (result) =>+ result.success &&+ !scope.signal.aborted &&+ lifecycle.capture() === scope &&+ store.getSnapshot().accountEpoch === scope.epoch+ ).catch(() => false).finally(() => {if (pendingProtectedMediaCookieRefresh?.promise === promise) {@@ -287,7 +300,7 @@ export const refreshProtectedMediaCookie = (): Promise<boolean> => {}});- pendingProtectedMediaCookieRefresh = { accountEpoch, promise };+ pendingProtectedMediaCookieRefresh = { promise, scope };return promise;};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFilmstrip.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFilmstrip.tsxindex 87b7ac5ad4..5029c71b95 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFilmstrip.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFilmstrip.tsx@@ -88,6 +88,7 @@ const FilmstripThumb = ({}) => {const itemRef = useMemo(() => toGalleryItemRef(item), [item]);const dragData = useMemo(() => getGalleryItemDragData([itemRef]), [itemRef]);+ const thumbnailSrc = item.thumbnailUrl || (item.kind === 'image' ? item.fullUrl : null);const { listeners, setNodeRef } = useDraggable({data: dragData,id: getGalleryItemDragId(itemRef, 'preview-filmstrip'),@@ -124,7 +125,11 @@ const FilmstripThumb = ({touchAction="none"onClick={handleClick}>- <img alt={item.name} loading="lazy" src={item.thumbnailUrl || item.fullUrl} style={FILMSTRIP_IMG_STYLE} />+ {thumbnailSrc ? (+ <img alt={item.name} loading="lazy" src={thumbnailSrc} style={FILMSTRIP_IMG_STYLE} />+ ) : (+ <Box aria-hidden bg="bg.muted" h="full" w="full" />+ )}{isSelected ? <Box bg="accent.solid" bottom="0" h="2px" left="0" position="absolute" right="0" /> : null}</Box>);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsxindex a362b16f6a..63d4696892 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFooter.tsx@@ -54,7 +54,7 @@ export const PreviewFooter = ({<Stack borderWidth="1px" borderColor="border.subtle" gap="2" p="3" rounded="lg"><HStack align="center" justify="space-between"><HStack gap="1" minW="0">- <Text color="fg.subtle" fontSize="2xs" truncate>+ <Text color="fg.subtle" fontSize="2xs" fontVariantNumeric="tabular-nums" truncate>{positionLabel}</Text><Text color="fg.subtle" flexShrink={0} fontSize="2xs">diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsxindex 26f950a469..a8e9964873 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewFrame.tsx@@ -2,10 +2,11 @@ import type { GalleryItemKey, GalleryItemRef } from '@features/gallery';/* eslint-disable react/react-compiler */import type { StreamingImageSource } from '@platform/ui/streaming-image/streamingImageSource';-import { Badge, Box, Button, Flex, Text, type SystemStyleObject } from '@chakra-ui/react';+import { Badge, Box, Flex, Text, type SystemStyleObject } from '@chakra-ui/react';import { useDraggable } from '@dnd-kit/core';import { getGalleryItemDragData, getGalleryItemDragId } from '@features/gallery/utility';import { getAuthSession, refreshProtectedMediaCookie } from '@features/identity';+import { Button } from '@platform/ui/Button';import {useCallback,useId,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 a7fb77b76a..8b95b6454c 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@@ -189,6 +189,32 @@ describe('PreviewFilmstrip mixed media', () => {await interact(() => pointer('pointerup', videoButton.ownerDocument, 150, 80), 300);});++ it('never falls back to the protected full video URL when a poster is unavailable', async () => {+ const videoWithoutPoster = {+ ...sharedVideo,+ fullUrl: '/protected/videos/shared.mp4',+ thumbnailUrl: '',+ };++ await render(+ <DndContext>+ <PreviewFilmstrip+ density="full"+ items={[sharedImage, videoWithoutPoster]}+ selectedItemKey="video:shared"+ onSelect={() => undefined}+ />+ </DndContext>+ );++ const videoButton = host?.querySelector<HTMLButtonElement>('[aria-label="Video shared"]');++ expect(videoButton?.querySelector('img')).toBeNull();+ expect(+ [...host!.querySelectorAll<HTMLImageElement>('img')].map((image) => image.getAttribute('src'))+ ).not.toContain(videoWithoutPoster.fullUrl);+ });});describe('Preview mixed media footer and actions', () => {@@ -216,7 +242,11 @@ describe('Preview mixed media footer and actions', () => {const status = Array.from(host!.querySelectorAll<HTMLElement>('p')).find((element) =>element.textContent?.includes('1920 × 1080'));+ const position = Array.from(host!.querySelectorAll<HTMLElement>('p')).find((element) =>+ element.textContent?.includes('2 of 3')+ );expect(status ? getComputedStyle(status).fontVariantNumeric : '').toContain('tabular-nums');+ expect(position ? getComputedStyle(position).fontVariantNumeric : '').toContain('tabular-nums');expect(host?.querySelector('[aria-label="Previous item in board"]')).not.toBeNull();expect(host?.querySelector('[aria-label="Next item in board"]')).not.toBeNull();});diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewNavigation.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewNavigation.browser.test.tsxindex 80f30ee859..1136e048fc 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewNavigation.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewNavigation.browser.test.tsx@@ -231,10 +231,29 @@ await i18n.use(initReactI18next).init({},});-const disposer = () => {};+const registeredCommands = new Map<string, () => void>();+const registeredHotkeys = new Map<string, readonly string[]>();const runtime = {- commands: { register: () => disposer },- hotkeys: { register: () => disposer },+ commands: {+ register: ({ handler, id }: { handler: () => void; id: string }) => {+ registeredCommands.set(id, handler);+ return () => {+ if (registeredCommands.get(id) === handler) {+ registeredCommands.delete(id);+ }+ };+ },+ },+ hotkeys: {+ register: ({ defaultKeys, id }: { defaultKeys: readonly string[]; id: string }) => {+ registeredHotkeys.set(id, defaultKeys);+ return () => {+ if (registeredHotkeys.get(id) === defaultKeys) {+ registeredHotkeys.delete(id);+ }+ };+ },+ },instanceId: 'preview-instance',workbench: { closeWidgetInstance: () => {} },} as unknown as WidgetViewProps['runtime'];@@ -285,6 +304,8 @@ const pressArrow = async (key: 'ArrowLeft' | 'ArrowRight') => {};beforeEach(() => {+ registeredCommands.clear();+ registeredHotkeys.clear();mocks.commands.account.updateProjectPreferences.mockClear();mocks.commands.gallery.selectImage.mockClear();mocks.commands.gallery.selectItem.mockClear();@@ -647,6 +668,46 @@ describe('preview keyboard navigation boundary', () => {expect(mocks.commands.gallery.selectItem).toHaveBeenCalledWith(sameNameImage, undefined, 0, true);});+ it('leaves native video keys untouched and omits image-only hotkey registrations', async () => {+ const videoItem = createVideoItem('native-controls', '2026-07-30T12:00:00Z');+ const galleryValues = mocks.project.widgetInstances.gallery.state.values as Record<string, unknown>;++ galleryValues.recentImages = [];+ galleryValues.selectedImage = videoItem;+ galleryValues.selectedImageName = 'video:native-controls';+ mocks.galleryItemPages = [{ items: [videoItem], total: 1 }];++ await render();++ const video = host?.querySelector<HTMLVideoElement>('video');+ expect(video).not.toBeNull();++ for (const key of ['ArrowLeft', 'ArrowRight', 'f', '1']) {+ const event = new KeyboardEvent('keydown', { bubbles: true, cancelable: true, key });+ await act(async () => {+ video?.dispatchEvent(event);+ await Promise.resolve();+ });+ expect(event.defaultPrevented).toBe(false);+ }++ expect(mocks.commands.gallery.selectItem).not.toHaveBeenCalled();+ expect([...registeredHotkeys.keys()]).not.toContain('viewer.swapImages');+ expect([...registeredHotkeys.keys()]).not.toContain('viewer.zoomToActual');+ expect([...registeredHotkeys.keys()]).not.toContain('viewer.zoomToFit');+ });++ it('retains compare and zoom hotkey registrations for images', async () => {+ await render();++ expect([...registeredHotkeys.keys()]).toEqual(+ expect.arrayContaining(['viewer.swapImages', 'viewer.zoomToActual', 'viewer.zoomToFit'])+ );+ expect([...registeredCommands.keys()]).toEqual(+ expect.arrayContaining(['viewer.swapImages', 'viewer.zoomToActual', 'viewer.zoomToFit'])+ );+ });+it('uses the common mixed deletion context without the legacy image successor callback', async () => {const sameNameImage = createImageItem('shared', '2026-07-30T13:00:00Z');const sameNameVideo = createVideoItem('shared', '2026-07-30T12:00:00Z');diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.tsindex 557edb9d1e..cb00f5026d 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.test.ts@@ -72,6 +72,27 @@ describe('mergePreviewBoardItems', () => {]);});+ it('uses the server kind/name tie-breakers for equal timestamps in both directions', () => {+ const createdAt = '2026-07-21T00:00:01.000Z';+ const imageA = item('image', 'a', createdAt);+ const imageZ = item('image', 'z', createdAt);+ const videoA = item('video', 'a', createdAt);+ const videoZ = item('video', 'z', createdAt);++ expect(mergePreviewBoardItems([videoA, imageZ], [videoZ, imageA], 'ASC', false)).toEqual([+ imageA,+ imageZ,+ videoA,+ videoZ,+ ]);+ expect(mergePreviewBoardItems([imageA, videoZ], [imageZ, videoA], 'DESC', false)).toEqual([+ videoZ,+ videoA,+ imageZ,+ imageA,+ ]);+ });+it('keeps same-name media independent and bounds the merged Gallery window', () => {const backend = Array.from({ length: GALLERY_MAX_ROWS }, (_, index) =>item('image', `backend-${index}`, new Date(index * 1_000).toISOString())diff --git a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsxindex cad72386f7..ebcbf031d9 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/preview/PreviewWidgetView.tsx@@ -21,6 +21,7 @@ import {getGallerySettings,getSelectedGalleryItemFromValues,getBoundedRecentImages,+ compareGalleryItems,galleryImageItemToGalleryImage,isGalleryImageItem,legacyGeneratedImageToGalleryItem,@@ -137,14 +138,10 @@ const getOrderedPreviewItems = (items.map((item, index) => ({ index, item })).sort((a, b) => {- if (starredFirst && a.item.starred !== b.item.starred) {- return a.item.starred ? -1 : 1;- }-- const chronological = a.item.createdAt.localeCompare(b.item.createdAt);+ const canonicalOrder = compareGalleryItems(a.item, b.item, { orderDir: imageOrderDir, starredFirst });- if (chronological !== 0) {- return imageOrderDir === 'DESC' ? -chronological : chronological;+ if (canonicalOrder !== 0) {+ return canonicalOrder;}return inputOrder === 'newest-first' && imageOrderDir === 'ASC' ? b.index - a.index : a.index - b.index;@@ -533,6 +530,10 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {const handleNavigationKeyDown = useCallback((event: KeyboardEvent<HTMLDivElement>) => {+ if (event.target instanceof Element && event.target.closest('video')) {+ return;+ }+if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {return;}@@ -734,11 +735,15 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {useEffect(() => {const hotkeys = [['viewer.toggleViewer', t('widgets.preview.commands.togglePreview'), ['z']],- ['viewer.swapImages', t('widgets.preview.commands.swapComparisonImages'), ['c']],['viewer.deleteImage', t('widgets.preview.commands.deletePreviewImage'), ['delete', 'backspace']],- ['viewer.zoomToActual', t('widgets.preview.commands.zoomToActual'), ['1']],- ['viewer.zoomToFit', t('widgets.preview.commands.zoomToFit'), ['f']],['viewer.toggleFilmstrip', t('widgets.preview.commands.toggleFilmstrip'), ['t']],+ ...(selectedItem?.kind === 'image'+ ? ([+ ['viewer.swapImages', t('widgets.preview.commands.swapComparisonImages'), ['c']],+ ['viewer.zoomToActual', t('widgets.preview.commands.zoomToActual'), ['1']],+ ['viewer.zoomToFit', t('widgets.preview.commands.zoomToFit'), ['f']],+ ] as const)+ : []),] as const;const disposers = hotkeys.flatMap(([id, title, defaultKeys]) => [runtime.commands.register({ handler: () => executeViewerHotkey(id), id, title }),@@ -748,7 +753,7 @@ export const PreviewWidgetView = ({ region, runtime }: WidgetViewProps) => {return () => {disposers.forEach((dispose) => dispose());};- }, [runtime.commands, runtime.hotkeys, t]);+ }, [runtime.commands, runtime.hotkeys, selectedItem?.kind, t]);return (<Box ref={rootRef} p="2" h="full">