Issue: Synchronous Unix command loading blocks UI during completion
Problem Description
When users trigger command completion (e.g., typing / or @), the system scans all PATH directories synchronously, causing UI freezing/hanging. This results in delayed or unresponsive command suggestions, especially on systems with many PATH entries or slow filesystems.
Current Behavior
- Command completion triggers synchronous scanning of all PATH directories using
readdirSync and statSync
- UI becomes unresponsive during scanning
- Users must wait for full PATH scanning to complete before seeing command suggestions
- No immediate fallback commands are provided
Expected Behavior
- Command completion should be responsive and non-blocking
- Users should see immediate basic command suggestions while full list loads in background
- UI should remain responsive during command loading
Root Cause
The loadSystemCommands function in src/ui/hooks/useUnifiedCompletion.ts (lines 118-175) uses blocking synchronous file operations:
readdirSync and statSync for scanning PATH directories
- No event loop yielding during batch processing
- No immediate fallback command provision
Impact
- User Experience: Poor with laggy/unresponsive command completion
- Performance: UI freezes during PATH scanning
- Responsiveness: Slower startup/initialization of completion features
Files Affected
src/ui/hooks/useUnifiedCompletion.ts (lines 118-175 - loadSystemCommands function)
Reproduction Steps
- Open the CLI application
- Type
/ to trigger command completion
- Observe UI freezing/hanging while system scans PATH directories
- Notice delayed appearance of command suggestions
Environment
- OS: Any (more noticeable on systems with many PATH entries)
- Application: CLI with command completion feature
- Affected Version: Current main branch
Priority
Medium-High - Affects core user interaction with command completion
Suggested Solution
Convert synchronous file operations to asynchronous with:
- Immediate provision of minimal fallback commands
- Async
fs/promises operations (readdir, stat)
- Batch processing with event loop yielding
- Better error handling for individual file/directory failures
Issue: Synchronous Unix command loading blocks UI during completion
Problem Description
When users trigger command completion (e.g., typing
/or@), the system scans all PATH directories synchronously, causing UI freezing/hanging. This results in delayed or unresponsive command suggestions, especially on systems with many PATH entries or slow filesystems.Current Behavior
readdirSyncandstatSyncExpected Behavior
Root Cause
The
loadSystemCommandsfunction insrc/ui/hooks/useUnifiedCompletion.ts(lines 118-175) uses blocking synchronous file operations:readdirSyncandstatSyncfor scanning PATH directoriesImpact
Files Affected
src/ui/hooks/useUnifiedCompletion.ts(lines 118-175 -loadSystemCommandsfunction)Reproduction Steps
/to trigger command completionEnvironment
Priority
Medium-High - Affects core user interaction with command completion
Suggested Solution
Convert synchronous file operations to asynchronous with:
fs/promisesoperations (readdir,stat)