@adminforth/agent 2.9.0 → 2.9.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.
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
class="absolute bg-black/10 backdrop-blur-md z-10 h-full w-full"
|
|
9
9
|
>
|
|
10
10
|
</div>
|
|
11
|
-
<div
|
|
11
|
+
<div class="relative flex-1 min-h-0 overflow-hidden [container-type:size]" @click="recalculateScroll()">
|
|
12
12
|
<CustomAutoScrollContainer
|
|
13
13
|
v-if="showScrollContainer"
|
|
14
14
|
class="relative h-full flex flex-col overflow-y-auto translate-x-[-50%] left-1/2"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
}"
|
|
27
27
|
:style="{
|
|
28
28
|
maxWidth: agentStore.isFullScreen ? agentStore.MAX_WIDTH+'rem' : '100%',
|
|
29
|
+
paddingBottom: showBottomSpacer ? `max(0px, 100cqh - ${lastTurnHeight}px)` : undefined,
|
|
29
30
|
transition: `
|
|
30
31
|
max-width ${agentTransitions.TRANSITION_DURATION}ms ease-in-out,
|
|
31
32
|
transform ${agentTransitions.TRANSITION_DURATION}ms ease-in-out
|
|
@@ -41,17 +42,14 @@
|
|
|
41
42
|
>
|
|
42
43
|
<MessageRenderer :message="message" :isLastMessageInChat="index === props.messages.length - 1"/>
|
|
43
44
|
</div>
|
|
44
|
-
|
|
45
|
+
<!-- absolute, so it doesn't resize the scroll content when the container resizes (see the spacer comment) -->
|
|
46
|
+
<div
|
|
45
47
|
v-if="props.messages.length === 0"
|
|
46
|
-
class="
|
|
47
|
-
:style="{
|
|
48
|
-
height: chatContainerRef ? chatContainerRef.clientHeight + 'px' : '100%',
|
|
49
|
-
}"
|
|
48
|
+
class="absolute inset-0 flex flex-col items-center justify-center text-gray-400 tracking-widest text-xl font-medium"
|
|
50
49
|
>
|
|
51
50
|
<p>{{ $t('Start the conversation') }}</p>
|
|
52
51
|
<p class="tracking-normal text-base text">{{ $t('Give any input to begin') }}</p>
|
|
53
52
|
</div>
|
|
54
|
-
<div v-if="showBottomSpacer" class="w-full" :style="{ height: spacerHeight + 'px' }"></div>
|
|
55
53
|
</CustomAutoScrollContainer>
|
|
56
54
|
<Transition
|
|
57
55
|
enter-active-class="transition-all duration-250 ease-out"
|
|
@@ -113,7 +111,6 @@ const innerScrollContainerRef = ref<HTMLElement | null>(null);
|
|
|
113
111
|
const agentStore = useAgentStore();
|
|
114
112
|
const agentTransitions = useAgentTransitions();
|
|
115
113
|
const showScrollContainer = ref(true);
|
|
116
|
-
const chatContainerRef = ref<HTMLElement | null>(null);
|
|
117
114
|
const messagesRefs = ref<Array<HTMLElement | null>>([]);
|
|
118
115
|
/*
|
|
119
116
|
* Whenever user sends a message, it adds a bottom spacer, that takes the remaining height
|
|
@@ -121,11 +118,17 @@ const messagesRefs = ref<Array<HTMLElement | null>>([]);
|
|
|
121
118
|
*
|
|
122
119
|
* On send message, happens the following logic:
|
|
123
120
|
* 1) showBottomSpacer is set to true
|
|
124
|
-
* 2) updateSpacerHeight is called, which
|
|
125
|
-
* 3) Spacer moves text up
|
|
121
|
+
* 2) updateSpacerHeight is called, which measures the last turn (last user + last agent message)
|
|
122
|
+
* 3) Spacer moves text up
|
|
123
|
+
*
|
|
124
|
+
* The spacer is the scroll element's padding-bottom, resolved in CSS (100cqh minus the last turn), so
|
|
125
|
+
* it follows the container height in the same layout pass, e.g. when the prompt textarea grows.
|
|
126
|
+
* It is padding rather than a child element on purpose: custom-vue-scrollbar measures the viewport and
|
|
127
|
+
* the content with separate debounced observers, and when both resize together it briefly computes a
|
|
128
|
+
* wrong scroll range and flashes the scrollbar thumb. Padding keeps the content size unchanged.
|
|
126
129
|
*/
|
|
127
130
|
const showBottomSpacer = ref(false);
|
|
128
|
-
const
|
|
131
|
+
const lastTurnHeight = ref(0);
|
|
129
132
|
const MASK_HEIGHT = 20;
|
|
130
133
|
const EMPTY_MESSAGE_HEIGHT = 18;
|
|
131
134
|
const THRESHOLD_TO_SHOW_BUTTON = 10;
|
|
@@ -195,7 +198,7 @@ watch(scrollContainer, async () => {
|
|
|
195
198
|
|
|
196
199
|
function resetSpacer() {
|
|
197
200
|
showBottomSpacer.value = false;
|
|
198
|
-
|
|
201
|
+
lastTurnHeight.value = 0;
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
function getLastMessageElement(role: 'user' | 'assistant') {
|
|
@@ -230,15 +233,7 @@ async function updateSpacerHeight() {
|
|
|
230
233
|
return;
|
|
231
234
|
}
|
|
232
235
|
|
|
233
|
-
|
|
234
|
-
if (!clientHeight) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const lastUserMessageHeight = getHeightOfLastUserMessage();
|
|
239
|
-
const lastAgentMessageHeight = getHeightOfLastAgentMessage();
|
|
240
|
-
const newSpacerHeight = Math.max(0, clientHeight - (lastUserMessageHeight + MASK_HEIGHT + lastAgentMessageHeight));
|
|
241
|
-
spacerHeight.value = newSpacerHeight;
|
|
236
|
+
lastTurnHeight.value = getHeightOfLastUserMessage() + MASK_HEIGHT + getHeightOfLastAgentMessage();
|
|
242
237
|
}
|
|
243
238
|
|
|
244
239
|
function scheduleSpacerHeightUpdate() {
|
|
@@ -328,7 +323,8 @@ async function handleSendMessage() {
|
|
|
328
323
|
|
|
329
324
|
function recalculateScroll() {
|
|
330
325
|
if (scrollContainer.value) {
|
|
331
|
-
scrollContainer.value.
|
|
326
|
+
const spacerHeight = parseFloat(getComputedStyle(scrollContainer.value.container.scrollEl).paddingBottom);
|
|
327
|
+
scrollContainer.value.handleScroll(false, spacerHeight + THRESHOLD_TO_SHOW_BUTTON);
|
|
332
328
|
const isScrolledUp = scrollContainer.value.isUserScrolledUp();
|
|
333
329
|
showScrollToBottomButton.value = !!isScrolledUp;
|
|
334
330
|
}
|