Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/app/src/components/project-picker-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function ProjectPickerModal() {

const inputRef = useRef<TextInput>(null);
const [query, setQuery] = useState("");
const [debouncedQuery, setDebouncedQuery] = useState("");
const [activeIndex, setActiveIndex] = useState(0);
const openProject = useOpenProject(serverId);

Expand All @@ -124,11 +125,11 @@ export function ProjectPickerModal() {
);

const directorySuggestionsQuery = useQuery({
queryKey: ["project-picker-directory-suggestions", serverId, query],
queryKey: ["project-picker-directory-suggestions", serverId, debouncedQuery],
queryFn: async () => {
if (!client) return [];
const result = await client.getDirectorySuggestions({
query,
query: debouncedQuery,
includeDirectories: true,
includeFiles: false,
limit: 30,
Expand Down Expand Up @@ -186,11 +187,19 @@ export function ProjectPickerModal() {
}

setQuery("");
setDebouncedQuery("");
setActiveIndex(0);
const id = setTimeout(() => inputRef.current?.focus(), 0);
return () => clearTimeout(id);
}, [open, resetSubmit]);

// Debounce the query that drives the (potentially multi-second) directory
// suggestions RPC so fast typing doesn't fire a filesystem scan per keystroke.
useEffect(() => {
const id = setTimeout(() => setDebouncedQuery(query), 250);
return () => clearTimeout(id);
}, [query]);

// Clamp active index
useEffect(() => {
if (!open) return;
Expand Down
8 changes: 6 additions & 2 deletions packages/client/src/daemon-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,9 @@ export class DaemonClient {
cwd,
},
responseType: "open_project_response",
timeout: 10000,
// Large local repos (e.g. a big monorepo/brain checkout) need >10s for the
// daemon to resolve the path, detect git, and materialize the workspace.
timeout: 60000,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 PR description has the timeout values swapped

The PR description states "openProject timeout from 10s to 30s" and "getDirectorySuggestions timeout from 10s to 60s", but the implementation does the opposite: openProject is raised to 60 000 ms and getDirectorySuggestions to 30 000 ms. The inline code comments and the logic both support the as-implemented values (opening a project does more work), so the code appears correct, but the PR description is misleading for anyone reviewing the change or reading git history.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

});
}

Expand Down Expand Up @@ -3462,7 +3464,9 @@ export class DaemonClient {
limit: options.limit,
},
responseType: "directory_suggestions_response",
timeout: 10000,
// Home-tree scans on large home dirs can take several seconds; don't cut
// the suggestion request off early (it would surface as an empty list).
timeout: 30000,
});
}

Expand Down