on main help sign in
chore: do not scroll sessions if not neccessary

this makes it so we only scroll if the selected item is not in the view, this was driving me nuts that it was always putting my last session at the top.

commite753d09af1e9279302388f7d4a15a7e7135b4396 authorKujtim Hoxha <kujtimii.h@gmail.com> dateThu 22 Jan 2026, 11:51 (9 months ago) parent40bfd6e
1 file changed+8−1
internal/ui/dialog/sessions.go+8−1
internal/ui/dialog/sessions.go+8−1
@@ -57,7 +57,6 @@ func NewSessions(com *common.Common, selectedSessionID string) (*Session, error)
5757 s.list = list.NewFilterableList(sessionItems(com.Styles, sessions...)...)
5858 s.list.Focus()
5959 s.list.SetSelected(s.selectedSessionInx)
60− s.list.ScrollToSelected()
6160
6261 s.input = textinput.New()
6362 s.input.SetVirtualCursor(false)
@@ -153,6 +152,14 @@ func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
153152 s.list.SetSize(innerWidth, height-heightOffset)
154153 s.help.SetWidth(innerWidth)
155154
155+ // This makes it so we do not scroll the list if we don't have to
156+ start, end := s.list.VisibleItemIndices()
157+
158+ // if selected index is outside visible range, scroll to it
159+ if s.selectedSessionInx < start || s.selectedSessionInx > end {
160+ s.list.ScrollToSelected()
161+ }
162+
156163 rc := NewRenderContext(t, width)
157164 rc.Title = "Switch Session"
158165 inputView := t.Dialog.InputPrompt.Render(s.input.View())