Skip to content

feat(picker): add optional interactive search/filter support#158

Open
MRThugh wants to merge 1 commit into
aisk:masterfrom
MRThugh:master
Open

feat(picker): add optional interactive search/filter support#158
MRThugh wants to merge 1 commit into
aisk:masterfrom
MRThugh:master

Conversation

@MRThugh
Copy link
Copy Markdown

@MRThugh MRThugh commented May 9, 2026

Summary

This PR introduces an optional interactive search/filter feature to the Picker UI component and the top-level pick() function.
Users can now type to dynamically filter the options list using case-insensitive substring matching.

This enhancement significantly improves usability for long option lists, while maintaining full backward compatibility.

Details

  • Added a new parameter: enable_search: bool = False to both Picker and pick() function.
  • When enabled, the UI shows a "Search: ..." prompt where user keystrokes update the filtered list in real-time.
  • If the search yields no matches, a “No results” message is displayed instead of empty options.
  • Internal state management updated to ensure index safety, preventing IndexError when filtering modifies the list.
  • Navigation with arrow keys respects the filtered subset.
  • Works transparently with both backend implementations (curses and blessed).
  • Default behavior remains unchanged for users who do not enable this feature, ensuring backward compatibility.
  • Code style and formatting follow existing project conventions.

Testing

  • Manual testing performed on Python 3.10+ in terminal environments.
  • Verified navigation, selection, and search input (including backspace).
  • Tested with both curses and blessed backends.

Impact

  • Non-breaking feature addition.
  • Improves experience for end-users dealing with large lists.
  • Lay groundwork for future enhancements like fuzzy search (optional).

- introduce enable_search parameter
- filter options based on user input
- display "No results" when search yields nothing
- ensure index safety when filtered list changes
- keep backward compatibility
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.

1 participant