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): redesign the model install queue as a docked table panel

Josh Corbett505e1db9e46e
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index fb6edef99b..6fb3c7ddfa 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1033,10 +1033,12 @@
"accessTokenForDownload": "Access token for this download",
"accessTokenHelp": "Attached to the next Pull only. For saved HuggingFace, Civitai, and provider keys, use the API Keys tab.",
"accessTokenPlaceholder": "Only needed for protected sources",
+ "accessTokenRequiredMessage": "This source needs an access token. Add one to continue.",
"actions": "Model actions",
"addImage": "Add image",
"addModels": "Add Models",
"addModelsResults": "Add models results",
+ "addToken": "Add token",
"addTriggerPhrase": "Add a trigger phrase...",
"allBases": "All bases",
"allInstalled": "all installed",
@@ -1067,9 +1069,10 @@
"bundleInstallQueuedDescription_one": "{{name}}: {{count}} install queued.",
"bundleInstallQueuedDescription_other": "{{name}}: {{count}} installs queued.",
"bytePlusApiKeyPlaceholder": "API key from BytePlus console",
+ "bytesCopied": "{{bytes}} copied",
"cacheEmptied": "Model cache emptied",
"currentPath": "Current path",
- "cancelAllInstalls": "Cancel all installs",
+ "cancelAll": "Cancel all",
"cancelFailed": "Cancel failed",
"cancelInstall": "Cancel install",
"civitaiKey": "Civitai key",
@@ -1145,6 +1148,11 @@
"downloadProgress": "Download progress",
"editing": "Editing",
"emptyCache": "Empty model cache",
+ "eta": {
+ "hours": "~{{count}} h left",
+ "minutes": "~{{count}} min left",
+ "seconds": "~{{count}}s left"
+ },
"externalProviderKeyDescription": "Stored server-side and used for every request to this provider.",
"externalProviderKeysUnavailable": "Could not load external provider keys",
"exportSettings": "Export settings…",
@@ -1174,6 +1182,7 @@
"format": "Format",
"formatHelp": "Changing the format re-classifies the model; invalid combinations are rejected.",
"fullRows": "Full rows",
+ "gatedRepoMessage": "This repo is gated. Add a Hugging Face token to continue.",
"hash": "Hash",
"huggingFaceKeyDescription": "For gated repos like FLUX. Stored on the InvokeAI server and verified with HuggingFace.",
"huggingFaceRejectedToken": "HuggingFace rejected this token. Check that it has read access.",
@@ -1223,6 +1232,8 @@
"manageApiKeys": "Manage API keys",
"manageModels": "Manage models",
"manager": "Model Manager",
+ "maximizeQueue": "Expand",
+ "maximizeQueueTooltip": "Fill the pane with the install queue",
"missingFile": "Missing file",
"missingFilesCount": "Missing files ({{count}})",
"modelAndDependenciesQueued_one": "{{name}} and {{count}} dependency",
@@ -1243,6 +1254,7 @@
"modelReidentified": "Model re-identified",
"modelType": "Model Type",
"modelUpdated": "Model updated",
+ "moreQueueActions": "More queue actions",
"noInstallableModelFiles": "This HuggingFace repo has no installable model files.",
"noInstallsDescription": "Model installs appear here while they download and import.",
"noExternalProviders": "No external model providers are available on this server.",
@@ -1260,6 +1272,7 @@
"noneInstalledDescription": "Use Add Models to install your first model.",
"noneMatchFilters": "No models match your filters",
"noneMatchFiltersDescription": "Try clearing the search or filters.",
+ "openModel": "Open model",
"orphanedCleanup": "Orphaned model cleanup",
"orphanedCleanupFailed": "Orphaned model cleanup failed",
"orphanedCleanupPartialDescription": "{{deleted}} deleted, {{failed}} failed: {{error}}",
@@ -1271,21 +1284,43 @@
"path": "Path",
"pathUpdateFailed": "Failed to update path",
"pathUpdated": "Path updated",
- "pauseAllDownloads": "Pause all downloads",
- "pauseAllInstalls": "Pause all installs",
+ "pauseAll": "Pause all",
"pauseDownload": "Pause download",
"pauseFailed": "Pause failed",
- "pauseInstall": "Pause install",
"predictionType": "Prediction Type",
"press": "Press",
+ "progressNotStarted": "Not started",
+ "progressStopped": "Stopped",
"pruneFailed": "Prune failed",
"pull": "Pull",
"emptyCacheConfirmBody": "Unloads all models from RAM and VRAM. The next generation reloads them from disk.",
"emptyCacheConfirmTitle": "Empty model cache?",
"providerId": "Provider",
"providerModelId": "Provider Model ID",
+ "queueAttentionCount_one": "{{count}} needs attention",
+ "queueAttentionCount_other": "{{count}} need attention",
"queueActionFailed": "Queue action failed",
"queueActionPartialDescription": "{{failed}} of {{total}} failed: {{error}}",
+ "queueColumns": {
+ "actions": "Actions",
+ "name": "Name",
+ "progress": "Progress",
+ "state": "State",
+ "status": "Status"
+ },
+ "queueDownloadingCount_one": "{{count}} downloading",
+ "queueDownloadingCount_other": "{{count}} downloading",
+ "queueInstalledCount_one": "{{count}} installed",
+ "queueInstalledCount_other": "{{count}} installed",
+ "queueInstallingCount_one": "{{count}} installing",
+ "queueInstallingCount_other": "{{count}} installing",
+ "queueMoreQueued_one": "+{{count}} queued",
+ "queueMoreQueued_other": "+{{count}} queued",
+ "queuePausedCount_one": "{{count}} paused",
+ "queuePausedCount_other": "{{count}} paused",
+ "queuePosition": "#{{position}} in queue",
+ "queueQueuedCount_one": "{{count}} queued",
+ "queueQueuedCount_other": "{{count}} queued",
"refreshFailed": "Failed to refresh models",
"refreshList": "Refresh model list",
"reidentified": "Models re-identified",
@@ -1294,6 +1329,7 @@
"reidentify": "Re-identify model",
"reidentifyFailed": "Re-identify failed",
"reidentifySelected": "Re-identify",
+ "removeFromList": "Remove from list",
"repoVariant": "Repo Variant",
"relatedModels": "Related Models",
"relatedModelsHelp": "Link the models that pair well with this one - they are suggested together elsewhere in the app.",
@@ -1301,14 +1337,13 @@
"removeModelImage": "Remove model image",
"removeTriggerPhrase": "Remove trigger phrase {{phrase}}",
"resetBaseFilters": "Reset base filters",
- "restartFile": "Restart file",
"restartFileFailed": "Restart file failed",
"restartThisFile": "Restart this file",
- "resumeAllInstalls": "Resume all installs",
- "resumeAllPausedDownloads": "Resume all paused downloads",
+ "restoreQueue": "Restore",
+ "restoreQueueTooltip": "Dock the install queue to the bottom of the pane",
+ "resumeAll": "Resume all",
"resumeDownload": "Resume download",
"resumeFailed": "Resume failed",
- "resumeInstall": "Resume install",
"resumeRequired": "Resume required",
"retryFailed": "Retry failed",
"retryFailedDownload": "Retry failed download",
@@ -1320,6 +1355,8 @@
"saveDefaults": "Save Defaults",
"scan": "Scan",
"scanFailed": "Scan failed",
+ "statusQueued": "Queued",
+ "statusUnauthorized": "Unauthorized",
"stopScan": "Stop",
"scanFolderTooltip": "Scan this folder for model files",
"scanSummary_one": "{{count}} file in {{path}} · {{notInstalled}} not installed",
@@ -1370,13 +1407,13 @@
"sourceUrl": "Source URL",
"sourceUrlHelp": "Model page or download URL.",
"statusCancelled": "Cancelled",
- "statusDownloaded": "Downloaded",
"statusDownloading": "Downloading",
"statusPaused": "Paused",
"statusWaiting": "Waiting",
"title": "Models",
"toFindModelsInFolder": "to find models in this folder.",
"toInstallFrom": "to install from {{source}}.",
+ "transferRate": "{{rate}}/s",
"triggerPhraseDuplicate": "That trigger phrase is already on this model.",
"triggerPhrases": "Trigger Phrases",
"triggerPhrasesHelp": "Phrases that activate this model, surfaced in the prompt editor.",
@@ -1390,8 +1427,7 @@
"variant": "Variant",
"variantHelp": "Architecture variant, e.g. inpaint or dev.",
"viewModel": "View model",
- "viewQueue": "View queue",
- "waitingForDownload": "Waiting for download"
+ "viewQueue": "View queue"
},
"nodes": {
"addNodes": "Add Nodes",
diff --git a/invokeai/frontend/webv2/src/features/models/core/types.ts b/invokeai/frontend/webv2/src/features/models/core/types.ts
index 9a64332dcc..57363b575e 100644
--- a/invokeai/frontend/webv2/src/features/models/core/types.ts
+++ b/invokeai/frontend/webv2/src/features/models/core/types.ts
@@ -179,7 +179,6 @@ export type ModelInstallStatus =
export interface ModelInstallDownloadPart {
source?: string;
- url?: string;
local_path?: string;
bytes: number;
total_bytes: number;
@@ -197,7 +196,19 @@ export interface ModelInstallJob {
id: number;
status: ModelInstallStatus;
/** Local path, URL, or HF repo id — may be a string or a structured source. */
- source: string | { repo_id?: string; url?: string; path?: string; type?: string; [key: string]: unknown };
+ source:
+ | string
+ | {
+ repo_id?: string;
+ url?: string;
+ path?: string;
+ type?: string;
+ variant?: string | null;
+ subfolder?: string | null;
+ provider_id?: string;
+ provider_model_id?: string;
+ [key: string]: unknown;
+ };
error?: string | null;
error_reason?: string | null;
error_traceback?: string | null;
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobProgress.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobProgress.tsx
deleted file mode 100644
index 68ab61c568..0000000000
--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobProgress.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { ModelInstallJob } from '@features/models/core/types';
-
-import { Box, Progress, Text } from '@chakra-ui/react';
-import { formatBytes } from '@features/models/core/taxonomy';
-import { useInstallProgress } from '@features/models/data/installsStore';
-import { useTranslation } from 'react-i18next';
-
-export const InstallJobProgress = ({ job }: { job: ModelInstallJob }) => {
- const { t } = useTranslation();
- const liveProgress = useInstallProgress(job.id);
- const bytes = liveProgress?.bytes ?? job.bytes ?? 0;
- const totalBytes = liveProgress?.totalBytes ?? job.total_bytes ?? 0;
- const hasTotal = totalBytes > 0;
- const ratio = hasTotal ? Math.min(1, bytes / totalBytes) : null;
-
- return (
- <Box>
- <Progress.Root aria-label={t('models.downloadProgress')} max={1} size="xs" value={ratio}>
- <Progress.Track>
- <Progress.Range />
- </Progress.Track>
- </Progress.Root>
- <Text color="fg.subtle" fontSize="2xs" mt="1">
- {hasTotal
- ? `${Math.round((ratio ?? 0) * 100)}% · ${formatBytes(bytes)} / ${formatBytes(totalBytes)}`
- : t('models.waitingForDownload')}
- </Text>
- </Box>
- );
-};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobRow.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobRow.tsx
index 54b9afc076..50f89a114e 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobRow.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallJobRow.tsx
@@ -1,204 +1,262 @@
-/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-array-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
-import type { ModelInstallJob } from '@features/models/core/types';
+import type { LucideIcon } from 'lucide-react';
-import { Badge, HStack, Icon, Stack, Text } from '@chakra-ui/react';
-import {
- cancelModelInstall,
- pauseModelInstall,
- restartFailedModelInstall,
- restartModelInstallFile,
- resumeModelInstall,
-} from '@features/models/data/api';
-import {
- getInstallSourceLabel,
- isActiveInstallStatus,
- refreshInstalls,
- replaceInstallJob,
-} from '@features/models/data/installsStore';
-import { useScopedAction } from '@platform/react/useScopedAction';
-import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';
+import { Badge, Box, HStack, Icon, Spinner, Stack, Table, Text } from '@chakra-ui/react';
+import { getModelTypeLabel } from '@features/models/core/taxonomy';
+import { useInstallProgress } from '@features/models/data/installsStore';
+import { useModelsSelector } from '@features/models/data/modelsStore';
+import { openModelDetail, openModelManagerTab } from '@features/models/ui/uiStore';
import { useConnectionStatusSelector } from '@platform/transport/connectionStore';
-import { IconButton, Tooltip } from '@platform/ui';
+import { Button, IconButton, Tooltip } from '@platform/ui';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
-import { PauseIcon, PlayIcon, RotateCcwIcon, TriangleAlertIcon, XIcon } from 'lucide-react';
+import {
+ CheckIcon,
+ ClockIcon,
+ LockIcon,
+ MinusIcon,
+ PauseIcon,
+ PlayIcon,
+ RotateCcwIcon,
+ SquareArrowOutUpRightIcon,
+ TriangleAlertIcon,
+ XIcon,
+} from 'lucide-react';
import { useTranslation } from 'react-i18next';
-import { InstallJobProgress } from './InstallJobProgress';
-import { STATUS_BADGES, getInstallJobDisplayName } from './queueUtils';
+/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-array-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
+import type { InstallQueueRow, InstallRowStatus } from './queueModel';
+
+import { InstallProgressCell } from './InstallProgressCell';
+import {
+ canRestartFailedParts,
+ getInstallJobDisplayName,
+ getInstallJobSourceLabel,
+ getProblemDownloadParts,
+ isActiveRowStatus,
+ isHuggingFaceSource,
+ isSettledRowStatus,
+ resolveInstallProgress,
+ STATUS_PRESENTATION,
+} from './queueModel';
+import { useInstallJobActions } from './useInstallJobActions';
-const partFileName = (part: { url?: string; source?: string; local_path?: string }): string =>
- (part.url ?? part.source ?? part.local_path ?? 'file').split(/[\\/]/).at(-1) ?? 'file';
+const STATUS_ICONS: Record<
+ Exclude<InstallRowStatus, 'downloading' | 'installing'>,
+ { icon: LucideIcon; color: string }
+> = {
+ cancelled: { color: 'fg.muted', icon: MinusIcon },
+ failed: { color: 'fg.error', icon: TriangleAlertIcon },
+ installed: { color: 'fg.success', icon: CheckIcon },
+ paused: { color: 'fg.muted', icon: PauseIcon },
+ queued: { color: 'fg.muted', icon: ClockIcon },
+ unauthorized: { color: 'fg.warning', icon: LockIcon },
+};
+
+const CELL_PROPS = { borderColor: 'border.subtle', py: '2', verticalAlign: 'top' } as const;
+
+const StatusGlyph = ({ status }: { status: InstallRowStatus }) => {
+ if (isActiveRowStatus(status)) {
+ return <Spinner borderWidth="1.5px" boxSize="3.5" color="accent.solid" />;
+ }
+
+ const { color, icon } = STATUS_ICONS[status];
+
+ return <Icon as={icon} boxSize="3.5" color={color} />;
+};
-export const InstallJobRow = ({
- job,
- onError,
+const RowAction = ({
+ disabled,
+ icon,
+ label,
+ onClick,
+ tone,
}: {
- job: ModelInstallJob;
- onError: (title: string, message: string) => void;
-}) => {
+ disabled: boolean;
+ icon: LucideIcon;
+ label: string;
+ onClick: () => void;
+ tone?: 'danger';
+}) => (
+ <Tooltip content={label}>
+ <IconButton
+ aria-label={label}
+ colorPalette={tone === 'danger' ? 'danger' : undefined}
+ disabled={disabled}
+ size="2xs"
+ variant="ghost"
+ onClick={onClick}
+ >
+ <Icon as={icon} boxSize="3" />
+ </IconButton>
+ </Tooltip>
+);
+
+export const InstallJobRow = ({ row }: { row: InstallQueueRow }) => {
+ const { job, queuePosition, status } = row;
const { t } = useTranslation();
- const { isBusy: isActing, run } = useScopedAction();
+ const actions = useInstallJobActions(job);
+ const liveProgress = useInstallProgress(job.id);
const connectionStatus = useConnectionStatusSelector((snapshot) => snapshot.status);
- // The Record is total for typed statuses; the fallback guards unknown
- // statuses from an untyped backend payload.
- const badge = STATUS_BADGES[job.status] as { labelKey: string; palette: string } | undefined;
- const badgeLabel = badge ? t(badge.labelKey) : job.status;
- const badgePalette = badge?.palette ?? 'gray';
- const sourceLabel = getInstallSourceLabel(job.source);
- const displayName = getInstallJobDisplayName(job);
- // Parts the backend could not resume (or that errored) need a manual restart.
- const problemParts = (job.download_parts ?? []).filter(
- (part) => part.resume_required === true || part.status === 'error'
+ const installedKey = job.config_out?.key ?? null;
+ const isInLibrary = useModelsSelector((snapshot) =>
+ installedKey !== null ? snapshot.modelsByKey.has(installedKey) : false
);
- const showDisconnected = connectionStatus !== 'connected' && isActiveInstallStatus(job.status);
-
- const runAction = (action: (signal: AbortSignal) => Promise<unknown>, failureTitle: string) =>
- run(
- async (owner) => {
- const result = await action(owner.signal);
-
- assertAccountScopeCurrent(owner);
- if (result && typeof result === 'object' && 'id' in (result as ModelInstallJob)) {
- replaceInstallJob(result as ModelInstallJob);
- // A coalesced refresh already in flight can clobber the optimistic
- // row with a stale snapshot; revalidating converges on server truth.
- void refreshInstalls(owner);
- } else {
- await refreshInstalls(owner);
- }
- },
- (message) => onError(failureTitle, message)
- );
+
+ const presentation = STATUS_PRESENTATION[status];
+ const progress = resolveInstallProgress(job, liveProgress);
+ const displayName = getInstallJobDisplayName(job);
+ const sourceLabel = getInstallJobSourceLabel(job);
+ const problemParts = getProblemDownloadParts(job);
+ const typeLabel = job.config_out?.type ? getModelTypeLabel(job.config_out.type) : null;
+ const showDisconnected = connectionStatus !== 'connected' && isActiveRowStatus(status);
+ const tone = status === 'failed' ? 'error' : status === 'unauthorized' ? 'warning' : undefined;
return (
- <Stack
- bg="bg"
- borderColor={job.status === 'error' ? 'border.error' : 'border.subtle'}
- borderWidth="1px"
- gap="1.5"
- p="2"
- rounded="md"
- >
- <HStack gap="2" justify="space-between">
- <MiddleTruncate flex="1" fontSize="2xs" fontWeight="600" minW="0" text={displayName} title={sourceLabel} />
- {showDisconnected ? (
- <Tooltip content={t('models.backendDisconnectedProgressStale')}>
- <Icon as={TriangleAlertIcon} boxSize="3" color="fg.warning" flexShrink={0} />
- </Tooltip>
- ) : null}
- <Badge colorPalette={badgePalette} flexShrink={0} fontSize="2xs" size="sm" variant="surface">
- {badgeLabel}
- </Badge>
- <HStack flexShrink={0} gap="0.5">
- {job.status === 'downloading' ? (
- <Tooltip content={t('models.pauseDownload')}>
- <IconButton
- aria-label={t('models.pauseInstall')}
- disabled={isActing}
- size="2xs"
- variant="ghost"
- onClick={() => void runAction((signal) => pauseModelInstall(job.id, signal), t('models.pauseFailed'))}
- >
- <Icon as={PauseIcon} boxSize="3" />
- </IconButton>
- </Tooltip>
- ) : null}
- {job.status === 'paused' ? (
- <Tooltip content={t('models.resumeDownload')}>
- <IconButton
- aria-label={t('models.resumeInstall')}
- disabled={isActing}
- size="2xs"
- variant="ghost"
- onClick={() => void runAction((signal) => resumeModelInstall(job.id, signal), t('models.resumeFailed'))}
- >
- <Icon as={PlayIcon} boxSize="3" />
- </IconButton>
- </Tooltip>
+ <Table.Row data-install-status={status} data-tone={tone}>
+ <Table.Cell {...CELL_PROPS} ps="3" pt="2.5">
+ <StatusGlyph status={status} />
+ </Table.Cell>
+
+ <Table.Cell {...CELL_PROPS}>
+ <Stack gap="0" minW="0">
+ <MiddleTruncate
+ color={status === 'installed' ? 'fg.muted' : 'fg'}
+ fontSize="xs"
+ fontWeight="600"
+ lineHeight="short"
+ text={displayName}
+ />
+ {sourceLabel !== displayName ? (
+ <MiddleTruncate color="fg.muted" fontFamily="mono" fontSize="2xs" text={sourceLabel} />
) : null}
- {job.status === 'error' ? (
- <Tooltip content={t('models.retryFailedDownload')}>
- <IconButton
- aria-label={t('models.retryInstall')}
- disabled={isActing}
- size="2xs"
- variant="ghost"
- onClick={() =>
- void runAction((signal) => restartFailedModelInstall(job.id, signal), t('models.retryFailed'))
- }
- >
- <Icon as={RotateCcwIcon} boxSize="3" />
- </IconButton>
- </Tooltip>
+ {status === 'failed' && job.error ? (
+ <HStack align="baseline" flexWrap="wrap" gap="1.5" pt="0.5">
+ {job.error_reason ? (
+ <Badge colorPalette="red" fontFamily="mono" size="sm" variant="surface">
+ {job.error_reason}
+ </Badge>
+ ) : null}
+ <Text color="fg" fontSize="2xs" lineClamp={2} overflowWrap="anywhere">
+ {job.error}
+ </Text>
+ </HStack>
) : null}
- {isActiveInstallStatus(job.status) || job.status === 'paused' ? (
- <Tooltip content={t('models.cancelInstall')}>
- <IconButton
- aria-label={t('models.cancelInstall')}
- disabled={isActing}
- size="2xs"
- variant="ghost"
- onClick={() => void runAction((signal) => cancelModelInstall(job.id, signal), t('models.cancelFailed'))}
+ {status === 'unauthorized' ? (
+ <HStack align="baseline" flexWrap="wrap" gap="1.5" pt="0.5">
+ <Text color="fg" fontSize="2xs">
+ {t(isHuggingFaceSource(job) ? 'models.gatedRepoMessage' : 'models.accessTokenRequiredMessage')}
+ </Text>
+ <Button
+ fontSize="2xs"
+ h="auto"
+ minW="0"
+ p="0"
+ textDecoration="underline"
+ variant="plain"
+ onClick={() => openModelManagerTab('keys')}
>
- <Icon as={XIcon} boxSize="3" />
- </IconButton>
- </Tooltip>
+ {t('models.addToken')}
+ </Button>
+ </HStack>
) : null}
- </HStack>
- </HStack>
- {displayName !== sourceLabel ? <MiddleTruncate color="fg.subtle" fontSize="2xs" text={sourceLabel} /> : null}
- {job.status === 'downloading' || job.status === 'waiting' ? <InstallJobProgress job={job} /> : null}
- {job.status === 'error' && job.error ? (
- <Text color="fg.error" fontSize="2xs" overflowWrap="anywhere">
- {job.error_reason ? `${job.error_reason}: ` : ''}
- {job.error}
- </Text>
- ) : null}
- {problemParts.map((part) => {
- const isResume = part.resume_required === true;
- const partUrl = typeof part.url === 'string' ? part.url : undefined;
-
- return (
- <Stack key={part.url ?? part.source ?? partFileName(part)} bg="bg.muted" gap="0.5" p="1.5" rounded="sm">
- <HStack gap="1.5">
- <Icon as={TriangleAlertIcon} boxSize="3" color={isResume ? 'fg.warning' : 'fg.error'} flexShrink={0} />
- <MiddleTruncate flex="1" fontSize="2xs" minW="0" text={partFileName(part)} />
- <Badge
- colorPalette={isResume ? 'orange' : 'red'}
+ {problemParts.map((part) => (
+ <HStack key={part.key} gap="1.5" pt="0.5">
+ <Icon
+ as={TriangleAlertIcon}
+ boxSize="3"
+ color={part.resumeRequired ? 'fg.warning' : 'fg.error'}
flexShrink={0}
- fontSize="2xs"
- size="sm"
- variant="surface"
- >
- {isResume ? t('models.resumeRequired') : t('common.failed')}
- </Badge>
- {partUrl ? (
- <Tooltip content={t('models.restartThisFile')}>
- <IconButton
- aria-label={t('models.restartFile')}
- disabled={isActing}
- size="2xs"
- variant="ghost"
- onClick={() =>
- void runAction(
- (signal) => restartModelInstallFile(job.id, partUrl, signal),
- t('models.restartFileFailed')
- )
- }
- >
- <Icon as={RotateCcwIcon} boxSize="3" />
- </IconButton>
- </Tooltip>
+ />
+ <MiddleTruncate color="fg" fontFamily="mono" fontSize="2xs" minW="0" text={part.fileName} />
+ <Text color="fg.muted" fontSize="2xs" whiteSpace="nowrap">
+ {part.message ?? (part.resumeRequired ? t('models.resumeRequired') : t('common.failed'))}
+ </Text>
+ {part.url ? (
+ <RowAction
+ disabled={actions.isBusy}
+ icon={RotateCcwIcon}
+ label={t('models.restartThisFile')}
+ onClick={() => actions.restartFile(part.url!)}
+ />
) : null}
</HStack>
- {part.resume_message ? (
- <Text color="fg.subtle" fontSize="2xs" overflowWrap="anywhere">
- {part.resume_message}
- </Text>
- ) : null}
- </Stack>
- );
- })}
- </Stack>
+ ))}
+ </Stack>
+ </Table.Cell>
+
+ <Table.Cell {...CELL_PROPS}>
+ <InstallProgressCell progress={progress} queuePosition={queuePosition} status={status} typeLabel={typeLabel} />
+ </Table.Cell>
+
+ <Table.Cell {...CELL_PROPS}>
+ <HStack gap="1.5">
+ <Badge
+ colorPalette={presentation.palette}
+ fontSize="2xs"
+ fontWeight="700"
+ letterSpacing="wider"
+ size="sm"
+ textTransform="uppercase"
+ variant="surface"
+ >
+ {t(presentation.labelKey)}
+ </Badge>
+ {showDisconnected ? (
+ <Tooltip content={t('models.backendDisconnectedProgressStale')}>
+ <Box display="inline-flex">
+ <Icon as={TriangleAlertIcon} boxSize="3" color="fg.warning" />
+ </Box>
+ </Tooltip>
+ ) : null}
+ </HStack>
+ </Table.Cell>
+
+ <Table.Cell {...CELL_PROPS} pe="2">
+ <HStack gap="0.5" justify="flex-end">
+ {status === 'downloading' ? (
+ <RowAction
+ disabled={actions.isBusy}
+ icon={PauseIcon}
+ label={t('models.pauseDownload')}
+ onClick={actions.pause}
+ />
+ ) : null}
+ {status === 'paused' ? (
+ <RowAction
+ disabled={actions.isBusy}
+ icon={canRestartFailedParts(job) ? RotateCcwIcon : PlayIcon}
+ label={canRestartFailedParts(job) ? t('models.retryFailedDownload') : t('models.resumeDownload')}
+ onClick={canRestartFailedParts(job) ? actions.retry : actions.resume}
+ />
+ ) : null}
+ {isSettledRowStatus(status) && status !== 'installed' ? (
+ <RowAction
+ disabled={actions.isBusy}
+ icon={RotateCcwIcon}
+ label={t('models.retryInstall')}
+ onClick={actions.retry}
+ />
+ ) : null}
+ {status === 'installed' && isInLibrary && installedKey !== null ? (
+ <RowAction
+ disabled={false}
+ icon={SquareArrowOutUpRightIcon}
+ label={t('models.openModel')}
+ onClick={() => openModelDetail(installedKey)}
+ />
+ ) : null}
+ {isSettledRowStatus(status) ? (
+ <RowAction disabled={false} icon={XIcon} label={t('models.removeFromList')} onClick={actions.dismiss} />
+ ) : (
+ <RowAction
+ disabled={actions.isBusy}
+ icon={XIcon}
+ label={t('models.cancelInstall')}
+ tone="danger"
+ onClick={actions.cancel}
+ />
+ )}
+ </HStack>
+ </Table.Cell>
+ </Table.Row>
);
};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallProgressCell.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallProgressCell.tsx
new file mode 100644
index 0000000000..564f8070bc
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallProgressCell.tsx
@@ -0,0 +1,135 @@
+import { Progress, Stack, Text } from '@chakra-ui/react';
+import { formatBytes } from '@features/models/core/taxonomy';
+import { useTranslation } from 'react-i18next';
+
+import type { InstallByteProgress, InstallRowStatus } from './queueModel';
+
+import { describeEta } from './queueModel';
+
+const BAR_STATUSES: ReadonlySet<InstallRowStatus> = new Set(['downloading', 'installing', 'queued', 'paused']);
+
+export const formatEta = (t: (key: string, options?: Record<string, unknown>) => string, etaSeconds: number) => {
+ const eta = describeEta(etaSeconds);
+
+ return t(`models.eta.${eta.unit}`, { count: eta.count });
+};
+
+export const InstallProgressBar = ({
+ label,
+ progress,
+ status,
+}: {
+ label: string;
+ progress: InstallByteProgress;
+ status: InstallRowStatus;
+}) => {
+ // Installing has no byte budget: sweep until the backend reports completion.
+ const value = status === 'installing' ? null : status === 'queued' ? 0 : (progress.ratio ?? 0);
+
+ return (
+ <Progress.Root
+ aria-label={label}
+ colorPalette={status === 'paused' ? 'gray' : 'accent'}
+ max={1}
+ minW="0"
+ size="xs"
+ value={value}
+ w="full"
+ >
+ <Progress.Track rounded="full">
+ <Progress.Range rounded="full" transition="width var(--wb-motion-duration-fast) ease" />
+ </Progress.Track>
+ </Progress.Root>
+ );
+};
+
+/** One caption per row status, joined with middle dots so the column reads as a single line. */
+export const useInstallProgressCaption = ({
+ compact = false,
+ progress,
+ queuePosition,
+ status,
+ typeLabel,
+}: {
+ /** Drop the transfer rate so the caption fits a one-line summary bar. */
+ compact?: boolean;
+ progress: InstallByteProgress;
+ queuePosition: number | null;
+ status: InstallRowStatus;
+ typeLabel: string | null;
+}): string => {
+ const { t } = useTranslation();
+ const hasTotal = progress.totalBytes > 0;
+ const doneOfTotal = `${formatBytes(progress.bytes)} / ${formatBytes(progress.totalBytes)}`;
+ const parts: (string | null)[] = [];
+
+ switch (status) {
+ case 'downloading':
+ if (hasTotal) {
+ parts.push(`${Math.round((progress.ratio ?? 0) * 100)}%`, doneOfTotal);
+ } else {
+ parts.push(t('models.statusDownloading'), formatBytes(progress.bytes));
+ }
+
+ parts.push(
+ progress.bytesPerSecond !== null && !compact
+ ? t('models.transferRate', { rate: formatBytes(progress.bytesPerSecond) })
+ : null,
+ progress.etaSeconds !== null ? formatEta(t, progress.etaSeconds) : null
+ );
+ break;
+ case 'installing':
+ parts.push(t('models.installing'), hasTotal ? formatBytes(progress.totalBytes) : null);
+ break;
+ case 'queued':
+ parts.push(
+ t('models.statusWaiting'),
+ queuePosition !== null ? t('models.queuePosition', { position: queuePosition }) : null,
+ hasTotal ? formatBytes(progress.totalBytes) : null
+ );
+ break;
+ case 'paused':
+ parts.push(t('models.statusPaused'), hasTotal ? doneOfTotal : null);
+ break;
+ case 'installed':
+ parts.push(t('common.done'), typeLabel, hasTotal ? formatBytes(progress.totalBytes) : null);
+ break;
+ case 'unauthorized':
+ parts.push(t('models.progressNotStarted'), hasTotal ? formatBytes(progress.totalBytes) : null);
+ break;
+ case 'failed':
+ parts.push(t('models.progressStopped'), t('models.bytesCopied', { bytes: formatBytes(progress.bytes) }));
+ break;
+ case 'cancelled':
+ parts.push(t('models.statusCancelled'), t('models.bytesCopied', { bytes: formatBytes(progress.bytes) }));
+ break;
+ }
+
+ return parts.filter((part): part is string => part !== null && part !== '').join(' · ');
+};
+
+export const InstallProgressCell = ({
+ progress,
+ queuePosition,
+ status,
+ typeLabel,
+}: {
+ progress: InstallByteProgress;
+ queuePosition: number | null;
+ status: InstallRowStatus;
+ typeLabel: string | null;
+}) => {
+ const { t } = useTranslation();
+ const caption = useInstallProgressCaption({ progress, queuePosition, status, typeLabel });
+
+ return (
+ <Stack gap="1" minW="0">
+ {BAR_STATUSES.has(status) ? (
+ <InstallProgressBar label={t('models.downloadProgress')} progress={progress} status={status} />
+ ) : null}
+ <Text color="fg.muted" fontFamily="mono" fontSize="2xs" lineHeight="short" overflowWrap="anywhere">
+ {caption}
+ </Text>
+ </Stack>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.browser.test.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.browser.test.tsx
new file mode 100644
index 0000000000..0e8a513e17
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.browser.test.tsx
@@ -0,0 +1,303 @@
+import type { ModelConfig, ModelInstallJob } from '@features/models/core/types';
+
+import { ChakraProvider } from '@chakra-ui/react';
+import { handleModelInstallSocketEvent } from '@features/models/data/installsStore';
+import { setModelsSnapshotForTests } from '@features/models/data/modelsStore';
+import { getModelsUiSnapshotForTests, updateModelsUi } from '@features/models/ui/uiStore';
+import { auditAccessibility } from '@platform/browser/auditAccessibility.testing';
+import { accountLifecycle } from '@platform/state/accountLifecycle';
+import { setConnectionStatus } from '@platform/transport/connectionStore';
+import { applyThemeToRoot } from '@theme/applyTheme';
+import { DEFAULT_THEME_ID, system } from '@theme/system';
+import { createInstance } from 'i18next';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { I18nextProvider, initReactI18next } from 'react-i18next';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { page } from 'vitest/browser';
+
+import { InstallQueueBar } from './InstallQueueBar';
+
+const api = vi.hoisted(() => ({
+ cancelModelInstall: vi.fn(),
+ installModel: vi.fn(),
+ listModelInstalls: vi.fn(),
+ pauseModelInstall: vi.fn(),
+ pruneCompletedModelInstalls: vi.fn(),
+ restartFailedModelInstall: vi.fn(),
+}));
+
+vi.mock('@features/models/data/api', async (importOriginal) => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ ...api,
+}));
+
+vi.mock('@features/models/ui/useModelsNotify', () => ({
+ useNotify: () => ({ error: vi.fn(), info: vi.fn(), success: vi.fn() }),
+}));
+
+const i18n = createInstance();
+await i18n.use(initReactI18next).init({
+ fallbackNS: 'translation',
+ interpolation: { escapeValue: false },
+ lng: 'en',
+ resources: { en: { translation: await fetch('/locales/en.json').then((response) => response.json()) } },
+});
+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+const JOBS: ModelInstallJob[] = [
+ {
+ bytes: 0,
+ id: 1,
+ source: { repo_id: 'vantagewithai/Krea-2-Turbo-GGUF', subfolder: 'krea2_turbo-Q4_K_M.gguf', type: 'hf' },
+ status: 'downloading',
+ total_bytes: 7_000_000_000,
+ },
+ {
+ id: 2,
+ source: { repo_id: 'unsloth/FLUX.1-Kontext-dev-GGUF', subfolder: 'flux1-kontext-dev-Q4_K_M.gguf', type: 'hf' },
+ status: 'waiting',
+ total_bytes: 6_800_000_000,
+ },
+ {
+ error: 'A model with this path is already installed.',
+ error_reason: 'DuplicateModelException',
+ id: 3,
+ source: { path: '/mnt/models/animosity_krea2Ver10FP8.safetensors', type: 'local' },
+ status: 'error',
+ },
+ {
+ error: 'Unauthorized',
+ error_reason: 'HTTPError',
+ id: 4,
+ source: { repo_id: 'black-forest-labs/FLUX.1-schnell', subfolder: 'ae.safetensors', type: 'hf' },
+ status: 'error',
+ total_bytes: 335_000_000,
+ },
+ {
+ config_out: {
+ base: 'flux',
+ key: 'lora-key',
+ name: 'Elegance_Niji_KR2',
+ type: 'lora',
+ } as ModelInstallJob['config_out'],
+ id: 5,
+ source: { path: '/mnt/models/Lora/Elegance_Niji_KR2.safetensors', type: 'local' },
+ status: 'completed',
+ },
+ {
+ bytes: 12_000_000,
+ id: 6,
+ source: 'https://example.com/old.safetensors',
+ status: 'cancelled',
+ total_bytes: 90_000_000,
+ },
+];
+
+const INSTALLED_LORA = {
+ base: 'flux',
+ key: 'lora-key',
+ name: 'Elegance_Niji_KR2',
+ type: 'lora',
+} as unknown as ModelConfig;
+
+let root: Root | undefined;
+let host: HTMLDivElement | undefined;
+
+const settle = () =>
+ act(async () => {
+ await new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 20);
+ });
+ });
+
+const render = async () => {
+ host = document.createElement('div');
+ host.style.cssText = 'display:flex;flex-direction:column;height:600px;width:1000px';
+ document.body.append(host);
+ root = createRoot(host);
+
+ await act(() => {
+ root?.render(
+ <I18nextProvider i18n={i18n}>
+ <ChakraProvider value={system}>
+ <InstallQueueBar />
+ </ChakraProvider>
+ </I18nextProvider>
+ );
+ });
+ await settle();
+};
+
+const rows = () => [...(host?.querySelectorAll<HTMLTableRowElement>('tbody tr[data-install-status]') ?? [])];
+const rowByStatus = (status: string) => rows().find((row) => row.dataset.installStatus === status);
+const click = (name: string, within: ParentNode | undefined = host) =>
+ act(() => {
+ const button = [...(within?.querySelectorAll<HTMLButtonElement>('button') ?? [])].find(
+ (candidate) => candidate.getAttribute('aria-label') === name || candidate.textContent?.trim() === name
+ );
+
+ if (!button) {
+ throw new Error(`No button named ${name}`);
+ }
+
+ button.click();
+ });
+
+beforeEach(async () => {
+ await page.viewport(1100, 700);
+ applyThemeToRoot(DEFAULT_THEME_ID);
+ accountLifecycle.invalidate();
+ accountLifecycle.activate('tester');
+ setConnectionStatus('connected');
+ setModelsSnapshotForTests({
+ modelsByKey: new Map([['lora-key', INSTALLED_LORA]]),
+ });
+ for (const mock of Object.values(api)) {
+ mock.mockReset();
+ }
+ api.listModelInstalls.mockResolvedValue(JOBS);
+ api.pruneCompletedModelInstalls.mockResolvedValue(undefined);
+ api.cancelModelInstall.mockResolvedValue(undefined);
+ api.pauseModelInstall.mockImplementation((id: number) =>
+ Promise.resolve({ ...JOBS.find((job) => job.id === id)!, status: 'paused' })
+ );
+ api.installModel.mockImplementation(() => {
+ const created: ModelInstallJob = { id: 7, source: 'https://example.com/old.safetensors', status: 'waiting' };
+
+ // The follow-up refresh must see the new job, as the real backend lists it immediately.
+ api.listModelInstalls.mockResolvedValue([...JOBS, created]);
+
+ return Promise.resolve(created);
+ });
+});
+
+afterEach(async () => {
+ await act(() => root?.unmount());
+ host?.remove();
+ root = undefined;
+ host = undefined;
+});
+
+describe('InstallQueueBar', () => {
+ it('renders one row per job with grouped ordering, captions, and status badges', async () => {
+ updateModelsUi({ queueExpanded: true, queueMaximized: false });
+ await render();
+
+ expect(rows().map((row) => row.dataset.installStatus)).toEqual([
+ 'downloading',
+ 'queued',
+ 'unauthorized',
+ 'failed',
+ 'installed',
+ 'cancelled',
+ ]);
+
+ const header = host?.querySelector('[aria-expanded="true"]')?.parentElement;
+ expect(header?.textContent).toContain('1 downloading');
+ expect(header?.textContent).toContain('1 queued');
+ expect(header?.textContent).toContain('2 need attention');
+ expect(header?.textContent).toContain('1 installed');
+
+ expect(rowByStatus('downloading')?.textContent).toContain('krea2_turbo-Q4_K_M.gguf');
+ expect(rowByStatus('downloading')?.textContent).toContain(
+ 'vantagewithai/Krea-2-Turbo-GGUF :: krea2_turbo-Q4_K_M.gguf'
+ );
+ expect(rowByStatus('queued')?.textContent).toContain('Waiting · #1 in queue · 6.3 GB');
+ expect(rowByStatus('failed')?.textContent).toContain('DuplicateModelException');
+ expect(rowByStatus('failed')?.textContent).toContain('A model with this path is already installed.');
+ expect(rowByStatus('failed')?.textContent).toContain('Stopped · 0 B copied');
+ expect(rowByStatus('unauthorized')?.textContent).toContain(
+ 'This repo is gated. Add a Hugging Face token to continue.'
+ );
+ expect(rowByStatus('unauthorized')?.textContent).toContain('Not started · 319.5 MB');
+ expect(rowByStatus('installed')?.textContent).toContain('Done · LoRA');
+ expect(rowByStatus('cancelled')?.textContent).toContain('Cancelled · 11.4 MB copied');
+
+ expect(await auditAccessibility(host!)).toEqual([]);
+ });
+
+ it('reflects live progress with a rate and ETA on the downloading row and the collapsed bar', async () => {
+ updateModelsUi({ queueExpanded: true, queueMaximized: false });
+ await render();
+
+ await act(() => {
+ handleModelInstallSocketEvent('model_install_download_progress', {
+ bytes: 2_660_000_000,
+ id: 1,
+ total_bytes: 7_000_000_000,
+ });
+ });
+ await new Promise<void>((resolve) => {
+ globalThis.setTimeout(resolve, 600);
+ });
+ await act(() => {
+ handleModelInstallSocketEvent('model_install_download_progress', {
+ bytes: 2_690_000_000,
+ id: 1,
+ total_bytes: 7_000_000_000,
+ });
+ });
+ await settle();
+
+ const caption = rowByStatus('downloading')?.textContent ?? '';
+ expect(caption).toContain('38% · 2.5 GB / 6.5 GB');
+ expect(caption).toMatch(/MB\/s · ~\d+ (s|min|h) left/);
+
+ await click('Install Queue');
+ await settle();
+ expect(rows()).toHaveLength(0);
+ const bar = host?.textContent ?? '';
+ expect(bar).toContain('krea2_turbo-Q4_K_M.gguf');
+ expect(bar).toContain('38% · 2.5 GB / 6.5 GB');
+ expect(bar).toContain('+1 queued');
+ expect(bar).toContain('2 need attention');
+
+ await click('Pause download');
+ await settle();
+ expect(api.pauseModelInstall).toHaveBeenCalledWith(1, expect.any(AbortSignal));
+ });
+
+ it('routes the unauthorized fix to the API keys tab and resubmits or dismisses settled jobs', async () => {
+ updateModelsUi({ activeTab: 'add', queueExpanded: true, queueMaximized: false });
+ await render();
+
+ await click('Add token', rowByStatus('unauthorized'));
+ expect(getModelsUiSnapshotForTests().activeTab).toBe('keys');
+
+ await click('Retry install', rowByStatus('cancelled'));
+ await settle();
+ expect(api.installModel).toHaveBeenCalledWith(
+ expect.objectContaining({ source: 'https://example.com/old.safetensors' }),
+ expect.any(AbortSignal)
+ );
+ expect(rowByStatus('cancelled')).toBeUndefined();
+ expect(rows().filter((row) => row.dataset.installStatus === 'queued')).toHaveLength(2);
+
+ await click('Remove from list', rowByStatus('installed'));
+ await settle();
+ expect(rowByStatus('installed')).toBeUndefined();
+ expect(api.pruneCompletedModelInstalls).not.toHaveBeenCalled();
+
+ await click('Clear finished');
+ await settle();
+ expect(api.pruneCompletedModelInstalls).toHaveBeenCalledTimes(1);
+ });
+
+ it('expands to fill the pane and restores', async () => {
+ updateModelsUi({ queueExpanded: true, queueMaximized: false });
+ await render();
+
+ await click('Expand');
+ expect(getModelsUiSnapshotForTests().queueMaximized).toBe(true);
+ await settle();
+ await click('Restore');
+ expect(getModelsUiSnapshotForTests().queueMaximized).toBe(false);
+
+ // Row navigation must uncover the pane it targets.
+ await click('Expand');
+ await settle();
+ await click('Add token', rowByStatus('unauthorized'));
+ expect(getModelsUiSnapshotForTests()).toMatchObject({ activeTab: 'keys', queueMaximized: false });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.tsx
index 315853f21b..7d0df5f1e4 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueBar.tsx
@@ -1,6 +1,6 @@
import type { ModelInstallJob } from '@features/models/core/types';
-import { Badge, Box, Collapsible, Flex, HStack, Icon, Spinner, Text } from '@chakra-ui/react';
+import { Badge, Box, Flex, HStack, Icon, Menu, Portal, Separator, Spinner, Text } from '@chakra-ui/react';
import {
cancelModelInstall,
pauseModelInstall,
@@ -9,72 +9,105 @@ import {
} from '@features/models/data/api';
import {
ensureInstallsLoaded,
- isActiveInstallStatus,
refreshInstalls,
+ useInstallProgress,
useInstallsSelector,
} from '@features/models/data/installsStore';
-import { setQueueExpanded, useModelsUiSelector } from '@features/models/ui/uiStore';
+import { setQueueExpanded, setQueueMaximized, useModelsUiSelector } from '@features/models/ui/uiStore';
import { useNotify } from '@features/models/ui/useModelsNotify';
import { useMountEffect } from '@platform/react/useMountEffect';
import { getErrorMessage, useScopedAction } from '@platform/react/useScopedAction';
import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';
-import { Button, IconButton, Tooltip } from '@platform/ui';
+import { Button, Group, IconButton, Tooltip, useTooltipTriggerIds } from '@platform/ui';
+import { MenuActionItem, MenuContent } from '@platform/ui/Menu';
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
-import { ChevronUpIcon, ListOrderedIcon, PauseIcon, PlayIcon, RefreshCcwIcon, Trash2Icon, XIcon } from 'lucide-react';
-import { useCallback, useMemo } from 'react';
+import {
+ ChevronDownIcon,
+ ChevronUpIcon,
+ Maximize2Icon,
+ Minimize2Icon,
+ PauseIcon,
+ PlayIcon,
+ RefreshCcwIcon,
+ Trash2Icon,
+ TriangleAlertIcon,
+ XIcon,
+} from 'lucide-react';
+import { useCallback, useId, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { InstallQueueList } from './InstallQueueList';
-import { getInstallJobDisplayName } from './queueUtils';
+/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
+import type { InstallQueueRow, InstallQueueSummary } from './queueModel';
+
+import { InstallProgressBar, useInstallProgressCaption } from './InstallProgressCell';
+import { InstallQueueTable } from './InstallQueueTable';
+import {
+ buildInstallQueueRows,
+ countFinishedInstallJobs,
+ getInstallJobDisplayName,
+ isActiveRowStatus,
+ resolveInstallProgress,
+ summarizeInstallQueue,
+} from './queueModel';
+import { useInstallJobActions } from './useInstallJobActions';
-const TRIGGER_HOVER = { color: 'fg' } as const;
-const INDICATOR_OPEN = { transform: 'rotate(180deg)' } as const;
+const DOCKED_HEIGHT = 'min(30rem, 60dvh)';
+const TOGGLE_HOVER = { color: 'fg' } as const;
+const BULK_MENU_POSITIONING = { placement: 'bottom-start' } as const;
-/** Persistent, collapsible install queue footer for the model manager detail pane. */
+/** Install queue docked to the bottom of the detail pane: a summary bar collapsed, a table expanded. */
export const InstallQueueBar = () => {
const { t } = useTranslation();
const notify = useNotify();
+ const contentId = useId();
+ const bulkMenuIds = useTooltipTriggerIds();
const error = useInstallsSelector((snapshot) => snapshot.error);
const jobs = useInstallsSelector((snapshot) => snapshot.jobs);
+ const dismissedJobIds = useInstallsSelector((snapshot) => snapshot.dismissedJobIds);
const status = useInstallsSelector((snapshot) => snapshot.status);
const queueExpanded = useModelsUiSelector((snapshot) => snapshot.queueExpanded);
+ const queueMaximized = useModelsUiSelector((snapshot) => snapshot.queueMaximized);
useMountEffect(() => {
ensureInstallsLoaded();
});
- const activeJobs = useMemo(() => jobs.filter((job) => isActiveInstallStatus(job.status)), [jobs]);
- const pausedJobs = useMemo(() => jobs.filter((job) => job.status === 'paused'), [jobs]);
+ const rows = useMemo(() => buildInstallQueueRows(jobs, dismissedJobIds), [dismissedJobIds, jobs]);
+ const summary = useMemo(() => summarizeInstallQueue(rows), [rows]);
+ const finishedCount = useMemo(() => countFinishedInstallJobs(jobs), [jobs]);
+ const featured = rows[0] && isActiveRowStatus(rows[0].status) ? rows[0] : null;
+ const isMaximized = queueExpanded && queueMaximized;
+
const pausableJobs = useMemo(() => jobs.filter((job) => job.status === 'downloading'), [jobs]);
+ const pausedJobs = useMemo(() => jobs.filter((job) => job.status === 'paused'), [jobs]);
const cancellableJobs = useMemo(
- () => jobs.filter((job) => isActiveInstallStatus(job.status) || job.status === 'paused'),
- [jobs]
- );
- const settledCount = jobs.filter((job) => !isActiveInstallStatus(job.status) && job.status !== 'paused').length;
+ () => rows.filter((row) => isActiveRowStatus(row.status) || row.status === 'queued' || row.status === 'paused'),
+ [rows]
+ ).map((row) => row.job);
- // One busy flag per queue-wide control so each button tracks its own action.
+ // One busy flag per control so each button tracks its own request.
+ const { isBusy: isPruning, run: runPrune } = useScopedAction();
+ const { isBusy: isRefreshing, run: runRefresh } = useScopedAction();
const { isBusy: isPausingAll, run: runPauseAll } = useScopedAction();
const { isBusy: isResumingAll, run: runResumeAll } = useScopedAction();
const { isBusy: isCancellingAll, run: runCancelAll } = useScopedAction();
- const { isBusy: isPruning, run: runPrune } = useScopedAction();
- const { isBusy: isRefreshing, run: runRefresh } = useScopedAction();
const runBulk = useCallback(
(
run: ReturnType<typeof useScopedAction>['run'],
- call: (id: ModelInstallJob['id'], signal: AbortSignal) => Promise<unknown>,
+ call: (id: number, signal: AbortSignal) => Promise<unknown>,
targets: ModelInstallJob[]
) =>
run(
async (owner) => {
- // allSettled: one failed job must not hide the others' outcomes,
- // and the requests that succeeded still deserve a fresh list.
+ // allSettled: one failure must not hide the others' outcomes, and the rest still deserve a fresh list.
const results = await Promise.allSettled(targets.map((job) => call(job.id, owner.signal)));
assertAccountScopeCurrent(owner);
await refreshInstalls(owner);
assertAccountScopeCurrent(owner);
const failures = results.filter((result): result is PromiseRejectedResult => result.status === 'rejected');
+
if (failures.length > 0) {
notify.error(
t('models.queueActionFailed'),
@@ -94,151 +127,292 @@ export const InstallQueueBar = () => {
[notify, t]
);
- const handlePrune = useCallback(
- () =>
- runPrune(
- async (owner) => {
- await pruneCompletedModelInstalls(owner.signal);
- assertAccountScopeCurrent(owner);
- await refreshInstalls(owner);
- assertAccountScopeCurrent(owner);
- },
- (message) => notify.error(t('models.pruneFailed'), message)
- ),
- [notify, runPrune, t]
- );
-
- const handleRefresh = useCallback(() => runRefresh((owner) => refreshInstalls(owner)), [runRefresh]);
- const handleOpenChange = useCallback((event: { open: boolean }) => setQueueExpanded(event.open), []);
- const handlePauseAll = useCallback(
- () => void runBulk(runPauseAll, pauseModelInstall, pausableJobs),
- [pausableJobs, runBulk, runPauseAll]
- );
- const handleResumeAll = useCallback(
- () => void runBulk(runResumeAll, resumeModelInstall, pausedJobs),
- [pausedJobs, runBulk, runResumeAll]
- );
- const handleCancelAll = useCallback(
- () => void runBulk(runCancelAll, cancelModelInstall, cancellableJobs),
- [cancellableJobs, runBulk, runCancelAll]
- );
-
- const summary =
- activeJobs.length > 0
- ? `${getInstallJobDisplayName(activeJobs[0]!)}${activeJobs.length > 1 ? t('common.plusMore', { count: activeJobs.length - 1 }) : ''}`
- : jobs.length > 0
- ? t('models.installJobSummary', { count: jobs.length })
- : t('models.noInstallsYet');
+ const handlePrune = () =>
+ runPrune(
+ async (owner) => {
+ await pruneCompletedModelInstalls(owner.signal);
+ assertAccountScopeCurrent(owner);
+ await refreshInstalls(owner);
+ },
+ (message) => notify.error(t('models.pruneFailed'), message)
+ );
return (
- <Collapsible.Root
+ <Flex
bg="bg.subtle"
borderTopWidth={1}
+ direction="column"
+ flex={isMaximized ? '1' : undefined}
flexShrink={0}
- open={queueExpanded}
- overflow="hidden"
- onOpenChange={handleOpenChange}
+ minH="0"
>
- <Collapsible.Content>
- <Flex direction="column" h="min(22rem, 45dvh)" minH="0" overflow="hidden">
- <HStack borderBottomWidth={1} gap="2" justify="space-between" px="3" py="1.5">
- <Text color="fg.subtle" fontSize="2xs" fontWeight="700" textTransform="uppercase">
- {t('models.installQueue')}
- </Text>
- <HStack gap="1">
- <Button loading={isRefreshing} size="2xs" variant="ghost" onClick={handleRefresh}>
- <Icon as={RefreshCcwIcon} boxSize="3" />
- {t('common.refresh')}
- </Button>
- <Button
- disabled={settledCount === 0}
- loading={isPruning}
- size="2xs"
- variant="ghost"
- onClick={handlePrune}
- >
- <Icon as={Trash2Icon} boxSize="3" />
- {t('models.clearFinished')}
+ <HStack flexWrap="wrap" gap="2" minH="2.5rem" px="3" py="1">
+ <Button
+ aria-controls={contentId}
+ aria-expanded={queueExpanded}
+ color="fg.muted"
+ flexShrink={0}
+ gap="1.5"
+ ms="-2"
+ ps="2"
+ pe="3"
+ size="xs"
+ variant="ghost"
+ _hover={TOGGLE_HOVER}
+ onClick={() => setQueueExpanded(!queueExpanded)}
+ >
+ <Icon as={queueExpanded ? ChevronDownIcon : ChevronUpIcon} boxSize="3.5" />
+ <Text color="fg" fontSize="xs" fontWeight="700">
+ {t('models.installQueue')}
+ </Text>
+ </Button>
+
+ {queueExpanded ? (
+ <SummaryChips summary={summary} />
+ ) : (
+ <CollapsedSummary featured={featured} jobCount={rows.length} summary={summary} />
+ )}
+
+ {queueExpanded ? (
+ <HStack flexShrink={0} gap="1">
+ {pausableJobs.length + pausedJobs.length + cancellableJobs.length > 0 ? (
+ <Group attached>
+ {pausedJobs.length > 0 ? (
+ <Button
+ loading={isResumingAll}
+ size="2xs"
+ variant="ghost"
+ onClick={() => void runBulk(runResumeAll, resumeModelInstall, pausedJobs)}
+ >
+ <Icon as={PlayIcon} boxSize="3" />
+ {t('models.resumeAll')}
+ </Button>
+ ) : (
+ <Button
+ disabled={pausableJobs.length === 0}
+ loading={isPausingAll}
+ size="2xs"
+ variant="ghost"
+ onClick={() => void runBulk(runPauseAll, pauseModelInstall, pausableJobs)}
+ >
+ <Icon as={PauseIcon} boxSize="3" />
+ {t('models.pauseAll')}
+ </Button>
+ )}
+ <Menu.Root ids={bulkMenuIds} positioning={BULK_MENU_POSITIONING}>
+ <Tooltip content={t('models.moreQueueActions')} ids={bulkMenuIds}>
+ <Menu.Trigger asChild>
+ <IconButton aria-label={t('models.moreQueueActions')} size="2xs" variant="ghost">
+ <Icon as={ChevronDownIcon} boxSize="3" />
+ </IconButton>
+ </Menu.Trigger>
+ </Tooltip>
+ <Portal>
+ <Menu.Positioner>
+ <MenuContent minW="10rem">
+ <MenuActionItem
+ disabled={cancellableJobs.length === 0 || isCancellingAll}
+ icon={XIcon}
+ label={t('models.cancelAll')}
+ tone="danger"
+ value="cancel-all"
+ onSelect={() => void runBulk(runCancelAll, cancelModelInstall, cancellableJobs)}
+ />
+ </MenuContent>
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
+ </Group>
+ ) : null}
+ {pausableJobs.length + pausedJobs.length + cancellableJobs.length > 0 ? (
+ <Separator h="4" mx="1" orientation="vertical" />
+ ) : null}
+ <Button loading={isRefreshing} size="2xs" variant="ghost" onClick={() => runRefresh(refreshInstalls)}>
+ <Icon as={RefreshCcwIcon} boxSize="3" />
+ {t('common.refresh')}
+ </Button>
+ <Button disabled={finishedCount === 0} loading={isPruning} size="2xs" variant="ghost" onClick={handlePrune}>
+ <Icon as={Trash2Icon} boxSize="3" />
+ {t('models.clearFinished')}
+ </Button>
+ <Tooltip content={queueMaximized ? t('models.restoreQueueTooltip') : t('models.maximizeQueueTooltip')}>
+ <Button size="2xs" variant="ghost" onClick={() => setQueueMaximized(!queueMaximized)}>
+ <Icon as={queueMaximized ? Minimize2Icon : Maximize2Icon} boxSize="3" />
+ {queueMaximized ? t('models.restoreQueue') : t('models.maximizeQueue')}
</Button>
- </HStack>
+ </Tooltip>
+ </HStack>
+ ) : (
+ <HStack flexShrink={0} gap="0.5">
+ {featured ? <FeaturedActions row={featured} /> : null}
+ {featured && finishedCount > 0 ? <Separator h="4" mx="1" orientation="vertical" /> : null}
+ {finishedCount > 0 ? (
+ <Tooltip content={t('models.clearFinished')}>
+ <IconButton
+ aria-label={t('models.clearFinished')}
+ loading={isPruning}
+ size="2xs"
+ variant="ghost"
+ onClick={handlePrune}
+ >
+ <Icon as={Trash2Icon} boxSize="3.5" />
+ </IconButton>
+ </Tooltip>
+ ) : null}
</HStack>
- <Box flex="1" minH="0" overflow="hidden" p="2">
- <InstallQueueList error={error} jobs={jobs} status={status} />
- </Box>
- </Flex>
- </Collapsible.Content>
-
- <HStack gap="1" px="3" py="2">
- <Collapsible.Trigger
- alignItems="center"
- bg="transparent"
- color="inherit"
- display="flex"
- flex="1"
- gap="2"
- minW="0"
- textAlign="start"
- _hover={TRIGGER_HOVER}
+ )}
+ </HStack>
+
+ {queueExpanded ? (
+ <Box
+ borderTopWidth={1}
+ flex={isMaximized ? '1' : undefined}
+ h={isMaximized ? undefined : DOCKED_HEIGHT}
+ id={contentId}
+ minH="0"
>
- {activeJobs.length > 0 ? (
- <Spinner borderWidth="1.5px" boxSize="3.5" color="accent.solid" flexShrink={0} />
- ) : (
- <Icon as={ListOrderedIcon} boxSize="3.5" color="fg.subtle" flexShrink={0} />
- )}
- <MiddleTruncate flex="1" fontSize="xs" fontWeight="600" minW="0" text={summary} />
-
- {activeJobs.length > 0 ? (
- <Badge colorPalette="accent" flexShrink={0} fontSize="2xs" size="sm" variant="solid">
- {activeJobs.length}
- </Badge>
- ) : null}
- <Collapsible.Indicator _open={INDICATOR_OPEN} transition="transform var(--wb-motion-duration-slow)">
- <Icon as={ChevronUpIcon} boxSize="4" color="fg.subtle" flexShrink={0} />
- </Collapsible.Indicator>
- </Collapsible.Trigger>
-
- <HStack flexShrink={0} gap="0.5">
- {pausableJobs.length > 0 ? (
- <Tooltip content={t('models.pauseAllDownloads')}>
- <IconButton
- aria-label={t('models.pauseAllInstalls')}
- loading={isPausingAll}
- size="2xs"
- variant="ghost"
- onClick={handlePauseAll}
- >
- <Icon as={PauseIcon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- ) : null}
- {pausedJobs.length > 0 ? (
- <Tooltip content={t('models.resumeAllPausedDownloads')}>
- <IconButton
- aria-label={t('models.resumeAllInstalls')}
- loading={isResumingAll}
- size="2xs"
- variant="ghost"
- onClick={handleResumeAll}
- >
- <Icon as={PlayIcon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- ) : null}
- {cancellableJobs.length > 0 ? (
- <Tooltip content={t('models.cancelAllInstalls')}>
- <IconButton
- aria-label={t('models.cancelAllInstalls')}
- loading={isCancellingAll}
- size="2xs"
- variant="ghost"
- onClick={handleCancelAll}
- >
- <Icon as={XIcon} boxSize="3.5" />
- </IconButton>
- </Tooltip>
- ) : null}
- </HStack>
+ <InstallQueueTable error={error} rows={rows} status={status} />
+ </Box>
+ ) : null}
+ </Flex>
+ );
+};
+
+const CountChip = ({
+ count,
+ labelKey,
+ palette,
+ icon,
+}: {
+ count: number;
+ labelKey: string;
+ palette: string;
+ icon?: 'dot' | 'alert';
+}) => {
+ const { t } = useTranslation();
+
+ if (count === 0) {
+ return null;
+ }
+
+ return (
+ <Badge colorPalette={palette} flexShrink={0} fontSize="2xs" gap="1.5" rounded="full" size="sm" variant="surface">
+ {icon === 'dot' ? <Box bg="colorPalette.solid" boxSize="1.5" rounded="full" /> : null}
+ {icon === 'alert' ? <Icon as={TriangleAlertIcon} boxSize="3" /> : null}
+ {t(labelKey, { count })}
+ </Badge>
+ );
+};
+
+// A real basis lets the header actions wrap beneath the chips instead of starving them in narrow panes.
+const SummaryChips = ({ summary }: { summary: InstallQueueSummary }) => (
+ <HStack flex="1 1 18rem" flexWrap="wrap" gap="1" minW="0">
+ <CountChip count={summary.downloading} icon="dot" labelKey="models.queueDownloadingCount" palette="accent" />
+ <CountChip count={summary.installing} icon="dot" labelKey="models.queueInstallingCount" palette="accent" />
+ <CountChip count={summary.queued} labelKey="models.queueQueuedCount" palette="gray" />
+ <CountChip count={summary.paused} labelKey="models.queuePausedCount" palette="gray" />
+ <CountChip count={summary.attention} icon="alert" labelKey="models.queueAttentionCount" palette="red" />
+ <CountChip count={summary.installed} labelKey="models.queueInstalledCount" palette="green" />
+ </HStack>
+);
+
+const CollapsedSummary = ({
+ featured,
+ jobCount,
+ summary,
+}: {
+ featured: InstallQueueRow | null;
+ jobCount: number;
+ summary: InstallQueueSummary;
+}) => {
+ const { t } = useTranslation();
+
+ // Chips wrap under the featured job before anything overlaps in a narrow pane.
+ return (
+ <HStack flex="1 1 16rem" flexWrap="wrap" gap="2" minW="0">
+ {featured ? (
+ <FeaturedJob row={featured} />
+ ) : (
+ <Text color="fg.muted" flex="1 1 10rem" fontSize="xs" minW="0" truncate>
+ {summary.paused > 0
+ ? t('models.queuePausedCount', { count: summary.paused })
+ : jobCount > 0
+ ? t('models.installJobSummary', { count: jobCount })
+ : t('models.noInstallsYet')}
+ </Text>
+ )}
+ <HStack flexShrink={0} gap="1">
+ <CountChip count={summary.queued} labelKey="models.queueMoreQueued" palette="gray" />
+ <CountChip count={summary.attention} icon="alert" labelKey="models.queueAttentionCount" palette="red" />
</HStack>
- </Collapsible.Root>
+ </HStack>
+ );
+};
+
+const FeaturedJob = ({ row }: { row: InstallQueueRow }) => {
+ const { t } = useTranslation();
+ const liveProgress = useInstallProgress(row.job.id);
+ const progress = resolveInstallProgress(row.job, liveProgress);
+ const caption = useInstallProgressCaption({
+ compact: true,
+ progress,
+ queuePosition: null,
+ status: row.status,
+ typeLabel: null,
+ });
+
+ return (
+ <HStack flex="1 1 14rem" gap="2" minW="0" overflow="hidden">
+ <Spinner borderWidth="1.5px" boxSize="3.5" color="accent.solid" flexShrink={0} />
+ <MiddleTruncate
+ flexShrink={1}
+ fontSize="xs"
+ fontWeight="600"
+ maxW="18rem"
+ minW="5rem"
+ text={getInstallJobDisplayName(row.job)}
+ />
+ <Box flexShrink={1} maxW="10rem" minW="3rem" w="full">
+ <InstallProgressBar label={t('models.downloadProgress')} progress={progress} status={row.status} />
+ </Box>
+ <Text color="fg.muted" flexShrink={3} fontFamily="mono" fontSize="2xs" minW="0" truncate>
+ {caption}
+ </Text>
+ </HStack>
+ );
+};
+
+const FeaturedActions = ({ row }: { row: InstallQueueRow }) => {
+ const { t } = useTranslation();
+ const actions = useInstallJobActions(row.job);
+
+ return (
+ <>
+ {row.status === 'downloading' ? (
+ <Tooltip content={t('models.pauseDownload')}>
+ <IconButton
+ aria-label={t('models.pauseDownload')}
+ disabled={actions.isBusy}
+ size="2xs"
+ variant="ghost"
+ onClick={actions.pause}
+ >
+ <Icon as={PauseIcon} boxSize="3.5" />
+ </IconButton>
+ </Tooltip>
+ ) : null}
+ <Tooltip content={t('models.cancelInstall')}>
+ <IconButton
+ aria-label={t('models.cancelInstall')}
+ colorPalette="danger"
+ disabled={actions.isBusy}
+ size="2xs"
+ variant="ghost"
+ onClick={actions.cancel}
+ >
+ <Icon as={XIcon} boxSize="3.5" />
+ </IconButton>
+ </Tooltip>
+ </>
);
};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueList.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueList.tsx
deleted file mode 100644
index e9f79b5efb..0000000000
--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueList.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-array-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
-import type { ModelInstallJob } from '@features/models/core/types';
-
-import { Flex, Spinner, Stack, Text } from '@chakra-ui/react';
-import { refreshInstalls } from '@features/models/data/installsStore';
-import { useNotify } from '@features/models/ui/useModelsNotify';
-import { Button, Scrollable } from '@platform/ui';
-import { useTranslation } from 'react-i18next';
-
-import { InstallJobRow } from './InstallJobRow';
-
-export const InstallQueueList = ({
- error,
- jobs,
- status,
-}: {
- error: string | null;
- jobs: ModelInstallJob[];
- status: 'idle' | 'loading' | 'loaded' | 'error';
-}) => {
- const { t } = useTranslation();
- const notify = useNotify();
-
- if (status === 'loading' || status === 'idle') {
- return (
- <Flex align="center" justify="center" py="6">
- <Spinner color="fg.subtle" size="sm" />
- </Flex>
- );
- }
-
- if (status === 'error') {
- return (
- <Stack align="center" gap="1" py="6">
- <Text color="fg.error" fontSize="xs" fontWeight="600">
- {t('models.couldNotLoadInstallQueue')}
- </Text>
- <Text color="fg.subtle" fontSize="2xs">
- {error}
- </Text>
- <Button mt="1" size="xs" variant="outline" onClick={() => void refreshInstalls()}>
- {t('common.retry')}
- </Button>
- </Stack>
- );
- }
-
- if (jobs.length === 0) {
- return (
- <Stack align="center" gap="1" py="6">
- <Text color="fg.muted" fontSize="xs" fontWeight="600">
- {t('models.noInstallsYet')}
- </Text>
- <Text color="fg.subtle" fontSize="2xs">
- {t('models.noInstallsDescription')}
- </Text>
- </Stack>
- );
- }
-
- return (
- <Scrollable h="full" label={t('models.installJobs')} minH="0">
- <Stack gap="1.5">
- {jobs.map((job) => (
- <InstallJobRow key={job.id} job={job} onError={notify.error} />
- ))}
- </Stack>
- </Scrollable>
- );
-};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueTable.tsx b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueTable.tsx
new file mode 100644
index 0000000000..5b71973aaa
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/InstallQueueTable.tsx
@@ -0,0 +1,104 @@
+import type { SystemStyleObject } from '@chakra-ui/react';
+
+import { Flex, Icon, Spinner, Table, VisuallyHidden } from '@chakra-ui/react';
+import { refreshInstalls } from '@features/models/data/installsStore';
+import { Button, Scrollable } from '@platform/ui';
+import { EmptyState } from '@platform/ui/EmptyState';
+import { DownloadIcon } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+/* eslint-disable react-perf/jsx-no-jsx-as-prop, react-perf/jsx-no-new-array-as-prop, react-perf/jsx-no-new-function-as-prop, react-perf/jsx-no-new-object-as-prop */
+import type { InstallQueueRow } from './queueModel';
+
+import { InstallJobRow } from './InstallJobRow';
+
+const TABLE_SX: SystemStyleObject = {
+ '& th': { bg: 'bg.subtle', position: 'sticky', top: 0, zIndex: 1 },
+ '& tr[data-tone="error"] > td': { bg: 'bg.error' },
+ '& tr[data-tone="error"] > td:first-of-type': { boxShadow: 'inset 2px 0 0 {colors.border.error}' },
+ '& tr[data-tone="warning"] > td': { bg: 'bg.warning' },
+ '& tr[data-tone="warning"] > td:first-of-type': { boxShadow: 'inset 2px 0 0 {colors.fg.warning}' },
+};
+
+const HEADER_PROPS = {
+ borderColor: 'border.subtle',
+ color: 'fg.muted',
+ fontSize: '2xs',
+ fontWeight: '700',
+ letterSpacing: 'wider',
+ py: '1.5',
+ textTransform: 'uppercase',
+} as const;
+
+export const InstallQueueTable = ({
+ error,
+ rows,
+ status,
+}: {
+ error: string | null;
+ rows: InstallQueueRow[];
+ status: 'idle' | 'loading' | 'loaded' | 'error';
+}) => {
+ const { t } = useTranslation();
+
+ if (status === 'loading' || status === 'idle') {
+ return (
+ <Flex align="center" h="full" justify="center" py="6">
+ <Spinner color="fg.muted" size="sm" />
+ </Flex>
+ );
+ }
+
+ if (status === 'error') {
+ return (
+ <EmptyState danger description={error ?? undefined} h="full" title={t('models.couldNotLoadInstallQueue')}>
+ <Button size="xs" variant="outline" onClick={() => void refreshInstalls()}>
+ {t('common.retry')}
+ </Button>
+ </EmptyState>
+ );
+ }
+
+ if (rows.length === 0) {
+ return (
+ <EmptyState
+ description={t('models.noInstallsDescription')}
+ h="full"
+ icon={<Icon as={DownloadIcon} />}
+ title={t('models.noInstallsYet')}
+ />
+ );
+ }
+
+ return (
+ <Scrollable h="full" label={t('models.installJobs')} minH="0">
+ <Table.Root css={TABLE_SX} minW="32rem" size="sm" tableLayout="fixed" w="full">
+ <Table.ColumnGroup>
+ <Table.Column w="2.25rem" />
+ <Table.Column />
+ <Table.Column w="30%" />
+ <Table.Column w="7.75rem" />
+ <Table.Column w="4.5rem" />
+ </Table.ColumnGroup>
+ <Table.Header>
+ <Table.Row>
+ <Table.ColumnHeader {...HEADER_PROPS} ps="3">
+ <VisuallyHidden>{t('models.queueColumns.state')}</VisuallyHidden>
+ </Table.ColumnHeader>
+ <Table.ColumnHeader {...HEADER_PROPS}>{t('models.queueColumns.name')}</Table.ColumnHeader>
+ <Table.ColumnHeader {...HEADER_PROPS}>{t('models.queueColumns.progress')}</Table.ColumnHeader>
+ <Table.ColumnHeader {...HEADER_PROPS}>{t('models.queueColumns.status')}</Table.ColumnHeader>
+ <Table.ColumnHeader {...HEADER_PROPS} pe="2" textAlign="end">
+ {t('models.queueColumns.actions')}
+ </Table.ColumnHeader>
+ </Table.Row>
+ </Table.Header>
+ <Table.Body>
+ {rows.map((row) => (
+ <InstallJobRow key={row.job.id} row={row} />
+ ))}
+ </Table.Body>
+ </Table.Root>
+ </Scrollable>
+ );
+};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.test.ts b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.test.ts
new file mode 100644
index 0000000000..132171648e
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.test.ts
@@ -0,0 +1,201 @@
+import type { ModelInstallJob } from '@features/models/core/types';
+
+import { describe, expect, it } from 'vitest';
+
+import {
+ buildInstallQueueRows,
+ canRestartFailedParts,
+ describeEta,
+ getInstallJobDisplayName,
+ getInstallJobSourceLabel,
+ getInstallJobSourceString,
+ getInstallRowStatus,
+ getProblemDownloadParts,
+ resolveInstallProgress,
+ summarizeInstallQueue,
+} from './queueModel';
+
+const job = (overrides: Partial<ModelInstallJob> & { id: number }): ModelInstallJob => ({
+ source: `https://example/${overrides.id}.safetensors`,
+ status: 'waiting',
+ ...overrides,
+});
+
+describe('install row status', () => {
+ it('folds backend statuses into row statuses', () => {
+ expect(getInstallRowStatus(job({ id: 1, status: 'downloads_done' }))).toBe('installing');
+ expect(getInstallRowStatus(job({ id: 1, status: 'running' }))).toBe('installing');
+ expect(getInstallRowStatus(job({ id: 1, status: 'waiting' }))).toBe('queued');
+ expect(getInstallRowStatus(job({ id: 1, status: 'completed' }))).toBe('installed');
+ });
+
+ it('recognises credential failures from the reason, message, or traceback', () => {
+ expect(
+ getInstallRowStatus(job({ error: 'boom', error_reason: 'DuplicateModelException', id: 1, status: 'error' }))
+ ).toBe('failed');
+ expect(getInstallRowStatus(job({ error: 'Unauthorized', error_reason: 'HTTPError', id: 1, status: 'error' }))).toBe(
+ 'unauthorized'
+ );
+ expect(
+ getInstallRowStatus(
+ job({
+ error: "'org/repo' not found. See trace for details.",
+ error_reason: 'UnknownMetadataException',
+ error_traceback: 'huggingface_hub.errors.GatedRepoError: 401 Client Error',
+ id: 1,
+ status: 'error',
+ })
+ )
+ ).toBe('unauthorized');
+ // Path segments and file names must not read as credential failures.
+ expect(
+ getInstallRowStatus(job({ error: 'No such file: /models/gated/model-401.safetensors', id: 1, status: 'error' }))
+ ).toBe('failed');
+ });
+});
+
+describe('problem download parts', () => {
+ const parts = [
+ {
+ bytes: 10,
+ resume_message: 'Resume refused by server.',
+ resume_required: true,
+ source: 'https://x/a.bin',
+ status: 'paused',
+ total_bytes: 100,
+ },
+ { bytes: 0, source: 'https://x/b.bin', status: 'error', total_bytes: 100 },
+ { bytes: 100, source: 'https://x/c.bin', status: 'completed', total_bytes: 100 },
+ ];
+
+ it('surfaces resume-required and errored parts with their restartable source URL', () => {
+ expect(getProblemDownloadParts(job({ download_parts: parts, id: 1, status: 'paused' }))).toEqual([
+ {
+ fileName: 'a.bin',
+ key: 'https://x/a.bin',
+ message: 'Resume refused by server.',
+ resumeRequired: true,
+ url: 'https://x/a.bin',
+ },
+ { fileName: 'b.bin', key: 'https://x/b.bin', message: null, resumeRequired: false, url: 'https://x/b.bin' },
+ ]);
+ });
+
+ it('only offers a part restart for live jobs', () => {
+ expect(canRestartFailedParts(job({ download_parts: parts, id: 1, status: 'error' }))).toBe(true);
+ expect(canRestartFailedParts(job({ download_parts: parts, id: 1, status: 'cancelled' }))).toBe(false);
+ expect(canRestartFailedParts(job({ id: 1, status: 'error' }))).toBe(false);
+ });
+});
+
+describe('install job labels', () => {
+ it('names hf subfolder installs by file and labels them by repo', () => {
+ const hf = job({
+ id: 1,
+ source: { repo_id: 'InvokeAI/flux_dev', subfolder: 'transformer/base/flux1-dev.safetensors', type: 'hf' },
+ });
+
+ expect(getInstallJobDisplayName(hf)).toBe('flux1-dev.safetensors');
+ expect(getInstallJobSourceLabel(hf)).toBe('InvokeAI/flux_dev :: transformer/base/flux1-dev.safetensors');
+ });
+
+ it('prefers the configured name and falls back to the last path segment', () => {
+ expect(getInstallJobDisplayName(job({ config_in: { name: 'Elegance' }, id: 1 }))).toBe('Elegance');
+ expect(
+ getInstallJobDisplayName(job({ id: 1, source: { path: '/mnt/models/lora/a.safetensors', type: 'local' } }))
+ ).toBe('a.safetensors');
+ });
+
+ it('rebuilds the install endpoint source string for resubmission', () => {
+ expect(
+ getInstallJobSourceString(
+ job({ id: 1, source: { repo_id: 'org/repo', subfolder: 'vae', type: 'hf', variant: 'fp16' } })
+ )
+ ).toBe('org/repo:fp16::vae');
+ expect(
+ getInstallJobSourceString(
+ job({ id: 1, source: { provider_id: 'civitai', provider_model_id: '42', type: 'external' } })
+ )
+ ).toBe('external://civitai/42');
+ expect(getInstallJobSourceString(job({ id: 1, source: { type: 'url', url: 'https://x/y.gguf' } }))).toBe(
+ 'https://x/y.gguf'
+ );
+ });
+});
+
+describe('install queue rows', () => {
+ const jobs = [
+ job({ id: 1, status: 'completed' }),
+ job({ id: 2, status: 'waiting' }),
+ job({ id: 3, status: 'downloading' }),
+ job({ error: 'Unauthorized', error_reason: 'HTTPError', id: 4, status: 'error' }),
+ job({ id: 5, status: 'waiting' }),
+ job({ id: 6, status: 'cancelled' }),
+ job({ id: 7, status: 'paused' }),
+ job({ id: 8, status: 'running' }),
+ ];
+
+ it('orders downloads, installs, queued in run order, paused, attention, installed, then cancelled', () => {
+ const rows = buildInstallQueueRows(jobs, new Set());
+
+ expect(rows.map((row) => row.job.id)).toEqual([3, 8, 2, 5, 7, 4, 1, 6]);
+ expect(rows.find((row) => row.job.id === 5)?.queuePosition).toBe(2);
+ expect(rows.find((row) => row.job.id === 3)?.queuePosition).toBeNull();
+ });
+
+ it('hides dismissed jobs and summarises the rest', () => {
+ const rows = buildInstallQueueRows(jobs, new Set([6]));
+
+ expect(rows.some((row) => row.job.id === 6)).toBe(false);
+ expect(summarizeInstallQueue(rows)).toEqual({
+ attention: 1,
+ downloading: 1,
+ installed: 1,
+ installing: 1,
+ paused: 1,
+ queued: 2,
+ settled: 2,
+ });
+ });
+});
+
+describe('install progress', () => {
+ it('prefers live bytes and derives an ETA from the smoothed rate', () => {
+ const progress = resolveInstallProgress(job({ bytes: 10, id: 1, total_bytes: 100 }), {
+ bytes: 40_000_000,
+ bytesPerSecond: 20_000_000,
+ totalBytes: 100_000_000,
+ });
+
+ expect(progress).toEqual({
+ bytes: 40_000_000,
+ bytesPerSecond: 20_000_000,
+ etaSeconds: 3,
+ ratio: 0.4,
+ totalBytes: 100_000_000,
+ });
+ });
+
+ it('falls back to the REST snapshot without a rate', () => {
+ expect(resolveInstallProgress(job({ bytes: 50, id: 1, total_bytes: 200 }), null)).toEqual({
+ bytes: 50,
+ bytesPerSecond: null,
+ etaSeconds: null,
+ ratio: 0.25,
+ totalBytes: 200,
+ });
+ expect(resolveInstallProgress(job({ id: 1 }), null).ratio).toBeNull();
+ });
+
+ it('withholds the ETA while the rate is below the floor', () => {
+ const progress = resolveInstallProgress(job({ id: 1 }), { bytes: 10, bytesPerSecond: 12, totalBytes: 10_000_000 });
+
+ expect(progress.etaSeconds).toBeNull();
+ });
+
+ it('buckets ETAs coarsely', () => {
+ expect(describeEta(3)).toEqual({ count: 5, unit: 'seconds' });
+ expect(describeEta(61)).toEqual({ count: 2, unit: 'minutes' });
+ expect(describeEta(7200)).toEqual({ count: 2, unit: 'hours' });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.ts b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.ts
new file mode 100644
index 0000000000..427ae595dd
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueModel.ts
@@ -0,0 +1,293 @@
+import type { ModelInstallJob } from '@features/models/core/types';
+
+import { getInstallSourceLabel, type InstallDownloadProgress } from '@features/models/data/installsStore';
+
+/** Row-level status: backend statuses folded into what the queue shows and offers actions for. */
+export type InstallRowStatus =
+ | 'downloading'
+ | 'installing'
+ | 'queued'
+ | 'paused'
+ | 'installed'
+ | 'failed'
+ | 'unauthorized'
+ | 'cancelled';
+
+export const STATUS_PRESENTATION: Record<InstallRowStatus, { labelKey: string; palette: string }> = {
+ cancelled: { labelKey: 'models.statusCancelled', palette: 'gray' },
+ downloading: { labelKey: 'models.statusDownloading', palette: 'blue' },
+ failed: { labelKey: 'common.failed', palette: 'red' },
+ installed: { labelKey: 'models.installed', palette: 'green' },
+ installing: { labelKey: 'models.installing', palette: 'blue' },
+ paused: { labelKey: 'models.statusPaused', palette: 'gray' },
+ queued: { labelKey: 'models.statusQueued', palette: 'gray' },
+ unauthorized: { labelKey: 'models.statusUnauthorized', palette: 'orange' },
+};
+
+const UNAUTHORIZED_REASONS = new Set(['GatedRepoError', 'HfHubHTTPError', 'UnauthorizedError']);
+// HTTPError reasons are bare phrases ("Unauthorized"); HF client errors carry the status code.
+const UNAUTHORIZED_TEXT = /^(unauthorized|forbidden)\b|\b40[13] client error\b|\bgated repo\b/i;
+
+/** Credential failures are fixable from the queue; the backend only reports them as generic errors. */
+export const isUnauthorizedFailure = (job: ModelInstallJob): boolean =>
+ UNAUTHORIZED_REASONS.has(job.error_reason ?? '') ||
+ UNAUTHORIZED_TEXT.test(job.error ?? '') ||
+ (job.error_traceback ?? '').includes('GatedRepoError');
+
+export const getInstallRowStatus = (job: ModelInstallJob): InstallRowStatus => {
+ switch (job.status) {
+ case 'downloading':
+ return 'downloading';
+ case 'downloads_done':
+ case 'running':
+ return 'installing';
+ case 'paused':
+ return 'paused';
+ case 'completed':
+ return 'installed';
+ case 'cancelled':
+ return 'cancelled';
+ case 'error':
+ return isUnauthorizedFailure(job) ? 'unauthorized' : 'failed';
+ default:
+ return 'queued';
+ }
+};
+
+export const isActiveRowStatus = (status: InstallRowStatus): status is 'downloading' | 'installing' =>
+ status === 'downloading' || status === 'installing';
+
+export const isSettledRowStatus = (status: InstallRowStatus): boolean =>
+ status === 'installed' || status === 'failed' || status === 'unauthorized' || status === 'cancelled';
+
+export const isHuggingFaceSource = (job: ModelInstallJob): boolean =>
+ typeof job.source === 'object' && job.source.type === 'hf';
+
+/** The `source` string the install endpoint accepts, so a settled job can be resubmitted as-is. */
+export const getInstallJobSourceString = (job: ModelInstallJob): string => {
+ const { source } = job;
+
+ if (typeof source === 'string') {
+ return source;
+ }
+
+ switch (source.type) {
+ case 'hf':
+ return `${source.repo_id ?? ''}${source.variant ? `:${source.variant}` : ''}${
+ source.subfolder ? `::${source.subfolder}` : ''
+ }`;
+ case 'external':
+ return `external://${source.provider_id ?? ''}/${source.provider_model_id ?? ''}`;
+ default:
+ return getInstallSourceLabel(source);
+ }
+};
+
+const lastSegment = (value: string): string => value.split(/[\\/]/).filter(Boolean).at(-1) ?? value;
+
+/** Where the model comes from: repo id (with subfolder), URL, or path. */
+export const getInstallJobSourceLabel = (job: ModelInstallJob): string => {
+ const { source } = job;
+
+ if (typeof source === 'object' && source.type === 'hf' && source.repo_id && source.subfolder) {
+ return `${source.repo_id} :: ${source.subfolder}`;
+ }
+
+ return getInstallSourceLabel(source);
+};
+
+/** Configured name first, then the file or folder the source points at. */
+export const getInstallJobDisplayName = (job: ModelInstallJob): string => {
+ const configured = job.config_out?.name ?? job.config_in?.name;
+
+ if (configured) {
+ return configured;
+ }
+
+ const { source } = job;
+
+ if (typeof source === 'object' && source.type === 'hf') {
+ return source.subfolder ? lastSegment(source.subfolder) : (source.repo_id ?? getInstallSourceLabel(source));
+ }
+
+ return lastSegment(getInstallSourceLabel(source));
+};
+
+const partFileName = (part: { source?: string; local_path?: string }): string =>
+ lastSegment(part.source ?? part.local_path ?? 'file');
+
+export interface ProblemDownloadPart {
+ key: string;
+ fileName: string;
+ /** The part's download URL, which `restart_file` matches against; null for parts without one. */
+ url: string | null;
+ resumeRequired: boolean;
+ message: string | null;
+}
+
+/** Parts the backend could not resume or that errored; each needs a manual restart. */
+export const getProblemDownloadParts = (job: ModelInstallJob): ProblemDownloadPart[] =>
+ (job.download_parts ?? [])
+ .filter((part) => part.resume_required === true || part.status === 'error')
+ .map((part) => ({
+ fileName: partFileName(part),
+ key: part.source ?? part.local_path ?? partFileName(part),
+ message: part.resume_message ?? null,
+ resumeRequired: part.resume_required === true,
+ url: typeof part.source === 'string' ? part.source : null,
+ }));
+
+/**
+ * `restart_failed` only acts on errored or paused jobs with restartable parts; a cancelled job's temp dir is gone,
+ * so it and anything else must be resubmitted.
+ */
+export const canRestartFailedParts = (job: ModelInstallJob): boolean =>
+ job.status !== 'cancelled' && getProblemDownloadParts(job).length > 0;
+
+/** A one-off token saved with the source wins over the stored provider key. */
+export const getInstallJobAccessToken = (job: ModelInstallJob): string | undefined =>
+ typeof job.source === 'object' && typeof job.source.access_token === 'string' && job.source.access_token
+ ? job.source.access_token
+ : undefined;
+
+export interface InstallQueueRow {
+ job: ModelInstallJob;
+ status: InstallRowStatus;
+ /** 1-based position among waiting jobs; null unless queued. */
+ queuePosition: number | null;
+}
+
+const STATUS_RANK: Record<InstallRowStatus, number> = {
+ cancelled: 6,
+ downloading: 0,
+ failed: 4,
+ installed: 5,
+ installing: 1,
+ paused: 3,
+ queued: 2,
+ unauthorized: 4,
+};
+
+/** Live downloads first, then installs, queued in run order, paused, attention, installed, cancelled. */
+export const buildInstallQueueRows = (
+ jobs: readonly ModelInstallJob[],
+ dismissedJobIds: ReadonlySet<number>
+): InstallQueueRow[] => {
+ const visible = jobs.filter((job) => !dismissedJobIds.has(job.id));
+ const waitingIds = visible
+ .filter((job) => job.status === 'waiting')
+ .map((job) => job.id)
+ .sort((left, right) => left - right);
+
+ return visible
+ .map((job) => {
+ const status = getInstallRowStatus(job);
+
+ return {
+ job,
+ queuePosition: status === 'queued' ? waitingIds.indexOf(job.id) + 1 : null,
+ status,
+ };
+ })
+ .sort((left, right) => {
+ const rank = STATUS_RANK[left.status] - STATUS_RANK[right.status];
+
+ if (rank !== 0) {
+ return rank;
+ }
+
+ return left.status === 'queued' ? left.job.id - right.job.id : right.job.id - left.job.id;
+ });
+};
+
+export interface InstallQueueSummary {
+ downloading: number;
+ installing: number;
+ queued: number;
+ paused: number;
+ attention: number;
+ installed: number;
+ settled: number;
+}
+
+/** Terminal jobs the backend still holds, dismissed or not: what "Clear finished" would prune. */
+export const countFinishedInstallJobs = (jobs: readonly ModelInstallJob[]): number =>
+ jobs.filter((job) => isSettledRowStatus(getInstallRowStatus(job))).length;
+
+export const summarizeInstallQueue = (rows: readonly InstallQueueRow[]): InstallQueueSummary => {
+ const summary: InstallQueueSummary = {
+ attention: 0,
+ downloading: 0,
+ installed: 0,
+ installing: 0,
+ paused: 0,
+ queued: 0,
+ settled: 0,
+ };
+
+ for (const { status } of rows) {
+ if (status === 'downloading') {
+ summary.downloading += 1;
+ } else if (status === 'installing') {
+ summary.installing += 1;
+ } else if (status === 'queued') {
+ summary.queued += 1;
+ } else if (status === 'paused') {
+ summary.paused += 1;
+ } else if (status === 'failed' || status === 'unauthorized') {
+ summary.attention += 1;
+ } else if (status === 'installed') {
+ summary.installed += 1;
+ }
+
+ if (isSettledRowStatus(status)) {
+ summary.settled += 1;
+ }
+ }
+
+ return summary;
+};
+
+const MIN_ETA_RATE_BYTES_PER_SECOND = 8 * 1024;
+
+export interface InstallByteProgress {
+ bytes: number;
+ totalBytes: number;
+ ratio: number | null;
+ bytesPerSecond: number | null;
+ /** Seconds until done at the smoothed rate; null without a rate or total. */
+ etaSeconds: number | null;
+}
+
+/** Live socket bytes win over the REST snapshot; the snapshot still carries paused/settled totals. */
+export const resolveInstallProgress = (
+ job: ModelInstallJob,
+ live: InstallDownloadProgress | null
+): InstallByteProgress => {
+ const bytes = live?.bytes ?? job.bytes ?? 0;
+ const totalBytes = live?.totalBytes ?? job.total_bytes ?? 0;
+ const ratio = totalBytes > 0 ? Math.min(1, bytes / totalBytes) : null;
+ const bytesPerSecond = live?.bytesPerSecond ?? null;
+ // A decayed or stalled rate would print an absurd ETA; below the floor the estimate is unknown.
+ const etaSeconds =
+ bytesPerSecond !== null && bytesPerSecond >= MIN_ETA_RATE_BYTES_PER_SECOND && totalBytes > bytes
+ ? Math.ceil((totalBytes - bytes) / bytesPerSecond)
+ : null;
+
+ return { bytes, bytesPerSecond, etaSeconds, ratio, totalBytes };
+};
+
+export type EtaLabel = { unit: 'seconds' | 'minutes' | 'hours'; count: number };
+
+/** Coarse, rounded-up buckets: a download ETA is an estimate, not a countdown. */
+export const describeEta = (etaSeconds: number): EtaLabel => {
+ if (etaSeconds < 60) {
+ return { count: Math.max(1, Math.ceil(etaSeconds / 5) * 5), unit: 'seconds' };
+ }
+
+ if (etaSeconds < 3600) {
+ return { count: Math.ceil(etaSeconds / 60), unit: 'minutes' };
+ }
+
+ return { count: Math.ceil(etaSeconds / 3600), unit: 'hours' };
+};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueUtils.ts b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueUtils.ts
deleted file mode 100644
index 03f96c8508..0000000000
--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueUtils.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { ModelInstallJob, ModelInstallStatus } from '@features/models/core/types';
-
-import { getInstallSourceLabel } from '@features/models/data/installsStore';
-
-/** Labels are i18n keys — translate with `t(labelKey)` at the render site. */
-export const STATUS_BADGES: Record<ModelInstallStatus, { labelKey: string; palette: string }> = {
- cancelled: { labelKey: 'models.statusCancelled', palette: 'gray' },
- completed: { labelKey: 'models.installed', palette: 'green' },
- downloading: { labelKey: 'models.statusDownloading', palette: 'blue' },
- downloads_done: { labelKey: 'models.statusDownloaded', palette: 'blue' },
- error: { labelKey: 'common.failed', palette: 'red' },
- paused: { labelKey: 'models.statusPaused', palette: 'orange' },
- running: { labelKey: 'models.installing', palette: 'blue' },
- waiting: { labelKey: 'models.statusWaiting', palette: 'gray' },
-};
-
-export const getInstallJobDisplayName = (job: ModelInstallJob): string =>
- job.config_out?.name ?? getInstallSourceLabel(job.source);
diff --git a/invokeai/frontend/webv2/src/features/models/ui/install-queue/useInstallJobActions.ts b/invokeai/frontend/webv2/src/features/models/ui/install-queue/useInstallJobActions.ts
new file mode 100644
index 0000000000..15019bcd1d
--- /dev/null
+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/useInstallJobActions.ts
@@ -0,0 +1,84 @@
+import type { ModelInstallJob } from '@features/models/core/types';
+
+import {
+ cancelModelInstall,
+ installModel,
+ pauseModelInstall,
+ restartFailedModelInstall,
+ restartModelInstallFile,
+ resumeModelInstall,
+} from '@features/models/data/api';
+import { getAccessTokenForSource } from '@features/models/data/apiKeys';
+import {
+ addInstallJob,
+ dismissInstallJob,
+ refreshInstalls,
+ replaceInstallJob,
+} from '@features/models/data/installsStore';
+import { useNotify } from '@features/models/ui/useModelsNotify';
+import { useScopedAction } from '@platform/react/useScopedAction';
+import { assertAccountScopeCurrent, type AccountScope } from '@platform/state/accountLifecycle';
+import { useTranslation } from 'react-i18next';
+
+import { canRestartFailedParts, getInstallJobAccessToken, getInstallJobSourceString } from './queueModel';
+
+const isInstallJob = (value: unknown): value is ModelInstallJob =>
+ typeof value === 'object' && value !== null && 'id' in value;
+
+/** Row actions share one busy flag so a second click cannot race the first request. */
+export const useInstallJobActions = (job: ModelInstallJob) => {
+ const { t } = useTranslation();
+ const notify = useNotify();
+ const { isBusy, run } = useScopedAction();
+
+ const runAction = (action: (owner: AccountScope) => Promise<unknown>, failureTitle: string) =>
+ run(
+ async (owner) => {
+ const result = await action(owner);
+
+ assertAccountScopeCurrent(owner);
+
+ if (isInstallJob(result)) {
+ replaceInstallJob(result);
+ // A coalesced refresh already in flight can clobber the optimistic row; revalidate to converge.
+ void refreshInstalls(owner);
+ } else {
+ await refreshInstalls(owner);
+ }
+ },
+ (message) => notify.error(failureTitle, message)
+ );
+
+ const resubmit = async (owner: AccountScope) => {
+ const source = getInstallJobSourceString(job);
+ const created = await installModel(
+ {
+ accessToken: getInstallJobAccessToken(job) ?? getAccessTokenForSource(source),
+ config: job.config_in ?? undefined,
+ inplace: job.inplace,
+ source,
+ },
+ owner.signal
+ );
+
+ assertAccountScopeCurrent(owner);
+ dismissInstallJob(job.id);
+ addInstallJob(created);
+ };
+
+ return {
+ cancel: () => void runAction((owner) => cancelModelInstall(job.id, owner.signal), t('models.cancelFailed')),
+ dismiss: () => dismissInstallJob(job.id),
+ isBusy,
+ pause: () => void runAction((owner) => pauseModelInstall(job.id, owner.signal), t('models.pauseFailed')),
+ restartFile: (fileUrl: string) =>
+ void runAction((owner) => restartModelInstallFile(job.id, fileUrl, owner.signal), t('models.restartFileFailed')),
+ resume: () => void runAction((owner) => resumeModelInstall(job.id, owner.signal), t('models.resumeFailed')),
+ // The backend restarts only failed parts of a live job; anything else is queued again from its source.
+ retry: () =>
+ void runAction(
+ (owner) => (canRestartFailedParts(job) ? restartFailedModelInstall(job.id, owner.signal) : resubmit(owner)),
+ t('models.retryFailed')
+ ),
+ };
+};
diff --git a/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx b/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx
index 32e3ce7163..42926bee43 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx
@@ -17,9 +17,16 @@ import { HEADER_MIN_HEIGHT } from './layoutConstants';
/** The tabbed detail pane: selected model, Add Models, API Keys, and queue footer. */
export const DetailPane = () => {
const { t } = useTranslation();
- const { activeModelKey, activeTab } = useModelsUiSelector(
- (snapshot) => ({ activeModelKey: snapshot.activeModelKey, activeTab: snapshot.activeTab }),
- (left, right) => left.activeModelKey === right.activeModelKey && left.activeTab === right.activeTab
+ const { activeModelKey, activeTab, queueFillsPane } = useModelsUiSelector(
+ (snapshot) => ({
+ activeModelKey: snapshot.activeModelKey,
+ activeTab: snapshot.activeTab,
+ queueFillsPane: snapshot.queueExpanded && snapshot.queueMaximized,
+ }),
+ (left, right) =>
+ left.activeModelKey === right.activeModelKey &&
+ left.activeTab === right.activeTab &&
+ left.queueFillsPane === right.queueFillsPane
);
const detailLabel = useModelsSelector(
(snapshot) => (activeModelKey ? snapshot.modelsByKey.get(activeModelKey)?.name : undefined) ?? t('models.details')
@@ -28,7 +35,7 @@ export const DetailPane = () => {
return (
<Flex direction="column" flex="1" minH="0" minW="0">
<Tabs.Root
- display="flex"
+ display={queueFillsPane ? 'none' : 'flex'}
flex="1"
flexDirection="column"
minH="0"