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
fix(ui): keep shared display helpers out of the initial graphs
Josh Corbett0f379c4d59cf
diff --git a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.tsindex 5f3519eb01..37124339d6 100644--- a/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts+++ b/invokeai/frontend/webv2/src/features/models/core/baseIdentity.ts@@ -1,10 +1,12 @@import type { ModelBase, ModelConfig } from './types';-import { toTitleCase } from './strings';-// Model-base identity registry: labels, colors, and scalar display facts only.// Generation behavior keyed by base lives in @features/generation/settings.+/** Fallback display casing for open-union taxonomy values ("t5_encoder" -> "T5 Encoder"). */+export const toTitleCase = (value: string): string =>+ value.replaceAll(/[_-]+/g, ' ').replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.slice(1));+export type ModelBaseColorPalette = 'blue' | 'cyan' | 'gray' | 'green' | 'orange' | 'pink' | 'purple' | 'red' | 'teal';export interface ModelBaseInfo {diff --git a/invokeai/frontend/webv2/src/features/models/core/strings.ts b/invokeai/frontend/webv2/src/features/models/core/strings.tsdeleted file mode 100644index cc81580e5f..0000000000--- a/invokeai/frontend/webv2/src/features/models/core/strings.ts+++ /dev/null@@ -1,3 +0,0 @@-/** Fallback display casing for open-union taxonomy values ("t5_encoder" -> "T5 Encoder"). */-export const toTitleCase = (value: string): string =>- value.replaceAll(/[_-]+/g, ' ').replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.slice(1));diff --git a/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts b/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.tsindex 8c1003e7f8..48236bb52e 100644--- a/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts+++ b/invokeai/frontend/webv2/src/features/models/core/taxonomy.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from 'vitest';-import { formatBytes, getInstallSourceLabel, getModelFormatLabel, getModelTypeLabel } from './taxonomy';+import { formatBytes, getModelFormatLabel, getModelTypeLabel } from './taxonomy';describe('formatBytes', () => {it('renders a dash for missing or invalid sizes', () => {@@ -19,23 +19,6 @@ describe('formatBytes', () => {});});-describe('getInstallSourceLabel', () => {- it('passes strings through and extracts structured source fields in order', () => {- expect(getInstallSourceLabel('https://example.com/model.safetensors')).toBe(- 'https://example.com/model.safetensors'- );- expect(getInstallSourceLabel({ repo_id: 'owner/repo', url: 'https://x' })).toBe('owner/repo');- expect(getInstallSourceLabel({ url: 'https://x' })).toBe('https://x');- expect(getInstallSourceLabel({ path: '/models/x' })).toBe('/models/x');- });-- it('falls back to a generic label for unrecognized payloads', () => {- expect(getInstallSourceLabel({ something: 'else' })).toBe('model');- expect(getInstallSourceLabel(undefined)).toBe('model');- expect(getInstallSourceLabel(42)).toBe('model');- });-});-describe('label fallbacks', () => {it('title-cases unknown open-union values', () => {expect(getModelTypeLabel('some_new_type')).toBe('Some New Type');diff --git a/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts b/invokeai/frontend/webv2/src/features/models/core/taxonomy.tsindex 2caa4c96dd..d99156b0fa 100644--- a/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts+++ b/invokeai/frontend/webv2/src/features/models/core/taxonomy.ts@@ -1,6 +1,6 @@import type { ModelFileFormat, ModelTaxonomyType } from './types';-import { toTitleCase } from './strings';+import { toTitleCase } from './baseIdentity';/*** Display metadata for the model taxonomy. Open-union friendly: unknown bases,@@ -98,28 +98,3 @@ export const formatBytes = (bytes: number | null | undefined): string => {return `${unitIndex === 0 ? value : value.toFixed(1)} ${BYTE_UNITS[unitIndex]}`;};--/**- * Human-readable source for an install job or install socket payload. Accepts- * `unknown` so untyped socket payloads and typed job sources produce the SAME- * string — active-install matching compares these labels.- */-export const getInstallSourceLabel = (source: unknown): string => {- if (typeof source === 'string') {- return source;- }-- if (source && typeof source === 'object') {- const record = source as Record<string, unknown>;-- for (const field of ['repo_id', 'url', 'path'] as const) {- const value = record[field];-- if (typeof value === 'string') {- return value;- }- }- }-- return 'model';-};diff --git a/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts b/invokeai/frontend/webv2/src/features/models/data/installsStore.test.tsindex f58138d2ce..85d0d072bc 100644--- a/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts+++ b/invokeai/frontend/webv2/src/features/models/data/installsStore.test.ts@@ -120,3 +120,24 @@ describe('model install event interpretation', () => {expect(store.getInstallsSnapshot()).toEqual({ error: null, jobs: [], status: 'idle' });});});++describe('getInstallSourceLabel', () => {+ it('passes strings through and extracts structured source fields in order', async () => {+ const store = await import('./installsStore');++ expect(store.getInstallSourceLabel('https://example.com/model.safetensors')).toBe(+ 'https://example.com/model.safetensors'+ );+ expect(store.getInstallSourceLabel({ repo_id: 'owner/repo', url: 'https://x' })).toBe('owner/repo');+ expect(store.getInstallSourceLabel({ url: 'https://x' })).toBe('https://x');+ expect(store.getInstallSourceLabel({ path: '/models/x' })).toBe('/models/x');+ });++ it('falls back to a generic label for unrecognized payloads', async () => {+ const store = await import('./installsStore');++ expect(store.getInstallSourceLabel({ something: 'else' })).toBe('model');+ expect(store.getInstallSourceLabel(undefined)).toBe('model');+ expect(store.getInstallSourceLabel(42)).toBe('model');+ });+});diff --git a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts b/invokeai/frontend/webv2/src/features/models/data/installsStore.tsindex b897024ad5..4d6b617351 100644--- a/invokeai/frontend/webv2/src/features/models/data/installsStore.ts+++ b/invokeai/frontend/webv2/src/features/models/data/installsStore.ts@@ -1,6 +1,5 @@import type { ModelInstallJob, ModelInstallStatus } from '@features/models/core/types';-import { getInstallSourceLabel } from '@features/models/core/taxonomy';import {type AccountScope,captureAccountScope,@@ -43,6 +42,33 @@ export interface InstallOutcome {error: string | null;}+/**+ * Human-readable source for an install job or install socket payload. Accepts+ * `unknown` so untyped socket payloads and typed job sources produce the SAME+ * string — active-install matching compares these labels. Lives here rather+ * than in `core/taxonomy` so the eagerly-loaded data layer does not pull the+ * taxonomy module out of the lazy UI chunks (the initial-graph byte budget).+ */+export const getInstallSourceLabel = (source: unknown): string => {+ if (typeof source === 'string') {+ return source;+ }++ if (source && typeof source === 'object') {+ const record = source as Record<string, unknown>;++ for (const field of ['repo_id', 'url', 'path'] as const) {+ const value = record[field];++ if (typeof value === 'string') {+ return value;+ }+ }+ }++ return 'model';+};+const REFRESH_COALESCE_MS = 250;const OUTCOME_LIMIT = 16;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.tsxindex 58d88413ff..538ff4b902 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@@ -2,7 +2,6 @@import type { ModelInstallJob } from '@features/models/core/types';import { Badge, HStack, Icon, Stack, Text } from '@chakra-ui/react';-import { getInstallSourceLabel } from '@features/models/core/taxonomy';import {cancelModelInstall,pauseModelInstall,@@ -10,7 +9,12 @@ import {restartModelInstallFile,resumeModelInstall,} from '@features/models/data/api';-import { isActiveInstallStatus, refreshInstalls, replaceInstallJob } from '@features/models/data/installsStore';+import {+ getInstallSourceLabel,+ isActiveInstallStatus,+ refreshInstalls,+ replaceInstallJob,+} from '@features/models/data/installsStore';import { useScopedAction } from '@features/models/ui/shared/useScopedAction';import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';import { useConnectionStatusSelector } from '@platform/transport/connectionStore';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.tsindex dcc291fdef..03f96c8508 100644--- a/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueUtils.ts+++ b/invokeai/frontend/webv2/src/features/models/ui/install-queue/queueUtils.ts@@ -1,6 +1,6 @@import type { ModelInstallJob, ModelInstallStatus } from '@features/models/core/types';-import { getInstallSourceLabel } from '@features/models/core/taxonomy';+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 }> = {