An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: do not render MessageActions when hidden or streaming to avoid invisible action row in text parts
Yoshiki Miuradb985d47dbfd
diff --git a/components/message-actions.tsx b/components/message-actions.tsxindex 4f19bf91..a8cccf27 100644--- a/components/message-actions.tsx+++ b/components/message-actions.tsx@@ -44,6 +44,15 @@ export function MessageActions({const [isSubmittingFeedback, setIsSubmittingFeedback] = useState(false)const isLoading = status === 'submitted' || status === 'streaming'+ // Do not render at all when actions should be hidden or while loading.+ // Previously we rendered with `opacity-0`, which still occupied layout+ // space and caused an invisible actions row to be placed for the first+ // text part. Returning null matches the intended behavior of not+ // rendering at all.+ if (!visible || isLoading) {+ return null+ }+async function handleCopy() {await navigator.clipboard.writeText(message)toast.success('Message copied to clipboard')@@ -87,7 +96,7 @@ export function MessageActions({<divclassName={cn('flex items-center gap-0.5 self-end transition-opacity duration-200',- !visible || isLoading ? 'opacity-0' : 'opacity-100',+ 'opacity-100',className)}>