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.

fix(webv2): stop the queue widget reloading on first item expand

joshistoasta31be6c3fc27
diff --git a/invokeai/frontend/webv2/src/app/QueueUiAdapter.tsx b/invokeai/frontend/webv2/src/app/QueueUiAdapter.tsx
index 74a4648d60..e1882bca33 100644
--- a/invokeai/frontend/webv2/src/app/QueueUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/QueueUiAdapter.tsx
@@ -6,9 +6,8 @@ import { useOpenWorkbenchWidget } from '@workbench/useOpenWorkbenchWidget';
import { useActiveProjectSelector, useWorkbenchSelector } from '@workbench/WorkbenchContext';
import { lazy, useMemo, type ReactNode } from 'react';
-const QueueItemActions = lazy(() =>
- import('@workbench/queue-integration/QueueItemActions').then((module) => ({ default: module.QueueItemActions }))
-);
+const importQueueItemActions = () => import('@workbench/queue-integration/QueueItemActions');
+const QueueItemActions = lazy(() => importQueueItemActions().then((module) => ({ default: module.QueueItemActions })));
/**
* Production binding of Queue's UI port: adapts the Workbench-owned concerns
@@ -38,6 +37,7 @@ export const QueueUiAdapterProvider = ({ children }: { children: ReactNode }) =>
isConnected,
notify,
openQueue: () => openWorkbenchWidget('queue'),
+ preloadItemActions: () => void importQueueItemActions(),
queueJobsScope,
};
}, [activeProjectId, canManageModels, isConnected, notify, openWorkbenchWidget, queueJobsScope, session]);
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx
index 063bd49109..a4dbde6d04 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemDetails.tsx
@@ -1,8 +1,9 @@
import type { QueueItemReadModel } from '@features/queue/core/types';
import type { ReactNode } from 'react';
-import { DataList, Separator, Text } from '@chakra-ui/react';
+import { Box, DataList, Separator, Text } from '@chakra-ui/react';
import { extractGenerationMeta } from '@features/queue/core/generationMeta';
+import { Suspense } from 'react';
import { useTranslation } from 'react-i18next';
import { formatDuration } from './formatDuration';
@@ -20,6 +21,15 @@ const DetailRow = ({ label, children }: { label: string; children: ReactNode })
</DataList.Item>
);
+/** Reserves the actions row's height so resolving the chunk doesn't shift the panel. */
+const ItemActionsPlaceholder = () => {
+ const { t } = useTranslation();
+
+ return <Box aria-busy="true" aria-label={t('widgets.queue.loading')} minH="6" role="status" w="full" />;
+};
+
+const ITEM_ACTIONS_PLACEHOLDER = <ItemActionsPlaceholder />;
+
/** Expanded detail grid + actions for a RECENT queue item row. */
export const QueueItemDetails = ({ item }: { item: QueueItemReadModel }) => {
const { t } = useTranslation();
@@ -62,7 +72,11 @@ export const QueueItemDetails = ({ item }: { item: QueueItemReadModel }) => {
) : null}
<Separator borderColor="border.subtle" my="0.5" />
- <ItemActions item={item} />
+ {/* ItemActions is a lazy chunk. Without this boundary the first expand
+ suspends against the widget root and blanks the whole queue panel. */}
+ <Suspense fallback={ITEM_ACTIONS_PLACEHOLDER}>
+ <ItemActions item={item} />
+ </Suspense>
</DataList.Root>
);
};
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
index 2a80165497..46da6fa3ca 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueItemRow.tsx
@@ -39,9 +39,11 @@ const QUEUE_ITEM_BUTTON_SX: SystemStyleObject = {
export const QueueItemRow = memo(
({ item, revealRequest }: { item: QueueItemReadModel; revealRequest?: QueueItemRevealRequest | null }) => {
const { t } = useTranslation();
- const { canManageItem, canViewItemDetails } = useQueueUi();
+ const { canManageItem, canViewItemDetails, preloadItemActions } = useQueueUi();
const [expanded, setExpanded] = useState(false);
const toggle = useCallback(() => setExpanded((open) => !open), []);
+ // Warm the actions chunk on intent so the first expand has nothing to wait for.
+ const preload = useCallback(() => preloadItemActions?.(), [preloadItemActions]);
const consumedRevealRequestIdRef = useRef<number | null>(null);
const meta = extractGenerationMeta(item);
const duration = formatDuration(item.startedAt, item.completedAt);
@@ -86,6 +88,8 @@ export const QueueItemRow = memo(
as={canExpand ? 'button' : 'div'}
css={QUEUE_ITEM_BUTTON_SX}
onClick={canExpand ? toggle : undefined}
+ onFocus={canExpand ? preload : undefined}
+ onPointerEnter={canExpand ? preload : undefined}
>
<QueueItemThumbnail boxSize="8" imageName={resultImageName} liveImage={liveImage} />
<Stack flex="1" gap="0.5" minW="0">
diff --git a/invokeai/frontend/webv2/src/features/queue/ui/QueueUiContext.tsx b/invokeai/frontend/webv2/src/features/queue/ui/QueueUiContext.tsx
index 983786f01e..fd79c2a1fc 100644
--- a/invokeai/frontend/webv2/src/features/queue/ui/QueueUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/queue/ui/QueueUiContext.tsx
@@ -21,6 +21,11 @@ export interface QueueUiAdapter {
isConnected: boolean;
notify: QueueUiNotificationPort;
openQueue(): void;
+ /**
+ * Warms the `ItemActions` chunk ahead of the first expand. Optional: an
+ * adapter that supplies `ItemActions` eagerly has nothing to preload.
+ */
+ preloadItemActions?(): void;
queueJobsScope: 'active-project' | 'all';
}