Scroll to the last message on mount
What does this MR do and why?
The MR makes sure the chat is scrolled to the latest message when mounted in case there are messages stored in cache.
Screenshots or screen recordings
Before | After |
---|---|
Screen_Recording_2023-06-08_at_6.05.17_PM | chat-scroll-to-last |
How to set up and validate locally
- Follow the instructions to enable the AI features in your local GDK
- Follow the instructions on setting up the GitLab chat locally
- Enable the
:super_sidebar_nav
feature flag (Feature.enable(:anthropic_experimentation)
in your rails console - Enable the new super sidebar in your settings via the web interface:
- In Rails console (
rails c
), run the script to pre-populate the cache
Pre-populate chat cache
user = User.first
user_cache = Gitlab::Llm::Cache.new(user)
10.times do |i|
# Add user message to cache with random Lorem Ipsum text
user_payload = {
request_id: "user#{i}",
role: Gitlab::Llm::Cache::ROLE_USER,
content: "User's Foo Bar #{i}"
}
user_cache.add(user_payload)
# Add assistant message to user's cache with random Lorem Ipsum text
assistant_payload = {
request_id: "assistant#{i}",
role: Gitlab::Llm::Cache::ROLE_ASSISTANT,
content: "Assistant's response #{i}"
}
user_cache.add(assistant_payload)
end
last_user_payload = {
request_id: "last-user",
role: Gitlab::Llm::Cache::ROLE_USER,
content: "Last user's Foo Bar"
}
user_cache.add(last_user_payload)
last_assistant_payload = {
request_id: "assistant-last",
role: Gitlab::Llm::Cache::ROLE_ASSISTANT,
content: "This is the last assistant's response"
}
user_cache.add(last_assistant_payload)
- Open the GitLab chat in Help -> Ask GitLab Chat
The chat should be scrolled down to This is the last assistant's response
as shown in the "After" video.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #414883
Edited by Denys Mishunov