Skip to content

Commit ca503bc

Browse files
committed
Add missing welcomeMessage dependency in sheetbuilder useeffect
1 parent 069ac2c commit ca503bc

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

llmstack/client/src/components/sheets/SheetBuilder.jsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import React, { useCallback, useState, useEffect, useRef } from "react";
1+
import React, {
2+
useCallback,
3+
useState,
4+
useEffect,
5+
useRef,
6+
useMemo,
7+
} from "react";
28
import { Ws } from "../../data/ws";
39
import { PaperAirplaneIcon } from "@heroicons/react/24/outline";
410
import LayoutRenderer from "../apps/renderer/LayoutRenderer";
@@ -17,17 +23,19 @@ function SheetBuilder({ sheetId, open, addOrUpdateColumns, addOrUpdateCells }) {
1723
}/ws`;
1824
const [suggestedMessages, setSuggestedMessages] = useState([]);
1925

20-
const welcomeMessage = {
21-
role: "assistant",
22-
content:
23-
"👋 Welcome to the Sheet Builder! I'm here to help you create and modify your sheet. 🚀\n\nYou can ask me to create new columns, update existing ones, or add data to your sheet. For example, you could say:\n\n- 📊 Create a new column for employee names\n- 💰 Add a column for calculating total sales\n- 🔄 Update the 'Status' column to use a formula\n\nHow can I assist you with your sheet today? 😊",
24-
};
26+
const welcomeMessage = useMemo(() => {
27+
return {
28+
role: "assistant",
29+
content:
30+
"👋 Welcome to the Sheet Builder! I'm here to help you create and modify your sheet. 🚀\n\nYou can ask me to create new columns, update existing ones, or add data to your sheet. For example, you could say:\n\n- 📊 Create a new column for employee names\n- 💰 Add a column for calculating total sales\n- 🔄 Update the 'Status' column to use a formula\n\nHow can I assist you with your sheet today? 😊",
31+
};
32+
}, []);
2533

2634
useEffect(() => {
2735
if (open && messages.length === 0) {
2836
setMessages([welcomeMessage]);
2937
}
30-
}, [open, messages.length]);
38+
}, [open, messages.length, welcomeMessage]);
3139

3240
const handleBuilderUpdates = useCallback(
3341
(updates) => {

0 commit comments

Comments
 (0)