fix: reset isLoading state in file autocomplete early-return paths (#631)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -81,6 +81,7 @@ export function FileAutocomplete({
|
||||
|
||||
if (!result) {
|
||||
setMatches([]);
|
||||
setIsLoading(false);
|
||||
onActiveChange?.(false);
|
||||
return;
|
||||
}
|
||||
@@ -96,6 +97,7 @@ export function FileAutocomplete({
|
||||
// Always hide if there's more non-whitespace content after, or another @
|
||||
if (afterSpace.trim().length > 0 || afterSpace.includes("@")) {
|
||||
setMatches([]);
|
||||
setIsLoading(false);
|
||||
onActiveChange?.(false);
|
||||
return;
|
||||
}
|
||||
@@ -107,12 +109,14 @@ export function FileAutocomplete({
|
||||
if (matches[0]?.path !== query) {
|
||||
setMatches([{ path: query, type: "file" }]);
|
||||
}
|
||||
setIsLoading(false);
|
||||
onActiveChange?.(false); // Don't block Enter key
|
||||
return;
|
||||
}
|
||||
|
||||
// No valid selection was made, hide
|
||||
setMatches([]);
|
||||
setIsLoading(false);
|
||||
onActiveChange?.(false);
|
||||
return;
|
||||
}
|
||||
@@ -138,6 +142,7 @@ export function FileAutocomplete({
|
||||
// Check if it's a URL pattern (no debounce)
|
||||
if (query.startsWith("http://") || query.startsWith("https://")) {
|
||||
setMatches([{ path: query, type: "url" }]);
|
||||
setIsLoading(false);
|
||||
onActiveChange?.(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user