fix(client): raise project-open & directory-suggestion timeouts for large repos (#1620)
openProject 10s->60s and getDirectorySuggestions 10s->30s + debounce the project-picker query 250ms. On large local repos the daemon's path-resolve and home-tree scan take several seconds; firing per-keystroke against a 10s timeout raced the suggestion list to empty (e.g. ~/gi found a hit but ~/gith blanked) and surfaced a spurious 'Timeout waiting for message (10000ms)' on add. Co-authored-by: jms830 <jms830@noreply.github.com>
This commit is contained in:
@@ -82,17 +82,18 @@ export function ProjectPickerModal() {
|
|||||||
|
|
||||||
const inputRef = useRef<TextInput>(null);
|
const inputRef = useRef<TextInput>(null);
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
|
const [debouncedQuery, setDebouncedQuery] = useState("");
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [openErrorReason, setOpenErrorReason] = useState<OpenProjectFailureReason | null>(null);
|
const [openErrorReason, setOpenErrorReason] = useState<OpenProjectFailureReason | null>(null);
|
||||||
const openProject = useOpenProject(serverId);
|
const openProject = useOpenProject(serverId);
|
||||||
|
|
||||||
const directorySuggestionsQuery = useQuery({
|
const directorySuggestionsQuery = useQuery({
|
||||||
queryKey: ["project-picker-directory-suggestions", serverId, query],
|
queryKey: ["project-picker-directory-suggestions", serverId, debouncedQuery],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!client) return [];
|
if (!client) return [];
|
||||||
const result = await client.getDirectorySuggestions({
|
const result = await client.getDirectorySuggestions({
|
||||||
query,
|
query: debouncedQuery,
|
||||||
includeDirectories: true,
|
includeDirectories: true,
|
||||||
includeFiles: false,
|
includeFiles: false,
|
||||||
limit: 30,
|
limit: 30,
|
||||||
@@ -165,6 +166,7 @@ export function ProjectPickerModal() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
setQuery("");
|
setQuery("");
|
||||||
|
setDebouncedQuery("");
|
||||||
setActiveIndex(0);
|
setActiveIndex(0);
|
||||||
setOpenErrorReason(null);
|
setOpenErrorReason(null);
|
||||||
const id = setTimeout(() => inputRef.current?.focus(), 0);
|
const id = setTimeout(() => inputRef.current?.focus(), 0);
|
||||||
@@ -172,6 +174,13 @@ export function ProjectPickerModal() {
|
|||||||
}
|
}
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
|
// 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]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
if (activeIndex >= options.length) {
|
if (activeIndex >= options.length) {
|
||||||
|
|||||||
@@ -1886,7 +1886,9 @@ export class DaemonClient {
|
|||||||
cwd,
|
cwd,
|
||||||
},
|
},
|
||||||
responseType: "open_project_response",
|
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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3512,7 +3514,9 @@ export class DaemonClient {
|
|||||||
limit: options.limit,
|
limit: options.limit,
|
||||||
},
|
},
|
||||||
responseType: "directory_suggestions_response",
|
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,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user