From 9fc7115b8654fc193f948570293485f16d89f60a Mon Sep 17 00:00:00 2001 From: Bryant Chandler Date: Thu, 7 Aug 2025 15:24:55 -0700 Subject: perf(filesearch): Use async fzf for non-blocking file search (#5771) Co-authored-by: Jacob Richman --- packages/cli/src/ui/hooks/useAtCompletion.test.ts | 6 +++--- packages/cli/src/ui/hooks/useAtCompletion.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'packages/cli/src/ui/hooks') diff --git a/packages/cli/src/ui/hooks/useAtCompletion.test.ts b/packages/cli/src/ui/hooks/useAtCompletion.test.ts index aa198fc1..599f8fdf 100644 --- a/packages/cli/src/ui/hooks/useAtCompletion.test.ts +++ b/packages/cli/src/ui/hooks/useAtCompletion.test.ts @@ -157,7 +157,7 @@ describe('useAtCompletion', () => { }); }); - it('should NOT show a loading indicator for subsequent searches that complete under 100ms', async () => { + it('should NOT show a loading indicator for subsequent searches that complete under 200ms', async () => { const structure: FileSystemStructure = { 'a.txt': '', 'b.txt': '' }; testRootDir = await createTmpDir(structure); @@ -186,7 +186,7 @@ describe('useAtCompletion', () => { expect(result.current.isLoadingSuggestions).toBe(false); }); - it('should show a loading indicator and clear old suggestions for subsequent searches that take longer than 100ms', async () => { + it('should show a loading indicator and clear old suggestions for subsequent searches that take longer than 200ms', async () => { const structure: FileSystemStructure = { 'a.txt': '', 'b.txt': '' }; testRootDir = await createTmpDir(structure); @@ -194,7 +194,7 @@ describe('useAtCompletion', () => { const originalSearch = FileSearch.prototype.search; vi.spyOn(FileSearch.prototype, 'search').mockImplementation( async function (...args) { - await new Promise((resolve) => setTimeout(resolve, 200)); + await new Promise((resolve) => setTimeout(resolve, 300)); return originalSearch.apply(this, args); }, ); diff --git a/packages/cli/src/ui/hooks/useAtCompletion.ts b/packages/cli/src/ui/hooks/useAtCompletion.ts index 82439c14..f6835dc8 100644 --- a/packages/cli/src/ui/hooks/useAtCompletion.ts +++ b/packages/cli/src/ui/hooks/useAtCompletion.ts @@ -194,7 +194,7 @@ export function useAtCompletion(props: UseAtCompletionProps): void { slowSearchTimer.current = setTimeout(() => { dispatch({ type: 'SET_LOADING', payload: true }); - }, 100); + }, 200); try { const results = await fileSearch.current.search(state.pattern, { -- cgit v1.2.3