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:
gsxdsm
2026-03-29 20:55:01 -07:00
parent 0e26d1df30
commit c5b09e1cb1
7 changed files with 498 additions and 11 deletions

View 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));
});
}