Skip to content

Commit 1034055

Browse files
authored
fix: auto-scroll messages is disabled now (#91)
1 parent fd6b803 commit 1034055

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

src/components/Chat.tsx

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useRef, useEffect, useMemo, useState } from 'react'
1+
import { useRef, useMemo, useState } from 'react'
22
import { ChatMessage } from './ChatMessage'
33
import { ChatInput } from './ChatInput'
44
import { ServerSelector } from './ServerSelector'
@@ -442,12 +442,7 @@ export function Chat() {
442442
const renderEvents: (StreamEvent | Message)[] =
443443
streaming || streamBuffer.length > 0 ? [...streamBuffer] : messages
444444

445-
// Auto-scroll to the bottom when messages or streamBuffer change
446-
useEffect(() => {
447-
if (messagesEndRef.current) {
448-
messagesEndRef.current.scrollIntoView({ behavior: 'smooth' })
449-
}
450-
}, [messages, streamBuffer])
445+
// Removed auto-scroll effect; replaced with manual scroll button
451446

452447
const onSendMessage = (prompt: string) => {
453448
if (!hasStartedChat) {
@@ -604,6 +599,36 @@ export function Chat() {
604599
</div>
605600
</div>
606601
<div className="sticky bottom-0 left-0 right-0">
602+
{(hasStartedChat || streaming) && (
603+
<div className="sticky bottom-16 left-0 right-0 flex justify-center px-4 pb-2 z-20">
604+
<Button
605+
variant="ghost"
606+
size="icon"
607+
aria-label="Scroll to bottom"
608+
className="rounded-full shadow"
609+
onClick={() => {
610+
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
611+
}}
612+
>
613+
<svg
614+
xmlns="http://www.w3.org/2000/svg"
615+
width="24"
616+
height="24"
617+
viewBox="0 0 24 24"
618+
fill="none"
619+
stroke="currentColor"
620+
strokeWidth="2"
621+
strokeLinecap="round"
622+
strokeLinejoin="round"
623+
className="lucide lucide-chevron-down"
624+
aria-hidden="true"
625+
>
626+
<path d="M6 9l6 6 6-6" />
627+
</svg>
628+
<span className="sr-only">Scroll to bottom</span>
629+
</Button>
630+
</div>
631+
)}
607632
<ServerSelector
608633
servers={servers}
609634
onServersChange={setServers}

0 commit comments

Comments
 (0)