An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: improve artifact search query and result count display
Yoshiki Miura279230abb1d1
diff --git a/components/artifact/search-artifact-content.tsx b/components/artifact/search-artifact-content.tsxindex ee2f06a6..f5c12a8a 100644--- a/components/artifact/search-artifact-content.tsx+++ b/components/artifact/search-artifact-content.tsx@@ -28,14 +28,16 @@ export function SearchArtifactContent({ tool }: { tool: ToolPart<'search'> }) {return (<div className="space-y-2">- <ToolArgsSection- tool="search"- number={- (searchResults.results?.length || 0) +- (searchResults.videos?.length || 0) +- (searchResults.images?.length || 0)- }- >{`${query}`}</ToolArgsSection>+ <div className="pb-2">+ <ToolArgsSection+ tool="search"+ number={+ (searchResults.results?.length || 0) ++ (searchResults.videos?.length || 0) ++ (searchResults.images?.length || 0)+ }+ >{`${query}`}</ToolArgsSection>+ </div>{searchResults.images && searchResults.images.length > 0 && (<SearchResultsImageSectiondiff --git a/components/section.tsx b/components/section.tsxindex 403111b9..4ca6d183 100644--- a/components/section.tsx+++ b/components/section.tsx@@ -109,13 +109,17 @@ export function ToolArgsSection({return (<Sectionsize="sm"- className="py-0 flex items-center justify-between w-full"+ className="py-0 flex items-center justify-between w-full gap-2">- <ToolBadge tool={tool}>{children}</ToolBadge>+ <div className="min-w-0 flex-1">+ <ToolBadge tool={tool}>{children}</ToolBadge>+ </div>{number && number > 0 && (- <StatusIndicator icon={Check} iconClassName="text-green-500">- {number} results- </StatusIndicator>+ <div className="flex-shrink-0">+ <StatusIndicator icon={Check} iconClassName="text-green-500">+ {number} results+ </StatusIndicator>+ </div>)}</Section>)diff --git a/components/tool-badge.tsx b/components/tool-badge.tsxindex dafb447a..5e62fbb1 100644--- a/components/tool-badge.tsx+++ b/components/tool-badge.tsx@@ -21,9 +21,9 @@ export const ToolBadge: React.FC<ToolBadgeProps> = ({}return (- <Badge className={className} variant={'secondary'}>- {icon[tool]}- <span className="ml-1">{children}</span>+ <Badge className={`inline-flex items-center max-w-full ${className || ''}`} variant={'secondary'}>+ <span className="flex-shrink-0">{icon[tool]}</span>+ <span className="ml-1 truncate">{children}</span></Badge>)}