on main help sign in
fix(ui): models dialog: filter each group separately
commit909244e4706a2408acf625ce38a7c5592c9322aa authorAyman Bagabas <ayman.bagabas@gmail.com> dateMon 5 Jan 2026, 16:21 (1 year ago) parentc280dd5
1 file changed+13−16
internal/ui/dialog/models_list.go+13−16
internal/ui/dialog/models_list.go+13−16
@@ -191,21 +191,6 @@ func (f *ModelsList) VisibleItems() []list.Item {
191191 }
192192 }
193193
194− filterValue := func(itm *ModelItem) string {
195− return strings.ToLower(fmt.Sprintf("%s %s", itm.prov.Name, itm.model.Name))
196− }
197−
198− names := make([]string, len(filterableItems))
199− for i, item := range filterableItems {
200− ms := item.(*ModelItem)
201− names[i] = filterValue(ms)
202− }
203−
204− matches := fuzzy.Find(query, names)
205− sort.SliceStable(matches, func(i, j int) bool {
206− return matches[i].Score > matches[j].Score
207− })
208−
209194 items := []list.Item{}
210195 visitedGroups := map[int]bool{}
211196
@@ -213,7 +198,19 @@ func (f *ModelsList) VisibleItems() []list.Item {
213198 // Find which group this item belongs to
214199 for gi, g := range f.groups {
215200 addedCount := 0
216− name := g.Title + " "
201+ name := strings.ToLower(g.Title) + " "
202+
203+ names := make([]string, len(filterableItems))
204+ for i, item := range filterableItems {
205+ ms := item.(*ModelItem)
206+ names[i] = fmt.Sprintf("%s%s", name, ms.Filter())
207+ }
208+
209+ matches := fuzzy.Find(query, names)
210+ sort.SliceStable(matches, func(i, j int) bool {
211+ return matches[i].Score > matches[j].Score
212+ })
213+
217214 for _, match := range matches {
218215 item := filterableItems[match.Index].(*ModelItem)
219216 idxs := []int{}