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(webv2): give the queue status chip a progress bar

joshistoast80f3a0c55868
diff --git a/invokeai/frontend/webv2/src/platform/ui/StatusWidgetChip.tsx b/invokeai/frontend/webv2/src/platform/ui/StatusWidgetChip.tsx
index 2f5532be6b..b6ad8d268a 100644
--- a/invokeai/frontend/webv2/src/platform/ui/StatusWidgetChip.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/StatusWidgetChip.tsx
@@ -1,24 +1,55 @@
import type { LucideIcon } from 'lucide-react';
import type { ReactNode } from 'react';
-import { HStack, Icon, Text, type RecipeVariantProps, useRecipe } from '@chakra-ui/react';
+import { Box, HStack, Icon, Text, type RecipeVariantProps, type SystemStyleObject, useRecipe } from '@chakra-ui/react';
import { chipRecipe } from '@theme/recipes';
+/** Presence turns on the bar; a null `value` renders it as a full quiet fill. */
+export interface StatusWidgetChipProgress {
+ value: number | null;
+}
+
+const PROGRESS_TRACK_SX: SystemStyleObject = {
+ bottom: 0,
+ height: '2px',
+ insetInline: 0,
+ pointerEvents: 'none',
+ position: 'absolute',
+};
+
+const PROGRESS_FILL_SX: SystemStyleObject = {
+ bg: 'accent.solid',
+ height: 'full',
+ transition: 'width var(--wb-motion-duration-fast) linear',
+};
+
export const StatusWidgetChip = ({
children,
icon,
+ progress,
tone,
}: {
children: ReactNode;
icon: LucideIcon;
+ /** Optional live progress, drawn as a hairline along the chip's bottom edge. */
+ progress?: StatusWidgetChipProgress;
tone?: NonNullable<RecipeVariantProps<typeof chipRecipe>>['tone'];
}) => {
const recipe = useRecipe({ recipe: chipRecipe });
return (
- <HStack css={recipe({ tone })}>
+ <HStack css={recipe({ tone })} position={progress ? 'relative' : undefined}>
<Icon as={icon} boxSize="3" />
<Text whiteSpace="nowrap">{children}</Text>
+ {progress ? (
+ <Box aria-hidden="true" css={PROGRESS_TRACK_SX}>
+ <Box
+ css={PROGRESS_FILL_SX}
+ opacity={progress.value === null ? 0.35 : 1}
+ width={`${(progress.value ?? 1) * 100}%`}
+ />
+ </Box>
+ ) : null}
</HStack>
);
};
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 9fd8c50dc9..952669e235 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/QueueStatusWidgetView.tsx
@@ -2,24 +2,29 @@ import type { WidgetViewProps } from '@workbench/widgetContracts';
import { Stack, Text } from '@chakra-ui/react';
import { getQueueSummary } from '@features/queue/contracts';
-import { useIsProcessorPaused } from '@features/queue/react';
+import { useIsProcessorPaused, useQueueItemProgress } from '@features/queue/react';
import { StatusWidgetChip } from '@workbench/widget-frame';
import { useActiveProjectSelector } from '@workbench/WorkbenchContext';
import { ListOrderedIcon, PauseIcon } from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { getQueueStatusChip } from './queueStatusModel';
+import { getQueueStatusChip, getQueueStatusProgress } from './queueStatusModel';
export const QueueStatusWidgetView = ({ presentation }: WidgetViewProps) => {
const { t } = useTranslation();
const queueItems = useActiveProjectSelector((project) => project.queue.items);
const isPaused = useIsProcessorPaused();
const summary = getQueueSummary(queueItems);
+ const progress = useQueueItemProgress(summary.runningQueueItemId ?? '');
const chip = getQueueStatusChip(summary, isPaused);
- const label =
+ const percent = typeof progress?.percentage === 'number' ? Math.round(progress.percentage * 100) : null;
+ const baseLabel =
chip.labelKey === 'idle'
? t('widgets.queueStatus.idle')
: t(`widgets.queueStatus.${chip.labelKey}`, { count: chip.count });
+ // The count answers "how much is left"; the percent answers "how far into the
+ // current one", which is the half the chip was missing.
+ const label = chip.tone === 'running' && percent !== null ? `${baseLabel} · ${percent}%` : baseLabel;
if (presentation === 'tooltip') {
return (
@@ -34,5 +39,12 @@ export const QueueStatusWidgetView = ({ presentation }: WidgetViewProps) => {
);
}
- return <StatusWidgetChip icon={chip.tone === 'paused' ? PauseIcon : ListOrderedIcon}>{label}</StatusWidgetChip>;
+ return (
+ <StatusWidgetChip
+ icon={chip.tone === 'paused' ? PauseIcon : ListOrderedIcon}
+ progress={getQueueStatusProgress(chip, progress?.percentage)}
+ >
+ {label}
+ </StatusWidgetChip>
+ );
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.test.ts
index 3462dbf558..3320029208 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.test.ts
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { getQueueStatusChip } from './queueStatusModel';
+import { getQueueStatusChip, getQueueStatusProgress } from './queueStatusModel';
describe('getQueueStatusChip', () => {
it('is idle with an empty queue', () => {
@@ -27,3 +27,22 @@ describe('getQueueStatusChip', () => {
});
});
});
+
+describe('getQueueStatusProgress', () => {
+ const running = getQueueStatusChip({ remaining: 3, total: 5 }, false);
+
+ it('fills to the reported percentage while running', () => {
+ expect(getQueueStatusProgress(running, 0.42)).toEqual({ value: 0.42 });
+ });
+
+ it('is indeterminate before the first step lands', () => {
+ expect(getQueueStatusProgress(running, 0)).toEqual({ value: null });
+ expect(getQueueStatusProgress(running, null)).toEqual({ value: null });
+ expect(getQueueStatusProgress(running, undefined)).toEqual({ value: null });
+ });
+
+ it('draws no bar when idle or paused', () => {
+ expect(getQueueStatusProgress(getQueueStatusChip({ remaining: 0, total: 0 }, false), 0.4)).toBeUndefined();
+ expect(getQueueStatusProgress(getQueueStatusChip({ remaining: 3, total: 5 }, true), 0.4)).toBeUndefined();
+ });
+});
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 c7d4736d5f..9ec769af8b 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/queue-status/queueStatusModel.ts
@@ -16,3 +16,17 @@ export const getQueueStatusChip = (
? { count: summary.remaining, labelKey: 'paused', tone: 'paused' }
: { count: summary.remaining, labelKey: 'queued', tone: 'running' };
};
+
+/**
+ * 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.
+ */
+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;