@agentscope-ai/chat 1.1.71-beta.1782467356478 → 1.1.71-beta.1782467989098
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/components/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/helpers.ts +4 -3
- package/components/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/index.tsx +5 -4
- package/lib/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/helpers.d.ts +2 -2
- package/lib/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/helpers.js +4 -2
- package/lib/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/index.js +5 -4
- package/package.json +1 -1
package/components/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/helpers.ts
CHANGED
|
@@ -190,19 +190,20 @@ export function getActiveAnchorId(scrollEl: HTMLElement, anchors: UserMessageAnc
|
|
|
190
190
|
return activeAnchorId;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
export function getTargetTopOffset(scrollEl: HTMLElement, target: HTMLElement) {
|
|
193
|
+
export function getTargetTopOffset(scrollEl: HTMLElement, target: HTMLElement, topOffset = 0) {
|
|
194
194
|
const scrollRect = scrollEl.getBoundingClientRect();
|
|
195
195
|
const targetRect = target.getBoundingClientRect();
|
|
196
196
|
|
|
197
|
-
return targetRect.top - scrollRect.top;
|
|
197
|
+
return targetRect.top - scrollRect.top - topOffset;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
export function scrollTargetIntoContainerTop(
|
|
201
201
|
scrollEl: HTMLElement,
|
|
202
202
|
target: HTMLElement,
|
|
203
203
|
behavior: ScrollBehavior = 'smooth',
|
|
204
|
+
topOffset = 0,
|
|
204
205
|
) {
|
|
205
|
-
const offset = getTargetTopOffset(scrollEl, target);
|
|
206
|
+
const offset = getTargetTopOffset(scrollEl, target, topOffset);
|
|
206
207
|
if (Math.abs(offset) < 1) return;
|
|
207
208
|
|
|
208
209
|
scrollEl.scrollBy({
|
package/components/AgentScopeRuntimeWebUI/core/Chat/MessageList/UserMessageAnchors/index.tsx
CHANGED
|
@@ -34,6 +34,7 @@ const TARGET_TOP_TOLERANCE = 2;
|
|
|
34
34
|
const TARGET_TOP_STABLE_FRAMES = 4;
|
|
35
35
|
const TARGET_TOP_SETTLE_TIMEOUT = 1600;
|
|
36
36
|
const TARGET_TOP_CORRECTION_DELAY = 360;
|
|
37
|
+
const TARGET_TOP_SAFE_OFFSET = 96;
|
|
37
38
|
const SCROLL_EDGE_TOLERANCE = 2;
|
|
38
39
|
|
|
39
40
|
function waitForNextFrame() {
|
|
@@ -79,13 +80,13 @@ async function scrollTargetIntoContainerTopAndSettle(
|
|
|
79
80
|
let stableFrames = 0;
|
|
80
81
|
const startTime = window.performance.now();
|
|
81
82
|
|
|
82
|
-
scrollTargetIntoContainerTop(scrollEl, target);
|
|
83
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'smooth', TARGET_TOP_SAFE_OFFSET);
|
|
83
84
|
|
|
84
85
|
while (window.performance.now() - startTime < TARGET_TOP_SETTLE_TIMEOUT) {
|
|
85
86
|
await waitForNextFrame();
|
|
86
87
|
|
|
87
88
|
target = getMessageElementInScrollContainer(scrollEl, messageId) || target;
|
|
88
|
-
const offset = getTargetTopOffset(scrollEl, target);
|
|
89
|
+
const offset = getTargetTopOffset(scrollEl, target, TARGET_TOP_SAFE_OFFSET);
|
|
89
90
|
if (Math.abs(offset) <= TARGET_TOP_TOLERANCE) {
|
|
90
91
|
stableFrames += 1;
|
|
91
92
|
if (stableFrames >= TARGET_TOP_STABLE_FRAMES) return target;
|
|
@@ -100,13 +101,13 @@ async function scrollTargetIntoContainerTopAndSettle(
|
|
|
100
101
|
const elapsed = window.performance.now() - startTime;
|
|
101
102
|
const offsetSettled = previousOffset !== undefined && Math.abs(offset - previousOffset) < 0.5;
|
|
102
103
|
if (elapsed > TARGET_TOP_CORRECTION_DELAY && offsetSettled) {
|
|
103
|
-
scrollTargetIntoContainerTop(scrollEl, target, 'auto');
|
|
104
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'auto', TARGET_TOP_SAFE_OFFSET);
|
|
104
105
|
}
|
|
105
106
|
previousOffset = offset;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
target = getMessageElementInScrollContainer(scrollEl, messageId) || target;
|
|
109
|
-
scrollTargetIntoContainerTop(scrollEl, target, 'auto');
|
|
110
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'auto', TARGET_TOP_SAFE_OFFSET);
|
|
110
111
|
await waitForNextFrame();
|
|
111
112
|
return target;
|
|
112
113
|
}
|
|
@@ -11,5 +11,5 @@ export declare function areAnchorPositionsEqual(prev: Record<string, number>, ne
|
|
|
11
11
|
export declare function getMessageElementMapInScrollContainer(scrollEl: HTMLElement): Map<string, HTMLElement>;
|
|
12
12
|
export declare function getMessageElementInScrollContainer(scrollEl: HTMLElement, messageId: string): HTMLElement;
|
|
13
13
|
export declare function getActiveAnchorId(scrollEl: HTMLElement, anchors: UserMessageAnchor[]): string;
|
|
14
|
-
export declare function getTargetTopOffset(scrollEl: HTMLElement, target: HTMLElement): number;
|
|
15
|
-
export declare function scrollTargetIntoContainerTop(scrollEl: HTMLElement, target: HTMLElement, behavior?: ScrollBehavior): void;
|
|
14
|
+
export declare function getTargetTopOffset(scrollEl: HTMLElement, target: HTMLElement, topOffset?: number): number;
|
|
15
|
+
export declare function scrollTargetIntoContainerTop(scrollEl: HTMLElement, target: HTMLElement, behavior?: ScrollBehavior, topOffset?: number): void;
|
|
@@ -173,13 +173,15 @@ export function getActiveAnchorId(scrollEl, anchors) {
|
|
|
173
173
|
return activeAnchorId;
|
|
174
174
|
}
|
|
175
175
|
export function getTargetTopOffset(scrollEl, target) {
|
|
176
|
+
var topOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
176
177
|
var scrollRect = scrollEl.getBoundingClientRect();
|
|
177
178
|
var targetRect = target.getBoundingClientRect();
|
|
178
|
-
return targetRect.top - scrollRect.top;
|
|
179
|
+
return targetRect.top - scrollRect.top - topOffset;
|
|
179
180
|
}
|
|
180
181
|
export function scrollTargetIntoContainerTop(scrollEl, target) {
|
|
181
182
|
var behavior = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'smooth';
|
|
182
|
-
var
|
|
183
|
+
var topOffset = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
184
|
+
var offset = getTargetTopOffset(scrollEl, target, topOffset);
|
|
183
185
|
if (Math.abs(offset) < 1) return;
|
|
184
186
|
scrollEl.scrollBy({
|
|
185
187
|
top: offset,
|
|
@@ -28,6 +28,7 @@ var TARGET_TOP_TOLERANCE = 2;
|
|
|
28
28
|
var TARGET_TOP_STABLE_FRAMES = 4;
|
|
29
29
|
var TARGET_TOP_SETTLE_TIMEOUT = 1600;
|
|
30
30
|
var TARGET_TOP_CORRECTION_DELAY = 360;
|
|
31
|
+
var TARGET_TOP_SAFE_OFFSET = 96;
|
|
31
32
|
var SCROLL_EDGE_TOLERANCE = 2;
|
|
32
33
|
function waitForNextFrame() {
|
|
33
34
|
return new Promise(function (resolve) {
|
|
@@ -96,7 +97,7 @@ function _scrollTargetIntoContainerTopAndSettle() {
|
|
|
96
97
|
target = initialTarget;
|
|
97
98
|
stableFrames = 0;
|
|
98
99
|
startTime = window.performance.now();
|
|
99
|
-
scrollTargetIntoContainerTop(scrollEl, target);
|
|
100
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'smooth', TARGET_TOP_SAFE_OFFSET);
|
|
100
101
|
case 4:
|
|
101
102
|
if (!(window.performance.now() - startTime < TARGET_TOP_SETTLE_TIMEOUT)) {
|
|
102
103
|
_context3.next = 23;
|
|
@@ -106,7 +107,7 @@ function _scrollTargetIntoContainerTopAndSettle() {
|
|
|
106
107
|
return waitForNextFrame();
|
|
107
108
|
case 7:
|
|
108
109
|
target = getMessageElementInScrollContainer(scrollEl, messageId) || target;
|
|
109
|
-
offset = getTargetTopOffset(scrollEl, target);
|
|
110
|
+
offset = getTargetTopOffset(scrollEl, target, TARGET_TOP_SAFE_OFFSET);
|
|
110
111
|
if (!(Math.abs(offset) <= TARGET_TOP_TOLERANCE)) {
|
|
111
112
|
_context3.next = 14;
|
|
112
113
|
break;
|
|
@@ -130,14 +131,14 @@ function _scrollTargetIntoContainerTopAndSettle() {
|
|
|
130
131
|
elapsed = window.performance.now() - startTime;
|
|
131
132
|
offsetSettled = previousOffset !== undefined && Math.abs(offset - previousOffset) < 0.5;
|
|
132
133
|
if (elapsed > TARGET_TOP_CORRECTION_DELAY && offsetSettled) {
|
|
133
|
-
scrollTargetIntoContainerTop(scrollEl, target, 'auto');
|
|
134
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'auto', TARGET_TOP_SAFE_OFFSET);
|
|
134
135
|
}
|
|
135
136
|
previousOffset = offset;
|
|
136
137
|
_context3.next = 4;
|
|
137
138
|
break;
|
|
138
139
|
case 23:
|
|
139
140
|
target = getMessageElementInScrollContainer(scrollEl, messageId) || target;
|
|
140
|
-
scrollTargetIntoContainerTop(scrollEl, target, 'auto');
|
|
141
|
+
scrollTargetIntoContainerTop(scrollEl, target, 'auto', TARGET_TOP_SAFE_OFFSET);
|
|
141
142
|
_context3.next = 27;
|
|
142
143
|
return waitForNextFrame();
|
|
143
144
|
case 27:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentscope-ai/chat",
|
|
3
|
-
"version": "1.1.71-beta.
|
|
3
|
+
"version": "1.1.71-beta.1782467989098",
|
|
4
4
|
"description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": [
|