on main help sign in
fix(ui): scroll to the properly select model
commit1320fcf5ce10ce0b8ac0e2f3580ae3adf1da18cc authorKieran Klukas <kieran@dunkirk.sh> dateThu 21 May 2026, 15:22 (5 months ago) parentdf3a04d
2 files changed+11−10
internal/ui/dialog/models.go+5−1 internal/ui/dialog/models_list.go+6−9
internal/ui/dialog/models.go+5−1
@@ -496,7 +496,11 @@ func (m *Models) setProviderItems() error {
496496 // Set model groups in the list.
497497 m.list.SetGroups(groups...)
498498 m.list.SetSelectedItem(selectedItemID)
499− m.list.ScrollToTop()
499+ if selectedItemID != "" {
500+ m.list.ScrollToSelected()
501+ } else {
502+ m.list.ScrollToTop()
503+ }
500504
501505 // Update placeholder based on model type
502506 if !m.isOnboarding {
internal/ui/dialog/models_list.go+6−9
@@ -85,18 +85,15 @@ func (f *ModelsList) SetSelected(index int) {
8585// SetSelectedItem sets the selected item in the list by item ID.
8686func (f *ModelsList) SetSelectedItem(itemID string) {
8787 if itemID == "" {
88− f.SetSelected(0)
8988 return
9089 }
9190
92− count := 0
93− for _, g := range f.groups {
94− for _, item := range g.Items {
95− if item.ID() == itemID {
96− f.SetSelected(count)
97− return
98− }
99− count++
91+ // Walk the selectable model items using the same helpers that
92+ // keyboard navigation uses, so we stay in sync with the flat
93+ // list layout.
94+ for ok := f.SelectFirst(); ok; ok = f.SelectNext() {
95+ if mi, is := f.SelectedItem().(*ModelItem); is && mi.ID() == itemID {
96+ return
10097 }
10198 }
10299}