feat(KB-061): add model filter search to model selectors
- Add search input with clear button and results count to ModelSelectorTab - Extract filterModels utility for shared filtering logic across components - Apply filtering to SettingsModal model section - Add CSS styles for filter UI components - Add comprehensive tests for ModelSelectorTab and SettingsModal filtering
This commit is contained in:
15
packages/dashboard/app/utils/modelFilter.ts
Normal file
15
packages/dashboard/app/utils/modelFilter.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { ModelInfo } from "../api";
|
||||
|
||||
/**
|
||||
* Filter models by search terms matching provider, id, or name.
|
||||
* Supports multi-word filters (space-separated AND logic).
|
||||
* Case-insensitive substring matching.
|
||||
*/
|
||||
export function filterModels(models: ModelInfo[], filter: string): ModelInfo[] {
|
||||
const terms = filter.toLowerCase().trim().split(/\s+/).filter(Boolean);
|
||||
if (terms.length === 0) return models;
|
||||
return models.filter((m) => {
|
||||
const haystack = `${m.provider} ${m.id} ${m.name}`.toLowerCase();
|
||||
return terms.every((term) => haystack.includes(term));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user