-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chat persistence #50
base: main
Are you sure you want to change the base?
Chat persistence #50
Conversation
With this change we store the chat and message history in postgres. The Chat UI supports creation and deletion of chats. Chats also have a title. The title of the active chat can be modified by clicking on the title in the chat header. The UI will not send all messages anymore, but only the most recent message. We fetch the chat history from the chats memory. The change introduces a chat memory in lib/ai/memory.ts The chats are stores in the new chats table. A chat is associated with a procject and can have an optional connection to act upon. The chat messages are stored in the messages table.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces chat persistence by storing chat and message history in PostgreSQL while updating both the backend and UI components to support chat creation, deletion, and title editing. Key changes include the addition of a new chat memory module in lib/ai/memory.ts, enhancements to the chat UI components (ChatsUI, ChatSidebar, and MessageCard), and updates to API routes and database schema changes.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
lib/ai/memory.ts | Introduces a Memory class for managing chats and a ChatMemory class for handling chat messages. |
components/chats/chats-ui.tsx | Updates UI components to load chats from the database, handle chat creation/deletion, and support title editing. |
components/chats/message-card.tsx | Refactors message rendering with a dedicated MarkdownRenderer and ThinkingIndicator. |
lib/db/chats.ts & schema.ts | Implements new database interactions and schema changes for chats and messages. |
app/api/chat/route.ts | Modifies the chat API route to integrate chat history and persist assistant responses. |
components/chats/actions.ts | Adds actions for creating, updating, and deleting chats using the new Memory classes. |
components/chats/chat-sidebar.tsx | Enhances the sidebar with a delete button and displays chat metadata. |
lib/db/relations.ts & projects/[project]/chats/page.tsx | Updates relational mappings and integrates the new projectId parameter into the UI. |
Comments suppressed due to low confidence (2)
apps/dbagent/src/app/api/chat/route.ts:39
- Ensure that chatId is validated (e.g. not null or undefined) before constructing a new ChatMemory instance to avoid potential runtime errors when processing the request.
const memory = new ChatMemory(chatId);
apps/dbagent/src/components/chats/chat-sidebar.tsx:47
- Consider adding an aria-label to the delete button (e.g. aria-label="Delete chat") to improve accessibility and clarify the button's purpose for assistive technologies.
<Button ...>{"×"}</Button>
With this change we store the chat and message history in postgres.
The Chat UI supports creation and deletion of chats. Chats also have a title. The title of the active chat can be modified by clicking on the title in the chat header.
The UI will not send all messages anymore, but only the most recent message. We fetch the chat history from the chats memory.
The change introduces a chat memory in lib/ai/memory.ts
The chats are stores in the new chats table. A chat is associated with a procject and can have an optional connection to act upon.
The chat messages are stored in the messages table.