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.

refactor(webv2): unify determinate-progress policy and the active-queue progress hook

joshistoast2729b3143236
diff --git a/invokeai/frontend/webv2/src/features/queue/contracts.ts b/invokeai/frontend/webv2/src/features/queue/contracts.ts
index 9abb75e5a9..7f1b9623cf 100644
--- a/invokeai/frontend/webv2/src/features/queue/contracts.ts
+++ b/invokeai/frontend/webv2/src/features/queue/contracts.ts
@@ -44,6 +44,8 @@ export {
type QueueSummary,
} from './core/historySummary';
export {
+ getDeterminateProgressFraction,
+ getDeterminateProgressPercent,
getProgressRailModel,
getProgressRailSegmentValue,
selectProjectProgressItemIds,
diff --git a/invokeai/frontend/webv2/src/features/queue/core/progressRail.test.ts b/invokeai/frontend/webv2/src/features/queue/core/progressRail.test.ts
index f5eda86d12..19c9c362a5 100644
--- a/invokeai/frontend/webv2/src/features/queue/core/progressRail.test.ts
+++ b/invokeai/frontend/webv2/src/features/queue/core/progressRail.test.ts
@@ -2,7 +2,13 @@ import type { QueueItem } from '@features/queue';
import { describe, expect, it } from 'vitest';
-import { getProgressRailModel, getProgressRailSegmentValue, selectProjectProgressItemIds } from './progressRail';
+import {
+ getDeterminateProgressFraction,
+ getDeterminateProgressPercent,
+ getProgressRailModel,
+ getProgressRailSegmentValue,
+ selectProjectProgressItemIds,
+} from './progressRail';
const createQueueItem = ({
backendItemIds,
@@ -56,6 +62,20 @@ describe('getProgressRailModel', () => {
});
});
+describe('getDeterminateProgressFraction', () => {
+ it('treats zero and missing as indeterminate', () => {
+ expect(getDeterminateProgressFraction(0)).toBeNull();
+ expect(getDeterminateProgressFraction(null)).toBeNull();
+ expect(getDeterminateProgressFraction(undefined)).toBeNull();
+ });
+
+ it('passes real fractions through and rounds percents', () => {
+ expect(getDeterminateProgressFraction(0.42)).toBe(0.42);
+ expect(getDeterminateProgressPercent(0.428)).toBe(43);
+ expect(getDeterminateProgressPercent(0)).toBeNull();
+ });
+});
+
describe('getProgressRailSegmentValue', () => {
it('passes a real percentage through', () => {
expect(getProgressRailSegmentValue({ isLoadingModels: false, percentage: 0.42 })).toBe(0.42);
diff --git a/invokeai/frontend/webv2/src/features/queue/core/progressRail.ts b/invokeai/frontend/webv2/src/features/queue/core/progressRail.ts
index ed096edb46..003ee01280 100644
--- a/invokeai/frontend/webv2/src/features/queue/core/progressRail.ts
+++ b/invokeai/frontend/webv2/src/features/queue/core/progressRail.ts
@@ -43,21 +43,32 @@ export const getProgressRailModel = ({
};
/**
- * A segment's fill, or null for the indeterminate sweep.
+ * A determinate fill fraction, or null for the indeterminate sweep.
*
- * Zero is treated as indeterminate rather than as an empty bar: the backend
- * reports `0` for the span between "session started" and "first step done",
- * which is exactly when models are loading and the wait feels longest. An empty
- * determinate bar reads as stalled there; the sweep reads as working.
+ * Zero is indeterminate rather than an empty bar: the backend reports `0` for
+ * the span between "session started" and "first step done", which is exactly
+ * when models are loading and the wait feels longest. An empty determinate
+ * bar (or a "0%" label) reads as stalled there; the sweep reads as working.
+ * Every progress surface routes through this so they cannot disagree.
*/
+export const getDeterminateProgressFraction = (percentage: number | null | undefined): number | null =>
+ typeof percentage === 'number' && percentage > 0 ? percentage : null;
+
+/** Whole percent for text surfaces (tab title, chip label), or null while indeterminate. */
+export const getDeterminateProgressPercent = (percentage: number | null | undefined): number | null => {
+ const fraction = getDeterminateProgressFraction(percentage);
+
+ return fraction === null ? null : Math.round(fraction * 100);
+};
+
+/** A rail segment's fill: also indeterminate while its model is still loading. */
export const getProgressRailSegmentValue = ({
isLoadingModels,
percentage,
}: {
isLoadingModels: boolean;
percentage: number | null | undefined;
-}): number | null =>
- isLoadingModels || percentage === null || percentage === undefined || percentage === 0 ? null : percentage;
+}): number | null => (isLoadingModels ? null : getDeterminateProgressFraction(percentage));
/**
* The live sessions belonging to this project, in ascending id order.
diff --git a/invokeai/frontend/webv2/src/workbench/queue-integration/useActiveQueueProgress.ts b/invokeai/frontend/webv2/src/workbench/queue-integration/useActiveQueueProgress.ts
new file mode 100644
index 0000000000..7fb7e6fca6
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/queue-integration/useActiveQueueProgress.ts
@@ -0,0 +1,17 @@
+import { getQueueSummary } from '@features/queue/contracts';
+import { useQueueItemProgress } from '@features/queue/react';
+import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
+
+/**
+ * The one pairing every aggregate progress surface needs: the active project's
+ * queue summary plus the running item's live progress. Extracted because four
+ * chrome surfaces (Invoke button, tab title, queue cluster, queue-status chip)
+ * had copies that could — and did — drift on edge-case handling.
+ */
+export const useActiveQueueProgress = () => {
+ const queueItems = useActiveProjectSelector((project) => project.queue.items);
+ const baseSummary = getQueueSummary(queueItems);
+ const progress = useQueueItemProgress(baseSummary.runningQueueItemId ?? '');
+
+ return { progress, queueItems, summary: getQueueSummary(queueItems, progress) };
+};
diff --git a/invokeai/frontend/webv2/src/workbench/shell/DocumentTitleProgress.tsx b/invokeai/frontend/webv2/src/workbench/shell/DocumentTitleProgress.tsx
index 396dfb43d1..fcd30ceeb5 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/DocumentTitleProgress.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/DocumentTitleProgress.tsx
@@ -1,7 +1,6 @@
-import { getQueueSummary } from '@features/queue/contracts';
-import { useQueueItemProgress } from '@features/queue/react';
+import { getDeterminateProgressPercent } from '@features/queue/contracts';
import { useMountEffect } from '@platform/react/useMountEffect';
-import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
+import { useActiveQueueProgress } from '@workbench/queue-integration/useActiveQueueProgress';
import { useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -16,11 +15,9 @@ import { DOCUMENT_TITLE_BASE, formatDocumentTitle } from './documentTitle';
*/
export const DocumentTitleProgress = () => {
const { t } = useTranslation();
- const queueItems = useActiveProjectSelector((project) => project.queue.items);
- const baseSummary = getQueueSummary(queueItems);
- const progress = useQueueItemProgress(baseSummary.runningQueueItemId ?? '');
- const { current, total } = getQueueSummary(queueItems, progress);
- const percent = typeof progress?.percentage === 'number' ? Math.round(progress.percentage * 100) : null;
+ const { progress, summary } = useActiveQueueProgress();
+ const { current, total } = summary;
+ const percent = getDeterminateProgressPercent(progress?.percentage);
const title = useMemo(
() =>
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.browser.test.tsx
new file mode 100644
index 0000000000..0a18391eda
--- /dev/null
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.browser.test.tsx
@@ -0,0 +1,123 @@
+import type { InvocationRoute } from '@workbench/invocationContracts';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { system } from '@theme/system';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { userEvent } from 'vitest/browser';
+
+import type * as UseTopbarShortcutModule from './useTopbarShortcut';
+
+// Isolates the regression this file exists to catch: the icon slot must swap
+// back to progress once the pointer leaves AND the button does not hold
+// `:focus-visible` — a plain mouse click leaves it focused (browsers focus a
+// button on mousedown) but must not count, or every mouse-invoked batch would
+// show a play glyph it cannot act on. Mocking the shared hook keeps the test
+// about that gating, not about queue-summary plumbing (which
+// `useActiveQueueProgress` and its call sites already cover elsewhere).
+const harness = vi.hoisted(() => ({
+ progress: { activeItemIndex: 1, completedItemCount: 0, message: '', percentage: 0.42 },
+ summary: { current: 1, remaining: 1, runningQueueItemId: 'item-1', total: 1 },
+}));
+
+vi.mock('@workbench/queue-integration/useActiveQueueProgress', () => ({
+ useActiveQueueProgress: () => ({ progress: harness.progress, queueItems: [], summary: harness.summary }),
+}));
+vi.mock('@workbench/invocation', () => ({ getDestinationLabel: () => 'Gallery' }));
+vi.mock('./useTopbarShortcut', async (importOriginal) => ({
+ ...(await importOriginal<typeof UseTopbarShortcutModule>()),
+ useTopbarShortcutBinding: () => null,
+}));
+vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));
+
+import { InvokeButton } from './InvokeButton';
+
+const invocation: InvocationRoute = {
+ destination: 'gallery',
+ destinationLocked: false,
+ sourceId: 'generate',
+ sourceLocked: false,
+};
+
+let host: HTMLDivElement | null = null;
+let root: Root | null = null;
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const makeInvocationState = () => ({
+ batchCount: 1,
+ blockingReasons: [],
+ invocation,
+ invoke: vi.fn(() => Promise.resolve()),
+ isValid: true,
+ placedTypeIds: new Set<never>(),
+ promptExpansion: { count: 1, error: null, isDynamic: false, isError: false, isLoading: false, prompts: [] },
+ sourceValues: {},
+ sources: [],
+ visibleTypeIds: new Set<never>(),
+});
+
+const renderInvokeButton = async () => {
+ host = document.createElement('div');
+ document.body.append(host);
+ root = createRoot(host);
+ const state = makeInvocationState();
+
+ await act(() =>
+ root?.render(
+ <ChakraProvider value={system}>
+ <InvokeButton state={state} />
+ </ChakraProvider>
+ )
+ );
+
+ return host.querySelector('button') as HTMLButtonElement;
+};
+
+const hasProgressRing = (button: HTMLButtonElement): boolean => button.querySelector('[role="progressbar"]') !== null;
+
+beforeEach(() => {
+ harness.progress.percentage = 0.42;
+ harness.summary.total = 1;
+ harness.summary.runningQueueItemId = 'item-1';
+});
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ host = null;
+ root = null;
+});
+
+describe('InvokeButton icon slot', () => {
+ it('shows the progress ring while a batch runs and nothing is hovered or keyboard-focused', async () => {
+ const button = await renderInvokeButton();
+
+ expect(hasProgressRing(button)).toBe(true);
+ });
+
+ it('does not treat a mouse-click focus as keyboard focus: the ring returns once the pointer leaves', async () => {
+ const button = await renderInvokeButton();
+
+ await act(() => userEvent.click(button));
+ // A plain click focuses the button (mousedown does that natively) but must
+ // not arm `:focus-visible`, so it must not be the reason the ring is hidden
+ // right after the click either.
+ expect(document.activeElement).toBe(button);
+ expect(button.matches(':focus-visible')).toBe(false);
+
+ await act(() => userEvent.unhover(button));
+
+ expect(hasProgressRing(button)).toBe(true);
+ });
+
+ it('suppresses the ring for real keyboard focus (:focus-visible) the same as hover', async () => {
+ const button = await renderInvokeButton();
+
+ await act(() => userEvent.tab());
+
+ expect(document.activeElement).toBe(button);
+ expect(button.matches(':focus-visible')).toBe(true);
+ expect(hasProgressRing(button)).toBe(false);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx
index d0f50c4e9c..9e4bb4e14e 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/InvokeButton.tsx
@@ -1,12 +1,11 @@
-import type { ComponentProps } from 'react';
+import type { ComponentProps, FocusEvent } from 'react';
import { Box, HStack, Icon, Kbd, ProgressCircle, Separator, Stack, Text } from '@chakra-ui/react';
-import { getQueueSummary } from '@features/queue/contracts';
-import { useQueueItemProgress } from '@features/queue/react';
+import { getDeterminateProgressFraction } from '@features/queue/contracts';
import { Button } from '@platform/ui/Button';
import { Tooltip } from '@platform/ui/Tooltip';
import { getDestinationLabel } from '@workbench/invocation';
-import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
+import { useActiveQueueProgress } from '@workbench/queue-integration/useActiveQueueProgress';
import { PlayIcon } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -43,8 +42,10 @@ const plural = (count: number, noun: string): string => `${count} ${noun}${count
* Invoke queues further items on top of a running batch, so a button that
* morphed into a progress bar would read as unavailable at exactly the
* moment it is most useful. Only the icon slot's content may change: it
- * shows the queue's progress while a batch runs and the pointer is
- * elsewhere, and reverts to the play glyph on hover so "queue more on top"
+ * shows the queue's progress while a batch runs and the pointer is elsewhere
+ * and the button does not hold keyboard focus, and reverts to the play glyph
+ * on hover or on `:focus-visible` (not a plain click-focus, which would leave
+ * a mouse-invoked batch stuck on the play glyph) so "queue more on top"
* always reads as available. Aggregate progress otherwise belongs to the
* queue group. (§5.1, contract §9.4.)
*/
@@ -58,20 +59,28 @@ export const InvokeButton = ({ state }: { state: InvocationState }) => {
[shortcutParts, state]
);
- const queueItems = useActiveProjectSelector((project) => project.queue.items);
- const baseSummary = getQueueSummary(queueItems);
- const runningProgress = useQueueItemProgress(baseSummary.runningQueueItemId ?? '');
- const hasOpenWork = baseSummary.total > 0;
+ const { progress: runningProgress, summary } = useActiveQueueProgress();
+ const hasOpenWork = summary.total > 0;
const [isHovered, setIsHovered] = useState(false);
const handlePointerEnter = useCallback(() => setIsHovered(true), []);
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
+ const [isFocused, setIsFocused] = useState(false);
+ // `focus`, unlike `:focus-visible`, fires on every mousedown too — gating on
+ // the pseudo-class keeps this keyboard-only so a mouse click mid-batch does
+ // not strand the icon on the play glyph until something else steals focus.
+ const handleFocus = useCallback((event: FocusEvent<HTMLButtonElement>) => {
+ if (event.currentTarget.matches(':focus-visible')) {
+ setIsFocused(true);
+ }
+ }, []);
+ const handleBlur = useCallback(() => setIsFocused(false), []);
const handleClick = useCallback(() => void invoke(), [invoke]);
const iconMode = getInvokeIconMode({
hasOpenWork,
- isHovered,
- progress: runningProgress?.percentage ?? null,
+ isHovered: isHovered || isFocused,
+ progress: getDeterminateProgressFraction(runningProgress?.percentage),
});
return (
@@ -91,7 +100,9 @@ export const InvokeButton = ({ state }: { state: InvocationState }) => {
flexShrink={0}
opacity={isValid ? undefined : 0.55}
size="xs"
+ onBlur={handleBlur}
onClick={isValid ? handleClick : undefined}
+ onFocus={handleFocus}
onPointerEnter={handlePointerEnter}
onPointerLeave={handlePointerLeave}
zIndex="2"
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
index 3bd62bf6ba..50c1597a25 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/QueueCluster.tsx
@@ -6,20 +6,21 @@ import type { ReactNode } from 'react';
import { Badge, chakra, HStack, Icon, Menu, Portal, Progress, Stack, Text } from '@chakra-ui/react';
import { useModelLoads } from '@features/models';
import {
+ getDeterminateProgressFraction,
getQueueItemExpectedImageCount,
getQueueItemSnapshotPositivePrompt,
- getQueueSummary,
} from '@features/queue/contracts';
import { QueueMenuItems, useQueueMenuActions } from '@features/queue/menu';
-import { useIsProcessorPaused, useQueueItemProgress } from '@features/queue/react';
+import { useIsProcessorPaused } from '@features/queue/react';
import { Button, IconButton } from '@platform/ui/Button';
import { Group } from '@platform/ui/Group';
import { MenuContent } from '@platform/ui/Menu';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { Tooltip } from '@platform/ui/Tooltip';
import { getDestinationLabel, getSourceLabel } from '@workbench/invocation';
+import { useActiveQueueProgress } from '@workbench/queue-integration/useActiveQueueProgress';
import { useOpenWorkbenchWidget } from '@workbench/useOpenWorkbenchWidget';
-import { useActiveProjectSelector, useWorkbenchSelector } from '@workbench/WorkbenchContext';
+import { useWorkbenchSelector } from '@workbench/WorkbenchContext';
import { ChevronDownIcon, ListOrderedIcon, PauseIcon, XIcon } from 'lucide-react';
import { useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -36,16 +37,13 @@ const tonePalettes: Record<QueueTone, string | undefined> = {
export const QueueCluster = () => {
const { t } = useTranslation();
- const queueItems = useActiveProjectSelector((project) => project.queue.items);
const backendConnectionStatus = useWorkbenchSelector((snapshot) => snapshot.backendConnection.status);
const modelLoads = useModelLoads();
const openWorkbenchWidget = useOpenWorkbenchWidget();
const actions = useQueueMenuActions({ includeOpenQueue: true });
const cancelCurrent = actions[0];
- const baseSummary = getQueueSummary(queueItems);
- const runningProgress = useQueueItemProgress(baseSummary.runningQueueItemId ?? '');
- const summary = getQueueSummary(queueItems, runningProgress);
+ const { progress: runningProgress, queueItems, summary } = useActiveQueueProgress();
const { current, remaining, total } = summary;
const runningItem = summary.runningQueueItemId
? queueItems.find((item) => item.id === summary.runningQueueItemId)
@@ -55,7 +53,7 @@ export const QueueCluster = () => {
const isPaused = useIsProcessorPaused();
const hasOpenWork = total > 0;
const tone: QueueTone = isPaused && hasOpenWork ? 'paused' : hasOpenWork && isConnected ? 'running' : 'idle';
- const progressValue = runningProgress?.percentage ?? null;
+ const progressValue = getDeterminateProgressFraction(runningProgress?.percentage);
const isCancellable = !cancelCurrent?.disabled;
const handleOpenQueue = useCallback(() => openWorkbenchWidget('queue'), [openWorkbenchWidget]);
@@ -256,18 +254,16 @@ const QueueTooltip = ({
{progressLabel}
</Text>
{modelLoads.length ? <ModelLoadList modelLoads={modelLoads} /> : null}
- {progress?.percentage !== null && progress?.percentage !== undefined ? (
- <Progress.Root
- aria-label={t('topbar.queue.currentImageProgress')}
- max={1}
- size="xs"
- value={progress.percentage}
- >
- <Progress.Track>
- <Progress.Range />
- </Progress.Track>
- </Progress.Root>
- ) : null}
+ <Progress.Root
+ aria-label={t('topbar.queue.currentImageProgress')}
+ max={1}
+ size="xs"
+ value={getDeterminateProgressFraction(progress?.percentage)}
+ >
+ <Progress.Track>
+ <Progress.Range />
+ </Progress.Track>
+ </Progress.Root>
</Stack>
<Stack gap="1" color="fg.subtle" fontSize="2xs">
<Text fontVariantNumeric="tabular-nums">
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/invokeButtonModel.ts b/invokeai/frontend/webv2/src/workbench/shell/topbar/invokeButtonModel.ts
index e59e0a6a56..a6ab3d2dbd 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/invokeButtonModel.ts
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/invokeButtonModel.ts
@@ -2,9 +2,12 @@ export type InvokeIconMode = { mode: 'play' } | { mode: 'progress'; value: numbe
/**
* The Invoke button's icon slot. Progress replaces the play glyph only while a
- * batch runs AND the pointer is elsewhere; hovering always restores the play
- * glyph so "queue more on top" stays legible. (Contract §9.4: geometry, width,
- * and enabled state never change — only the icon slot's content may.)
+ * batch runs AND `isHovered` is false; hovering always restores the play glyph
+ * so "queue more on top" stays legible. The caller folds `:focus-visible`
+ * keyboard focus into this same flag for parity — a plain click-focus does
+ * not count, or every mouse-invoked batch would be stuck on the play glyph.
+ * (Contract §9.4: geometry, width, and enabled state never change — only the
+ * icon slot's content may.)
*/
export const getInvokeIconMode = ({
hasOpenWork,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx
index 952669e235..bc277c3049 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx
@@ -1,10 +1,10 @@
import type { WidgetViewProps } from '@workbench/widgetContracts';
import { Stack, Text } from '@chakra-ui/react';
-import { getQueueSummary } from '@features/queue/contracts';
-import { useIsProcessorPaused, useQueueItemProgress } from '@features/queue/react';
+import { getDeterminateProgressPercent, getQueueSummary } from '@features/queue/contracts';
+import { useIsProcessorPaused } from '@features/queue/react';
+import { useActiveQueueProgress } from '@workbench/queue-integration/useActiveQueueProgress';
import { StatusWidgetChip } from '@workbench/widget-frame';
-import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
import { ListOrderedIcon, PauseIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
@@ -12,12 +12,14 @@ import { getQueueStatusChip, getQueueStatusProgress } from './queueStatusModel';
export const QueueStatusWidgetView = ({ presentation }: WidgetViewProps) => {
const { t } = useTranslation();
- const queueItems = useActiveProjectSelector((project) => project.queue.items);
+ const { progress, queueItems } = useActiveQueueProgress();
const isPaused = useIsProcessorPaused();
+ // The chip's remaining/total counts must hold steady as progress advances
+ // through a running batch's sub-images, so they come from a summary built
+ // without progress; only the percent label tracks live progress.
const summary = getQueueSummary(queueItems);
- const progress = useQueueItemProgress(summary.runningQueueItemId ?? '');
const chip = getQueueStatusChip(summary, isPaused);
- const percent = typeof progress?.percentage === 'number' ? Math.round(progress.percentage * 100) : null;
+ const percent = getDeterminateProgressPercent(progress?.percentage);
const baseLabel =
chip.labelKey === 'idle'
? t('widgets.queueStatus.idle')
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts
index 9ec769af8b..68a5cbc497 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts
@@ -1,3 +1,5 @@
+import { getDeterminateProgressFraction } from '@features/queue/contracts';
+
export interface QueueStatusChip {
count: number;
labelKey: 'idle' | 'paused' | 'queued';
@@ -21,12 +23,12 @@ export const getQueueStatusChip = (
* The chip's hairline, or `undefined` for no bar at all.
*
* Only the running tone gets one: an idle queue has nothing to fill, and a
- * paused one would show a bar that never moves, which reads as a hang. Zero and
- * missing percentages become the quiet indeterminate fill for the same reason
- * the top bar rail does — that is the model-loading window, not a stall.
+ * paused one would show a bar that never moves, which reads as a hang. The
+ * fill itself routes through `getDeterminateProgressFraction` — see that
+ * function for why zero reads as indeterminate.
*/
export const getQueueStatusProgress = (
chip: QueueStatusChip,
percentage: number | null | undefined
): { value: number | null } | undefined =>
- chip.tone === 'running' ? { value: typeof percentage === 'number' && percentage > 0 ? percentage : null } : undefined;
+ chip.tone === 'running' ? { value: getDeterminateProgressFraction(percentage) } : undefined;