Search: loading state
This commit is contained in:
@@ -306,6 +306,7 @@ export default function App() {
|
||||
}, [selectedChat, selectedChatSummary, selectedItem, selectedSearch, selectedSearchSummary]);
|
||||
|
||||
const isSearchMode = selectedItem?.kind === "search";
|
||||
const isSearchRunning = isSending && selectedItem?.kind === "search";
|
||||
|
||||
const handleCreateChat = async () => {
|
||||
setError(null);
|
||||
@@ -444,13 +445,27 @@ export default function App() {
|
||||
throw new Error("Unable to initialize search");
|
||||
}
|
||||
|
||||
const nowIso = new Date().toISOString();
|
||||
setSelectedSearch((current) => {
|
||||
if (!current || current.id !== searchId) return current;
|
||||
if (!current || current.id !== searchId) {
|
||||
return {
|
||||
id: searchId,
|
||||
title: query.slice(0, 80),
|
||||
query,
|
||||
createdAt: nowIso,
|
||||
updatedAt: nowIso,
|
||||
requestId: null,
|
||||
latencyMs: null,
|
||||
error: null,
|
||||
results: [],
|
||||
};
|
||||
}
|
||||
return {
|
||||
...current,
|
||||
title: query.slice(0, 80),
|
||||
query,
|
||||
error: null,
|
||||
latencyMs: null,
|
||||
results: [],
|
||||
};
|
||||
});
|
||||
@@ -725,8 +740,8 @@ export default function App() {
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isLoadingSelection && !selectedSearch?.results.length ? (
|
||||
<p className="text-sm text-muted-foreground">Loading search...</p>
|
||||
{(isLoadingSelection || isSearchRunning) && !selectedSearch?.results.length ? (
|
||||
<p className="text-sm text-muted-foreground">{isSearchRunning ? "Searching Exa..." : "Loading search..."}</p>
|
||||
) : null}
|
||||
|
||||
{!isLoadingSelection && !selectedSearch?.query ? (
|
||||
@@ -737,7 +752,7 @@ export default function App() {
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!isLoadingSelection && !!selectedSearch?.query && selectedSearch.results.length === 0 ? (
|
||||
{!isLoadingSelection && !isSearchRunning && !!selectedSearch?.query && selectedSearch.results.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">No results found.</p>
|
||||
) : null}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user