Skip to content

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Sep 24, 2025

Adds this to both message sending and entry points as it seems to make sense in both cases.

TBC by design.

@gagik gagik marked this pull request as ready for review September 24, 2025 20:11
@gagik gagik requested a review from a team as a code owner September 24, 2025 20:11
@gagik gagik requested review from Copilot and lerouxb September 24, 2025 20:11
Copy link
Contributor

@Copilot 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 auto-scroll functionality to the assistant chat component that automatically scrolls to the bottom when new user messages are sent. The feature includes scroll behavior for both message sending and entry points as mentioned in the description.

  • Implements auto-scroll to bottom functionality triggered by new user messages
  • Adds comprehensive test coverage for the new scroll behavior
  • Refactors message handling to be asynchronous with proper chat stopping

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/compass-assistant/src/components/assistant-chat.tsx Adds scroll-to-bottom logic with refs, useEffect hooks, and async message handling
packages/compass-assistant/src/components/assistant-chat.spec.tsx Adds test coverage for scroll behavior and refactors existing test assertions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gagik gagik force-pushed the gagik/scroll-bottom branch from 5c1e661 to 6df0be8 Compare September 24, 2025 20:15
const darkMode = useDarkMode();
const messagesContainerRef = useRef<HTMLDivElement>(null);
const previousLastMessageId = useRef<string | undefined>(undefined);
const { id: lastMessageId, role: lastMessageIsUser } =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't role "system" | "user" | "assistant" yet here you're using it as a boolean lastMessageIsUser?

useEffect(() => {
if (
lastMessageId &&
previousLastMessageId.current !== undefined &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check if there was a message and one before that? If not, what's the harm in scrolling to the bottom if the list is and was empty? If there's a reason we should probably spell it all out in a comment.

Copy link
Contributor Author

@gagik gagik Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to avoid unnecessary behavior of scroll to bottom, either is fine.

@gagik gagik force-pushed the gagik/scroll-bottom branch from 10be809 to 9c05d92 Compare September 25, 2025 13:35
@gagik
Copy link
Contributor Author

gagik commented Sep 25, 2025

scrolling in unit tests isn't really straightforward.... so going to follow up on this in e2e tests separately

@gagik gagik merged commit 7345916 into main Sep 25, 2025
78 of 81 checks passed
@gagik gagik deleted the gagik/scroll-bottom branch September 25, 2025 15:04
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.

2 participants