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.

fix(webv2): keep fuzzysort searches unlimited

Josh Corbettd5df7e65153a
diff --git a/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.test.ts b/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.test.ts
index a0e6519b22..a4c6bfd2b7 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.test.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.test.ts
@@ -28,6 +28,12 @@ describe('searchCatalog', () => {
expect(searchCatalog([dogs, colours], 'adg', getBody)).toEqual([dogs]);
});
+ it('returns every name match rather than the first ten', () => {
+ const items = Array.from({ length: 12 }, (_, index) => record(`portrait ${String(index)}`, 'body'));
+
+ expect(searchCatalog(items, 'portrait', getBody)).toHaveLength(12);
+ });
+
it('ranks name matches above prose matches', () => {
const byProse = record('animals', 'red panda');
const byName = record('red', 'crimson');
diff --git a/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.ts b/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.ts
index 517af38dc5..a59100c4be 100644
--- a/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.ts
+++ b/invokeai/frontend/webv2/src/features/generation/core/catalogSearch.ts
@@ -46,7 +46,8 @@ export const searchCatalog = <T extends { name: string }>(
return [...items];
}
- const nameMatches = fuzzysort.go(trimmed, items, { key: 'name', threshold: NAME_MATCH_THRESHOLD });
+ // fuzzysort 4 caps results at 10 unless told otherwise; 0 lifts the cap.
+ const nameMatches = fuzzysort.go(trimmed, items, { key: 'name', limit: 0, threshold: NAME_MATCH_THRESHOLD });
const named = new Set<T>();
const results: T[] = [];
diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
index 4157af5574..bc29fc7176 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.test.ts
@@ -294,6 +294,21 @@ describe('buildSettingsEntries', () => {
});
});
+describe('searchPaletteRows', () => {
+ it('returns every matching entry rather than the first ten', () => {
+ const entries: PaletteEntry[] = Array.from({ length: 12 }, (_, index) => ({
+ group: 'App',
+ id: `portrait-${String(index)}`,
+ isPersistentRecent: false,
+ run: () => undefined,
+ title: `Portrait ${String(index)}`,
+ }));
+ const rows = searchPaletteRows(entries, 'portrait', []);
+
+ expect(rows.filter((row) => row.kind === 'entry')).toHaveLength(12);
+ });
+});
+
describe('buildStageEntries', () => {
it('turns options into keep-open rows that apply then pop', () => {
const apply = vi.fn();
diff --git a/invokeai/frontend/webv2/src/workbench/palette/entries.ts b/invokeai/frontend/webv2/src/workbench/palette/entries.ts
index 240637b464..3794815500 100644
--- a/invokeai/frontend/webv2/src/workbench/palette/entries.ts
+++ b/invokeai/frontend/webv2/src/workbench/palette/entries.ts
@@ -538,6 +538,8 @@ export const searchPaletteRows = (
const results = fuzzysort.go(trimmed, searchable, {
keys: [(entry) => entry.title, (entry) => entry.keywords ?? '', (entry) => entry.subtitle ?? ''],
+ // fuzzysort 4 caps results at 10 unless told otherwise; 0 lifts the cap.
+ limit: 0,
scoreFn: (result) => Math.max(result[0]?.score ?? 0, (result[1]?.score ?? 0) * 0.9, (result[2]?.score ?? 0) * 0.5),
threshold: MATCH_THRESHOLD,
});