Skip to content

An AI-powered search engine with a generative UI

style: update background color for open sections and format code

Yoshiki Miura3cda19f720bb
diff --git a/components/collapsible-message.tsx b/components/collapsible-message.tsx
index 56716369..e9c450c9 100644
--- a/components/collapsible-message.tsx
+++ b/components/collapsible-message.tsx
@@ -69,7 +69,7 @@ export function CollapsibleMessage({
variant === 'process' && 'rounded-lg border bg-card',
variant === 'process-sub' && 'rounded-md border bg-card/50',
// Add background highlight when open and no border (grouped sections)
- isOpen && !showBorder && 'bg-accent/5'
+ isOpen && !showBorder && 'bg-background rounded-none'
)}
>
<Collapsible
diff --git a/components/fetch-section.tsx b/components/fetch-section.tsx
index 67e503e7..4181d228 100644
--- a/components/fetch-section.tsx
+++ b/components/fetch-section.tsx
@@ -17,14 +17,14 @@ interface FetchSectionProps {
isLast?: boolean
}
-export function FetchSection({
+export function FetchSection({
tool,
isOpen,
onOpenChange,
status,
borderless = false,
isFirst = false,
- isLast = false
+ isLast = false
}: FetchSectionProps) {
const url = tool.input?.url
diff --git a/components/process-rail.tsx b/components/process-rail.tsx
index ecbed42c..62c6079b 100644
--- a/components/process-rail.tsx
+++ b/components/process-rail.tsx
@@ -31,10 +31,15 @@ export function ProcessRail({
{/* Connector line below */}
{!isLast && (
- <div className="absolute w-px bg-border/50"
- style={{ top: '1.125rem', bottom: '-100%', height: 'calc(100% + 100%)' }}
+ <div
+ className="absolute w-px bg-border/50"
+ style={{
+ top: '1.125rem',
+ bottom: '-100%',
+ height: 'calc(100% + 100%)'
+ }}
/>
)}
</div>
)
-}
\ No newline at end of file
+}
diff --git a/components/render-message.tsx b/components/render-message.tsx
index 46108648..28453dbf 100644
--- a/components/render-message.tsx
+++ b/components/render-message.tsx
@@ -109,14 +109,20 @@ export function RenderMessage({
const remainingParts = message.parts?.slice(index + 1) || []
const hasMoreTextParts = remainingParts.some(p => p.type === 'text')
const isLastTextPart = !hasMoreTextParts
- const isStreamingComplete = status !== 'streaming' && status !== 'submitted'
- const shouldShowActions = isLastTextPart && (isLatestMessage ? isStreamingComplete : true)
+ const isStreamingComplete =
+ status !== 'streaming' && status !== 'submitted'
+ const shouldShowActions =
+ isLastTextPart && (isLatestMessage ? isStreamingComplete : true)
elements.push(
<AnswerSection
key={`${messageId}-text-${index}`}
content={part.text}
- isOpen={getIsOpen(messageId, part.type, index < (message.parts?.length ?? 0) - 1)}
+ isOpen={getIsOpen(
+ messageId,
+ part.type,
+ index < (message.parts?.length ?? 0) - 1
+ )}
onOpenChange={open => onOpenChange(messageId, open)}
chatId={chatId}
showActions={shouldShowActions}
diff --git a/components/research-process-section.tsx b/components/research-process-section.tsx
index c1a2010c..09f65ff1 100644
--- a/components/research-process-section.tsx
+++ b/components/research-process-section.tsx
@@ -59,7 +59,6 @@ function groupTools(segment: AnyPart[]): AnyPart[][] {
return groups
}
-
export function ResearchProcessSection({
message,
messageId,
@@ -72,14 +71,18 @@ export function ResearchProcessSection({
}: Props) {
const allParts = partsOverride ?? (message.parts || [])
const segments = partsOverride ? [allParts] : splitByText(allParts)
-
+
// Track which section is open within grouped sections (accordion behavior)
const [openSectionId, setOpenSectionId] = useState<string | null>(null)
if (segments.length === 0) return null
// Handle accordion-style open/close for grouped sections
- const handleAccordionChange = (id: string, open: boolean, isSingle: boolean) => {
+ const handleAccordionChange = (
+ id: string,
+ open: boolean,
+ isSingle: boolean
+ ) => {
if (isSingle) {
// For single sections, use the original behavior
onOpenChange(id, open)
@@ -116,16 +119,18 @@ export function ResearchProcessSection({
const hasNext = pidx < grp.length - 1
if (part.type === 'reasoning') {
const rid = `${messageId}-reasoning-${sidx}-${gidx}-${pidx}`
- const isOpen = isSingle
+ const isOpen = isSingle
? getIsOpen(rid, 'reasoning', hasNext)
: openSectionId === rid
-
+
return (
<ReasoningSection
key={rid}
content={{ reasoning: part.text, isDone: !hasNext }}
isOpen={isOpen}
- onOpenChange={open => handleAccordionChange(rid, open, isSingle)}
+ onOpenChange={open =>
+ handleAccordionChange(rid, open, isSingle)
+ }
isSingle={isSingle}
isFirst={isFirstGroup && pidx === 0}
isLast={isLastGroup && pidx === grp.length - 1}
@@ -138,13 +143,15 @@ export function ResearchProcessSection({
const isOpen = isSingle
? getIsOpen(id, part.type, hasNext)
: openSectionId === id
-
+
return (
<ToolSection
key={id}
tool={part}
isOpen={isOpen}
- onOpenChange={open => handleAccordionChange(id, open, isSingle)}
+ onOpenChange={open =>
+ handleAccordionChange(id, open, isSingle)
+ }
status={status}
addToolResult={addToolResult}
onQuerySelect={onQuerySelect}
diff --git a/components/search-section.tsx b/components/search-section.tsx
index 56ab77b8..4e3fabb5 100644
--- a/components/search-section.tsx
+++ b/components/search-section.tsx
@@ -106,62 +106,62 @@ export function SearchSection({
variant="default"
showSeparator={false}
>
- <div className="flex">
- {/* Rail when expanded and in a group */}
- {isOpen && borderless && (
- <>
- <div className="w-[16px] shrink-0 flex justify-center">
- <div
- className="w-px bg-border/50"
- style={{
- marginTop: isFirst ? '0' : '-1rem',
- marginBottom: isLast ? '0' : '-1rem'
- }}
- />
- </div>
- <div className="w-2 shrink-0" />
- </>
- )}
- <div className="flex-1">
- {searchResults &&
- searchResults.images &&
- searchResults.images.length > 0 && (
- <Section>
- <SearchResultsImageSection
- images={searchResults.images}
- query={query}
+ <div className="flex">
+ {/* Rail when expanded and in a group */}
+ {isOpen && borderless && (
+ <>
+ <div className="w-[16px] shrink-0 flex justify-center">
+ <div
+ className="w-px bg-border/50"
+ style={{
+ marginTop: isFirst ? '0' : '-1rem',
+ marginBottom: isLast ? '0' : '-1rem'
+ }}
/>
+ </div>
+ <div className="w-2 shrink-0" />
+ </>
+ )}
+ <div className="flex-1">
+ {searchResults &&
+ searchResults.images &&
+ searchResults.images.length > 0 && (
+ <Section>
+ <SearchResultsImageSection
+ images={searchResults.images}
+ query={query}
+ />
+ </Section>
+ )}
+ {searchResults &&
+ searchResults.videos &&
+ searchResults.videos.length > 0 && (
+ <Section title="Videos">
+ <VideoSearchResults
+ results={createVideoSearchResults(searchResults, query)}
+ />
+ </Section>
+ )}
+ {isError ? (
+ <Section>
+ <div className="bg-card rounded-lg">
+ <div className="flex items-center gap-2 w-full">
+ <span className="text-sm text-destructive block flex-1 min-w-0">
+ {errorMessage}
+ </span>
+ </div>
+ </div>
</Section>
- )}
- {searchResults &&
- searchResults.videos &&
- searchResults.videos.length > 0 && (
- <Section title="Videos">
- <VideoSearchResults
- results={createVideoSearchResults(searchResults, query)}
- />
+ ) : isLoading && isToolLoading ? (
+ <SearchSkeleton />
+ ) : searchResults?.results && searchResults.results.length > 0 ? (
+ <Section title="Sources">
+ <SearchResults results={searchResults.results} />
</Section>
- )}
- {isError ? (
- <Section>
- <div className="bg-card rounded-lg">
- <div className="flex items-center gap-2 w-full">
- <span className="text-sm text-destructive block flex-1 min-w-0">
- {errorMessage}
- </span>
- </div>
- </div>
- </Section>
- ) : isLoading && isToolLoading ? (
- <SearchSkeleton />
- ) : searchResults?.results && searchResults.results.length > 0 ? (
- <Section title="Sources">
- <SearchResults results={searchResults.results} />
- </Section>
- ) : null}
+ ) : null}
+ </div>
</div>
- </div>
- </CollapsibleMessage>
+ </CollapsibleMessage>
</div>
)
}
diff --git a/components/tool-todo-display.tsx b/components/tool-todo-display.tsx
index 558a121f..79e2d636 100644
--- a/components/tool-todo-display.tsx
+++ b/components/tool-todo-display.tsx
@@ -126,45 +126,45 @@ export function ToolTodoDisplay({
variant="default"
showSeparator={false}
>
- <div className="flex">
- {/* Rail when expanded and in a group */}
- {isOpen && borderless && (
- <>
- <div className="w-[16px] shrink-0 flex justify-center">
- <div
- className="w-px bg-border/50"
- style={{
- marginTop: isFirst ? '0' : '-1rem',
- marginBottom: isLast ? '0' : '-1rem'
- }}
+ <div className="flex">
+ {/* Rail when expanded and in a group */}
+ {isOpen && borderless && (
+ <>
+ <div className="w-[16px] shrink-0 flex justify-center">
+ <div
+ className="w-px bg-border/50"
+ style={{
+ marginTop: isFirst ? '0' : '-1rem',
+ marginBottom: isLast ? '0' : '-1rem'
+ }}
+ />
+ </div>
+ <div className="w-2 shrink-0" />
+ </>
+ )}
+ <div className="flex-1">
+ {state === 'output-available' ? (
+ <TodoListContent
+ todos={output?.todos}
+ message={
+ tool === 'todoRead'
+ ? (output as any)?.summary || output?.message
+ : output?.message
+ }
+ completedCount={completedCount}
+ totalCount={totalCount}
+ showSummary={false}
+ itemVariant="plain"
+ className="pb-1"
/>
- </div>
- <div className="w-2 shrink-0" />
- </>
- )}
- <div className="flex-1">
- {state === 'output-available' ? (
- <TodoListContent
- todos={output?.todos}
- message={
- tool === 'todoRead'
- ? (output as any)?.summary || output?.message
- : output?.message
- }
- completedCount={completedCount}
- totalCount={totalCount}
- showSummary={false}
- itemVariant="plain"
- className="pb-1"
- />
- ) : state === 'output-error' ? (
- <div className="px-3 pb-3 text-xs text-destructive">{`Todo tool failed${
- (output as any)?.message ? `: ${(output as any).message}` : ''
- }`}</div>
- ) : null}
+ ) : state === 'output-error' ? (
+ <div className="px-3 pb-3 text-xs text-destructive">{`Todo tool failed${
+ (output as any)?.message ? `: ${(output as any).message}` : ''
+ }`}</div>
+ ) : null}
+ </div>
</div>
- </div>
- </CollapsibleMessage>
+ </CollapsibleMessage>
</div>
)
}