mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend/builder): auto-scroll to bottom when AI responds in chat panel
This commit is contained in:
@@ -9,7 +9,7 @@ import {
|
||||
StopCircle,
|
||||
X,
|
||||
} from "@phosphor-icons/react";
|
||||
import { KeyboardEvent, useRef, useState } from "react";
|
||||
import { KeyboardEvent, useEffect, useRef, useState } from "react";
|
||||
import type { CustomNode } from "../FlowEditor/nodes/CustomNode/CustomNode";
|
||||
import { GraphAction } from "./helpers";
|
||||
import { useBuilderChatPanel } from "./useBuilderChatPanel";
|
||||
@@ -38,6 +38,11 @@ export function BuilderChatPanel({ className, isGraphLoaded }: Props) {
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const isStreaming = status === "streaming" || status === "submitted";
|
||||
|
||||
// Scroll to bottom whenever a new message lands (AI response or user send)
|
||||
useEffect(() => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [messages.length]);
|
||||
|
||||
function handleSend() {
|
||||
const text = inputValue.trim();
|
||||
if (!text || isStreaming) return;
|
||||
|
||||
Reference in New Issue
Block a user