Overview
Implement advanced tab completion capabilities for bssh's interactive mode, including remote path completion, command completion based on remote $PATH, and history-based completion suggestions. This will significantly improve the user experience by providing context-aware autocompletion similar to modern shells.
Technical Approach
Architecture Design
The implementation will use rustyline's built-in completion framework with custom completers that leverage SSH channels to fetch remote information. We'll implement a multi-tiered completion system:
-
Completion Engine Architecture
- Create a composite completer that delegates to specialized completers based on context
- Cache remote data to minimize SSH round-trips
- Implement async completion fetching with timeout handling
- Use a priority system: history > remote paths > remote commands
-
Data Caching Strategy
- Cache remote $PATH directories and executables for 5 minutes
- Cache recently accessed directory listings for 1 minute
- Maintain a sliding window of command history (last 1000 commands)
- Implement cache invalidation on directory changes
-
Context Detection
- Parse current command line to determine completion context
- Detect if completing a command, path, or argument
- Handle special characters and escape sequences
- Support both absolute and relative path completion
Key Features
Implementation Phases
Phase 1: Foundation and Architecture
Phase 2: Core Completion Implementations
Phase 3: Integration with Interactive Mode
Phase 4: Advanced Features and Optimization
Phase 5: Testing & Polish
Dependencies
External Dependencies
rustyline = "17.0" - Already present, provides completion framework
- Consider adding
fuzzy-matcher = "0.3" for fuzzy history matching
- Consider adding
lru = "0.12" for LRU cache implementation
- May need
shellexpand = "3.1" for path expansion
Internal Dependencies
- Existing SSH client implementation (
src/ssh/tokio_client/)
- Existing interactive mode infrastructure (
src/commands/interactive.rs)
- Configuration system (
src/config.rs)
- Node session management
Success Criteria
Functional Requirements
- Tab completion works for remote paths with <100ms latency (cached)
- Command completion includes all executables in remote $PATH
- History-based suggestions appear within 50ms
- Completion works correctly across node switches
- Cache persists between sessions
Performance Benchmarks
- Initial PATH scan completes within 2 seconds
- Subsequent completions served from cache in <10ms
- Memory usage for caches stays under 50MB
- No blocking of interactive input during completion
- Support for directories with 10,000+ files
User Experience
- Completion feels as responsive as local shell
- Clear visual feedback for completion types
- Intuitive behavior matching user expectations
- Graceful handling of network issues
- Consistent behavior across all nodes
Related Work
- Original task document:
.claude/tasks/todo/1_enhanced_tab_completion.md
Overview
Implement advanced tab completion capabilities for bssh's interactive mode, including remote path completion, command completion based on remote $PATH, and history-based completion suggestions. This will significantly improve the user experience by providing context-aware autocompletion similar to modern shells.
Technical Approach
Architecture Design
The implementation will use rustyline's built-in completion framework with custom completers that leverage SSH channels to fetch remote information. We'll implement a multi-tiered completion system:
Completion Engine Architecture
Data Caching Strategy
Context Detection
Key Features
Implementation Phases
Phase 1: Foundation and Architecture
src/completion/mod.rssrc/completion/parser.rssrc/completion/cache.rssrc/completion/remote_fetcher.rsPhase 2: Core Completion Implementations
src/completion/path_completer.rssrc/completion/command_completer.rssrc/completion/history_completer.rssrc/completion/composite_completer.rsPhase 3: Integration with Interactive Mode
InteractiveCommandto use custom completerInteractiveConfigPhase 4: Advanced Features and Optimization
Phase 5: Testing & Polish
Dependencies
External Dependencies
rustyline = "17.0"- Already present, provides completion frameworkfuzzy-matcher = "0.3"for fuzzy history matchinglru = "0.12"for LRU cache implementationshellexpand = "3.1"for path expansionInternal Dependencies
src/ssh/tokio_client/)src/commands/interactive.rs)src/config.rs)Success Criteria
Functional Requirements
Performance Benchmarks
User Experience
Related Work
.claude/tasks/todo/1_enhanced_tab_completion.md