Skip to content

Commit bf2d0ac

Browse files
committed
Merge branch 'main' of https://github.com/SciSharp/BotSharp-UI into features/refactor-project-styling
2 parents 3b7e1b7 + 75a7fba commit bf2d0ac

4 files changed

Lines changed: 30 additions & 24 deletions

File tree

src/routes/VerticalLayout/Header.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
7979
<header
8080
id="page-topbar"
81-
class="fixed inset-x-0 top-0 z-[1002] h-[var(--header-height)] bg-white shadow-sm dark:bg-gray-800 font-script"
81+
class="fixed inset-x-0 top-0 z-[1002] h-[var(--header-height)] bg-white shadow-sm dark:bg-gray-800"
8282
>
8383
<div class="mx-auto flex h-full items-center justify-between pr-2">
8484
<div class="flex items-center">

src/routes/VerticalLayout/Sidebar.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
</script>
278278
279279
<div
280-
class="vertical-menu fixed bottom-0 left-0 top-[var(--header-height)] z-[1001] w-[var(--sidebar-width)] bg-[var(--sidebar-bg)] shadow-sm transition-[width,transform] duration-200 dark:bg-gray-800 font-averia"
280+
class="vertical-menu fixed bottom-0 left-0 top-[var(--header-height)] z-[1001] w-[var(--sidebar-width)] bg-[var(--sidebar-bg)] shadow-sm transition-[width,transform] duration-200 dark:bg-gray-800"
281281
>
282282
<div class="h-full" id="vertical-menu">
283283
<!--- Sidemenu -->

src/routes/chat/[agentId]/[conversationId]/chat-box.svelte

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@
216216
let isHandlingQueue = $state(false);
217217
let isStopStreamClicked = $state(false);
218218
219-
let isWaiting = $derived(isSendingMsg || isThinking || messageQueue.length > 0);
219+
let isWaiting = $derived(isSendingMsg || isThinking || isStreaming || messageQueue.length > 0);
220220
let loadEditor = true;
221221
let disableAction = $derived(!ADMIN_ROLES.includes(currentUser?.role || '')
222222
&& currentUser?.id !== conversationUser?.id
@@ -464,7 +464,9 @@
464464
requestAnimationFrame(() => {
465465
scrollbars.forEach(scrollbar => {
466466
if (!scrollbar) return;
467-
scrollbar.scrollTo({ top: scrollbar.scrollHeight, behavior: 'smooth' });
467+
setTimeout(() => {
468+
scrollbar.scrollTo({ top: scrollbar.scrollHeight, behavior: 'smooth' });
469+
}, 150);
468470
});
469471
_autoScrollScheduled = false;
470472
});
@@ -914,7 +916,7 @@
914916
return;
915917
}
916918
917-
if ((e.key === 'Enter' && (!!e.shiftKey || !!e.ctrlKey)) || e.key !== 'Enter' || !_.trim(text) || isSendingMsg || isThinking) {
919+
if ((e.key === 'Enter' && (!!e.shiftKey || !!e.ctrlKey)) || e.key !== 'Enter' || !_.trim(text) || isWaiting) {
918920
return;
919921
}
920922
@@ -960,7 +962,7 @@
960962
* @param {string} payload
961963
*/
962964
async function confirmSelectedOption(title, payload) {
963-
if (isSendingMsg || isThinking) return;
965+
if (isWaiting) return;
964966
965967
const postback = buildPostbackMessage(dialogs, payload || title, null);;
966968
await sendChatMessage(title, { postback: postback });
@@ -1135,6 +1137,7 @@
11351137
* @param {string} messageId
11361138
*/
11371139
function deleteMessage(e, messageId) {
1140+
if (isWaiting || disableAction) return;
11381141
handleDeleteMessage(messageId);
11391142
}
11401143
@@ -1151,6 +1154,7 @@
11511154
* @param {import('$conversationTypes').ChatResponseModel} message
11521155
*/
11531156
async function editMessage(message) {
1157+
if (isWaiting || disableAction) return;
11541158
truncateMsgId = message?.message_id;
11551159
editText = message?.text || '';
11561160
await tick();
@@ -1190,7 +1194,7 @@
11901194
11911195
/** @param {import('$conversationTypes').ChatResponseModel} message */
11921196
async function resendMessage(message) {
1193-
if (isSendingMsg || isThinking || disableAction) return;
1197+
if (isWaiting || disableAction) return;
11941198
const msgId = message?.message_id;
11951199
const msgText = message?.text || '';
11961200
if (!msgId || !msgText) return;
@@ -1385,6 +1389,7 @@
13851389
13861390
/** @param {import('$conversationTypes').ChatResponseModel} message */
13871391
async function openBotMsgEditor(message) {
1392+
if (isWaiting || disableAction) return;
13881393
let source = "text";
13891394
if (message.rich_content?.message?.text === message.text) {
13901395
source = "both";
@@ -1973,6 +1978,7 @@
19731978
data-bs-toggle="tooltip"
19741979
data-bs-placement="top"
19751980
title="Edit"
1981+
aria-disabled={isWaiting || disableAction}
19761982
onclick={() => editMessage(message)}
19771983
>
19781984
<i class="bx bxs-edit cb-text-primary"></i>
@@ -1986,7 +1992,7 @@
19861992
data-bs-toggle="tooltip"
19871993
data-bs-placement="top"
19881994
title="Resend"
1989-
aria-disabled={isSendingMsg || isThinking || disableAction}
1995+
aria-disabled={isWaiting || disableAction}
19901996
onclick={() => resendMessage(message)}
19911997
>
19921998
<i class="bx bx-redo cb-text-primary"></i>
@@ -2019,11 +2025,8 @@
20192025
data-bs-toggle="tooltip"
20202026
data-bs-placement="top"
20212027
title="Delete"
2022-
aria-disabled={isSendingMsg || isThinking || disableAction}
2023-
onclick={(e) => {
2024-
if (isSendingMsg || isThinking || disableAction) return;
2025-
deleteMessage(e, message.message_id);
2026-
}}
2028+
aria-disabled={isWaiting || disableAction}
2029+
onclick={(e) => deleteMessage(e, message.message_id)}
20272030
>
20282031
<i class="bx bx-trash cb-text-danger"></i>
20292032
</div>
@@ -2127,6 +2130,7 @@
21272130
data-bs-toggle="tooltip"
21282131
data-bs-placement="top"
21292132
title="Edit"
2133+
aria-disabled={isWaiting || disableAction}
21302134
onclick={() => openBotMsgEditor(message)}
21312135
>
21322136
<i class="bx bxs-edit cb-text-primary"></i>
@@ -2207,11 +2211,11 @@
22072211
{/if}
22082212
</ul>
22092213
2210-
<ChatFileGallery disabled={isSendingMsg || isThinking} />
2214+
<ChatFileGallery disabled={isWaiting} />
22112215
{#if !!lastBotMsg && !isSendingMsg && !isThinking}
22122216
<RichContent
22132217
message={lastBotMsg}
2214-
disabled={isSendingMsg || isThinking || disableAction}
2218+
disabled={isWaiting || disableAction}
22152219
onConfirm={(title, payload) => confirmSelectedOption(title, payload)}
22162220
/>
22172221
{/if}
@@ -2227,7 +2231,7 @@
22272231
class={`cb-btn cb-btn-round ${mode === TRAINING_MODE ? 'cb-btn-danger' : 'cb-btn-primary'} ${isListening ? 'cb-btn-listening' : ''}`}
22282232
aria-label="Start/stop listening"
22292233
aria-pressed={isListening}
2230-
disabled={isSendingMsg || isThinking || disableAction}
2234+
disabled={isWaiting || disableAction}
22312235
onclick={() => startListen()}
22322236
>
22332237
<i class="mdi mdi-{isListening ? 'microphone' : 'microphone-off'} cb-md-36"></i>
@@ -2240,7 +2244,7 @@
22402244
id={'chat-textarea'}
22412245
className={`${!isLite ? 'cb-textarea-more-util' : ''}`}
22422246
maxLength={maxTextLength}
2243-
disabled={isSendingMsg || isThinking || disableAction}
2247+
disabled={isWaiting || disableAction}
22442248
bind:text={text}
22452249
bind:loadUtils={loadChatUtils}
22462250
bind:options={chatUtilOptions}
@@ -2252,7 +2256,7 @@
22522256
<ChatFileUploader
22532257
accept={'.png,.jpg,.jpeg'}
22542258
containerClasses={'cb-util-uploader'}
2255-
disabled={isSendingMsg || isThinking || disableAction}
2259+
disabled={isWaiting || disableAction}
22562260
onfiledroped={() => refresh()}
22572261
>
22582262
<span>
@@ -2266,7 +2270,7 @@
22662270
<ChatFileUploader
22672271
accept={'.pdf,.xlsx,.xls,.csv'}
22682272
containerClasses={'cb-util-uploader'}
2269-
disabled={isSendingMsg || isThinking || disableAction}
2273+
disabled={isWaiting || disableAction}
22702274
onfiledroped={() => refresh()}
22712275
>
22722276
<span>
@@ -2280,7 +2284,7 @@
22802284
<ChatFileUploader
22812285
accept={'.wav,.mp3'}
22822286
containerClasses={'cb-util-uploader'}
2283-
disabled={isSendingMsg || isThinking || disableAction}
2287+
disabled={isWaiting || disableAction}
22842288
onfiledroped={() => refresh()}
22852289
>
22862290
<span>
@@ -2294,12 +2298,12 @@
22942298
</ChatTextArea>
22952299
<div class="cb-util-links">
22962300
<ChatBigMessage
2297-
disabled={isSendingMsg || isThinking || disableAction}
2301+
disabled={isWaiting || disableAction}
22982302
onclick={() => toggleBigMessageModal()}
22992303
/>
23002304
{#if PUBLIC_LIVECHAT_FILES_ENABLED === 'true'}
23012305
<ChatUtil
2302-
disabled={isSendingMsg || isThinking || disableAction}
2306+
disabled={isWaiting || disableAction}
23032307
onclick={() => loadChatUtils = true}
23042308
/>
23052309
{/if}
@@ -2321,7 +2325,7 @@
23212325
<button
23222326
type="submit"
23232327
class={`cb-btn cb-btn-round cb-btn-send ${mode === TRAINING_MODE ? 'cb-btn-danger' : 'cb-btn-primary'}`}
2324-
disabled={!_.trim(text) || isSendingMsg || isThinking || disableAction}
2328+
disabled={!_.trim(text) || isWaiting || disableAction}
23252329
onclick={() => sentTextMessage()}
23262330
>
23272331
<span class="cb-send-label">Send</span>

src/routes/chat/[agentId]/[conversationId]/rich-content/rc-message.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
requestAnimationFrame(() => {
6868
const el = thinkingContentEl;
6969
if (el) {
70-
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' });
70+
setTimeout(() => {
71+
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' });
72+
}, 150);
7173
}
7274
_thinkingScrollScheduled = false;
7375
});

0 commit comments

Comments
 (0)