@gitlab/ui 92.1.0 → 92.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [92.1.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v92.1.0...v92.1.1) (2024-09-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ensure chat scrolls to bottom with new message ([3d048f8](https://gitlab.com/gitlab-org/gitlab-ui/commit/3d048f82c586cd3860a7cf5c86d0572ee44d0dc6))
7
+
1
8
  # [92.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v92.0.0...v92.1.0) (2024-09-10)
2
9
 
3
10
 
@@ -14,7 +14,7 @@ import { SafeHtmlDirective } from '../../../../directives/safe_html/safe_html';
14
14
  import GlDuoChatLoader from './components/duo_chat_loader/duo_chat_loader';
15
15
  import GlDuoChatPredefinedPrompts from './components/duo_chat_predefined_prompts/duo_chat_predefined_prompts';
16
16
  import GlDuoChatConversation from './components/duo_chat_conversation/duo_chat_conversation';
17
- import { CHAT_RESET_MESSAGE, CHAT_INCLUDE_MESSAGE, CHAT_CLEAN_MESSAGE, CHAT_CLEAR_MESSAGE } from './constants';
17
+ import { CHAT_RESET_MESSAGE, CHAT_INCLUDE_MESSAGE, MESSAGE_MODEL_ROLES, CHAT_CLEAN_MESSAGE, CHAT_CLEAR_MESSAGE } from './constants';
18
18
  import { INCLUDE_SLASH_COMMAND } from './mock_data';
19
19
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
20
20
 
@@ -292,12 +292,18 @@ var script = {
292
292
  this.displaySubmitButton = true; // Re-enable submit button when loading stops
293
293
  }
294
294
  this.isHidden = false;
295
- this.scrollToBottom();
296
295
  },
297
296
  isStreaming(newVal) {
298
297
  if (!newVal && !this.isLoading) {
299
298
  this.displaySubmitButton = true; // Re-enable submit button when streaming stops
300
299
  }
300
+ },
301
+ lastMessage(newMessage) {
302
+ if (this.scrolledToBottom || newMessage.role.toLowerCase() === MESSAGE_MODEL_ROLES.user) {
303
+ // only scroll to bottom on new message if the user hasn't explicitly scrolled up to view an earlier message
304
+ // or if the user has just submitted a new message
305
+ this.scrollToBottom();
306
+ }
301
307
  }
302
308
  },
303
309
  created() {
@@ -366,8 +372,6 @@ var script = {
366
372
  },
367
373
  async scrollToBottom() {
368
374
  var _this$$refs$anchor, _this$$refs$anchor$sc;
369
- // This method is also called directly by consumers of this component
370
- // https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/3269f6200dc3821c62a3992b40c971dd9ee55d87/webviews/vue2/gitlab_duo_chat/src/App.vue#L97
371
375
  await this.$nextTick();
372
376
  (_this$$refs$anchor = this.$refs.anchor) === null || _this$$refs$anchor === void 0 ? void 0 : (_this$$refs$anchor$sc = _this$$refs$anchor.scrollIntoView) === null || _this$$refs$anchor$sc === void 0 ? void 0 : _this$$refs$anchor$sc.call(_this$$refs$anchor);
373
377
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "92.1.0",
3
+ "version": "92.1.1",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,7 @@ import {
20
20
  CHAT_RESET_MESSAGE,
21
21
  CHAT_CLEAR_MESSAGE,
22
22
  CHAT_INCLUDE_MESSAGE,
23
+ MESSAGE_MODEL_ROLES,
23
24
  } from './constants';
24
25
  import { INCLUDE_SLASH_COMMAND } from './mock_data';
25
26
 
@@ -317,13 +318,19 @@ export default {
317
318
  this.displaySubmitButton = true; // Re-enable submit button when loading stops
318
319
  }
319
320
  this.isHidden = false;
320
- this.scrollToBottom();
321
321
  },
322
322
  isStreaming(newVal) {
323
323
  if (!newVal && !this.isLoading) {
324
324
  this.displaySubmitButton = true; // Re-enable submit button when streaming stops
325
325
  }
326
326
  },
327
+ lastMessage(newMessage) {
328
+ if (this.scrolledToBottom || newMessage.role.toLowerCase() === MESSAGE_MODEL_ROLES.user) {
329
+ // only scroll to bottom on new message if the user hasn't explicitly scrolled up to view an earlier message
330
+ // or if the user has just submitted a new message
331
+ this.scrollToBottom();
332
+ }
333
+ },
327
334
  },
328
335
  created() {
329
336
  this.handleScrollingTrottled = throttle(this.handleScrolling, 200); // Assume a 200ms throttle for example
@@ -396,8 +403,6 @@ export default {
396
403
  this.scrolledToBottom = scrollTop + offsetHeight >= scrollHeight;
397
404
  },
398
405
  async scrollToBottom() {
399
- // This method is also called directly by consumers of this component
400
- // https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/blob/3269f6200dc3821c62a3992b40c971dd9ee55d87/webviews/vue2/gitlab_duo_chat/src/App.vue#L97
401
406
  await this.$nextTick();
402
407
 
403
408
  this.$refs.anchor?.scrollIntoView?.();