-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
priority:mediumMedium priority issueMedium priority issuestatus:readyReady to be worked onReady to be worked ontype:enhancementNew feature or requestNew feature or request
Description
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
- Tab completion 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
Implementation Phases
Phase 1: Foundation and Architecture
- Create completion module structure at
src/completion/mod.rs - Implement context parser at
src/completion/parser.rs - Create cache manager at
src/completion/cache.rs - Implement SSH data fetcher at
src/completion/remote_fetcher.rs
Phase 2: Core Completion Implementations
- Implement remote path completer at
src/completion/path_completer.rs - Implement remote command completer at
src/completion/command_completer.rs - Implement history-based completer at
src/completion/history_completer.rs - Create composite completer at
src/completion/composite_completer.rs
Phase 3: Integration with Interactive Mode
- Extend
InteractiveCommandto use custom completer - Add completion configuration to
InteractiveConfig - Implement async completion updates
- Add multi-node completion support
Phase 4: Advanced Features and Optimization
- Implement smart completion features (git, docker, kubectl argument completion)
- Add visual completion enhancements (color-coding, hints, preview)
- Optimize performance (incremental updates, bloom filters, batching)
- Add completion debugging and metrics
Phase 5: Testing & Polish
- Write comprehensive unit tests
- Add integration tests
- Update documentation
- Polish user experience
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
Metadata
Metadata
Assignees
Labels
priority:mediumMedium priority issueMedium priority issuestatus:readyReady to be worked onReady to be worked ontype:enhancementNew feature or requestNew feature or request