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.

perf(ui): defer and gate the select-all filter pass

joshistoast822d92c4fab0
diff --git a/invokeai/frontend/webv2/src/features/models/ui/manager/LibraryColumn.tsx b/invokeai/frontend/webv2/src/features/models/ui/manager/LibraryColumn.tsx
index 0abcd77eba..3926bef1c3 100644
--- a/invokeai/frontend/webv2/src/features/models/ui/manager/LibraryColumn.tsx
+++ b/invokeai/frontend/webv2/src/features/models/ui/manager/LibraryColumn.tsx
@@ -19,11 +19,13 @@ import { useScopedAction } from '@platform/react/useScopedAction';
import { assertAccountScopeCurrent } from '@platform/state/accountLifecycle';
import { Button, IconButton, ConfirmDialog } from '@platform/ui';
import { RefreshCcwIcon, Trash2Icon, XIcon } from 'lucide-react';
-import { useCallback, useMemo, useState } from 'react';
+import { useCallback, useDeferredValue, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { HEADER_MIN_HEIGHT, LIBRARY_WIDTH } from './layoutConstants';
+const EMPTY_KEYS: string[] = [];
+
/** The persistent master list: header, search/filter bar, and bulk actions. */
export const LibraryColumn = () => {
const { t } = useTranslation();
@@ -51,11 +53,16 @@ export const LibraryColumn = () => {
const availableTypes = useMemo(() => collectTypes(models), [models]);
const availableBases = useMemo(() => collectBases(models), [models]);
- // The same filter logic the list renders with, so "Select all" matches
- // exactly what the user sees (search, type/base, missing-only).
+ const hasSelection = selectedKeys.size > 0;
+ const deferredFilters = useDeferredValue(filters);
+ // The same filter logic the list renders with (deferred identically), so
+ // "Select all" matches exactly what the user sees (search, type/base,
+ // missing-only). The bulk bar is the only consumer — skip it until a
+ // selection exists rather than re-filtering on every search keystroke.
const filteredKeys = useMemo(
- () => filterModels(models, filters, missingModelKeys).map((model) => model.key),
- [filters, missingModelKeys, models]
+ () =>
+ hasSelection ? filterModels(models, deferredFilters, missingModelKeys).map((model) => model.key) : EMPTY_KEYS,
+ [deferredFilters, hasSelection, missingModelKeys, models]
);
const hasUnselectedFiltered = useMemo(
() => filteredKeys.some((key) => !selectedKeys.has(key)),