@lvce-editor/chat-view 4.4.0 → 4.6.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 +287 -134
- package/package.json +1 -1
|
@@ -1075,6 +1075,7 @@ const create$2 = rpcId => {
|
|
|
1075
1075
|
};
|
|
1076
1076
|
|
|
1077
1077
|
const {
|
|
1078
|
+
invoke: invoke$4,
|
|
1078
1079
|
set: set$4
|
|
1079
1080
|
} = create$2(6007);
|
|
1080
1081
|
|
|
@@ -1160,22 +1161,22 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1160
1161
|
const FocusChatInput = 8000;
|
|
1161
1162
|
|
|
1162
1163
|
const {
|
|
1163
|
-
invoke: invoke$
|
|
1164
|
+
invoke: invoke$3,
|
|
1164
1165
|
set: set$3
|
|
1165
1166
|
} = create$2(ChatNetworkWorker);
|
|
1166
1167
|
|
|
1167
1168
|
const {
|
|
1168
|
-
invoke: invoke$
|
|
1169
|
+
invoke: invoke$2,
|
|
1169
1170
|
set: set$2
|
|
1170
1171
|
} = create$2(ExtensionHostWorker);
|
|
1171
1172
|
|
|
1172
1173
|
const {
|
|
1173
|
-
invoke,
|
|
1174
|
+
invoke: invoke$1,
|
|
1174
1175
|
invokeAndTransfer,
|
|
1175
1176
|
set: set$1
|
|
1176
1177
|
} = create$2(RendererWorker);
|
|
1177
1178
|
const readFile = async uri => {
|
|
1178
|
-
return invoke('FileSystem.readFile', uri);
|
|
1179
|
+
return invoke$1('FileSystem.readFile', uri);
|
|
1179
1180
|
};
|
|
1180
1181
|
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
1181
1182
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
@@ -1184,27 +1185,23 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
|
1184
1185
|
const sendMessagePortToChatNetworkWorker = async port => {
|
|
1185
1186
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToChatNetworkWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
1186
1187
|
};
|
|
1187
|
-
const confirm = async (message, options) => {
|
|
1188
|
-
const result = await invoke('ConfirmPrompt.prompt', message, options);
|
|
1189
|
-
return result;
|
|
1190
|
-
};
|
|
1191
1188
|
const writeFile = async (uri, text) => {
|
|
1192
|
-
await invoke('FileSystem.writeFile', uri, text);
|
|
1189
|
+
await invoke$1('FileSystem.writeFile', uri, text);
|
|
1193
1190
|
};
|
|
1194
1191
|
const activateByEvent$1 = (event, assetDir, platform) => {
|
|
1195
|
-
return invoke('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1192
|
+
return invoke$1('ExtensionHostManagement.activateByEvent', event, assetDir, platform);
|
|
1196
1193
|
};
|
|
1197
1194
|
const getWorkspacePath = () => {
|
|
1198
|
-
return invoke('Workspace.getPath');
|
|
1195
|
+
return invoke$1('Workspace.getPath');
|
|
1199
1196
|
};
|
|
1200
1197
|
const getPreference = async key => {
|
|
1201
|
-
return await invoke('Preferences.get', key);
|
|
1198
|
+
return await invoke$1('Preferences.get', key);
|
|
1202
1199
|
};
|
|
1203
1200
|
const openExternal = async uri => {
|
|
1204
|
-
await invoke('Open.openExternal', uri);
|
|
1201
|
+
await invoke$1('Open.openExternal', uri);
|
|
1205
1202
|
};
|
|
1206
1203
|
const measureTextBlockHeight$1 = async (actualInput, fontFamily, fontSize, lineHeightPx, width) => {
|
|
1207
|
-
return invoke(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1204
|
+
return invoke$1(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1208
1205
|
};
|
|
1209
1206
|
|
|
1210
1207
|
const toCommandId = key => {
|
|
@@ -1328,6 +1325,9 @@ const terminate = () => {
|
|
|
1328
1325
|
};
|
|
1329
1326
|
|
|
1330
1327
|
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
1328
|
+
// Upstream renderer types currently require number, but runtime accepts px strings.
|
|
1329
|
+
// Keep forwarding the string to preserve chat-view behavior until upstream is updated.
|
|
1330
|
+
// @ts-ignore
|
|
1331
1331
|
return measureTextBlockHeight$1(text, fontFamily, fontSize, lineHeight, width);
|
|
1332
1332
|
};
|
|
1333
1333
|
|
|
@@ -1359,7 +1359,7 @@ const getComposerHeight = async (state, value, width = state.width) => {
|
|
|
1359
1359
|
const content = value || ' ';
|
|
1360
1360
|
const composerWidth = getComposerWidth(width);
|
|
1361
1361
|
try {
|
|
1362
|
-
const measuredHeight = await measureTextBlockHeight(content, composerFontFamily, composerFontSize, composerLineHeight
|
|
1362
|
+
const measuredHeight = await measureTextBlockHeight(content, composerFontFamily, composerFontSize, `${composerLineHeight}px`, composerWidth);
|
|
1363
1363
|
const height = Math.ceil(measuredHeight) + 8;
|
|
1364
1364
|
return Math.max(minimumHeight, Math.min(maximumHeight, height));
|
|
1365
1365
|
} catch {
|
|
@@ -1628,6 +1628,7 @@ const createDefaultState = () => {
|
|
|
1628
1628
|
tokensUsed: 0,
|
|
1629
1629
|
uid: 0,
|
|
1630
1630
|
usageOverviewEnabled: false,
|
|
1631
|
+
useChatMathWorker: true,
|
|
1631
1632
|
useChatNetworkWorkerForRequests: false,
|
|
1632
1633
|
useMockApi: false,
|
|
1633
1634
|
viewMode: 'list',
|
|
@@ -2435,7 +2436,7 @@ const isEqualProjectExpandedIds = (a, b) => {
|
|
|
2435
2436
|
return true;
|
|
2436
2437
|
};
|
|
2437
2438
|
const isEqual = (oldState, newState) => {
|
|
2438
|
-
return oldState.composerDropActive === newState.composerDropActive && oldState.composerDropEnabled === newState.composerDropEnabled && oldState.composerValue === newState.composerValue && oldState.initial === newState.initial && isEqualProjectExpandedIds(oldState.projectExpandedIds, newState.projectExpandedIds) && oldState.projectListScrollTop === newState.projectListScrollTop && oldState.renamingSessionId === newState.renamingSessionId && oldState.selectedModelId === newState.selectedModelId && oldState.selectedProjectId === newState.selectedProjectId && oldState.selectedSessionId === newState.selectedSessionId && oldState.sessions === newState.sessions && oldState.tokensMax === newState.tokensMax && oldState.tokensUsed === newState.tokensUsed && oldState.usageOverviewEnabled === newState.usageOverviewEnabled && oldState.viewMode === newState.viewMode && oldState.voiceDictationEnabled === newState.voiceDictationEnabled;
|
|
2439
|
+
return oldState.composerDropActive === newState.composerDropActive && oldState.composerDropEnabled === newState.composerDropEnabled && oldState.composerValue === newState.composerValue && oldState.initial === newState.initial && isEqualProjectExpandedIds(oldState.projectExpandedIds, newState.projectExpandedIds) && oldState.projectListScrollTop === newState.projectListScrollTop && oldState.renamingSessionId === newState.renamingSessionId && oldState.selectedModelId === newState.selectedModelId && oldState.selectedProjectId === newState.selectedProjectId && oldState.selectedSessionId === newState.selectedSessionId && oldState.sessions === newState.sessions && oldState.tokensMax === newState.tokensMax && oldState.tokensUsed === newState.tokensUsed && oldState.usageOverviewEnabled === newState.usageOverviewEnabled && oldState.useChatMathWorker === newState.useChatMathWorker && oldState.viewMode === newState.viewMode && oldState.voiceDictationEnabled === newState.voiceDictationEnabled;
|
|
2439
2440
|
};
|
|
2440
2441
|
|
|
2441
2442
|
const diffScrollTop = (oldState, newState) => {
|
|
@@ -2824,7 +2825,7 @@ const handleChatListContextMenu = async (state, eventX, eventY) => {
|
|
|
2824
2825
|
if (!item) {
|
|
2825
2826
|
return state;
|
|
2826
2827
|
}
|
|
2827
|
-
await invoke('ContextMenu.show', eventX, eventY, CHAT_LIST_ITEM_CONTEXT_MENU, item.id);
|
|
2828
|
+
await invoke$1('ContextMenu.show', eventX, eventY, CHAT_LIST_ITEM_CONTEXT_MENU, item.id);
|
|
2828
2829
|
return state;
|
|
2829
2830
|
};
|
|
2830
2831
|
|
|
@@ -2853,6 +2854,14 @@ const createSession = async (state, projectIdOverride = '') => {
|
|
|
2853
2854
|
};
|
|
2854
2855
|
};
|
|
2855
2856
|
|
|
2857
|
+
const openFolder = async () => {
|
|
2858
|
+
try {
|
|
2859
|
+
return await invoke$1('FilePicker.showDirectoryPicker');
|
|
2860
|
+
} catch {
|
|
2861
|
+
return '';
|
|
2862
|
+
}
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2856
2865
|
const selectProject = async (state, projectId) => {
|
|
2857
2866
|
if (!projectId || state.selectedProjectId === projectId) {
|
|
2858
2867
|
return state;
|
|
@@ -2899,17 +2908,8 @@ const getProjectName = (uri, fallbackIndex) => {
|
|
|
2899
2908
|
const getNextProjectId = projects => {
|
|
2900
2909
|
return `project-${projects.length + 1}`;
|
|
2901
2910
|
};
|
|
2902
|
-
const pickProjectUri = async () => {
|
|
2903
|
-
try {
|
|
2904
|
-
const workspaceUri = await getWorkspacePath();
|
|
2905
|
-
return workspaceUri;
|
|
2906
|
-
} catch {
|
|
2907
|
-
return '';
|
|
2908
|
-
}
|
|
2909
|
-
};
|
|
2910
2911
|
const handleClickCreateProject = async state => {
|
|
2911
|
-
await
|
|
2912
|
-
const uri = await pickProjectUri();
|
|
2912
|
+
const uri = await openFolder();
|
|
2913
2913
|
if (!uri) {
|
|
2914
2914
|
return state;
|
|
2915
2915
|
}
|
|
@@ -2933,7 +2933,7 @@ const handleClickCreateProject = async state => {
|
|
|
2933
2933
|
};
|
|
2934
2934
|
|
|
2935
2935
|
const handleClickOpenApiApiKeySettings = async state => {
|
|
2936
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
2936
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
2937
2937
|
return state;
|
|
2938
2938
|
};
|
|
2939
2939
|
|
|
@@ -2943,7 +2943,7 @@ const handleClickOpenApiApiKeyWebsite = async state => {
|
|
|
2943
2943
|
};
|
|
2944
2944
|
|
|
2945
2945
|
const handleClickOpenRouterApiKeySettings = async state => {
|
|
2946
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
2946
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
2947
2947
|
return state;
|
|
2948
2948
|
};
|
|
2949
2949
|
|
|
@@ -2994,7 +2994,7 @@ const executeListFilesTool = async (args, _options) => {
|
|
|
2994
2994
|
});
|
|
2995
2995
|
}
|
|
2996
2996
|
try {
|
|
2997
|
-
const entries = await invoke('FileSystem.readDirWithFileTypes', uri);
|
|
2997
|
+
const entries = await invoke$1('FileSystem.readDirWithFileTypes', uri);
|
|
2998
2998
|
return JSON.stringify({
|
|
2999
2999
|
entries,
|
|
3000
3000
|
uri
|
|
@@ -3586,7 +3586,7 @@ const executeProvider = async ({
|
|
|
3586
3586
|
}) => {
|
|
3587
3587
|
await activateByEvent(event, assetDir, platform);
|
|
3588
3588
|
// @ts-ignore
|
|
3589
|
-
const result = invoke$
|
|
3589
|
+
const result = invoke$2(method, ...params);
|
|
3590
3590
|
return result;
|
|
3591
3591
|
};
|
|
3592
3592
|
|
|
@@ -3718,10 +3718,10 @@ const getOpenApiApiEndpoint = openApiApiBaseUrl => {
|
|
|
3718
3718
|
};
|
|
3719
3719
|
|
|
3720
3720
|
const makeApiRequest = async options => {
|
|
3721
|
-
return invoke$
|
|
3721
|
+
return invoke$3('ChatNetwork.makeApiRequest', options);
|
|
3722
3722
|
};
|
|
3723
3723
|
const makeStreamingApiRequest = async options => {
|
|
3724
|
-
return invoke$
|
|
3724
|
+
return invoke$3('ChatNetwork.makeStreamingApiRequest', options);
|
|
3725
3725
|
};
|
|
3726
3726
|
|
|
3727
3727
|
const getTextContent = content => {
|
|
@@ -5320,7 +5320,7 @@ const get = async key => {
|
|
|
5320
5320
|
return getPreference(key);
|
|
5321
5321
|
};
|
|
5322
5322
|
const update = async settings => {
|
|
5323
|
-
await invoke('Preferences.update', settings);
|
|
5323
|
+
await invoke$1('Preferences.update', settings);
|
|
5324
5324
|
};
|
|
5325
5325
|
|
|
5326
5326
|
const setOpenApiApiKey = async (state, openApiApiKey, persist = true) => {
|
|
@@ -5421,7 +5421,7 @@ const handleClickSaveOpenRouterApiKey = async state => {
|
|
|
5421
5421
|
};
|
|
5422
5422
|
set(state.uid, state, optimisticState);
|
|
5423
5423
|
// @ts-ignore
|
|
5424
|
-
await invoke('Chat.rerender');
|
|
5424
|
+
await invoke$1('Chat.rerender');
|
|
5425
5425
|
const persistedState = await setOpenRouterApiKey(optimisticState, openRouterApiKey);
|
|
5426
5426
|
const updatedState = {
|
|
5427
5427
|
...persistedState,
|
|
@@ -5765,7 +5765,7 @@ const handleTextChunkFunction = async (uid, assistantMessageId, chunk, handleTex
|
|
|
5765
5765
|
};
|
|
5766
5766
|
set(uid, handleTextChunkState.previousState, nextState);
|
|
5767
5767
|
// @ts-ignore
|
|
5768
|
-
await invoke('Chat.rerender');
|
|
5768
|
+
await invoke$1('Chat.rerender');
|
|
5769
5769
|
return {
|
|
5770
5770
|
latestState: nextState,
|
|
5771
5771
|
previousState: nextState
|
|
@@ -5793,7 +5793,7 @@ const handleToolCallsChunkFunction = async (uid, assistantMessageId, toolCalls,
|
|
|
5793
5793
|
};
|
|
5794
5794
|
set(uid, handleTextChunkState.previousState, nextState);
|
|
5795
5795
|
// @ts-ignore
|
|
5796
|
-
await invoke('Chat.rerender');
|
|
5796
|
+
await invoke$1('Chat.rerender');
|
|
5797
5797
|
return {
|
|
5798
5798
|
latestState: nextState,
|
|
5799
5799
|
previousState: nextState
|
|
@@ -5973,7 +5973,7 @@ const handleSubmit = async state => {
|
|
|
5973
5973
|
}
|
|
5974
5974
|
set(state.uid, state, optimisticState);
|
|
5975
5975
|
// @ts-ignore
|
|
5976
|
-
await invoke('Chat.rerender');
|
|
5976
|
+
await invoke$1('Chat.rerender');
|
|
5977
5977
|
let handleTextChunkState = {
|
|
5978
5978
|
latestState: optimisticState,
|
|
5979
5979
|
previousState: optimisticState
|
|
@@ -6306,7 +6306,7 @@ const handleClickBack = async state => {
|
|
|
6306
6306
|
|
|
6307
6307
|
const handleClickClose = async () => {
|
|
6308
6308
|
// @ts-ignore
|
|
6309
|
-
await invoke('Layout.hideSecondarySideBar');
|
|
6309
|
+
await invoke$1('Layout.hideSecondarySideBar');
|
|
6310
6310
|
};
|
|
6311
6311
|
|
|
6312
6312
|
const handleClickDelete = async (state, sessionId = '') => {
|
|
@@ -6325,17 +6325,17 @@ const handleClickReadFile = async uri => {
|
|
|
6325
6325
|
if (!uri) {
|
|
6326
6326
|
return;
|
|
6327
6327
|
}
|
|
6328
|
-
await invoke('Main.openUri', uri);
|
|
6328
|
+
await invoke$1('Main.openUri', uri);
|
|
6329
6329
|
};
|
|
6330
6330
|
|
|
6331
6331
|
const handleClickSessionDebug = async state => {
|
|
6332
|
-
await invoke('Main.openUri', `chat-debug://${state.selectedSessionId}`);
|
|
6332
|
+
await invoke$1('Main.openUri', `chat-debug://${state.selectedSessionId}`);
|
|
6333
6333
|
return state;
|
|
6334
6334
|
};
|
|
6335
6335
|
|
|
6336
6336
|
const handleClickSettings = async () => {
|
|
6337
6337
|
// TODO
|
|
6338
|
-
await invoke('Main.openUri', 'app://settings.json');
|
|
6338
|
+
await invoke$1('Main.openUri', 'app://settings.json');
|
|
6339
6339
|
};
|
|
6340
6340
|
|
|
6341
6341
|
const handleDragEnter = async (state, name, hasFiles = true) => {
|
|
@@ -6548,7 +6548,7 @@ const handleKeyDown = async (state, key, shiftKey) => {
|
|
|
6548
6548
|
};
|
|
6549
6549
|
|
|
6550
6550
|
const handleMessagesContextMenu = async state => {
|
|
6551
|
-
await invoke('ContextMenu.show', 1234);
|
|
6551
|
+
await invoke$1('ContextMenu.show', 1234);
|
|
6552
6552
|
return state;
|
|
6553
6553
|
};
|
|
6554
6554
|
|
|
@@ -6773,6 +6773,15 @@ const loadStreamingEnabled = async () => {
|
|
|
6773
6773
|
}
|
|
6774
6774
|
};
|
|
6775
6775
|
|
|
6776
|
+
const loadUseChatMathWorker = async () => {
|
|
6777
|
+
try {
|
|
6778
|
+
const savedUseChatMathWorker = await get('chatView.useChatMathWorker');
|
|
6779
|
+
return typeof savedUseChatMathWorker === 'boolean' ? savedUseChatMathWorker : true;
|
|
6780
|
+
} catch {
|
|
6781
|
+
return true;
|
|
6782
|
+
}
|
|
6783
|
+
};
|
|
6784
|
+
|
|
6776
6785
|
const loadUseChatNetworkWorkerForRequests = async () => {
|
|
6777
6786
|
try {
|
|
6778
6787
|
const savedUseChatNetworkWorkerForRequests = await get('chatView.useChatNetworkWorkerForRequests');
|
|
@@ -6792,7 +6801,7 @@ const loadVoiceDictationEnabled = async () => {
|
|
|
6792
6801
|
};
|
|
6793
6802
|
|
|
6794
6803
|
const loadPreferences = async () => {
|
|
6795
|
-
const [aiSessionTitleGenerationEnabled, composerDropEnabled, openApiApiKey, openRouterApiKey, emitStreamingFunctionCallEvents, streamingEnabled, passIncludeObfuscation, useChatNetworkWorkerForRequests, voiceDictationEnabled] = await Promise.all([loadAiSessionTitleGenerationEnabled(), loadComposerDropEnabled(), loadOpenApiApiKey(), loadOpenRouterApiKey(), loadEmitStreamingFunctionCallEvents(), loadStreamingEnabled(), loadPassIncludeObfuscation(), loadUseChatNetworkWorkerForRequests(), loadVoiceDictationEnabled()]);
|
|
6804
|
+
const [aiSessionTitleGenerationEnabled, composerDropEnabled, openApiApiKey, openRouterApiKey, emitStreamingFunctionCallEvents, streamingEnabled, passIncludeObfuscation, useChatMathWorker, useChatNetworkWorkerForRequests, voiceDictationEnabled] = await Promise.all([loadAiSessionTitleGenerationEnabled(), loadComposerDropEnabled(), loadOpenApiApiKey(), loadOpenRouterApiKey(), loadEmitStreamingFunctionCallEvents(), loadStreamingEnabled(), loadPassIncludeObfuscation(), loadUseChatMathWorker(), loadUseChatNetworkWorkerForRequests(), loadVoiceDictationEnabled()]);
|
|
6796
6805
|
return {
|
|
6797
6806
|
aiSessionTitleGenerationEnabled,
|
|
6798
6807
|
composerDropEnabled,
|
|
@@ -6801,6 +6810,7 @@ const loadPreferences = async () => {
|
|
|
6801
6810
|
openRouterApiKey,
|
|
6802
6811
|
passIncludeObfuscation,
|
|
6803
6812
|
streamingEnabled,
|
|
6813
|
+
useChatMathWorker,
|
|
6804
6814
|
useChatNetworkWorkerForRequests,
|
|
6805
6815
|
voiceDictationEnabled
|
|
6806
6816
|
};
|
|
@@ -6915,9 +6925,22 @@ const getSavedLastNormalViewMode = savedState => {
|
|
|
6915
6925
|
}
|
|
6916
6926
|
return lastNormalViewMode;
|
|
6917
6927
|
};
|
|
6928
|
+
const getSavedComposerValue = savedState => {
|
|
6929
|
+
if (!isObject(savedState)) {
|
|
6930
|
+
return undefined;
|
|
6931
|
+
}
|
|
6932
|
+
const {
|
|
6933
|
+
composerValue
|
|
6934
|
+
} = savedState;
|
|
6935
|
+
if (typeof composerValue !== 'string') {
|
|
6936
|
+
return undefined;
|
|
6937
|
+
}
|
|
6938
|
+
return composerValue;
|
|
6939
|
+
};
|
|
6918
6940
|
const loadContent = async (state, savedState) => {
|
|
6919
6941
|
const savedSelectedModelId = getSavedSelectedModelId(savedState);
|
|
6920
6942
|
const savedViewMode = getSavedViewMode(savedState);
|
|
6943
|
+
const savedComposerValue = getSavedComposerValue(savedState);
|
|
6921
6944
|
const {
|
|
6922
6945
|
aiSessionTitleGenerationEnabled,
|
|
6923
6946
|
composerDropEnabled,
|
|
@@ -6926,6 +6949,7 @@ const loadContent = async (state, savedState) => {
|
|
|
6926
6949
|
openRouterApiKey,
|
|
6927
6950
|
passIncludeObfuscation,
|
|
6928
6951
|
streamingEnabled,
|
|
6952
|
+
useChatMathWorker,
|
|
6929
6953
|
useChatNetworkWorkerForRequests,
|
|
6930
6954
|
voiceDictationEnabled
|
|
6931
6955
|
} = await loadPreferences();
|
|
@@ -6975,6 +6999,7 @@ const loadContent = async (state, savedState) => {
|
|
|
6975
6999
|
chatListScrollTop,
|
|
6976
7000
|
composerDropActive: false,
|
|
6977
7001
|
composerDropEnabled,
|
|
7002
|
+
composerValue: savedComposerValue ?? state.composerValue,
|
|
6978
7003
|
emitStreamingFunctionCallEvents,
|
|
6979
7004
|
initial: false,
|
|
6980
7005
|
lastNormalViewMode,
|
|
@@ -6992,6 +7017,7 @@ const loadContent = async (state, savedState) => {
|
|
|
6992
7017
|
selectedSessionId,
|
|
6993
7018
|
sessions,
|
|
6994
7019
|
streamingEnabled,
|
|
7020
|
+
useChatMathWorker,
|
|
6995
7021
|
useChatNetworkWorkerForRequests,
|
|
6996
7022
|
viewMode,
|
|
6997
7023
|
voiceDictationEnabled
|
|
@@ -24038,6 +24064,88 @@ var katex = {
|
|
|
24038
24064
|
__domTree
|
|
24039
24065
|
};
|
|
24040
24066
|
|
|
24067
|
+
let initialized = false;
|
|
24068
|
+
const renderCache = new Map();
|
|
24069
|
+
const pendingRenders = new Set();
|
|
24070
|
+
const getCacheKey = (value, displayMode) => {
|
|
24071
|
+
return `${displayMode ? '1' : '0'}:${value}`;
|
|
24072
|
+
};
|
|
24073
|
+
const sendMessagePortToChatMathWorker = async port => {
|
|
24074
|
+
try {
|
|
24075
|
+
await invoke$1('sendMessagePortToChatMathWorker', port);
|
|
24076
|
+
} catch {
|
|
24077
|
+
await invoke$1('SendMessagePortToChatMathWorker.sendMessagePortToChatMathWorker', port);
|
|
24078
|
+
}
|
|
24079
|
+
};
|
|
24080
|
+
const createRpc = () => {
|
|
24081
|
+
return create$4({
|
|
24082
|
+
commandMap: {},
|
|
24083
|
+
send: sendMessagePortToChatMathWorker
|
|
24084
|
+
});
|
|
24085
|
+
};
|
|
24086
|
+
const initialize = async () => {
|
|
24087
|
+
if (initialized) {
|
|
24088
|
+
return;
|
|
24089
|
+
}
|
|
24090
|
+
const rpc = await createRpc();
|
|
24091
|
+
set$4(rpc);
|
|
24092
|
+
initialized = true;
|
|
24093
|
+
};
|
|
24094
|
+
const invoke = async (method, ...params) => {
|
|
24095
|
+
await initialize();
|
|
24096
|
+
return invoke$4(method, ...params);
|
|
24097
|
+
};
|
|
24098
|
+
const renderViaRpc = async (value, displayMode) => {
|
|
24099
|
+
const methods = ['renderToString', 'RenderToString.renderToString', 'RenderMath.renderMath', 'Math.renderToString'];
|
|
24100
|
+
for (const method of methods) {
|
|
24101
|
+
try {
|
|
24102
|
+
const result = await invoke(method, value, {
|
|
24103
|
+
displayMode,
|
|
24104
|
+
throwOnError: true
|
|
24105
|
+
});
|
|
24106
|
+
if (typeof result === 'string') {
|
|
24107
|
+
return result;
|
|
24108
|
+
}
|
|
24109
|
+
} catch {
|
|
24110
|
+
// Try next known method signature.
|
|
24111
|
+
}
|
|
24112
|
+
try {
|
|
24113
|
+
const result = await invoke(method, value, displayMode);
|
|
24114
|
+
if (typeof result === 'string') {
|
|
24115
|
+
return result;
|
|
24116
|
+
}
|
|
24117
|
+
} catch {
|
|
24118
|
+
// Try next known method signature.
|
|
24119
|
+
}
|
|
24120
|
+
}
|
|
24121
|
+
throw new Error('ChatMathWorker did not provide renderToString');
|
|
24122
|
+
};
|
|
24123
|
+
const startRender = (cacheKey, value, displayMode) => {
|
|
24124
|
+
if (pendingRenders.has(cacheKey)) {
|
|
24125
|
+
return;
|
|
24126
|
+
}
|
|
24127
|
+
pendingRenders.add(cacheKey);
|
|
24128
|
+
void (async () => {
|
|
24129
|
+
try {
|
|
24130
|
+
const html = await renderViaRpc(value, displayMode);
|
|
24131
|
+
renderCache.set(cacheKey, html);
|
|
24132
|
+
} catch {
|
|
24133
|
+
// Keep cache empty so caller can continue to show fallback text.
|
|
24134
|
+
} finally {
|
|
24135
|
+
pendingRenders.delete(cacheKey);
|
|
24136
|
+
}
|
|
24137
|
+
})();
|
|
24138
|
+
};
|
|
24139
|
+
const tryRenderToString = (value, displayMode) => {
|
|
24140
|
+
const cacheKey = getCacheKey(value, displayMode);
|
|
24141
|
+
const cached = renderCache.get(cacheKey);
|
|
24142
|
+
if (cached) {
|
|
24143
|
+
return cached;
|
|
24144
|
+
}
|
|
24145
|
+
startRender(cacheKey, value, displayMode);
|
|
24146
|
+
return undefined;
|
|
24147
|
+
};
|
|
24148
|
+
|
|
24041
24149
|
const maxHtmlLength = 40_000;
|
|
24042
24150
|
const tokenRegex = /<!--[\s\S]*?-->|<\/?[a-zA-Z][\w:-]*(?:\s[^<>]*?)?>|[^<]+/g;
|
|
24043
24151
|
const attributeRegex = /([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
|
|
@@ -24313,19 +24421,28 @@ const parseHtmlToVirtualDomWithRootCount = value => {
|
|
|
24313
24421
|
|
|
24314
24422
|
// cspell:ignore katex
|
|
24315
24423
|
|
|
24316
|
-
const renderMath = (value, displayMode) => {
|
|
24424
|
+
const renderMath = (value, displayMode, useChatMathWorker = false) => {
|
|
24317
24425
|
try {
|
|
24318
|
-
|
|
24319
|
-
|
|
24320
|
-
|
|
24321
|
-
}
|
|
24426
|
+
let html;
|
|
24427
|
+
if (useChatMathWorker) {
|
|
24428
|
+
html = tryRenderToString(value, displayMode);
|
|
24429
|
+
}
|
|
24430
|
+
if (typeof html !== 'string') {
|
|
24431
|
+
html = katex.renderToString(value, {
|
|
24432
|
+
displayMode,
|
|
24433
|
+
throwOnError: true
|
|
24434
|
+
});
|
|
24435
|
+
}
|
|
24436
|
+
if (typeof html !== 'string') {
|
|
24437
|
+
return undefined;
|
|
24438
|
+
}
|
|
24322
24439
|
return parseHtmlToVirtualDomWithRootCount(html);
|
|
24323
24440
|
} catch {
|
|
24324
24441
|
return undefined;
|
|
24325
24442
|
}
|
|
24326
24443
|
};
|
|
24327
|
-
const getMathInlineDom = node => {
|
|
24328
|
-
const rendered = renderMath(node.text, node.displayMode);
|
|
24444
|
+
const getMathInlineDom = (node, useChatMathWorker = false) => {
|
|
24445
|
+
const rendered = renderMath(node.text, node.displayMode, useChatMathWorker);
|
|
24329
24446
|
if (!rendered) {
|
|
24330
24447
|
const fallback = node.displayMode ? `$$${node.text}$$` : `$${node.text}$`;
|
|
24331
24448
|
return [text$2(fallback)];
|
|
@@ -24336,8 +24453,8 @@ const getMathInlineDom = node => {
|
|
|
24336
24453
|
type: Span$1
|
|
24337
24454
|
}, ...rendered.virtualDom];
|
|
24338
24455
|
};
|
|
24339
|
-
const getMathBlockDom = node => {
|
|
24340
|
-
const rendered = renderMath(node.text, true);
|
|
24456
|
+
const getMathBlockDom = (node, useChatMathWorker = false) => {
|
|
24457
|
+
const rendered = renderMath(node.text, true, useChatMathWorker);
|
|
24341
24458
|
if (!rendered) {
|
|
24342
24459
|
return [{
|
|
24343
24460
|
childCount: 1,
|
|
@@ -24352,7 +24469,7 @@ const getMathBlockDom = node => {
|
|
|
24352
24469
|
}, ...rendered.virtualDom];
|
|
24353
24470
|
};
|
|
24354
24471
|
|
|
24355
|
-
const getInlineNodeDom = inlineNode => {
|
|
24472
|
+
const getInlineNodeDom = (inlineNode, useChatMathWorker = false) => {
|
|
24356
24473
|
if (inlineNode.type === 'text') {
|
|
24357
24474
|
return [text$2(inlineNode.text)];
|
|
24358
24475
|
}
|
|
@@ -24369,7 +24486,7 @@ const getInlineNodeDom = inlineNode => {
|
|
|
24369
24486
|
}, text$2(inlineNode.text)];
|
|
24370
24487
|
}
|
|
24371
24488
|
if (inlineNode.type === 'math-inline') {
|
|
24372
|
-
return getMathInlineDom(inlineNode);
|
|
24489
|
+
return getMathInlineDom(inlineNode, useChatMathWorker);
|
|
24373
24490
|
}
|
|
24374
24491
|
return [{
|
|
24375
24492
|
childCount: 1,
|
|
@@ -24525,45 +24642,45 @@ const getCodeBlockDom = node => {
|
|
|
24525
24642
|
type: Code
|
|
24526
24643
|
}, ...tokenDom];
|
|
24527
24644
|
};
|
|
24528
|
-
const getOrderedListItemDom = item => {
|
|
24645
|
+
const getOrderedListItemDom = (item, useChatMathWorker) => {
|
|
24529
24646
|
const hasNestedUnorderedList = (item.nestedItems?.length || 0) > 0;
|
|
24530
24647
|
const nestedUnorderedListDom = hasNestedUnorderedList ? [{
|
|
24531
24648
|
childCount: item.nestedItems?.length || 0,
|
|
24532
24649
|
className: ChatUnorderedList,
|
|
24533
24650
|
type: Ul
|
|
24534
|
-
}, ...(item.nestedItems || []).flatMap(getUnorderedListItemDom)] : [];
|
|
24651
|
+
}, ...(item.nestedItems || []).flatMap(nestedItem => getUnorderedListItemDom(nestedItem, useChatMathWorker))] : [];
|
|
24535
24652
|
return [{
|
|
24536
24653
|
childCount: item.children.length + (hasNestedUnorderedList ? 1 : 0),
|
|
24537
24654
|
className: ChatOrderedListItem,
|
|
24538
24655
|
type: Li
|
|
24539
|
-
}, ...item.children.flatMap(getInlineNodeDom), ...nestedUnorderedListDom];
|
|
24656
|
+
}, ...item.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker)), ...nestedUnorderedListDom];
|
|
24540
24657
|
};
|
|
24541
|
-
const getUnorderedListItemDom = item => {
|
|
24658
|
+
const getUnorderedListItemDom = (item, useChatMathWorker) => {
|
|
24542
24659
|
return [{
|
|
24543
24660
|
childCount: item.children.length,
|
|
24544
24661
|
className: ChatUnorderedListItem,
|
|
24545
24662
|
type: Li
|
|
24546
|
-
}, ...item.children.flatMap(getInlineNodeDom)];
|
|
24663
|
+
}, ...item.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker))];
|
|
24547
24664
|
};
|
|
24548
|
-
const getTableHeadCellDom = cell => {
|
|
24665
|
+
const getTableHeadCellDom = (cell, useChatMathWorker) => {
|
|
24549
24666
|
return [{
|
|
24550
24667
|
childCount: cell.children.length,
|
|
24551
24668
|
type: Th
|
|
24552
|
-
}, ...cell.children.flatMap(getInlineNodeDom)];
|
|
24669
|
+
}, ...cell.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker))];
|
|
24553
24670
|
};
|
|
24554
|
-
const getTableBodyCellDom = cell => {
|
|
24671
|
+
const getTableBodyCellDom = (cell, useChatMathWorker) => {
|
|
24555
24672
|
return [{
|
|
24556
24673
|
childCount: cell.children.length,
|
|
24557
24674
|
type: Td
|
|
24558
|
-
}, ...cell.children.flatMap(getInlineNodeDom)];
|
|
24675
|
+
}, ...cell.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker))];
|
|
24559
24676
|
};
|
|
24560
|
-
const getTableRowDom = row => {
|
|
24677
|
+
const getTableRowDom = (row, useChatMathWorker) => {
|
|
24561
24678
|
return [{
|
|
24562
24679
|
childCount: row.cells.length,
|
|
24563
24680
|
type: Tr
|
|
24564
|
-
}, ...row.cells.flatMap(getTableBodyCellDom)];
|
|
24681
|
+
}, ...row.cells.flatMap(cell => getTableBodyCellDom(cell, useChatMathWorker))];
|
|
24565
24682
|
};
|
|
24566
|
-
const getTableDom = node => {
|
|
24683
|
+
const getTableDom = (node, useChatMathWorker) => {
|
|
24567
24684
|
return [{
|
|
24568
24685
|
childCount: 2,
|
|
24569
24686
|
className: MarkdownTable,
|
|
@@ -24574,10 +24691,10 @@ const getTableDom = node => {
|
|
|
24574
24691
|
}, {
|
|
24575
24692
|
childCount: node.headers.length,
|
|
24576
24693
|
type: Tr
|
|
24577
|
-
}, ...node.headers.flatMap(getTableHeadCellDom), {
|
|
24694
|
+
}, ...node.headers.flatMap(cell => getTableHeadCellDom(cell, useChatMathWorker)), {
|
|
24578
24695
|
childCount: node.rows.length,
|
|
24579
24696
|
type: TBody
|
|
24580
|
-
}, ...node.rows.flatMap(getTableRowDom)];
|
|
24697
|
+
}, ...node.rows.flatMap(row => getTableRowDom(row, useChatMathWorker))];
|
|
24581
24698
|
};
|
|
24582
24699
|
const getHeadingElementType = level => {
|
|
24583
24700
|
switch (level) {
|
|
@@ -24595,69 +24712,73 @@ const getHeadingElementType = level => {
|
|
|
24595
24712
|
return H6;
|
|
24596
24713
|
}
|
|
24597
24714
|
};
|
|
24598
|
-
const getHeadingDom = node => {
|
|
24715
|
+
const getHeadingDom = (node, useChatMathWorker) => {
|
|
24599
24716
|
return [{
|
|
24600
24717
|
childCount: node.children.length,
|
|
24601
24718
|
type: getHeadingElementType(node.level)
|
|
24602
|
-
}, ...node.children.flatMap(getInlineNodeDom)];
|
|
24719
|
+
}, ...node.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker))];
|
|
24603
24720
|
};
|
|
24604
|
-
const getMessageNodeDom = node => {
|
|
24721
|
+
const getMessageNodeDom = (node, useChatMathWorker = false) => {
|
|
24605
24722
|
if (node.type === 'text') {
|
|
24606
24723
|
return [{
|
|
24607
24724
|
childCount: node.children.length,
|
|
24608
24725
|
className: Markdown,
|
|
24609
24726
|
type: P
|
|
24610
|
-
}, ...node.children.flatMap(getInlineNodeDom)];
|
|
24727
|
+
}, ...node.children.flatMap(child => getInlineNodeDom(child, useChatMathWorker))];
|
|
24611
24728
|
}
|
|
24612
24729
|
if (node.type === 'table') {
|
|
24613
|
-
return getTableDom(node);
|
|
24730
|
+
return getTableDom(node, useChatMathWorker);
|
|
24614
24731
|
}
|
|
24615
24732
|
if (node.type === 'code-block') {
|
|
24616
24733
|
return getCodeBlockDom(node);
|
|
24617
24734
|
}
|
|
24618
24735
|
if (node.type === 'math-block') {
|
|
24619
|
-
return getMathBlockDom(node);
|
|
24736
|
+
return getMathBlockDom(node, useChatMathWorker);
|
|
24620
24737
|
}
|
|
24621
24738
|
if (node.type === 'heading') {
|
|
24622
|
-
return getHeadingDom(node);
|
|
24739
|
+
return getHeadingDom(node, useChatMathWorker);
|
|
24623
24740
|
}
|
|
24624
24741
|
if (node.type === 'ordered-list') {
|
|
24625
24742
|
return [{
|
|
24626
24743
|
childCount: node.items.length,
|
|
24627
24744
|
className: ChatOrderedList,
|
|
24628
24745
|
type: Ol
|
|
24629
|
-
}, ...node.items.flatMap(getOrderedListItemDom)];
|
|
24746
|
+
}, ...node.items.flatMap(item => getOrderedListItemDom(item, useChatMathWorker))];
|
|
24630
24747
|
}
|
|
24631
24748
|
return [{
|
|
24632
24749
|
childCount: node.items.length,
|
|
24633
24750
|
className: ChatUnorderedList,
|
|
24634
24751
|
type: Ul
|
|
24635
|
-
}, ...node.items.flatMap(getUnorderedListItemDom)];
|
|
24752
|
+
}, ...node.items.flatMap(item => getUnorderedListItemDom(item, useChatMathWorker))];
|
|
24636
24753
|
};
|
|
24637
24754
|
|
|
24638
|
-
const getMessageContentDom = nodes => {
|
|
24639
|
-
return nodes.flatMap(getMessageNodeDom);
|
|
24755
|
+
const getMessageContentDom = (nodes, useChatMathWorker = false) => {
|
|
24756
|
+
return nodes.flatMap(node => getMessageNodeDom(node, useChatMathWorker));
|
|
24640
24757
|
};
|
|
24641
24758
|
|
|
24642
24759
|
const getMissingApiKeyDom = ({
|
|
24643
24760
|
getApiKeyText,
|
|
24644
24761
|
inputName,
|
|
24762
|
+
inputRequired = false,
|
|
24645
24763
|
inputValue,
|
|
24646
24764
|
openSettingsButtonName,
|
|
24647
24765
|
placeholder,
|
|
24648
24766
|
saveButtonDisabled = false,
|
|
24649
24767
|
saveButtonName,
|
|
24650
|
-
saveButtonText = save()
|
|
24768
|
+
saveButtonText = save(),
|
|
24769
|
+
saveButtonType = 'button',
|
|
24770
|
+
useForm = false
|
|
24651
24771
|
}) => {
|
|
24652
24772
|
return [{
|
|
24653
24773
|
childCount: 2,
|
|
24654
|
-
type: Div
|
|
24774
|
+
type: useForm ? Form : Div
|
|
24655
24775
|
}, {
|
|
24656
24776
|
childCount: 0,
|
|
24657
24777
|
className: InputBox,
|
|
24658
24778
|
name: inputName,
|
|
24659
24779
|
onInput: HandleInput,
|
|
24660
24780
|
placeholder,
|
|
24781
|
+
required: inputRequired,
|
|
24661
24782
|
type: Input,
|
|
24662
24783
|
value: inputValue
|
|
24663
24784
|
}, {
|
|
@@ -24665,6 +24786,7 @@ const getMissingApiKeyDom = ({
|
|
|
24665
24786
|
className: Actions,
|
|
24666
24787
|
type: Div
|
|
24667
24788
|
}, {
|
|
24789
|
+
buttonType: saveButtonType,
|
|
24668
24790
|
childCount: 1,
|
|
24669
24791
|
className: mergeClassNames(Button, ButtonPrimary),
|
|
24670
24792
|
disabled: saveButtonDisabled,
|
|
@@ -24684,10 +24806,13 @@ const getMissingOpenApiApiKeyDom = openApiApiKeyInput => {
|
|
|
24684
24806
|
return getMissingApiKeyDom({
|
|
24685
24807
|
getApiKeyText: getOpenApiApiKey(),
|
|
24686
24808
|
inputName: OpenApiApiKeyInput,
|
|
24809
|
+
inputRequired: true,
|
|
24687
24810
|
inputValue: openApiApiKeyInput,
|
|
24688
24811
|
openSettingsButtonName: OpenOpenApiApiKeySettings,
|
|
24689
24812
|
placeholder: openApiApiKeyPlaceholder(),
|
|
24690
|
-
saveButtonName: SaveOpenApiApiKey
|
|
24813
|
+
saveButtonName: SaveOpenApiApiKey,
|
|
24814
|
+
saveButtonType: 'submit',
|
|
24815
|
+
useForm: true
|
|
24691
24816
|
});
|
|
24692
24817
|
};
|
|
24693
24818
|
|
|
@@ -24969,6 +25094,7 @@ const getToolCallsDom = message => {
|
|
|
24969
25094
|
const orderedListItemRegex = /^\s*\d+\.\s+(.*)$/;
|
|
24970
25095
|
const unorderedListItemRegex = /^(\s*)[-*]\s+(.*)$/;
|
|
24971
25096
|
const markdownInlineRegex = /\[([^\]]+)\]\(([^)]+)\)|\*\*([^*]+)\*\*|\*([^*]+)\*|(?<![a-zA-Z0-9])(?<mathDollars>\${1,2})(?!\.|\(["'])(?<mathText>(?:\\.|[^\\\n])*?(?:\\.|[^\\\n$]))\k<mathDollars>(?![a-zA-Z0-9])/g;
|
|
25097
|
+
const markdownItalicWithBoldRegex = /\*([^*\n]*?)\*\*([^*\n]+)\*\*([^*\n]*?)\*/g;
|
|
24972
25098
|
const markdownTableSeparatorCellRegex = /^:?-{3,}:?$/;
|
|
24973
25099
|
const fencedCodeBlockRegex = /^```/;
|
|
24974
25100
|
const markdownHeadingRegex = /^\s*(#{1,6})\s+(.*)$/;
|
|
@@ -25030,7 +25156,7 @@ const toTableRow = line => {
|
|
|
25030
25156
|
type: 'table-row'
|
|
25031
25157
|
};
|
|
25032
25158
|
};
|
|
25033
|
-
const
|
|
25159
|
+
const parseInlineNodesSimple = value => {
|
|
25034
25160
|
const matches = value.matchAll(markdownInlineRegex);
|
|
25035
25161
|
const nodes = [];
|
|
25036
25162
|
let lastIndex = 0;
|
|
@@ -25088,6 +25214,53 @@ const parseInlineNodes = value => {
|
|
|
25088
25214
|
}
|
|
25089
25215
|
return nodes;
|
|
25090
25216
|
};
|
|
25217
|
+
const parseInlineNodes = value => {
|
|
25218
|
+
const nestedMatches = value.matchAll(markdownItalicWithBoldRegex);
|
|
25219
|
+
const nodes = [];
|
|
25220
|
+
let lastIndex = 0;
|
|
25221
|
+
let foundNestedItalicBold = false;
|
|
25222
|
+
for (const match of nestedMatches) {
|
|
25223
|
+
const fullMatch = match[0];
|
|
25224
|
+
const italicBefore = match[1];
|
|
25225
|
+
const boldText = match[2];
|
|
25226
|
+
const italicAfter = match[3];
|
|
25227
|
+
const index = match.index ?? 0;
|
|
25228
|
+
foundNestedItalicBold = true;
|
|
25229
|
+
if (index > lastIndex) {
|
|
25230
|
+
nodes.push(...parseInlineNodesSimple(value.slice(lastIndex, index)));
|
|
25231
|
+
}
|
|
25232
|
+
if (italicBefore) {
|
|
25233
|
+
nodes.push({
|
|
25234
|
+
text: italicBefore,
|
|
25235
|
+
type: 'italic'
|
|
25236
|
+
});
|
|
25237
|
+
}
|
|
25238
|
+
nodes.push({
|
|
25239
|
+
text: boldText,
|
|
25240
|
+
type: 'bold'
|
|
25241
|
+
});
|
|
25242
|
+
if (italicAfter) {
|
|
25243
|
+
nodes.push({
|
|
25244
|
+
text: italicAfter,
|
|
25245
|
+
type: 'italic'
|
|
25246
|
+
});
|
|
25247
|
+
}
|
|
25248
|
+
lastIndex = index + fullMatch.length;
|
|
25249
|
+
}
|
|
25250
|
+
if (!foundNestedItalicBold) {
|
|
25251
|
+
return parseInlineNodesSimple(value);
|
|
25252
|
+
}
|
|
25253
|
+
if (lastIndex < value.length) {
|
|
25254
|
+
nodes.push(...parseInlineNodesSimple(value.slice(lastIndex)));
|
|
25255
|
+
}
|
|
25256
|
+
if (nodes.length === 0) {
|
|
25257
|
+
return [{
|
|
25258
|
+
text: value,
|
|
25259
|
+
type: 'text'
|
|
25260
|
+
}];
|
|
25261
|
+
}
|
|
25262
|
+
return nodes;
|
|
25263
|
+
};
|
|
25091
25264
|
const parseMessageContent = rawMessage => {
|
|
25092
25265
|
if (rawMessage === '') {
|
|
25093
25266
|
return [{
|
|
@@ -25265,14 +25438,14 @@ const parseMessageContent = rawMessage => {
|
|
|
25265
25438
|
}] : nodes;
|
|
25266
25439
|
};
|
|
25267
25440
|
|
|
25268
|
-
const getChatMessageDom = (message, openRouterApiKeyInput, openApiApiKeyInput = '', openRouterApiKeyState = 'idle') => {
|
|
25441
|
+
const getChatMessageDom = (message, openRouterApiKeyInput, openApiApiKeyInput = '', openRouterApiKeyState = 'idle', useChatMathWorker = false) => {
|
|
25269
25442
|
const roleClassName = message.role === 'user' ? MessageUser : MessageAssistant;
|
|
25270
25443
|
const isOpenApiApiKeyMissingMessage = message.role === 'assistant' && message.text === openApiApiKeyRequiredMessage;
|
|
25271
25444
|
const isOpenRouterApiKeyMissingMessage = message.role === 'assistant' && message.text === openRouterApiKeyRequiredMessage;
|
|
25272
25445
|
const isOpenRouterRequestFailedMessage = message.role === 'assistant' && message.text === openRouterRequestFailedMessage;
|
|
25273
25446
|
const isOpenRouterTooManyRequestsMessage = message.role === 'assistant' && message.text.startsWith(openRouterTooManyRequestsMessage);
|
|
25274
25447
|
const messageIntermediate = parseMessageContent(message.text);
|
|
25275
|
-
const messageDom = getMessageContentDom(messageIntermediate);
|
|
25448
|
+
const messageDom = getMessageContentDom(messageIntermediate, useChatMathWorker);
|
|
25276
25449
|
const toolCallsDom = getToolCallsDom(message);
|
|
25277
25450
|
const toolCallsChildCount = toolCallsDom.length > 0 ? 1 : 0;
|
|
25278
25451
|
const extraChildCount = isOpenApiApiKeyMissingMessage || isOpenRouterApiKeyMissingMessage || isOpenRouterRequestFailedMessage || isOpenRouterTooManyRequestsMessage ? messageIntermediate.length + 1 + toolCallsChildCount : messageIntermediate.length + toolCallsChildCount;
|
|
@@ -25321,7 +25494,7 @@ const getDisplayMessages = messages => {
|
|
|
25321
25494
|
}
|
|
25322
25495
|
return displayMessages;
|
|
25323
25496
|
};
|
|
25324
|
-
const getMessagesDom = (messages, openRouterApiKeyInput, openApiApiKeyInput = '', openRouterApiKeyState = 'idle', messagesScrollTop = 0) => {
|
|
25497
|
+
const getMessagesDom = (messages, openRouterApiKeyInput, openApiApiKeyInput = '', openRouterApiKeyState = 'idle', messagesScrollTop = 0, useChatMathWorker = false) => {
|
|
25325
25498
|
if (messages.length === 0) {
|
|
25326
25499
|
return getEmptyMessagesDom();
|
|
25327
25500
|
}
|
|
@@ -25333,7 +25506,7 @@ const getMessagesDom = (messages, openRouterApiKeyInput, openApiApiKeyInput = ''
|
|
|
25333
25506
|
onScroll: HandleMessagesScroll,
|
|
25334
25507
|
scrollTop: messagesScrollTop,
|
|
25335
25508
|
type: Div
|
|
25336
|
-
}, ...displayMessages.flatMap(message => getChatMessageDom(message, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState))];
|
|
25509
|
+
}, ...displayMessages.flatMap(message => getChatMessageDom(message, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState, useChatMathWorker))];
|
|
25337
25510
|
};
|
|
25338
25511
|
|
|
25339
25512
|
const getProjectSessionDom = (session, selectedSessionId) => {
|
|
@@ -25421,29 +25594,17 @@ const getProjectListDom = (projects, sessions, projectExpandedIds, selectedProje
|
|
|
25421
25594
|
}, text$2('+ Add Project')];
|
|
25422
25595
|
};
|
|
25423
25596
|
|
|
25424
|
-
const getChatModeChatFocusVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState = 'idle', composerHeight = 28, composerFontSize = 13, composerFontFamily = 'system-ui', composerLineHeight = 20, messagesScrollTop = 0, composerDropActive = false, composerDropEnabled = true, projects = [], projectExpandedIds = [], selectedProjectId = '', projectListScrollTop = 0, voiceDictationEnabled = false) => {
|
|
25597
|
+
const getChatModeChatFocusVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState = 'idle', composerHeight = 28, composerFontSize = 13, composerFontFamily = 'system-ui', composerLineHeight = 20, messagesScrollTop = 0, composerDropActive = false, composerDropEnabled = true, projects = [], projectExpandedIds = [], selectedProjectId = '', projectListScrollTop = 0, voiceDictationEnabled = false, useChatMathWorker = false) => {
|
|
25425
25598
|
const selectedSession = sessions.find(session => session.id === selectedSessionId);
|
|
25426
|
-
const selectedSessionTitle = selectedSession?.title || chatTitle();
|
|
25427
25599
|
const messages = selectedSession ? selectedSession.messages : [];
|
|
25428
25600
|
const isDropOverlayVisible = composerDropEnabled && composerDropActive;
|
|
25429
25601
|
return [{
|
|
25430
|
-
childCount:
|
|
25602
|
+
childCount: 4,
|
|
25431
25603
|
className: mergeClassNames(Viewlet, Chat, 'ChatFocus'),
|
|
25432
25604
|
onDragEnter: HandleDragEnterChatView,
|
|
25433
25605
|
onDragOver: HandleDragOverChatView,
|
|
25434
25606
|
type: Div
|
|
25435
|
-
}, {
|
|
25436
|
-
childCount: 1,
|
|
25437
|
-
className: ChatHeader,
|
|
25438
|
-
type: Div
|
|
25439
|
-
}, {
|
|
25440
|
-
childCount: 1,
|
|
25441
|
-
className: Label,
|
|
25442
|
-
type: Span$1
|
|
25443
|
-
}, {
|
|
25444
|
-
text: selectedSessionTitle,
|
|
25445
|
-
type: Text
|
|
25446
|
-
}, ...getProjectListDom(projects, sessions, projectExpandedIds, selectedProjectId, selectedSessionId, projectListScrollTop), ...getMessagesDom(messages, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState, messagesScrollTop), ...getChatSendAreaDom(composerValue, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, voiceDictationEnabled), {
|
|
25607
|
+
}, ...getProjectListDom(projects, sessions, projectExpandedIds, selectedProjectId, selectedSessionId, projectListScrollTop), ...getMessagesDom(messages, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState, messagesScrollTop, useChatMathWorker), ...getChatSendAreaDom(composerValue, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, voiceDictationEnabled), {
|
|
25447
25608
|
childCount: 1,
|
|
25448
25609
|
className: mergeClassNames(ChatViewDropOverlay, isDropOverlayVisible ? ChatViewDropOverlayActive : Empty),
|
|
25449
25610
|
name: ComposerDropTarget,
|
|
@@ -25539,7 +25700,7 @@ const getChatHeaderDomDetailMode = selectedSessionTitle => {
|
|
|
25539
25700
|
}, text$2(selectedSessionTitle), ...getChatHeaderActionsDom('detail')];
|
|
25540
25701
|
};
|
|
25541
25702
|
|
|
25542
|
-
const getChatModeDetailVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState = 'idle', composerHeight = 28, composerFontSize = 13, composerFontFamily = 'system-ui', composerLineHeight = 20, messagesScrollTop = 0, composerDropActive = false, composerDropEnabled = true, voiceDictationEnabled = false) => {
|
|
25703
|
+
const getChatModeDetailVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState = 'idle', composerHeight = 28, composerFontSize = 13, composerFontFamily = 'system-ui', composerLineHeight = 20, messagesScrollTop = 0, composerDropActive = false, composerDropEnabled = true, voiceDictationEnabled = false, useChatMathWorker = false) => {
|
|
25543
25704
|
const selectedSession = sessions.find(session => session.id === selectedSessionId);
|
|
25544
25705
|
const selectedSessionTitle = selectedSession?.title || chatTitle();
|
|
25545
25706
|
const messages = selectedSession ? selectedSession.messages : [];
|
|
@@ -25550,7 +25711,7 @@ const getChatModeDetailVirtualDom = (sessions, selectedSessionId, composerValue,
|
|
|
25550
25711
|
onDragEnter: HandleDragEnterChatView,
|
|
25551
25712
|
onDragOver: HandleDragOverChatView,
|
|
25552
25713
|
type: Div
|
|
25553
|
-
}, ...getChatHeaderDomDetailMode(selectedSessionTitle), ...getMessagesDom(messages, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState, messagesScrollTop), ...getChatSendAreaDom(composerValue, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, voiceDictationEnabled), {
|
|
25714
|
+
}, ...getChatHeaderDomDetailMode(selectedSessionTitle), ...getMessagesDom(messages, openRouterApiKeyInput, openApiApiKeyInput, openRouterApiKeyState, messagesScrollTop, useChatMathWorker), ...getChatSendAreaDom(composerValue, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, voiceDictationEnabled), {
|
|
25554
25715
|
childCount: 1,
|
|
25555
25716
|
className: mergeClassNames(ChatViewDropOverlay, isDropOverlayVisible ? ChatViewDropOverlayActive : Empty),
|
|
25556
25717
|
name: ComposerDropTarget,
|
|
@@ -25660,12 +25821,12 @@ const getChatModeUnsupportedVirtualDom = () => {
|
|
|
25660
25821
|
}, text$2(unknownViewMode())];
|
|
25661
25822
|
};
|
|
25662
25823
|
|
|
25663
|
-
const getChatVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, viewMode, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openApiApiKeyInput, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, chatListScrollTop, messagesScrollTop, composerDropActive = false, composerDropEnabled = true, projects = [], projectExpandedIds = [], selectedProjectId = '', projectListScrollTop = 0, voiceDictationEnabled = false) => {
|
|
25824
|
+
const getChatVirtualDom = (sessions, selectedSessionId, composerValue, openRouterApiKeyInput, viewMode, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openApiApiKeyInput, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, chatListScrollTop, messagesScrollTop, composerDropActive = false, composerDropEnabled = true, projects = [], projectExpandedIds = [], selectedProjectId = '', projectListScrollTop = 0, voiceDictationEnabled = false, useChatMathWorker = false) => {
|
|
25664
25825
|
switch (viewMode) {
|
|
25665
25826
|
case 'chat-focus':
|
|
25666
|
-
return getChatModeChatFocusVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, messagesScrollTop, composerDropActive, composerDropEnabled, projects, projectExpandedIds, selectedProjectId, projectListScrollTop, voiceDictationEnabled);
|
|
25827
|
+
return getChatModeChatFocusVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, messagesScrollTop, composerDropActive, composerDropEnabled, projects, projectExpandedIds, selectedProjectId, projectListScrollTop, voiceDictationEnabled, useChatMathWorker);
|
|
25667
25828
|
case 'detail':
|
|
25668
|
-
return getChatModeDetailVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, messagesScrollTop, composerDropActive, composerDropEnabled, voiceDictationEnabled);
|
|
25829
|
+
return getChatModeDetailVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, openApiApiKeyInput, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, messagesScrollTop, composerDropActive, composerDropEnabled, voiceDictationEnabled, useChatMathWorker);
|
|
25669
25830
|
case 'list':
|
|
25670
25831
|
return getChatModeListVirtualDom(sessions, selectedSessionId, composerValue, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, chatListScrollTop, composerDropActive, composerDropEnabled, voiceDictationEnabled);
|
|
25671
25832
|
default:
|
|
@@ -25700,13 +25861,14 @@ const renderItems = (oldState, newState) => {
|
|
|
25700
25861
|
tokensUsed,
|
|
25701
25862
|
uid,
|
|
25702
25863
|
usageOverviewEnabled,
|
|
25864
|
+
useChatMathWorker,
|
|
25703
25865
|
viewMode,
|
|
25704
25866
|
voiceDictationEnabled
|
|
25705
25867
|
} = newState;
|
|
25706
25868
|
if (initial) {
|
|
25707
25869
|
return [SetDom2, uid, []];
|
|
25708
25870
|
}
|
|
25709
|
-
const dom = getChatVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, viewMode, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openApiApiKeyInput, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, chatListScrollTop, messagesScrollTop, composerDropActive, composerDropEnabled, projects, projectExpandedIds, selectedProjectId, projectListScrollTop, voiceDictationEnabled);
|
|
25871
|
+
const dom = getChatVirtualDom(sessions, selectedSessionId, composerValue, openRouterApiKeyInput, viewMode, models, selectedModelId, usageOverviewEnabled, tokensUsed, tokensMax, openApiApiKeyInput, openRouterApiKeyState, composerHeight, composerFontSize, composerFontFamily, composerLineHeight, chatListScrollTop, messagesScrollTop, composerDropActive, composerDropEnabled, projects, projectExpandedIds, selectedProjectId, projectListScrollTop, voiceDictationEnabled, useChatMathWorker);
|
|
25710
25872
|
return [SetDom2, uid, dom];
|
|
25711
25873
|
};
|
|
25712
25874
|
|
|
@@ -25727,9 +25889,10 @@ const renderScrollTop = (oldState, newState) => {
|
|
|
25727
25889
|
|
|
25728
25890
|
const renderValue = (oldState, newState) => {
|
|
25729
25891
|
const {
|
|
25730
|
-
composerValue
|
|
25892
|
+
composerValue,
|
|
25893
|
+
uid
|
|
25731
25894
|
} = newState;
|
|
25732
|
-
return [SetValueByName,
|
|
25895
|
+
return [SetValueByName, uid, Composer, composerValue];
|
|
25733
25896
|
};
|
|
25734
25897
|
|
|
25735
25898
|
const getRenderer = diffType => {
|
|
@@ -26022,6 +26185,18 @@ const setStreamingEnabled = (state, streamingEnabled) => {
|
|
|
26022
26185
|
};
|
|
26023
26186
|
};
|
|
26024
26187
|
|
|
26188
|
+
const setUseChatMathWorker = async (state, useChatMathWorker, persist = true) => {
|
|
26189
|
+
if (persist) {
|
|
26190
|
+
await update({
|
|
26191
|
+
'chatView.useChatMathWorker': useChatMathWorker
|
|
26192
|
+
});
|
|
26193
|
+
}
|
|
26194
|
+
return {
|
|
26195
|
+
...state,
|
|
26196
|
+
useChatMathWorker
|
|
26197
|
+
};
|
|
26198
|
+
};
|
|
26199
|
+
|
|
26025
26200
|
const setUseChatNetworkWorkerForRequests = async (state, useChatNetworkWorkerForRequests, persist = true) => {
|
|
26026
26201
|
if (persist) {
|
|
26027
26202
|
await update({
|
|
@@ -26104,34 +26279,12 @@ const commandMap = {
|
|
|
26104
26279
|
'Chat.setEmitStreamingFunctionCallEvents': wrapCommand(setEmitStreamingFunctionCallEvents),
|
|
26105
26280
|
'Chat.setOpenRouterApiKey': wrapCommand(setOpenRouterApiKey),
|
|
26106
26281
|
'Chat.setStreamingEnabled': wrapCommand(setStreamingEnabled),
|
|
26282
|
+
'Chat.setUseChatMathWorker': wrapCommand(setUseChatMathWorker),
|
|
26107
26283
|
'Chat.setUseChatNetworkWorkerForRequests': wrapCommand(setUseChatNetworkWorkerForRequests),
|
|
26108
26284
|
'Chat.terminate': terminate,
|
|
26109
26285
|
'Chat.useMockApi': wrapCommand(useMockApi)
|
|
26110
26286
|
};
|
|
26111
26287
|
|
|
26112
|
-
let initialized = false;
|
|
26113
|
-
const sendMessagePortToChatMathWorker = async port => {
|
|
26114
|
-
try {
|
|
26115
|
-
await invoke('sendMessagePortToChatMathWorker', port);
|
|
26116
|
-
} catch {
|
|
26117
|
-
await invoke('SendMessagePortToChatMathWorker.sendMessagePortToChatMathWorker', port);
|
|
26118
|
-
}
|
|
26119
|
-
};
|
|
26120
|
-
const createRpc = () => {
|
|
26121
|
-
return create$4({
|
|
26122
|
-
commandMap: {},
|
|
26123
|
-
send: sendMessagePortToChatMathWorker
|
|
26124
|
-
});
|
|
26125
|
-
};
|
|
26126
|
-
const initialize = async () => {
|
|
26127
|
-
if (initialized) {
|
|
26128
|
-
return;
|
|
26129
|
-
}
|
|
26130
|
-
const rpc = await createRpc();
|
|
26131
|
-
set$4(rpc);
|
|
26132
|
-
initialized = true;
|
|
26133
|
-
};
|
|
26134
|
-
|
|
26135
26288
|
const initializeChatMathWorker = async () => {
|
|
26136
26289
|
await initialize();
|
|
26137
26290
|
};
|