@adminforth/agent 2.2.2 → 2.2.4

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.
@@ -24,15 +24,15 @@ const props = withDefaults(defineProps<{
24
24
  wrapperStyle?: Record<string, string>
25
25
  contentStyle?: Record<string, string>
26
26
  scrollBarAutoHide?: boolean
27
- scrollToBottomOnMount?: boolean
28
27
  debugMode?: boolean
28
+ scrollToBottomOnMount?: boolean
29
29
  }>(), {
30
30
  enabled: true,
31
31
  threshold: 50,
32
32
  behavior: 'instant',
33
33
  scrollBarAutoHide: true,
34
- scrollToBottomOnMount: true,
35
- debugMode: false
34
+ debugMode: false,
35
+ scrollToBottomOnMount: true
36
36
  })
37
37
 
38
38
  const containerRef = ref<HTMLDivElement | null>(null)
@@ -43,6 +43,18 @@ let lastScrollTop = 0
43
43
  let lastScrollHeight = 0
44
44
  let observer: MutationObserver | null = null
45
45
 
46
+ const INITIAL_SCROLL_DEBOUNCE = 200
47
+ let initialScrollDone = false
48
+ let initialScrollTimer: ReturnType<typeof setTimeout> | null = null
49
+
50
+ function scheduleInitialScrollEnd(): void {
51
+ if (initialScrollTimer) clearTimeout(initialScrollTimer)
52
+ initialScrollTimer = setTimeout(() => {
53
+ initialScrollDone = true
54
+ initialScrollTimer = null
55
+ }, INITIAL_SCROLL_DEBOUNCE)
56
+ }
57
+
46
58
  const scrollParams = ref({
47
59
  scrollTop: 0,
48
60
  scrollHeight: 0,
@@ -71,26 +83,37 @@ onMounted(() => {
71
83
  if (!hasScrollbar()) {
72
84
  isUserScrolledUp.value = false
73
85
  }
74
-
86
+
75
87
  lastScrollHeight = containerRef.value.scrollEl.scrollHeight
76
88
  scrollParams.value.scrollTop = containerRef.value.scrollEl.scrollTop
77
89
  scrollParams.value.scrollHeight = containerRef.value.scrollEl.scrollHeight
78
90
  scrollParams.value.clientHeight = containerRef.value.scrollEl.clientHeight
79
- if (!isUserScrolledUp.value && props.scrollToBottomOnMount) {
91
+ if (props.enabled && !isUserScrolledUp.value) {
80
92
  scrollToBottom()
93
+ } else if (props.scrollToBottomOnMount && !initialScrollDone) {
94
+ // Delayed content is still settling in the initial scroll phase: keep
95
+ // pinning to the bottom and restart the quiet-period debounce.
96
+ scrollToBottom(true)
97
+ scheduleInitialScrollEnd()
81
98
  }
82
99
  })
83
100
  })
84
-
101
+
85
102
  observer.observe(containerRef.value?.scrollEl, {
86
103
  childList: true,
87
104
  subtree: true,
88
105
  characterData: true
89
106
  })
107
+
108
+ if (props.scrollToBottomOnMount) {
109
+ nextTick(() => scrollToBottom(true))
110
+ scheduleInitialScrollEnd()
111
+ }
90
112
  })
91
113
 
92
114
  onUnmounted(() => {
93
115
  observer?.disconnect()
116
+ if (initialScrollTimer) clearTimeout(initialScrollTimer)
94
117
  })
95
118
 
96
119
  function isNearBottom(customThreshold?: number): boolean {
@@ -11,9 +11,9 @@
11
11
  <div ref="chatContainerRef" class="relative flex-1 min-h-0 overflow-hidden" @click="recalculateScroll()">
12
12
  <CustomAutoScrollContainer
13
13
  v-if="showScrollContainer"
14
- :enabled="false"
15
14
  class="relative h-full flex flex-col overflow-y-auto translate-x-[-50%] left-1/2"
16
15
  ref="scrollContainer"
16
+ :enabled="false"
17
17
  :threshold="THRESHOLD_TO_SHOW_BUTTON"
18
18
  behavior="smooth"
19
19
  :wrapperStyle = "{
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <div
3
- class="flex rounded-xl border px-4 border-gray-200 dark:border-gray-700 min-w-0"
3
+ class="flex items-center justify-center rounded-xl border px-6 border-gray-200 dark:border-gray-700 min-w-0"
4
4
  @click="handleMarkdownLinkClick"
5
5
  :class="[
6
- hasVegaLite ? 'w-full my-2' : 'm-2',
6
+ hasVegaLite ? 'w-full my-2' : '',
7
7
  props.role === 'user' ? 'bg-lightListTableHeading dark:bg-darkListTableHeading self-end max-w-[80%] mr-4'
8
8
  : 'border-none self-start max-w-full'
9
9
  ]"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",