Skip to content

perf: make unix command loading non-blocking in completion hook#165

Open
jlguo wants to merge 1 commit into
shareAI-lab:mainfrom
jlguo:perf/non-blocking-unix-command-loading
Open

perf: make unix command loading non-blocking in completion hook#165
jlguo wants to merge 1 commit into
shareAI-lab:mainfrom
jlguo:perf/non-blocking-unix-command-loading

Conversation

@jlguo

@jlguo jlguo commented Jan 19, 2026

Copy link
Copy Markdown

Summary

  • Performance improvement: Convert synchronous Unix command loading to asynchronous
  • User experience: Eliminates UI blocking during PATH directory scanning
  • Responsiveness: Provides immediate fallback commands while full list loads

Changes

  • Replace readdirSync/statSync with async fs/promises operations
  • Use minimal fallback commands immediately to avoid UI blocking
  • Process PATH directories in batches with event loop yielding
  • Add robust error handling for individual file/directory failures
  • Preserve fallback commands on load failure instead of resetting

Benefits

  1. No more UI freezing when triggering command completion
  2. Immediate command suggestions via fallback commands
  3. Better error resilience - individual failures don't break entire process
  4. Improved responsiveness on systems with many PATH entries or slow filesystems

Technical Details

  • Before: Synchronous blocking operations that freeze UI during PATH scanning
  • After: Asynchronous non-blocking operations with progressive loading
  • Batch processing: 10 entries per batch with setImmediate yielding
  • Error handling: Individual file/directory errors caught and ignored

Coworker: @claude
Issue: #164

- Replace synchronous fs operations with async/await for better responsiveness
- Use minimal fallback commands immediately to avoid UI blocking
- Process PATH directories in batches with yields to event loop
- Add error handling for individual file/directory access failures
- Keep minimal fallback commands as fallback on load failure
@im10furry

im10furry commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

I see you are use claude,make sure it test pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants