From 1a2ab427fe63f1e7617ad420b60c29b8245691a8 Mon Sep 17 00:00:00 2001 From: patriceckhart Date: Sun, 19 Apr 2026 17:16:45 +0200 Subject: [PATCH] fix(tui): hide empty sessions from the /sessions picker Zero-message sessions no longer appear in the picker. Covers three cases: the currently-running session (its file exists but no prompt has landed in it yet), sessions the user exited immediately after /clear, and any stale empties that PruneEmptySessions hasn't swept yet. Resuming an empty session was always a no-op, so nothing is lost. The '(empty)' fallback summary in formatSessionRowPlain stays as defense in case MessageCount > 0 but FirstUserText is blank. --- internal/agent/modes/session_dialog.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/agent/modes/session_dialog.go b/internal/agent/modes/session_dialog.go index 4bc4ed7..03ae035 100644 --- a/internal/agent/modes/session_dialog.go +++ b/internal/agent/modes/session_dialog.go @@ -25,9 +25,21 @@ type sessionDialogAction struct { func newSessionDialog() *sessionDialog { return &sessionDialog{} } -// Open populates the dialog from root + cwd and shows it. +// Open populates the dialog from root + cwd and shows it. Empty +// sessions (zero messages) are filtered out so the currently-running +// session, a freshly-opened one that hasn't received a prompt yet, +// and any stale empties that haven't been pruned yet all stay out +// of the picker. Resuming an empty session is a no-op anyway. func (d *sessionDialog) Open(root, cwd string) { - d.sessions = core.DescribeSessions(root, cwd) + all := core.DescribeSessions(root, cwd) + filtered := make([]core.SessionSummary, 0, len(all)) + for _, s := range all { + if s.MessageCount == 0 { + continue + } + filtered = append(filtered, s) + } + d.sessions = filtered d.cursor = 0 d.active = true }