File tree Expand file tree Collapse file tree 2 files changed +20
-20
lines changed
src/routes/chat/[agentId]/[conversationId] Expand file tree Collapse file tree 2 files changed +20
-20
lines changed Original file line number Diff line number Diff line change 211211
212212 onMount (async () => {
213213 disableSpeech = navigator .userAgent .includes (' Firefox' );
214- autoScrollLog = true ;
215214 conversation = await getConversation (params .conversationId );
216215 dialogs = await getDialogs (params .conversationId );
217216 conversationUser = await getConversationUser (params .conversationId );
220219 initChatView ();
221220
222221 signalr .onMessageReceivedFromClient = onMessageReceivedFromClient;
223- signalr .onMessageReceivedFromCsr = onMessageReceivedFromCsr ;
222+ signalr .onMessageReceivedFromCsr = onMessageReceivedFromClient ;
224223 signalr .onMessageReceivedFromAssistant = onMessageReceivedFromAssistant;
225224 signalr .onNotificationGenerated = onNotificationGenerated;
226225 signalr .onConversationContentLogGenerated = onConversationContentLogGenerated;
235234 document .querySelector (' .chat-scrollbar' )
236235 ].filter (Boolean );
237236 refresh ();
238- autoScrollLog = false ;
239237
240238 window .addEventListener (' message' , async (e ) => {
241239 if (e .data .action === ChatAction .Logout ) {
459457
460458 /** @param {import('$conversationTypes').ChatResponseModel} message */
461459 function onMessageReceivedFromClient (message ) {
460+ autoScrollLog = true ;
461+ clearInstantLogs ();
462462 dialogs .push ({
463463 ... message,
464464 is_chat_message: true
467467 text = " " ;
468468 }
469469
470- /** @param {import('$conversationTypes').ChatResponseModel} message */
471- function onMessageReceivedFromCsr (message ) {
472- dialogs .push ({
473- ... message,
474- is_chat_message: true
475- });
476- refresh ();
477- }
478-
479470 /** @param {import('$conversationTypes').ChatResponseModel} message */
480471 function onMessageReceivedFromAssistant (message ) {
481472 // webSpeech.utter(message.text);
572563 */
573564 function sendChatMessage (msgText , data = null , conversationId = null ) {
574565 isSendingMsg = true ;
575- autoScrollLog = true ;
576566 clearInstantLogs ();
577567 renewUserSentMessages (msgText);
578568 const agentId = params .agentId ;
618608 reject(err);
619609 }).finally(() => {
620610 isSendingMsg = false;
621- autoScrollLog = false;
622611 });
623612 });
624613 });
644633 reject(err);
645634 }).finally(() => {
646635 isSendingMsg = false;
647- autoScrollLog = false;
648636 });
649637 });
650638 } else {
654642 reject(err);
655643 }).finally(() => {
656644 isSendingMsg = false;
657- autoScrollLog = false;
658645 });
659646 }
660647 });
Original file line number Diff line number Diff line change 11<script >
22 import ' overlayscrollbars/overlayscrollbars.css' ;
33 import { OverlayScrollbars } from ' overlayscrollbars' ;
4- import { afterUpdate , onDestroy , onMount } from ' svelte' ;
4+ import { afterUpdate , beforeUpdate , onDestroy , onMount } from ' svelte' ;
55 import { page } from ' $app/stores' ;
66 import { GetContentLogs , GetStateLogs } from ' $lib/services/logging-service' ;
77 import NavBar from ' $lib/common/nav-bar/NavBar.svelte' ;
3434 let scrollbars = [];
3535 /** @type {number} */
3636 let selectedTab = contentLogTab;
37+ let tabChanged = false ;
3738
3839 const options = {
3940 scrollbars: {
6364 scrollToBottom ();
6465 });
6566
67+ beforeUpdate (() => {
68+ if (tabChanged) {
69+ autoScroll = false ;
70+ tabChanged = false ;
71+ }
72+ });
73+
6674 afterUpdate (() => {
6775 refresh ();
6876 });
7583 if (autoScroll) {
7684 scrollToBottom ();
7785 }
86+
7887 }
7988
8089 function scrollToBottom () {
97106 cleanScreen && cleanScreen ();
98107 }
99108
100- /** @param {number} tab */
101- function handleTabClick (tab ) {
102- selectedTab = tab;
109+ /** @param {number} selected */
110+ function handleTabClick (selected ) {
111+ if (selectedTab === selected) {
112+ return ;
113+ }
114+ tabChanged = true ;
115+ selectedTab = selected;
103116 }
104117 </script >
105118
You can’t perform that action at this time.
0 commit comments