Skip to content

An AI-powered search engine with a generative UI

Keep single tool sections open and stabilize image previews

Yoshiki Miura658f620f8ca2
diff --git a/app/globals.css b/app/globals.css
index c400795f..ec3117be 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -423,7 +423,7 @@
/* Tailwind v4: Restore pointer cursor for buttons */
button:not(:disabled),
- [role="button"]:not(:disabled) {
+ [role='button']:not(:disabled) {
cursor: pointer;
}
}
diff --git a/components/chat-messages.tsx b/components/chat-messages.tsx
index 3360ca2f..1eab5374 100644
--- a/components/chat-messages.tsx
+++ b/components/chat-messages.tsx
@@ -146,9 +146,8 @@ export function ChatMessages({
if (toolCount > 1) {
return false
}
- // Single tool: check if there's a next part
- // If there's subsequent content, default to closed
- return !hasNextPart
+ // Single tool results stay open even if more content follows
+ return true
}
// For tool-invocations, default to open
diff --git a/components/search-results-image.tsx b/components/search-results-image.tsx
index 568d9ffe..f726894d 100644
--- a/components/search-results-image.tsx
+++ b/components/search-results-image.tsx
@@ -7,6 +7,7 @@ import {
useCallback,
useEffect,
useMemo,
+ useRef,
useState
} from 'react'
@@ -71,6 +72,7 @@ const normalizeImages = (images: SearchResultImage[]): NormalizedImage[] => {
const useFilteredImages = (images: SearchResultImage[]) => {
const normalizedImages = useMemo(() => normalizeImages(images), [images])
+ const previousIdsRef = useRef<string | null>(null)
const [state, setState] = useState<FilteredImagesState>(() => ({
status: normalizedImages.length === 0 ? 'empty' : 'loading',
@@ -78,16 +80,37 @@ const useFilteredImages = (images: SearchResultImage[]) => {
}))
useEffect(() => {
+ const normalizedKey = normalizedImages.map(image => image.id).join('|')
+
if (normalizedImages.length === 0) {
setState({ status: 'empty', images: [] })
+ previousIdsRef.current = normalizedKey
return
}
if (typeof window === 'undefined') {
setState({ status: 'ready', images: normalizedImages })
+ previousIdsRef.current = normalizedKey
return
}
+ if (previousIdsRef.current === normalizedKey) {
+ setState(prevState => {
+ if (prevState.status === 'ready') {
+ return prevState
+ }
+
+ return {
+ status: 'ready',
+ images:
+ prevState.images.length > 0 ? prevState.images : normalizedImages
+ }
+ })
+ return
+ }
+
+ previousIdsRef.current = normalizedKey
+
let cancelled = false
setState({ status: 'loading', images: [] })