feat(cosh): add Tab-completion for shell mode#131
Conversation
- Implement useShellCompletion hook with command completion ($PATH executables, 30s cache) and file-system path completion (supports ~/, absolute and relative paths; directories suffixed with /) - Integrate shell completion into InputPrompt: Tab triggers/accepts completion, arrow keys navigate suggestions, Enter always falls through to execute the command without interception
samchu-zsl
left a comment
There was a problem hiding this comment.
A performance concern: will processing a large number of files - say, 10k or more - in the directory impact UI responsiveness?
Thanks for raising this! Since completions are only triggered on explicit Tab press (not on every keystroke), which limits exposure. I've filed this as a follow-up optimization item — moving the directory scan to an async path (or a Worker thread) to keep the UI fully responsive regardless of directory size. |
samchu-zsl
left a comment
There was a problem hiding this comment.
Basic functionality LGTM. Remaining performance optimizations will be tracked in the issue.
|
Progress on this optimization is being tracked in GitHub issue #138. |
Description
Add Tab-key auto-completion for cosh shell mode (
!).When the user enters shell mode by typing
!, pressingTabnow:$PATH) when the cursoris on the first token; results are cached for 30 s to avoid repeated
directory scans.
~/-prefixed, absolute and relative paths; directories are displayedwith a trailing
/and kept open for further tab-navigation.Enter— the command is always executableregardless of completion state.
@-file (AT-mode)completion inside shell mode; Tab falls through to the regular
handler when AT suggestions are already visible.
Related Issue
closes #22
Type of Change
Scope
cosh(copilot-shell)sec-core(agent-sec-core)skill(os-skills)sight(agentsight)Checklist
cosh: Lint passes, type check passes, and tests passsec-core(Rust):cargo clippy -- -D warningsandcargo fmt --checkpasssec-core(Python): Ruff format and pytest passskill: Skill directory structure is valid and shell scripts pass syntax checksight:cargo clippy -- -D warningsandcargo fmt --checkpasspackage-lock.json/Cargo.lock)Testing
npm run startinsrc/copilot-shell)!to enter shell modegi) and pressTab→ command listappears;
↑/↓to navigate,Tabagain to acceptls ~/) and pressTab→ file-systemcompletions appear; directories are suffixed with
/Tabon a directory suggestion to navigate deeperEnterat any time → command executes immediately@filename→ dropdown appears,Tabaccepts as before (no regression)Additional Notes
Tabpress;results are cached for 30 s at module level.
packages/cli/src/ui/hooks/useShellCompletion.ts