MCPcopy Create free account
hub / github.com/celerforge/freenote / handleSaveMessage

Function handleSaveMessage

src/components/chat/chat-container.tsx:96–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94 const { updateChat, insertChatMessage } = useChatStore();
95
96 const handleSaveMessage = async () => {
97 await insertChatMessage({
98 content: input,
99 createdAt: new Date(),
100 role: "user",
101 chatId: chat.id,
102 });
103
104 // If this is the first user message and the chat title is "New Chat", generate a title
105 if (messages.length === 0 && chat.title === "New Chat") {
106 try {
107 const generatedTitle = generateChatTitle(input);
108 await updateChat(chat.id, {
109 title: generatedTitle,
110 updatedAt: new Date(),
111 });
112 } catch (error) {
113 console.error("Failed to generate chat title:", error);
114 }
115 }
116 };
117
118 const handleSubmitWithSave = async () => {
119 if (input.trim()) {

Callers 1

handleSubmitWithSaveFunction · 0.85

Calls 1

generateChatTitleFunction · 0.90

Tested by

no test coverage detected