@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.
- package/esm2020/lib/components/chat-drawer/chat-drawer.component.mjs +57 -13
- package/fesm2015/hivegpt-hiveai-angular.mjs +58 -12
- package/fesm2015/hivegpt-hiveai-angular.mjs.map +1 -1
- package/fesm2020/hivegpt-hiveai-angular.mjs +56 -12
- package/fesm2020/hivegpt-hiveai-angular.mjs.map +1 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts +6 -1
- package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1639,6 +1639,11 @@ class ChatDrawerComponent {
|
|
|
1639
1639
|
this.displayAvatarUrl = 'https://www.jotform.com/uploads/mehmetkarakasli/form_files/1564593667676a8e85f23758.86945537_icon.png';
|
|
1640
1640
|
/** When true, chat auto-scrolls to bottom when new content is added. Default: false (no auto scroll). */
|
|
1641
1641
|
this.autoScrollOnNewMessage = false;
|
|
1642
|
+
/** Tracks whether the user has manually scrolled up, suppressing auto-scroll until they scroll back to bottom or send a new message. */
|
|
1643
|
+
this.userHasScrolled = false;
|
|
1644
|
+
/** Guards against our own programmatic scrolls triggering the userHasScrolled detection. */
|
|
1645
|
+
this.isProgrammaticScroll = false;
|
|
1646
|
+
this.scrollListenerTimer = null;
|
|
1642
1647
|
/** Connections list from host (e.g. from store selectConnectionsList). Each item has userId. When set, used for Connect/Request Sent/Disconnect button state. */
|
|
1643
1648
|
this.connectionsList = [];
|
|
1644
1649
|
/** Pending sent request user IDs from host (e.g. from store selectPendingConnectionsSentList). When set, used for Request Sent state. */
|
|
@@ -3336,6 +3341,8 @@ class ChatDrawerComponent {
|
|
|
3336
3341
|
if (!this.input || this.loading) {
|
|
3337
3342
|
return;
|
|
3338
3343
|
}
|
|
3344
|
+
// Reset auto-scroll suppression when user sends a new message
|
|
3345
|
+
this.userHasScrolled = false;
|
|
3339
3346
|
this.chatLog.push({
|
|
3340
3347
|
type: 'user',
|
|
3341
3348
|
message: this.processMessageForDisplay(this.input),
|
|
@@ -3359,6 +3366,8 @@ class ChatDrawerComponent {
|
|
|
3359
3366
|
if (!inputMsg || this.loading) {
|
|
3360
3367
|
return;
|
|
3361
3368
|
}
|
|
3369
|
+
// Reset auto-scroll suppression when user sends a new message
|
|
3370
|
+
this.userHasScrolled = false;
|
|
3362
3371
|
try {
|
|
3363
3372
|
chat.relatedListItems = [];
|
|
3364
3373
|
this.cdr.detectChanges();
|
|
@@ -3734,32 +3743,43 @@ class ChatDrawerComponent {
|
|
|
3734
3743
|
}
|
|
3735
3744
|
this.cdr.detectChanges();
|
|
3736
3745
|
}
|
|
3737
|
-
scrollToBottom(force = false) {
|
|
3746
|
+
scrollToBottom(force = false, smooth = true) {
|
|
3738
3747
|
var _a;
|
|
3739
3748
|
if (!force && !this.autoScrollOnNewMessage) {
|
|
3740
3749
|
return;
|
|
3741
3750
|
}
|
|
3751
|
+
if (this.userHasScrolled) {
|
|
3752
|
+
return;
|
|
3753
|
+
}
|
|
3742
3754
|
if (!((_a = this.chatMain) === null || _a === void 0 ? void 0 : _a.nativeElement))
|
|
3743
3755
|
return;
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3756
|
+
const el = this.chatMain.nativeElement;
|
|
3757
|
+
this.isProgrammaticScroll = true;
|
|
3758
|
+
el.scrollTo({
|
|
3759
|
+
top: el.scrollHeight,
|
|
3760
|
+
behavior: smooth ? 'smooth' : 'auto',
|
|
3761
|
+
});
|
|
3762
|
+
// Release the guard after the smooth scroll settles
|
|
3763
|
+
setTimeout(() => { this.isProgrammaticScroll = false; }, smooth ? 400 : 50);
|
|
3751
3764
|
}
|
|
3752
3765
|
/** Scrolls the chat container so the top of the AI message with the given id is visible. */
|
|
3753
3766
|
scrollToAiMessage(messageId) {
|
|
3754
3767
|
var _a;
|
|
3768
|
+
if (this.userHasScrolled)
|
|
3769
|
+
return;
|
|
3755
3770
|
if (!((_a = this.chatMain) === null || _a === void 0 ? void 0 : _a.nativeElement))
|
|
3756
3771
|
return;
|
|
3757
3772
|
const container = this.chatMain.nativeElement;
|
|
3758
3773
|
const el = container.querySelector(`[data-msg-id="${messageId}"]`);
|
|
3759
3774
|
if (!el)
|
|
3760
3775
|
return;
|
|
3761
|
-
const
|
|
3762
|
-
|
|
3776
|
+
const targetTop = el.getBoundingClientRect().top - container.getBoundingClientRect().top;
|
|
3777
|
+
this.isProgrammaticScroll = true;
|
|
3778
|
+
container.scrollTo({
|
|
3779
|
+
top: container.scrollTop + targetTop - 8,
|
|
3780
|
+
behavior: 'smooth',
|
|
3781
|
+
});
|
|
3782
|
+
setTimeout(() => { this.isProgrammaticScroll = false; }, 400);
|
|
3763
3783
|
}
|
|
3764
3784
|
focusOnTextarea() {
|
|
3765
3785
|
setTimeout(() => {
|
|
@@ -3775,6 +3795,23 @@ class ChatDrawerComponent {
|
|
|
3775
3795
|
}
|
|
3776
3796
|
}
|
|
3777
3797
|
ngAfterViewInit() {
|
|
3798
|
+
var _a;
|
|
3799
|
+
// Detect user manual scroll to suppress auto-scroll (debounced, ignores programmatic scrolls)
|
|
3800
|
+
if ((_a = this.chatMain) === null || _a === void 0 ? void 0 : _a.nativeElement) {
|
|
3801
|
+
this.chatMain.nativeElement.addEventListener('scroll', () => {
|
|
3802
|
+
if (this.isProgrammaticScroll)
|
|
3803
|
+
return;
|
|
3804
|
+
clearTimeout(this.scrollListenerTimer);
|
|
3805
|
+
this.scrollListenerTimer = setTimeout(() => {
|
|
3806
|
+
var _a;
|
|
3807
|
+
const el = (_a = this.chatMain) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
3808
|
+
if (!el)
|
|
3809
|
+
return;
|
|
3810
|
+
const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
|
|
3811
|
+
this.userHasScrolled = !atBottom;
|
|
3812
|
+
}, 100);
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3778
3815
|
// Check if the drawer is initially open and apply overflow hidden to body if so
|
|
3779
3816
|
if (this.drawer.opened) {
|
|
3780
3817
|
this.setBodyOverflow();
|
|
@@ -4644,7 +4681,7 @@ class ChatDrawerComponent {
|
|
|
4644
4681
|
}
|
|
4645
4682
|
else {
|
|
4646
4683
|
this.cdr.markForCheck();
|
|
4647
|
-
setTimeout(() => this.scrollToBottom(true), 0);
|
|
4684
|
+
setTimeout(() => this.scrollToBottom(true, false), 0);
|
|
4648
4685
|
}
|
|
4649
4686
|
break;
|
|
4650
4687
|
}
|
|
@@ -4675,7 +4712,15 @@ class ChatDrawerComponent {
|
|
|
4675
4712
|
this.showFeedBackIconsIndex = this.chatLog.length - 1;
|
|
4676
4713
|
this.activeAskMessageId = '';
|
|
4677
4714
|
this.isChatingWithAi = false;
|
|
4678
|
-
|
|
4715
|
+
// For card responses (tool results), scroll to the message text bubble
|
|
4716
|
+
// instead of the very bottom — avoids cards pushing the view too far down
|
|
4717
|
+
if (hasCardResponse && messageId) {
|
|
4718
|
+
this.cdr.markForCheck();
|
|
4719
|
+
setTimeout(() => this.scrollToAiMessage(messageId), 30);
|
|
4720
|
+
}
|
|
4721
|
+
else {
|
|
4722
|
+
this.scrollToBottom();
|
|
4723
|
+
}
|
|
4679
4724
|
this.focusOnTextarea();
|
|
4680
4725
|
this.cdr.markForCheck();
|
|
4681
4726
|
break;
|
|
@@ -4794,6 +4839,7 @@ class ChatDrawerComponent {
|
|
|
4794
4839
|
return Object.keys(obj).map((key) => ({ key, value: obj[key] }));
|
|
4795
4840
|
}
|
|
4796
4841
|
startNewConversation() {
|
|
4842
|
+
this.userHasScrolled = false;
|
|
4797
4843
|
this.conversationKey = this.conversationService.getKey(this.botId, true, this.eventId);
|
|
4798
4844
|
this.chatLog = [this.chatLog[0]];
|
|
4799
4845
|
this.isChatingWithAi = false;
|