@xinghunm/ai-chat 1.3.2 → 1.3.3
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/dist/index.js +45 -50
- package/dist/index.mjs +45 -50
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1338,6 +1338,14 @@ var createTimelineAnchorState = ({
|
|
|
1338
1338
|
timelineBlockAnchors: {},
|
|
1339
1339
|
visibleTimelineBlockKeys: {}
|
|
1340
1340
|
});
|
|
1341
|
+
var createInitialTimelineAnchorState = ({
|
|
1342
|
+
messageId
|
|
1343
|
+
}) => ({
|
|
1344
|
+
messageId,
|
|
1345
|
+
previousBlockKeys: [],
|
|
1346
|
+
timelineBlockAnchors: {},
|
|
1347
|
+
visibleTimelineBlockKeys: {}
|
|
1348
|
+
});
|
|
1341
1349
|
var timelineAnchorReducer = (state, action) => {
|
|
1342
1350
|
switch (action.type) {
|
|
1343
1351
|
case "reset-message":
|
|
@@ -1427,7 +1435,7 @@ var useTimelineBlockAnchors = ({
|
|
|
1427
1435
|
messageId: message.id,
|
|
1428
1436
|
currentBlockKeys: currentTimelineBlockKeys
|
|
1429
1437
|
},
|
|
1430
|
-
|
|
1438
|
+
createInitialTimelineAnchorState
|
|
1431
1439
|
);
|
|
1432
1440
|
const effectiveTimelineBlockAnchors = (0, import_react6.useMemo)(() => {
|
|
1433
1441
|
if (messageRenderOrder !== "timeline" || !isAssistantStreaming) {
|
|
@@ -3624,7 +3632,6 @@ var ChatThreadView = ({
|
|
|
3624
3632
|
[historyMessages, streamingMessage]
|
|
3625
3633
|
);
|
|
3626
3634
|
const latestTurn = conversationTurns[conversationTurns.length - 1];
|
|
3627
|
-
const previousTurns = conversationTurns.slice(0, -1);
|
|
3628
3635
|
const latestUserMessageId = latestTurn?.userMessage?.id;
|
|
3629
3636
|
const latestHistoryMessage = historyMessages[historyMessages.length - 1];
|
|
3630
3637
|
const latestTurnRef = (0, import_react11.useRef)(null);
|
|
@@ -3813,54 +3820,42 @@ var ChatThreadView = ({
|
|
|
3813
3820
|
}, [latestTurn, scrollToBottom]);
|
|
3814
3821
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ThreadViewport, { children: [
|
|
3815
3822
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(Container, { ref: containerRef, "data-testid": "chat-thread", onScroll: handleContainerScroll, children: [
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
) : null,
|
|
3853
|
-
latestTurn.responseMessages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MessageSlot, { children: renderChatMessage({
|
|
3854
|
-
message,
|
|
3855
|
-
mode: activeSessionMode,
|
|
3856
|
-
onConfirmationSubmit,
|
|
3857
|
-
onQuestionnaireSubmit,
|
|
3858
|
-
renderMessageBlock
|
|
3859
|
-
}) }, message.id)),
|
|
3860
|
-
error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3861
|
-
]
|
|
3862
|
-
}
|
|
3863
|
-
) : null,
|
|
3823
|
+
conversationTurns.map((turn, turnIndex) => {
|
|
3824
|
+
const isLatestTurn = turnIndex === conversationTurns.length - 1;
|
|
3825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
3826
|
+
ConversationTurn,
|
|
3827
|
+
{
|
|
3828
|
+
ref: isLatestTurn ? latestTurnRef : null,
|
|
3829
|
+
"data-testid": isLatestTurn ? "chat-thread-latest-turn" : "chat-thread-turn",
|
|
3830
|
+
style: isLatestTurn && latestTurnMinHeight > 0 ? { minHeight: `${latestTurnMinHeight}px` } : void 0,
|
|
3831
|
+
children: [
|
|
3832
|
+
turn.userMessage ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3833
|
+
MessageSlot,
|
|
3834
|
+
{
|
|
3835
|
+
"data-testid": isLatestTurn ? "chat-latest-user-anchor" : void 0,
|
|
3836
|
+
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
3837
|
+
children: renderChatMessage({
|
|
3838
|
+
message: turn.userMessage,
|
|
3839
|
+
mode: activeSessionMode,
|
|
3840
|
+
onConfirmationSubmit,
|
|
3841
|
+
onQuestionnaireSubmit,
|
|
3842
|
+
renderMessageBlock
|
|
3843
|
+
})
|
|
3844
|
+
}
|
|
3845
|
+
) : null,
|
|
3846
|
+
turn.responseMessages.map((message) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MessageSlot, { children: renderChatMessage({
|
|
3847
|
+
message,
|
|
3848
|
+
mode: activeSessionMode,
|
|
3849
|
+
onConfirmationSubmit,
|
|
3850
|
+
onQuestionnaireSubmit,
|
|
3851
|
+
renderMessageBlock
|
|
3852
|
+
}) }, message.id)),
|
|
3853
|
+
isLatestTurn && error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3854
|
+
]
|
|
3855
|
+
},
|
|
3856
|
+
turn.id
|
|
3857
|
+
);
|
|
3858
|
+
}),
|
|
3864
3859
|
!latestTurn && error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3865
3860
|
] }),
|
|
3866
3861
|
isDetached ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScrollToLatestOverlay, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
package/dist/index.mjs
CHANGED
|
@@ -1291,6 +1291,14 @@ var createTimelineAnchorState = ({
|
|
|
1291
1291
|
timelineBlockAnchors: {},
|
|
1292
1292
|
visibleTimelineBlockKeys: {}
|
|
1293
1293
|
});
|
|
1294
|
+
var createInitialTimelineAnchorState = ({
|
|
1295
|
+
messageId
|
|
1296
|
+
}) => ({
|
|
1297
|
+
messageId,
|
|
1298
|
+
previousBlockKeys: [],
|
|
1299
|
+
timelineBlockAnchors: {},
|
|
1300
|
+
visibleTimelineBlockKeys: {}
|
|
1301
|
+
});
|
|
1294
1302
|
var timelineAnchorReducer = (state, action) => {
|
|
1295
1303
|
switch (action.type) {
|
|
1296
1304
|
case "reset-message":
|
|
@@ -1380,7 +1388,7 @@ var useTimelineBlockAnchors = ({
|
|
|
1380
1388
|
messageId: message.id,
|
|
1381
1389
|
currentBlockKeys: currentTimelineBlockKeys
|
|
1382
1390
|
},
|
|
1383
|
-
|
|
1391
|
+
createInitialTimelineAnchorState
|
|
1384
1392
|
);
|
|
1385
1393
|
const effectiveTimelineBlockAnchors = useMemo3(() => {
|
|
1386
1394
|
if (messageRenderOrder !== "timeline" || !isAssistantStreaming) {
|
|
@@ -3581,7 +3589,6 @@ var ChatThreadView = ({
|
|
|
3581
3589
|
[historyMessages, streamingMessage]
|
|
3582
3590
|
);
|
|
3583
3591
|
const latestTurn = conversationTurns[conversationTurns.length - 1];
|
|
3584
|
-
const previousTurns = conversationTurns.slice(0, -1);
|
|
3585
3592
|
const latestUserMessageId = latestTurn?.userMessage?.id;
|
|
3586
3593
|
const latestHistoryMessage = historyMessages[historyMessages.length - 1];
|
|
3587
3594
|
const latestTurnRef = useRef5(null);
|
|
@@ -3770,54 +3777,42 @@ var ChatThreadView = ({
|
|
|
3770
3777
|
}, [latestTurn, scrollToBottom]);
|
|
3771
3778
|
return /* @__PURE__ */ jsxs7(ThreadViewport, { children: [
|
|
3772
3779
|
/* @__PURE__ */ jsxs7(Container, { ref: containerRef, "data-testid": "chat-thread", onScroll: handleContainerScroll, children: [
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
) : null,
|
|
3810
|
-
latestTurn.responseMessages.map((message) => /* @__PURE__ */ jsx10(MessageSlot, { children: renderChatMessage({
|
|
3811
|
-
message,
|
|
3812
|
-
mode: activeSessionMode,
|
|
3813
|
-
onConfirmationSubmit,
|
|
3814
|
-
onQuestionnaireSubmit,
|
|
3815
|
-
renderMessageBlock
|
|
3816
|
-
}) }, message.id)),
|
|
3817
|
-
error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3818
|
-
]
|
|
3819
|
-
}
|
|
3820
|
-
) : null,
|
|
3780
|
+
conversationTurns.map((turn, turnIndex) => {
|
|
3781
|
+
const isLatestTurn = turnIndex === conversationTurns.length - 1;
|
|
3782
|
+
return /* @__PURE__ */ jsxs7(
|
|
3783
|
+
ConversationTurn,
|
|
3784
|
+
{
|
|
3785
|
+
ref: isLatestTurn ? latestTurnRef : null,
|
|
3786
|
+
"data-testid": isLatestTurn ? "chat-thread-latest-turn" : "chat-thread-turn",
|
|
3787
|
+
style: isLatestTurn && latestTurnMinHeight > 0 ? { minHeight: `${latestTurnMinHeight}px` } : void 0,
|
|
3788
|
+
children: [
|
|
3789
|
+
turn.userMessage ? /* @__PURE__ */ jsx10(
|
|
3790
|
+
MessageSlot,
|
|
3791
|
+
{
|
|
3792
|
+
"data-testid": isLatestTurn ? "chat-latest-user-anchor" : void 0,
|
|
3793
|
+
style: isLatestTurn ? { scrollMarginTop: `${CHAT_THREAD_SCROLL_TOP_GAP}px` } : void 0,
|
|
3794
|
+
children: renderChatMessage({
|
|
3795
|
+
message: turn.userMessage,
|
|
3796
|
+
mode: activeSessionMode,
|
|
3797
|
+
onConfirmationSubmit,
|
|
3798
|
+
onQuestionnaireSubmit,
|
|
3799
|
+
renderMessageBlock
|
|
3800
|
+
})
|
|
3801
|
+
}
|
|
3802
|
+
) : null,
|
|
3803
|
+
turn.responseMessages.map((message) => /* @__PURE__ */ jsx10(MessageSlot, { children: renderChatMessage({
|
|
3804
|
+
message,
|
|
3805
|
+
mode: activeSessionMode,
|
|
3806
|
+
onConfirmationSubmit,
|
|
3807
|
+
onQuestionnaireSubmit,
|
|
3808
|
+
renderMessageBlock
|
|
3809
|
+
}) }, message.id)),
|
|
3810
|
+
isLatestTurn && error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3811
|
+
]
|
|
3812
|
+
},
|
|
3813
|
+
turn.id
|
|
3814
|
+
);
|
|
3815
|
+
}),
|
|
3821
3816
|
!latestTurn && error2 ? renderErrorState({ error: error2, onRetry, retryButtonLabel }) : null
|
|
3822
3817
|
] }),
|
|
3823
3818
|
isDetached ? /* @__PURE__ */ jsx10(ScrollToLatestOverlay, { children: /* @__PURE__ */ jsxs7(
|