Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: autoscroll in chat (#3030)

Myles Scolnick9b60b80a7a0a
diff --git a/frontend/src/components/chat/chat-panel.tsx b/frontend/src/components/chat/chat-panel.tsx
index d83739842d..b20b34a6b7 100644
--- a/frontend/src/components/chat/chat-panel.tsx
+++ b/frontend/src/components/chat/chat-panel.tsx
@@ -32,6 +32,7 @@ export const ChatPanel = () => {
const [newThreadInput, setNewThreadInput] = useState("");
const newThreadInputRef = useRef<ReactCodeMirrorRef>(null);
const newMessageInputRef = useRef<ReactCodeMirrorRef>(null);
+ const messagesEndRef = useRef<HTMLDivElement>(null);
const {
messages,
@@ -88,6 +89,13 @@ export const ChatPanel = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [activeChat?.id]);
+ const lastMessageText = messages.at(-1)?.content;
+ useEffect(() => {
+ if (isLoading) {
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
+ }
+ }, [messages, isLoading, lastMessageText]);
+
const createNewThread = (initialMessage: string) => {
const newChat: Chat = {
id: generateUUID(),
@@ -268,6 +276,8 @@ export const ChatPanel = () => {
</Button>
</div>
)}
+
+ <div ref={messagesEndRef} />
</div>
{messages && messages.length > 0 && (
diff --git a/frontend/vite.config.mts b/frontend/vite.config.mts
index 5e54366b9d..922f86303a 100644
--- a/frontend/vite.config.mts
+++ b/frontend/vite.config.mts
@@ -128,7 +128,6 @@ If the server is already running, make sure it is using port ${SERVER_PORT} with
// copies these elements from server to dev
const copyElements = [
- "base",
"title",
"marimo-filename",
"marimo-version",