Uh oh!
There was an error while loading. Please reload this page.
📝 CodeRabbit Chat: Implement requested code changes - #599
📝 CodeRabbit Chat: Implement requested code changes#599coderabbitai[bot] wants to merge 1 commit into
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
CLAassistant
commented
May 7, 2026
|
ngoiyaeric
commented
May 9, 2026
@coderabbitai the reads is loading open instead of animating consecutively after the page loads to preview all the text as the user scrolls, fix this bug |
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me look at the relevant files to understand the current implementation. 🏁 Script executed: Length of output: 25352 Let me look at the collapsible message and chat message components. 🏁 Script executed: Length of output: 5945
Here is the fix across both files:
'use client'importReact,{useEffect,useRef,useState}from'react'import{Collapsible,CollapsibleTrigger,CollapsibleContent}from'@radix-ui/react-collapsible'import{Button}from'./ui/button'import{ChevronDown}from'lucide-react'import{StreamableValue,useStreamableValue}from'ai/rsc'import{motion,AnimatePresence,useInView}from'framer-motion'import{cn}from'@/lib/utils'import{Separator}from'./ui/separator'interfaceCollapsibleMessageProps{message: {id: stringisCollapsed?: StreamableValue<boolean>component: React.ReactNode}isLastMessage?: booleanindex?: number}exportconstCollapsibleMessage: React.FC<CollapsibleMessageProps>=({
message,
isLastMessage =false,
index =0})=>{const[data]=useStreamableValue(message.isCollapsed)constisCollapsed=data??false// Always start closed so the staggered open animation can playconst[open,setOpen]=useState(false)// Ref used to detect when this message scrolls into viewconstref=useRef<HTMLDivElement>(null)constisInView=useInView(ref,{once: true,margin: '-60px'})useEffect(()=>{if(isInView){// Stagger: each message waits a little longer based on its positionconsttimer=setTimeout(()=>setOpen(true),index*120// 0 ms, 120 ms, 240 ms …)return()=>clearTimeout(timer)}},[isInView,index])// When the user manually toggles, respect that immediatelyconsthandleOpenChange=(value: boolean)=>setOpen(value)// Non-collapsed messages (BotMessage, Section wrappers, etc.)// Animate in with a fade + slight upward slide as they enter the viewportif(!isCollapsed){return(<motion.divref={ref}initial={{opacity: 0,y: 16}}animate={isInView ? {opacity: 1,y: 0} : {opacity: 0,y: 16}}transition={{duration: 0.45,ease: 'easeOut',delay: index*0.08}}>{message.component}</motion.div>)}return(<divref={ref}><Collapsibleopen={open}onOpenChange={handleOpenChange}><CollapsibleTriggerasChild><divclassName="w-full flex justify-end"><Buttonvariant="ghost"size={'icon'}className={cn('-mt-3 rounded-full')}><ChevronDownsize={14}className={cn(open ? 'rotate-180' : 'rotate-0','h-4 w-4 transition-all')}/><spanclassName="sr-only">collapse</span></Button></div></CollapsibleTrigger>{/* Remove initial={false} so the animation fires on first mount */}<AnimatePresence>{open&&(<CollapsibleContentasChildforceMount><motion.divinitial={{opacity: 0,height: 0}}animate={{opacity: 1,height: 'auto'}}exit={{opacity: 0,height: 0}}transition={{duration: 0.35,ease: 'easeInOut'}}className="overflow-hidden">{message.component}</motion.div></CollapsibleContent>)}</AnimatePresence>{!open&&<SeparatorclassName="my-2 bg-muted"/>}</Collapsible></div>)}
return(<>{groupedMessagesArray.map((groupedMessage: {id: stringcomponents: React.ReactNode[]isCollapsed?: StreamableValue<boolean>},index// ← already available, just pass it down)=>(<CollapsibleMessagekey={`${groupedMessage.id}`}message={{id: groupedMessage.id,component: groupedMessage.components.map((component,i)=>(<divkey={`${groupedMessage.id}-${i}`}>{component}</div>)),isCollapsed: groupedMessage.isCollapsed}}isLastMessage={groupedMessage.id===messages[messages.length-1].id}index={index}// ← add this/>))}</>)What this achieves:
The requested changes have been implemented and a pull request has been created: View PR |
Code changes was requested by @ngoiyaeric.
The following files were modified:
app/actions.tsx