Skip to content

Conversation

@gagik
Copy link
Contributor

@gagik gagik commented Aug 21, 2025

Adds chat clearing to the Assistant drawer:
Screenshot 2025-08-21 at 2 01 29 PM
Screenshot 2025-08-21 at 2 01 50 PM

Copilot AI review requested due to automatic review settings August 21, 2025 12:02
@gagik gagik requested a review from a team as a code owner August 21, 2025 12:02
Copy link
Contributor

Copilot AI left a 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 clearChat action 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 = [];
Copy link

Copilot AI Aug 21, 2025

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.

Suggested change
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.');
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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

Copy link
Contributor

@lerouxb lerouxb Aug 22, 2025

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();
}

@gagik gagik merged commit 20f1326 into main Aug 22, 2025
54 of 58 checks passed
@gagik gagik deleted the gagik/add-erasing branch August 22, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants