fix: keep original order when filtering models (#2416)

Andrey Nering created

Change summary

internal/ui/dialog/models_list.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

internal/ui/dialog/models_list.go 🔗

@@ -216,8 +216,10 @@ func (f *ModelsList) VisibleItems() []list.Item {
 		}
 
 		matches := fuzzy.Find(query, names)
+
+		// Sort by original index to preserve order within the group
 		sort.SliceStable(matches, func(i, j int) bool {
-			return matches[i].Score > matches[j].Score
+			return matches[i].Index < matches[j].Index
 		})
 
 		for _, match := range matches {