-
Notifications
You must be signed in to change notification settings - Fork 244
chore(compass-assistant): add clear chat button COMPASS-9731 #7219
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
Conversation
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 adds a clear chat button to the MongoDB Assistant drawer that allows users to delete all messages from the current chat session with a confirmation dialog.
- Added a
clearChataction to the AssistantActionsContext that clears all messages from the chat - Implemented a clear chat button in the drawer header with confirmation modal
- Added comprehensive tests for both confirmation and cancellation scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| compass-assistant-provider.tsx | Adds clearChat action to context that empties the chat messages array |
| compass-assistant-provider.spec.tsx | Adds test coverage for clear chat functionality with confirmation and cancellation flows |
| compass-assistant-drawer.tsx | Implements clear chat button in drawer header with confirmation dialog |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ); | ||
| }, | ||
| clearChat: () => { | ||
| chat.messages = []; |
Copilot
AI
Aug 21, 2025
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.
Direct mutation of the chat.messages array may not trigger re-renders in React components that depend on this data. Consider using a proper state update method or immutable update pattern to ensure components re-render when messages are cleared.
| chat.messages = []; | |
| if (typeof chat.setMessages === 'function') { | |
| chat.setMessages([]); | |
| } else if (typeof chat.clearMessages === 'function') { | |
| chat.clearMessages(); | |
| } else { | |
| // Fallback: do nothing or log a warning | |
| console.warn('No method to clear chat messages found.'); | |
| } |
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.
It will, this is a ai-sdk thing
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.
| set messages(newMessages: UI_MESSAGE[]) { | |
| this.#messages = [...newMessages]; | |
| this.#callMessagesCallbacks(); | |
| } |
Adds chat clearing to the Assistant drawer:

