nanocoder
nanocoder copied to clipboard
[Feature] Navigable Slash Commands (Arrow Keys + Enter Selection)
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:
- source/hooks/useUIState.ts - Add selectedCompletionIndex state
- 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] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
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:
- useUIState.ts — track which item is highlighted (index)
- 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) highlights not working
Can i work on this