|
1 | | -import { useRef, useEffect, useMemo, useState } from 'react' |
| 1 | +import { useRef, useMemo, useState } from 'react' |
2 | 2 | import { ChatMessage } from './ChatMessage' |
3 | 3 | import { ChatInput } from './ChatInput' |
4 | 4 | import { ServerSelector } from './ServerSelector' |
@@ -442,12 +442,7 @@ export function Chat() { |
442 | 442 | const renderEvents: (StreamEvent | Message)[] = |
443 | 443 | streaming || streamBuffer.length > 0 ? [...streamBuffer] : messages |
444 | 444 |
|
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 |
451 | 446 |
|
452 | 447 | const onSendMessage = (prompt: string) => { |
453 | 448 | if (!hasStartedChat) { |
@@ -604,6 +599,36 @@ export function Chat() { |
604 | 599 | </div> |
605 | 600 | </div> |
606 | 601 | <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 | + )} |
607 | 632 | <ServerSelector |
608 | 633 | servers={servers} |
609 | 634 | onServersChange={setServers} |
|
0 commit comments