@hivegpt/hiveai-angular 0.0.610 → 0.0.611

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.
@@ -1609,6 +1609,11 @@ class ChatDrawerComponent {
1609
1609
  this.displayAvatarUrl = 'https://www.jotform.com/uploads/mehmetkarakasli/form_files/1564593667676a8e85f23758.86945537_icon.png';
1610
1610
  /** When true, chat auto-scrolls to bottom when new content is added. Default: false (no auto scroll). */
1611
1611
  this.autoScrollOnNewMessage = false;
1612
+ /** Tracks whether the user has manually scrolled up, suppressing auto-scroll until they scroll back to bottom or send a new message. */
1613
+ this.userHasScrolled = false;
1614
+ /** Guards against our own programmatic scrolls triggering the userHasScrolled detection. */
1615
+ this.isProgrammaticScroll = false;
1616
+ this.scrollListenerTimer = null;
1612
1617
  /** Connections list from host (e.g. from store selectConnectionsList). Each item has userId. When set, used for Connect/Request Sent/Disconnect button state. */
1613
1618
  this.connectionsList = [];
1614
1619
  /** Pending sent request user IDs from host (e.g. from store selectPendingConnectionsSentList). When set, used for Request Sent state. */
@@ -3352,6 +3357,8 @@ class ChatDrawerComponent {
3352
3357
  if (!this.input || this.loading) {
3353
3358
  return;
3354
3359
  }
3360
+ // Reset auto-scroll suppression when user sends a new message
3361
+ this.userHasScrolled = false;
3355
3362
  this.chatLog.push({
3356
3363
  type: 'user',
3357
3364
  message: this.processMessageForDisplay(this.input),
@@ -3375,6 +3382,8 @@ class ChatDrawerComponent {
3375
3382
  if (!inputMsg || this.loading) {
3376
3383
  return;
3377
3384
  }
3385
+ // Reset auto-scroll suppression when user sends a new message
3386
+ this.userHasScrolled = false;
3378
3387
  try {
3379
3388
  chat.relatedListItems = [];
3380
3389
  this.cdr.detectChanges();
@@ -3748,30 +3757,41 @@ class ChatDrawerComponent {
3748
3757
  }
3749
3758
  this.cdr.detectChanges();
3750
3759
  }
3751
- scrollToBottom(force = false) {
3760
+ scrollToBottom(force = false, smooth = true) {
3752
3761
  if (!force && !this.autoScrollOnNewMessage) {
3753
3762
  return;
3754
3763
  }
3764
+ if (this.userHasScrolled) {
3765
+ return;
3766
+ }
3755
3767
  if (!this.chatMain?.nativeElement)
3756
3768
  return;
3757
- let counter = 0;
3758
- const interval = setInterval(() => {
3759
- this.chatMain.nativeElement.scrollTop =
3760
- this.chatMain.nativeElement.scrollHeight;
3761
- if (counter++ > 5)
3762
- clearInterval(interval);
3763
- }, 5);
3769
+ const el = this.chatMain.nativeElement;
3770
+ this.isProgrammaticScroll = true;
3771
+ el.scrollTo({
3772
+ top: el.scrollHeight,
3773
+ behavior: smooth ? 'smooth' : 'auto',
3774
+ });
3775
+ // Release the guard after the smooth scroll settles
3776
+ setTimeout(() => { this.isProgrammaticScroll = false; }, smooth ? 400 : 50);
3764
3777
  }
3765
3778
  /** Scrolls the chat container so the top of the AI message with the given id is visible. */
3766
3779
  scrollToAiMessage(messageId) {
3780
+ if (this.userHasScrolled)
3781
+ return;
3767
3782
  if (!this.chatMain?.nativeElement)
3768
3783
  return;
3769
3784
  const container = this.chatMain.nativeElement;
3770
3785
  const el = container.querySelector(`[data-msg-id="${messageId}"]`);
3771
3786
  if (!el)
3772
3787
  return;
3773
- const offset = el.getBoundingClientRect().top - container.getBoundingClientRect().top;
3774
- container.scrollTop = container.scrollTop + offset - 8;
3788
+ const targetTop = el.getBoundingClientRect().top - container.getBoundingClientRect().top;
3789
+ this.isProgrammaticScroll = true;
3790
+ container.scrollTo({
3791
+ top: container.scrollTop + targetTop - 8,
3792
+ behavior: 'smooth',
3793
+ });
3794
+ setTimeout(() => { this.isProgrammaticScroll = false; }, 400);
3775
3795
  }
3776
3796
  focusOnTextarea() {
3777
3797
  setTimeout(() => {
@@ -3787,6 +3807,21 @@ class ChatDrawerComponent {
3787
3807
  }
3788
3808
  }
3789
3809
  ngAfterViewInit() {
3810
+ // Detect user manual scroll to suppress auto-scroll (debounced, ignores programmatic scrolls)
3811
+ if (this.chatMain?.nativeElement) {
3812
+ this.chatMain.nativeElement.addEventListener('scroll', () => {
3813
+ if (this.isProgrammaticScroll)
3814
+ return;
3815
+ clearTimeout(this.scrollListenerTimer);
3816
+ this.scrollListenerTimer = setTimeout(() => {
3817
+ const el = this.chatMain?.nativeElement;
3818
+ if (!el)
3819
+ return;
3820
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
3821
+ this.userHasScrolled = !atBottom;
3822
+ }, 100);
3823
+ });
3824
+ }
3790
3825
  // Check if the drawer is initially open and apply overflow hidden to body if so
3791
3826
  if (this.drawer.opened) {
3792
3827
  this.setBodyOverflow();
@@ -4649,7 +4684,7 @@ class ChatDrawerComponent {
4649
4684
  }
4650
4685
  else {
4651
4686
  this.cdr.markForCheck();
4652
- setTimeout(() => this.scrollToBottom(true), 0);
4687
+ setTimeout(() => this.scrollToBottom(true, false), 0);
4653
4688
  }
4654
4689
  break;
4655
4690
  }
@@ -4680,7 +4715,15 @@ class ChatDrawerComponent {
4680
4715
  this.showFeedBackIconsIndex = this.chatLog.length - 1;
4681
4716
  this.activeAskMessageId = '';
4682
4717
  this.isChatingWithAi = false;
4683
- this.scrollToBottom();
4718
+ // For card responses (tool results), scroll to the message text bubble
4719
+ // instead of the very bottom — avoids cards pushing the view too far down
4720
+ if (hasCardResponse && messageId) {
4721
+ this.cdr.markForCheck();
4722
+ setTimeout(() => this.scrollToAiMessage(messageId), 30);
4723
+ }
4724
+ else {
4725
+ this.scrollToBottom();
4726
+ }
4684
4727
  this.focusOnTextarea();
4685
4728
  this.cdr.markForCheck();
4686
4729
  break;
@@ -4797,6 +4840,7 @@ class ChatDrawerComponent {
4797
4840
  return Object.keys(obj).map((key) => ({ key, value: obj[key] }));
4798
4841
  }
4799
4842
  startNewConversation() {
4843
+ this.userHasScrolled = false;
4800
4844
  this.conversationKey = this.conversationService.getKey(this.botId, true, this.eventId);
4801
4845
  this.chatLog = [this.chatLog[0]];
4802
4846
  this.isChatingWithAi = false;