Skip to content

feat(ui): add as-you-type filtering to the slash command menu - #91

Draft
aryansk wants to merge 1 commit into
shauryagangrade:mainfrom
aryansk:codex/issue-61-slash-filter
Draft

feat(ui): add as-you-type filtering to the slash command menu#91
aryansk wants to merge 1 commit into
shauryagangrade:mainfrom
aryansk:codex/issue-61-slash-filter

Conversation

@aryansk

@aryansk aryansk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

The interactive slash menu (/ then arrow keys) lists 12 commands with no
way to filter. Users who remember part of a command (e.g. "ollama") have to
scroll and read every entry. Closes #61.

Change

Enables questionary's built-in as-you-type search filter in
_show_slash_menu (gcode/ui.py):

  • Typing narrows the choices by case-insensitive substring match — "oll"
    filters to /ollama and anything else containing "oll".
  • Backspace edits the filter; Enter runs the highlighted command; Esc still
    cancels (returns "").
  • Arrow keys keep working; j/k navigation is disabled because questionary
    rejects combining it with the search filter (j/k are part of the prefix).
  • If nothing matches the filter, questionary falls back to the full list,
    so the menu is never empty.

The instruction line now reads (↑↓ navigate, type to filter, Enter select, Esc cancel).

Why this approach

questionary (already a dependency, pinned >=2.1.1) ships this filter —
no new dependency, no custom key-binding code, and the interaction (typing,
backspace, Enter, Esc) is the library's own well-tested behavior.

Testing

uv run pytest:  111 passed (4 new UI tests: filter flag passed, cancel
                returns "", labels searchable by substring, every label
                maps back to its command)
uv run ruff check .:  All checks passed
uv run ruff format --check .:  32 files already formatted
uv run mypy gcode:  Success: no issues found in 12 source files
uv run bandit -q -r gcode/ -c pyproject.toml:  clean
uv run python -m compileall -q gcode demo:  clean

Acceptance criteria covered: "oll" filters to /ollama (substring match on
the command label), and arrow keys/Esc behavior is preserved (tested via
the mocked select call and cancel paths).

Documentation and release impact

  • User-facing documentation updated
  • Changelog/release note needed
  • Migration or compatibility note needed
  • No documentation impact

Review notes

  • Known limitations: filtering is substring-based (questionary's built-in
    behavior), not fuzzy-scored; matches the issue's prefix example ("oll").
  • Merge note: draft PR test: cover ui.py rendering helpers and slash menu #86 (test-only, test_ui.py coverage) may touch
    tests/test_ui.py; a trivial rebase may be needed if both merge — happy
    to do it.
  • Follow-up issue: none.

Enables questionary's search filter so typing narrows the slash menu
(e.g. "oll" filters to /ollama) while arrow keys, Enter, and Esc keep
working; j/k navigation is disabled because the filter consumes those
keys. Closes shauryagangrade#61.
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.

[Feature]: Fuzzy/prefix filtering in the slash-command menu

1 participant