Skip to content

An AI-powered search engine with a generative UI

fix: prevent displaying '0' during search loading state

Yoshiki Miura59b4d1c5368a
diff --git a/components/search-section.tsx b/components/search-section.tsx
index 22aa7323..77740cf3 100644
--- a/components/search-section.tsx
+++ b/components/search-section.tsx
@@ -43,6 +43,12 @@ export function SearchSection({
: ''
const { open } = useArtifact()
+
+ const totalResults =
+ (searchResults?.results?.length || 0) +
+ (searchResults?.videos?.length || 0) +
+ (searchResults?.images?.length || 0)
+
const header = (
<button
type="button"
@@ -52,11 +58,7 @@ export function SearchSection({
>
<ToolArgsSection
tool="search"
- number={
- (searchResults?.results?.length || 0) +
- (searchResults?.videos?.length || 0) +
- (searchResults?.images?.length || 0)
- }
+ number={searchResults ? totalResults : undefined}
>{`${query}${includeDomainsString}`}</ToolArgsSection>
</button>
)