From ccb25641712cc61fe30438c64313c6a1434b7966 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 11 Feb 2026 04:20:56 +0000 Subject: fix(list): Constrain session list to terminal height --- internal/app/state.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'internal/app/state.go') diff --git a/internal/app/state.go b/internal/app/state.go index 6b24d80..aa9fb77 100644 --- a/internal/app/state.go +++ b/internal/app/state.go @@ -88,14 +88,14 @@ func (m *Model) reloadSessions() { } func (m *Model) ensureVisible() { - visibleHeight := m.listHeight() + visible := m.visibleItemCount() if m.cursor < m.offset { m.offset = m.cursor } - if m.cursor >= m.offset+visibleHeight { - m.offset = m.cursor - visibleHeight + 1 + if m.cursor >= m.offset+visible { + m.offset = m.cursor - visible + 1 } } @@ -120,3 +120,11 @@ func (m Model) listHeight() int { return max(1, m.height-reserved) } + +func (m Model) visibleItemCount() int { + if m.showPreview { + return m.listHeight() - 2 + } + + return max(1, m.listHeight()/2) +} -- cgit v1.2.3