nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Feature] Navigable Slash Commands (Arrow Keys + Enter Selection)

Open rakshith1928 opened this issue 5 months ago • 0 comments

##Description

Add keyboard navigation (up/down arrows) and Enter selection to the slash command completion menu.

##Use Case

Currently, typing / shows command completions but users must either type the full command name or press Tab only when there's exactly one match.

##Proposed Solution

Files to modify:

  1. source/hooks/useUIState.ts - Add selectedCompletionIndex state
  2. source/components/user-input.tsx - Handle arrow keys + Enter, highlight selected item

Behavior:

  • / typed → completions show, index 0 auto-selected
  • ↓/↑ → navigate completions (wrap around), not history
  • Enter (when completions visible) → select → fill /command in input, hide list
  • Typing more chars → filter + reset to index 0
  • Esc → clear input, hide completions, reset index

##Alternatives Considered

  • Mouse click support
  • Tab to cycle: Already used for file autocomplete; Enter is standard for selection

##Additional Context

  • [x] Searched existing issues - no duplicate found
  • [x] Aligns with project goals (improved CLI UX, local-first polish)

##Implementation Notes The foundation already exists — just needs wiring:

  • Command registry already finds matches (/mod → /mode, /model, /model-database)
  • UserInput already computes matches and shows the list
  • UI state already shares the completion list between components Only 2 small additions needed:
  1. useUIState.ts — track which item is highlighted (index)
  2. user-input.tsx — arrow keys move highlight, Enter fills the command

Tests needed in:

  • source/hooks/useUIState.spec.ts (new state + reset)
  • source/components/user-input.spec.tsx (navigation, selection, rendering)

rakshith1928 avatar Jun 15 '26 11:06 rakshith1928