Skip to content

An AI-powered search engine with a generative UI

fix: maintain rail space during collapse animation

Yoshiki Miuraadf4b5101ee3
diff --git a/components/reasoning-section.tsx b/components/reasoning-section.tsx
index c330e1c9..37503d2f 100644
--- a/components/reasoning-section.tsx
+++ b/components/reasoning-section.tsx
@@ -4,6 +4,8 @@ import { useEffect, useState } from 'react'
import type { ReasoningPart } from '@ai-sdk/provider-utils'
+import { cn } from '@/lib/utils'
+
import { useArtifact } from '@/components/artifact/artifact-context'
import { CollapsibleMessage } from './collapsible-message'
@@ -132,12 +134,15 @@ export function ReasoningSection({
showSeparator={false}
>
<div className="flex">
- {/* Rail when expanded and in a group */}
- {isOpen && !isSingle && (
+ {/* Rail space - always reserved when grouped */}
+ {!isSingle && (
<>
<div className="w-[16px] shrink-0 flex justify-center">
<div
- className="w-px bg-border/50"
+ className={cn(
+ "w-px bg-border/50 transition-opacity duration-200",
+ isOpen ? "opacity-100" : "opacity-0"
+ )}
style={{
marginTop: isFirst ? '0' : '-1rem',
marginBottom: isLast ? '0' : '-1rem'
diff --git a/components/search-section.tsx b/components/search-section.tsx
index 4e3fabb5..3af768e0 100644
--- a/components/search-section.tsx
+++ b/components/search-section.tsx
@@ -5,6 +5,7 @@ import { Check, Search as SearchIcon } from 'lucide-react'
import type { SearchResults as TypeSearchResults } from '@/lib/types'
import type { ToolPart, UIDataTypes, UIMessage, UITools } from '@/lib/types/ai'
+import { cn } from '@/lib/utils'
import { useArtifact } from '@/components/artifact/artifact-context'
@@ -107,12 +108,15 @@ export function SearchSection({
showSeparator={false}
>
<div className="flex">
- {/* Rail when expanded and in a group */}
- {isOpen && borderless && (
+ {/* Rail space - always reserved when grouped */}
+ {borderless && (
<>
<div className="w-[16px] shrink-0 flex justify-center">
<div
- className="w-px bg-border/50"
+ className={cn(
+ "w-px bg-border/50 transition-opacity duration-200",
+ isOpen ? "opacity-100" : "opacity-0"
+ )}
style={{
marginTop: isFirst ? '0' : '-1rem',
marginBottom: isLast ? '0' : '-1rem'
diff --git a/components/tool-todo-display.tsx b/components/tool-todo-display.tsx
index 79e2d636..8d5e23c6 100644
--- a/components/tool-todo-display.tsx
+++ b/components/tool-todo-display.tsx
@@ -1,6 +1,7 @@
import { Check, ListTodo } from 'lucide-react'
import { Part, TodoItem } from '@/lib/types/ai'
+import { cn } from '@/lib/utils'
import { useArtifact } from './artifact/artifact-context'
import { CollapsibleMessage } from './collapsible-message'
@@ -127,12 +128,15 @@ export function ToolTodoDisplay({
showSeparator={false}
>
<div className="flex">
- {/* Rail when expanded and in a group */}
- {isOpen && borderless && (
+ {/* Rail space - always reserved when grouped */}
+ {borderless && (
<>
<div className="w-[16px] shrink-0 flex justify-center">
<div
- className="w-px bg-border/50"
+ className={cn(
+ "w-px bg-border/50 transition-opacity duration-200",
+ isOpen ? "opacity-100" : "opacity-0"
+ )}
style={{
marginTop: isFirst ? '0' : '-1rem',
marginBottom: isLast ? '0' : '-1rem'