-
Notifications
You must be signed in to change notification settings - Fork 649
Open
Description
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
readdirSyncandstatSync - 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:
readdirSyncandstatSyncfor 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 -loadSystemCommandsfunction)
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/promisesoperations (readdir,stat) - Batch processing with event loop yielding
- Better error handling for individual file/directory failures
Metadata
Metadata
Assignees
Labels
No labels