Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
refactor(ui): collapse ModelDetail and library list props to their single shapes
joshistoast8fab28c431cc
diff --git a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsxindex d3c32e21d7..e4de516adf 100644--- a/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/detail/ModelDetail.tsx@@ -9,7 +9,7 @@ import { useModelsSelector } from '@features/models/data/modelsStore';import { useNotify } from '@features/models/ui/useModelsNotify';import { areArraysEqual } from '@platform/state/selectors';import { Button, IconButton, ConfirmDialog, MenuContent } from '@platform/ui';-import { ArrowLeftIcon, MoreHorizontalIcon, PencilIcon, RefreshCcwIcon, Trash2Icon } from 'lucide-react';+import { MoreHorizontalIcon, PencilIcon, RefreshCcwIcon, Trash2Icon } from 'lucide-react';import { memo, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { SiHuggingface } from 'react-icons/si';@@ -108,26 +108,15 @@ const areTriggerPhrasesModelsEqual = (left: TriggerPhrasesModel | null, right: T* Full detail pane for one model: identity (view/edit), per-model default* settings, related models, trigger phrases, and lifecycle actions (convert,* re-identify, delete). Mount keyed by model key so per-model form state never- * leaks between models. `density="panel"` tightens the side-panel drill-in.+ * leaks between models.*/-export const ModelDetail = ({- density = 'full',- modelKey,- onBack,- onDeleted,-}: {- density?: 'panel' | 'full';- modelKey: string;- onBack?: () => void;- onDeleted: () => void;-}) => {+export const ModelDetail = ({ modelKey, onDeleted }: { modelKey: string; onDeleted: () => void }) => {const { t } = useTranslation();const model = useModelsSelector((snapshot) => selectModelShell(snapshot.models, modelKey));if (!model) {return (<Stack align="start" gap="2" p="1">- {onBack ? <BackButton onBack={onBack} /> : null}<Text color="fg.subtle" fontSize="xs">{t('models.modelNoLongerInLibrary')}</Text>@@ -136,10 +125,8 @@ export const ModelDetail = ({}return (- <Stack gap={density === 'panel' ? '3' : '4'} pb="4">- {onBack ? <BackButton onBack={onBack} /> : null}-- <ModelIdentitySectionContainer density={density} modelKey={model.key} onDeleted={onDeleted} />+ <Stack gap="4" pb="4">+ <ModelIdentitySectionContainer modelKey={model.key} onDeleted={onDeleted} />{supportsVaeCpuOnlySetting(model) ? (<>@@ -173,18 +160,15 @@ export const ModelDetail = ({};interface ModelIdentitySectionProps {- density: 'panel' | 'full';isMissing: boolean;model: ModelIdentityModel;onDeleted: () => void;}const ModelIdentitySectionContainer = memo(function ModelIdentitySectionContainer({- density,modelKey,onDeleted,}: {- density: 'panel' | 'full';modelKey: string;onDeleted: () => void;}) {@@ -195,11 +179,10 @@ const ModelIdentitySectionContainer = memo(function ModelIdentitySectionContainereturn null;}- return <ModelIdentitySection density={density} isMissing={isMissing} model={model} onDeleted={onDeleted} />;+ return <ModelIdentitySection isMissing={isMissing} model={model} onDeleted={onDeleted} />;});const ModelIdentitySection = memo(function ModelIdentitySection({- density,isMissing,model,onDeleted,@@ -258,7 +241,7 @@ const ModelIdentitySection = memo(function ModelIdentitySection({}}/>) : (- <ModelAttributes density={density} model={model} />+ <ModelAttributes model={model} />)}</>);@@ -436,20 +419,9 @@ const RelatedModelsSectionContainer = memo(function RelatedModelsSectionContainereturn <RelatedModelsSection model={model} onError={handleSectionError} />;});-const BackButton = ({ onBack }: { onBack: () => void }) => {- const { t } = useTranslation();-- return (- <Button alignSelf="start" size="2xs" variant="ghost" onClick={onBack}>- <Icon as={ArrowLeftIcon} boxSize="3" />- {t('models.allModels')}- </Button>- );-};-const isAbsolutePath = (path: string): boolean => path.startsWith('/') || /^[A-Za-z]:[\\/]/.test(path);-const ModelAttributes = ({ density, model }: { density: 'panel' | 'full'; model: ModelIdentityModel }) => {+const ModelAttributes = ({ model }: { model: ModelIdentityModel }) => {const { t } = useTranslation();const modelsDir = useModelsSelector((snapshot) => snapshot.modelsDir);// Managed models store paths relative to the models directory; show the@@ -467,7 +439,7 @@ const ModelAttributes = ({ density, model }: { density: 'panel' | 'full'; model:];return (- <DataList.Root gap="2.5" orientation={density === 'panel' ? 'vertical' : 'horizontal'} size="sm" variant="subtle">+ <DataList.Root gap="2.5" orientation="horizontal" size="sm" variant="subtle">{attributes.map((attribute) => (<DataList.Item key={attribute.label}><DataList.ItemLabel color="fg.subtle" fontSize="2xs" minW="8rem" textTransform="uppercase">diff --git a/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx b/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsxindex ff370fa3a8..e9eaa56de9 100644--- a/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/library/ModelLibraryList.tsx@@ -29,8 +29,8 @@ const MODEL_ROW_HEIGHT_PX = 56;* header is rendered as a pinned overlay above the scroll viewport — CSS* sticky positioning is unreliable inside ScrollArea's content wrapper — and* the virtual content lives in ScrollArea.Content so the scrollbar thumb is- * measured correctly. Rows carry a thumbnail, a right-click action menu, and —- * when `onToggleSelected` is provided — bulk-select checkboxes.+ * measured correctly. Rows carry a thumbnail, a right-click action menu, and+ * bulk-select checkboxes.*/export const ModelLibraryList = ({activeModelKey,@@ -42,12 +42,11 @@ export const ModelLibraryList = ({}: {activeModelKey: string | null;filters: ModelLibraryFilters;- /** Identifies this list's scroll-offset slot ('panel', 'manager', ...). */+ /** Identifies this list's scroll-offset slot ('manager'). */instanceId: string;onActivate: (modelKey: string) => void;- /** Present in the manager library: enables bulk-select checkboxes. */- onToggleSelected?: (modelKey: string) => void;- selectedKeys?: ReadonlySet<string>;+ onToggleSelected: (modelKey: string) => void;+ selectedKeys: ReadonlySet<string>;}) => {const { t } = useTranslation();const { coverImageVersions, error, missingModelKeys, models, status } = useModelsSelector(@@ -175,7 +174,7 @@ export const ModelLibraryList = ({imageVersion={coverImageVersions[row.model.key]}isActive={row.model.key === activeModelKey}isMissing={missingModelKeys.has(row.model.key)}- isSelected={selectedKeys?.has(row.model.key) ?? false}+ isSelected={selectedKeys.has(row.model.key)}modelKey={row.model.key}name={row.model.name}virtualStart={virtualRow.start}@@ -242,7 +241,7 @@ interface ModelRowProps {name: string;onActivate: (modelKey: string) => void;onContextMenu: (modelKey: string, x: number, y: number) => void;- onToggleSelected?: (modelKey: string) => void;+ onToggleSelected: (modelKey: string) => void;}interface VirtualModelRowProps extends ModelRowProps {@@ -281,23 +280,21 @@ const ModelRow = memo(function ModelRow({onContextMenu(modelKey, event.clientX, event.clientY);}}>- {onToggleSelected ? (- <Checkbox.Root- aria-label={`Select ${name}`}- checked={isSelected}- colorPalette="accent"- insetStart="2"- position="absolute"- size="xs"- top="50%"- transform="translateY(-50%)"- zIndex={1}- onCheckedChange={() => onToggleSelected(modelKey)}- >- <Checkbox.HiddenInput />- <Checkbox.Control />- </Checkbox.Root>- ) : null}+ <Checkbox.Root+ aria-label={`Select ${name}`}+ checked={isSelected}+ colorPalette="accent"+ insetStart="2"+ position="absolute"+ size="xs"+ top="50%"+ transform="translateY(-50%)"+ zIndex={1}+ onCheckedChange={() => onToggleSelected(modelKey)}+ >+ <Checkbox.HiddenInput />+ <Checkbox.Control />+ </Checkbox.Root><Rowactive={isActive ? 'accent' : isSelected ? 'muted' : 'none'}aria-current={isActive || undefined}@@ -305,7 +302,7 @@ const ModelRow = memo(function ModelRow({h={`${MODEL_ROW_HEIGHT_PX - 4}px`}minW="0"pe="2"- ps={onToggleSelected ? '9' : '2'}+ ps="9"rounded="md"_focusVisible={{ boxShadow: 'inset 0 0 0 2px {colors.accent.solid}', outline: 'none' }}>diff --git a/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx b/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsxindex 93ceb64388..4c45b86145 100644--- a/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx+++ b/invokeai/frontend/webv2/src/features/models/ui/manager/DetailPane.tsx@@ -97,7 +97,7 @@ const DetailTab = ({ modelKey }: { modelKey: string | null }) => {return (<Scrollable h="full" label={t('models.details')} minH="0" p="3">- <ModelDetail key={modelKey} density="full" modelKey={modelKey} onDeleted={handleDeleted} />+ <ModelDetail key={modelKey} modelKey={modelKey} onDeleted={handleDeleted} /></Scrollable>);};