Skip to content

fix(ui): close picker on empty items#345

Merged
sudo-tee merged 1 commit intosudo-tee:mainfrom
hermandavid:fix/close-picker-on-empty-items
Mar 31, 2026
Merged

fix(ui): close picker on empty items#345
sudo-tee merged 1 commit intosudo-tee:mainfrom
hermandavid:fix/close-picker-on-empty-items

Conversation

@hermandavid
Copy link
Copy Markdown
Contributor

Summary

  • When a reload action (e.g. <C-d> delete in the session picker) results in an empty item list, the picker now closes automatically instead of staying open in an invalid empty state.
  • Adds a close function to PickerOptions that each backend sets with its own cleanup logic, and checks for empty results in all reload handlers.

Problem

Deleting the last session with <C-d> left the picker open with no items. There was no handling for the empty-list case after a reload action resolved, so the picker would refresh with zero entries.

With an empty picker, no recovery was possible either -- all action handlers in every backend (Telescope, fzf-lua, mini.pick, Snacks) guard execution on having a currently selected item, so <C-s> (new session) would silently do nothing. The user's only option was to dismiss the broken picker and reopen it.

Approach

Each picker backend now provides an opts.close() implementation using its native close mechanism:

  • Telescope: actions.close() with selection_made guard
  • fzf-lua: closes the fzf window via  fzf-lua.win with a closed flag to prevent double-callback from default/esc handlers
  • mini.pick: mini_pick.stop(), with callback handled naturally by on_done
  • Snacks: _picker:close() with selection_made guard

All reload handlers check #resolved_items == 0 and call opts.close() instead of refreshing.

@hermandavid hermandavid changed the title Fix/close picker on empty items fix(ui): close picker on empty items Mar 30, 2026
@hermandavid hermandavid force-pushed the fix/close-picker-on-empty-items branch from b56f6ed to 001e969 Compare March 30, 2026 21:32
@sudo-tee
Copy link
Copy Markdown
Owner

Thanks for the PR
It looks good to me

@sudo-tee sudo-tee merged commit 97da492 into sudo-tee:main Mar 31, 2026
5 checks passed
@hermandavid hermandavid deleted the fix/close-picker-on-empty-items branch March 31, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants