@lvce-editor/chat-view 5.4.0 → 6.0.0
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/chatViewWorkerMain.js +36 -12
- package/package.json +1 -1
|
@@ -1604,6 +1604,7 @@ const createDefaultState = () => {
|
|
|
1604
1604
|
lastSubmittedSessionId: '',
|
|
1605
1605
|
listItemHeight: 40,
|
|
1606
1606
|
maxComposerRows: 5,
|
|
1607
|
+
messagesAutoScrollEnabled: true,
|
|
1607
1608
|
messagesScrollTop: 0,
|
|
1608
1609
|
mockAiResponseDelay: 800,
|
|
1609
1610
|
mockApiCommandId: '',
|
|
@@ -1643,7 +1644,7 @@ const createDefaultState = () => {
|
|
|
1643
1644
|
tokensUsed: 0,
|
|
1644
1645
|
uid: 0,
|
|
1645
1646
|
usageOverviewEnabled: false,
|
|
1646
|
-
useChatCoordinatorWorker:
|
|
1647
|
+
useChatCoordinatorWorker: true,
|
|
1647
1648
|
useChatMathWorker: true,
|
|
1648
1649
|
useChatNetworkWorkerForRequests: false,
|
|
1649
1650
|
useMockApi: false,
|
|
@@ -6649,6 +6650,12 @@ const getMentionContextMessage = async value => {
|
|
|
6649
6650
|
};
|
|
6650
6651
|
};
|
|
6651
6652
|
|
|
6653
|
+
const AutoScrollTopA = Number.MAX_SAFE_INTEGER;
|
|
6654
|
+
const AutoScrollTopB = Number.MAX_SAFE_INTEGER - 1;
|
|
6655
|
+
const getNextAutoScrollTop = currentScrollTop => {
|
|
6656
|
+
return currentScrollTop === AutoScrollTopA ? AutoScrollTopB : AutoScrollTopA;
|
|
6657
|
+
};
|
|
6658
|
+
|
|
6652
6659
|
const slashCommandRegex = /^\/(clear|export|help|new)(?:\s+.*)?$/;
|
|
6653
6660
|
const getSlashCommand = value => {
|
|
6654
6661
|
const trimmed = value.trim();
|
|
@@ -6738,6 +6745,9 @@ const handleTextChunkFunction = async (uid, assistantMessageId, chunk, handleTex
|
|
|
6738
6745
|
const updated = await updateMessageTextInSelectedSession(handleTextChunkState.latestState.sessions, handleTextChunkState.latestState.parsedMessages, handleTextChunkState.latestState.selectedSessionId, assistantMessageId, updatedText, true);
|
|
6739
6746
|
const nextState = {
|
|
6740
6747
|
...handleTextChunkState.latestState,
|
|
6748
|
+
...(handleTextChunkState.latestState.messagesAutoScrollEnabled ? {
|
|
6749
|
+
messagesScrollTop: getNextAutoScrollTop(handleTextChunkState.latestState.messagesScrollTop)
|
|
6750
|
+
} : {}),
|
|
6741
6751
|
parsedMessages: updated.parsedMessages,
|
|
6742
6752
|
sessions: updated.sessions
|
|
6743
6753
|
};
|
|
@@ -6767,6 +6777,9 @@ const handleToolCallsChunkFunction = async (uid, assistantMessageId, toolCalls,
|
|
|
6767
6777
|
const updated = updateMessageToolCallsInSelectedSession(handleTextChunkState.latestState.sessions, handleTextChunkState.latestState.parsedMessages, handleTextChunkState.latestState.selectedSessionId, assistantMessageId, toolCalls);
|
|
6768
6778
|
const nextState = {
|
|
6769
6779
|
...handleTextChunkState.latestState,
|
|
6780
|
+
...(handleTextChunkState.latestState.messagesAutoScrollEnabled ? {
|
|
6781
|
+
messagesScrollTop: getNextAutoScrollTop(handleTextChunkState.latestState.messagesScrollTop)
|
|
6782
|
+
} : {}),
|
|
6770
6783
|
parsedMessages: updated.parsedMessages,
|
|
6771
6784
|
sessions: updated.sessions
|
|
6772
6785
|
};
|
|
@@ -6832,6 +6845,15 @@ const updateSessionTitle = (sessions, selectedSessionId, title) => {
|
|
|
6832
6845
|
});
|
|
6833
6846
|
};
|
|
6834
6847
|
|
|
6848
|
+
const withUpdatedMessageScrollTop = state => {
|
|
6849
|
+
if (!state.messagesAutoScrollEnabled) {
|
|
6850
|
+
return state;
|
|
6851
|
+
}
|
|
6852
|
+
return {
|
|
6853
|
+
...state,
|
|
6854
|
+
messagesScrollTop: getNextAutoScrollTop(state.messagesScrollTop)
|
|
6855
|
+
};
|
|
6856
|
+
};
|
|
6835
6857
|
const handleSubmit = async state => {
|
|
6836
6858
|
const {
|
|
6837
6859
|
aiSessionTitleGenerationEnabled,
|
|
@@ -6922,7 +6944,7 @@ const handleSubmit = async state => {
|
|
|
6922
6944
|
title: `Chat ${workingSessions.length + 1}`
|
|
6923
6945
|
};
|
|
6924
6946
|
await saveChatSession(newSession);
|
|
6925
|
-
optimisticState = focusInput({
|
|
6947
|
+
optimisticState = withUpdatedMessageScrollTop(focusInput({
|
|
6926
6948
|
...state,
|
|
6927
6949
|
composerHeight: getMinComposerHeightForState(state),
|
|
6928
6950
|
composerValue: '',
|
|
@@ -6933,7 +6955,7 @@ const handleSubmit = async state => {
|
|
|
6933
6955
|
selectedSessionId: newSessionId,
|
|
6934
6956
|
sessions: [...workingSessions, newSession],
|
|
6935
6957
|
viewMode: 'detail'
|
|
6936
|
-
});
|
|
6958
|
+
}));
|
|
6937
6959
|
} else {
|
|
6938
6960
|
await appendChatViewEvent({
|
|
6939
6961
|
sessionId: selectedSessionId,
|
|
@@ -6947,7 +6969,7 @@ const handleSubmit = async state => {
|
|
|
6947
6969
|
if (selectedSession) {
|
|
6948
6970
|
await saveChatSession(selectedSession);
|
|
6949
6971
|
}
|
|
6950
|
-
optimisticState = focusInput({
|
|
6972
|
+
optimisticState = withUpdatedMessageScrollTop(focusInput({
|
|
6951
6973
|
...state,
|
|
6952
6974
|
composerHeight: getMinComposerHeightForState(state),
|
|
6953
6975
|
composerValue: '',
|
|
@@ -6956,7 +6978,7 @@ const handleSubmit = async state => {
|
|
|
6956
6978
|
nextMessageId: nextMessageId + 1,
|
|
6957
6979
|
parsedMessages,
|
|
6958
6980
|
sessions: updatedSessions
|
|
6959
|
-
});
|
|
6981
|
+
}));
|
|
6960
6982
|
}
|
|
6961
6983
|
set$1(state.uid, state, optimisticState);
|
|
6962
6984
|
// @ts-ignore
|
|
@@ -7046,12 +7068,12 @@ const handleSubmit = async state => {
|
|
|
7046
7068
|
if (selectedSession) {
|
|
7047
7069
|
await saveChatSession(selectedSession);
|
|
7048
7070
|
}
|
|
7049
|
-
return focusInput({
|
|
7071
|
+
return withUpdatedMessageScrollTop(focusInput({
|
|
7050
7072
|
...latestState,
|
|
7051
7073
|
nextMessageId: latestState.nextMessageId + 1,
|
|
7052
7074
|
parsedMessages: finalParsedMessages,
|
|
7053
7075
|
sessions: updatedSessions
|
|
7054
|
-
});
|
|
7076
|
+
}));
|
|
7055
7077
|
};
|
|
7056
7078
|
|
|
7057
7079
|
const handleClickSend = async state => {
|
|
@@ -7574,12 +7596,14 @@ const handleChatListScroll = async (state, chatListScrollTop) => {
|
|
|
7574
7596
|
chatListScrollTop
|
|
7575
7597
|
};
|
|
7576
7598
|
};
|
|
7577
|
-
const handleMessagesScroll = async (state, messagesScrollTop) => {
|
|
7578
|
-
|
|
7599
|
+
const handleMessagesScroll = async (state, messagesScrollTop, scrollHeight, clientHeight) => {
|
|
7600
|
+
const messagesAutoScrollEnabled = messagesScrollTop + clientHeight >= scrollHeight - 8;
|
|
7601
|
+
if (state.messagesScrollTop === messagesScrollTop && state.messagesAutoScrollEnabled === messagesAutoScrollEnabled) {
|
|
7579
7602
|
return state;
|
|
7580
7603
|
}
|
|
7581
7604
|
return {
|
|
7582
7605
|
...state,
|
|
7606
|
+
messagesAutoScrollEnabled,
|
|
7583
7607
|
messagesScrollTop
|
|
7584
7608
|
};
|
|
7585
7609
|
};
|
|
@@ -7771,9 +7795,9 @@ const loadStreamingEnabled = async () => {
|
|
|
7771
7795
|
const loadUseChatCoordinatorWorker = async () => {
|
|
7772
7796
|
try {
|
|
7773
7797
|
const savedUseChatCoordinatorWorker = await get('chatView.useChatCoordinatorWorker');
|
|
7774
|
-
return typeof savedUseChatCoordinatorWorker === 'boolean' ? savedUseChatCoordinatorWorker :
|
|
7798
|
+
return typeof savedUseChatCoordinatorWorker === 'boolean' ? savedUseChatCoordinatorWorker : true;
|
|
7775
7799
|
} catch {
|
|
7776
|
-
return
|
|
7800
|
+
return true;
|
|
7777
7801
|
}
|
|
7778
7802
|
};
|
|
7779
7803
|
|
|
@@ -10199,7 +10223,7 @@ const renderEventListeners = () => {
|
|
|
10199
10223
|
params: ['handleChatListScroll', 'event.target.scrollTop']
|
|
10200
10224
|
}, {
|
|
10201
10225
|
name: HandleMessagesScroll,
|
|
10202
|
-
params: ['handleMessagesScroll', 'event.target.scrollTop']
|
|
10226
|
+
params: ['handleMessagesScroll', 'event.target.scrollTop', 'event.target.scrollHeight', 'event.target.clientHeight']
|
|
10203
10227
|
}, {
|
|
10204
10228
|
name: HandleProjectListScroll,
|
|
10205
10229
|
params: ['handleProjectListScroll', 'event.target.scrollTop']
|