Skip to content

✨ feat: add fzf-style interactive selection for lists and dictionaries - #524

Open
guptadev21 wants to merge 2 commits into
develfrom
feat/fzf-style-slection
Open

✨ feat: add fzf-style interactive selection for lists and dictionaries#524
guptadev21 wants to merge 2 commits into
develfrom
feat/fzf-style-slection

Conversation

@guptadev21

Copy link
Copy Markdown
Member

Problem

When running rio auth login, organizations and projects are displayed as a numbered list in the terminal. Users must scroll through the entire list and type a number to select an entry. With 50+ projects this becomes tedious and error-prone.

Solution

Replaced the numbered list with an fzf-style interactive picker when running in a real terminal (TTY). Users can now type to fuzzy-search and use arrow keys to navigate, then press Enter to confirm. The old numbered list behavior is preserved as a fallback for non-interactive use (pipes, scripts, CI).

Controls

Key Action
Type Filter list (fuzzy match)
↑ / ↓ Navigate
Enter Select
Backspace / Ctrl-U Edit / clear query
Esc / Ctrl-C Abort

No new dependencies — uses prompt_toolkit, which is already available as a transitive dependency of click.

demo

Copilot AI review requested due to automatic review settings May 12, 2026 06:18
@guptadev21
guptadev21 requested review from a team as code owners May 12, 2026 06:18
@guptadev21 guptadev21 self-assigned this May 12, 2026
@github-actions

github-actions Bot commented May 12, 2026

Copy link
Copy Markdown

🤖 Pull Request Artifacts (#25719838141) 🎉

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an interactive, fzf-style selector (fuzzy search + arrow navigation) to improve large list/dict selections (notably org/project selection during rio auth login), while keeping the existing numbered-list prompt as a non-TTY fallback.

Changes:

  • Detects TTY and switches show_selection() to an interactive prompt_toolkit-based picker.
  • Introduces prompt_toolkit UI rendering + keybindings for fuzzy filtering and selection.
  • Preserves legacy numbered-list behavior for non-interactive environments.

Comment thread riocli/utils/selector.py Outdated
Comment on lines +75 to +80
chosen_label = _run_fuzzy_picker(labels, labels, header)
# Return the key whose value matches the chosen label
for k, v in ranger.items():
if v == chosen_label:
return k
return keys[0]
Comment thread riocli/utils/selector.py
Comment on lines +119 to +126
def _matches(query: str, text: str) -> bool:
"""Simple case-insensitive substring / fuzzy match."""
query = query.lower()
text = text.lower()
# Fuzzy: every character of query must appear in order in text
it = iter(text)
return all(c in it for c in query)

Comment thread riocli/utils/selector.py Outdated
Comment on lines +159 to +160
_add(f"<ansibrightblack> &gt; </ansibrightblack>{_escape(state['query'])}\n")
_add(f"<ansibrightblack> {'─' * 60}</ansibrightblack>\n")
Comment thread riocli/utils/selector.py Outdated
style=style,
full_screen=False,
mouse_support=False,
refresh_interval=0.05,
Comment thread riocli/utils/selector.py
Comment on lines +46 to +52
# Use interactive fuzzy selector when stdout is a real TTY
if sys.stdout.isatty() and sys.stdin.isatty():
if isinstance(ranger, dict):
return _fuzzy_selection_dict(ranger, header)
if isinstance(ranger, list):
return _fuzzy_selection_list(ranger, header)

@guptadev21
guptadev21 requested a review from Copilot May 12, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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