@lvce-editor/chat-view 6.68.0 → 6.70.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.
@@ -1214,6 +1214,7 @@ const Home = 12;
1214
1214
  const UpArrow = 14;
1215
1215
  const DownArrow = 16;
1216
1216
  const KeyN = 42;
1217
+ const KeyV = 50;
1217
1218
 
1218
1219
  const CtrlCmd = 1 << 11 >>> 0;
1219
1220
  const Shift = 1 << 10 >>> 0;
@@ -2876,10 +2877,7 @@ const RenderIncremental = 11;
2876
2877
  const RenderScrollTop = 12;
2877
2878
 
2878
2879
  const diffValue = (oldState, newState) => {
2879
- if (oldState.composerValue === newState.composerValue) {
2880
- return true;
2881
- }
2882
- return newState.inputSource !== 'script';
2880
+ return oldState.composerValue === newState.composerValue || newState.inputSource !== 'script';
2883
2881
  };
2884
2882
 
2885
2883
  const modules = [isEqual, diffValue, diffSelection, diffFocus, isEqual$1, diffFocus, diffScrollTop];
@@ -2901,8 +2899,7 @@ const diff2 = uid => {
2901
2899
  newState,
2902
2900
  oldState
2903
2901
  } = get$1(uid);
2904
- const result = diff(oldState, newState);
2905
- return result;
2902
+ return diff(oldState, newState);
2906
2903
  };
2907
2904
 
2908
2905
  const getAuthState = state => {
@@ -3260,6 +3257,10 @@ const getKeyBindings = () => {
3260
3257
  command: 'Chat.chatInputHistoryDown',
3261
3258
  key: DownArrow,
3262
3259
  when: FocusChatInput
3260
+ }, {
3261
+ command: 'Chat.pasteInput',
3262
+ key: CtrlCmd | KeyV,
3263
+ when: FocusChatInput
3263
3264
  }, {
3264
3265
  command: 'Chat.chatInputHistoryUp',
3265
3266
  key: UpArrow,
@@ -3934,8 +3935,7 @@ const executeProvider = async ({
3934
3935
  }) => {
3935
3936
  await activateByEvent(event, assetDir, platform);
3936
3937
  // @ts-ignore
3937
- const result = invoke$2(method, ...params);
3938
- return result;
3938
+ return invoke$2(method, ...params);
3939
3939
  };
3940
3940
 
3941
3941
  const CommandExecute = 'ExtensionHostCommand.executeCommand';
@@ -6997,6 +6997,28 @@ const jsRules = [{
6997
6997
  className: TokenKeyword,
6998
6998
  regex: /\b(?:const|let|var|function|return|if|else|for|while|class|new|typeof|instanceof|import|export|from|default|async|await|try|catch|finally|throw|this|true|false|null|undefined)\b/
6999
6999
  }];
7000
+ const tsRules = [{
7001
+ className: TokenComment,
7002
+ regex: /\/\/[^\n]*/
7003
+ }, {
7004
+ className: TokenComment,
7005
+ regex: /\/\*[\s\S]*?\*\//
7006
+ }, {
7007
+ className: TokenString,
7008
+ regex: /"[^"\\]*(?:\\.[^"\\]*)*"/
7009
+ }, {
7010
+ className: TokenString,
7011
+ regex: /'[^'\\]*(?:\\.[^'\\]*)*'/
7012
+ }, {
7013
+ className: TokenString,
7014
+ regex: /`[^`\\]*(?:\\.[^`\\]*)*`/
7015
+ }, {
7016
+ className: TokenNumber,
7017
+ regex: /\b\d+\.?\d*\b/
7018
+ }, {
7019
+ className: TokenKeyword,
7020
+ regex: /\b(?:abstract|any|as|asserts|async|await|boolean|class|const|constructor|declare|default|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|infer|instanceof|interface|is|keyof|let|module|namespace|never|new|null|number|object|override|private|protected|public|readonly|return|satisfies|set|static|string|super|switch|symbol|this|throw|true|try|type|typeof|undefined|unknown|var|void|while)\b/
7021
+ }];
7000
7022
  const htmlRules = [{
7001
7023
  className: TokenComment,
7002
7024
  regex: /<!--[\s\S]*?-->/
@@ -7120,6 +7142,9 @@ const highlightCode = (code, language) => {
7120
7142
  if (normalized === 'js' || normalized === 'javascript') {
7121
7143
  return tokenize(code, jsRules);
7122
7144
  }
7145
+ if (normalized === 'ts' || normalized === 'typescript') {
7146
+ return tokenize(code, tsRules);
7147
+ }
7123
7148
  if (normalized === 'py' || normalized === 'python') {
7124
7149
  return tokenize(code, pythonRules);
7125
7150
  }
@@ -9975,15 +10000,6 @@ const handleSearchValueChange = (state, newValue) => {
9975
10000
  };
9976
10001
 
9977
10002
  const handleInput = async (state, name, value, inputSource = 'user') => {
9978
- const {
9979
- chatInputHistoryDraft,
9980
- chatInputHistoryIndex,
9981
- composerAttachments,
9982
- modelPickerHeaderHeight,
9983
- models,
9984
- selectedSessionId,
9985
- width
9986
- } = state;
9987
10003
  if (name === OpenApiApiKeyInput) {
9988
10004
  return {
9989
10005
  ...state,
@@ -10000,10 +10016,10 @@ const handleInput = async (state, name, value, inputSource = 'user') => {
10000
10016
  return handleSearchValueChange(state, value);
10001
10017
  }
10002
10018
  if (name === ModelPickerSearch) {
10003
- const visibleModels = getVisibleModels(models, value);
10019
+ const visibleModels = getVisibleModels(state.models, value);
10004
10020
  return {
10005
10021
  ...state,
10006
- modelPickerHeight: getModelPickerHeight(modelPickerHeaderHeight, visibleModels.length),
10022
+ modelPickerHeight: getModelPickerHeight(state.modelPickerHeaderHeight, visibleModels.length),
10007
10023
  modelPickerListScrollTop: 0,
10008
10024
  modelPickerSearchValue: value,
10009
10025
  visibleModels
@@ -10012,19 +10028,20 @@ const handleInput = async (state, name, value, inputSource = 'user') => {
10012
10028
  if (name !== Composer) {
10013
10029
  return state;
10014
10030
  }
10015
- if (selectedSessionId) {
10031
+ if (state.selectedSessionId) {
10016
10032
  await appendChatViewEvent({
10017
- sessionId: selectedSessionId,
10033
+ sessionId: state.selectedSessionId,
10018
10034
  timestamp: new Date().toISOString(),
10019
10035
  type: 'handle-input',
10020
10036
  value
10021
10037
  });
10022
10038
  }
10023
10039
  const composerHeight = await getComposerHeight(state, value);
10024
- const composerAttachmentsHeight = getComposerAttachmentsHeight(composerAttachments, width);
10040
+ const composerAttachmentsHeight = getComposerAttachmentsHeight(state.composerAttachments, state.width);
10041
+ const chatInputHistoryDraft = state.chatInputHistoryIndex === -1 ? value : state.chatInputHistoryDraft;
10025
10042
  return {
10026
10043
  ...state,
10027
- chatInputHistoryDraft: chatInputHistoryIndex === -1 ? value : chatInputHistoryDraft,
10044
+ chatInputHistoryDraft,
10028
10045
  composerAttachmentsHeight,
10029
10046
  composerHeight,
10030
10047
  composerSelectionEnd: value.length,
@@ -10081,6 +10098,18 @@ const handleInputFocus = async (state, name) => {
10081
10098
  };
10082
10099
  };
10083
10100
 
10101
+ const getSubmittedRenameState = (state, sessions) => {
10102
+ return {
10103
+ ...state,
10104
+ composerHeight: getMinComposerHeightForState(state),
10105
+ composerSelectionEnd: 0,
10106
+ composerSelectionStart: 0,
10107
+ composerValue: '',
10108
+ inputSource: 'script',
10109
+ renamingSessionId: '',
10110
+ sessions
10111
+ };
10112
+ };
10084
10113
  const submitRename = async state => {
10085
10114
  const {
10086
10115
  composerValue,
@@ -10094,29 +10123,24 @@ const submitRename = async state => {
10094
10123
  renamingSessionId: ''
10095
10124
  };
10096
10125
  }
10126
+ const promptedTitle = sanitizeGeneratedTitle(await invoke('Main.prompt', title));
10127
+ if (!promptedTitle) {
10128
+ return getSubmittedRenameState(state, sessions);
10129
+ }
10097
10130
  const updatedSessions = sessions.map(session => {
10098
10131
  if (session.id !== renamingSessionId) {
10099
10132
  return session;
10100
10133
  }
10101
10134
  return {
10102
10135
  ...session,
10103
- title
10136
+ title: promptedTitle
10104
10137
  };
10105
10138
  });
10106
10139
  const renamedSession = updatedSessions.find(session => session.id === renamingSessionId);
10107
10140
  if (renamedSession) {
10108
10141
  await saveChatSession(renamedSession);
10109
10142
  }
10110
- return {
10111
- ...state,
10112
- composerHeight: getMinComposerHeightForState(state),
10113
- composerSelectionEnd: 0,
10114
- composerSelectionStart: 0,
10115
- composerValue: '',
10116
- inputSource: 'script',
10117
- renamingSessionId: '',
10118
- sessions: updatedSessions
10119
- };
10143
+ return getSubmittedRenameState(state, updatedSessions);
10120
10144
  };
10121
10145
 
10122
10146
  const handleKeyDown = async (state, key, shiftKey) => {
@@ -12888,11 +12912,22 @@ const getReadFileTarget = rawArguments => {
12888
12912
  };
12889
12913
  };
12890
12914
 
12891
- const getToolCallFileNameDom = (fileName, fileNameClickableProps = {}) => {
12915
+ const getToolCallFileNameDom = (fileName, {
12916
+ clickableProps = {},
12917
+ title
12918
+ } = {}) => {
12892
12919
  return [{
12920
+ childCount: 1,
12921
+ className: ChatToolCallReadFileLink,
12922
+ ...(title === undefined ? {} : {
12923
+ title
12924
+ }),
12925
+ ...clickableProps,
12926
+ type: Span
12927
+ }, {
12893
12928
  childCount: 1,
12894
12929
  className: ChatToolCallFileName,
12895
- ...fileNameClickableProps,
12930
+ ...clickableProps,
12896
12931
  type: Span
12897
12932
  }, text(fileName)];
12898
12933
  };
@@ -12921,12 +12956,9 @@ const getToolCallCreateDirectoryVirtualDom = toolCall => {
12921
12956
  childCount: 1,
12922
12957
  className: ToolCallName,
12923
12958
  type: Span
12924
- }, text('create_directory '), {
12925
- childCount: 1,
12926
- className: ChatToolCallReadFileLink,
12927
- ...fileNameClickableProps,
12928
- type: Span
12929
- }, ...getToolCallFileNameDom(directoryName, fileNameClickableProps), ...(statusLabel ? [text(statusLabel)] : [])];
12959
+ }, text('create_directory '), ...getToolCallFileNameDom(directoryName, {
12960
+ clickableProps: fileNameClickableProps
12961
+ }), ...(statusLabel ? [text(statusLabel)] : [])];
12930
12962
  };
12931
12963
 
12932
12964
  const getToolCallArgumentPreview = rawArguments => {
@@ -13048,13 +13080,10 @@ const getToolCallEditFileVirtualDom = toolCall => {
13048
13080
  childCount: 1,
13049
13081
  className: ToolCallName,
13050
13082
  type: Span
13051
- }, text('edit_file '), {
13052
- childCount: 1,
13053
- className: ChatToolCallReadFileLink,
13054
- title: target.clickableUri,
13055
- ...fileNameClickableProps,
13056
- type: Span
13057
- }, ...getToolCallFileNameDom(fileName, fileNameClickableProps)];
13083
+ }, text('edit_file '), ...getToolCallFileNameDom(fileName, {
13084
+ clickableProps: fileNameClickableProps,
13085
+ title: target.clickableUri
13086
+ })];
13058
13087
  };
13059
13088
 
13060
13089
  const getToolCallGetWorkspaceUriVirtualDom = toolCall => {
@@ -13080,12 +13109,9 @@ const getToolCallGetWorkspaceUriVirtualDom = toolCall => {
13080
13109
  childCount: 1,
13081
13110
  className: ToolCallName,
13082
13111
  type: Span
13083
- }, text('get_workspace_uri '), {
13084
- childCount: 1,
13085
- className: ChatToolCallReadFileLink,
13086
- ...fileNameClickableProps,
13087
- type: Span
13088
- }, ...getToolCallFileNameDom(fileName, fileNameClickableProps), ...(statusLabel ? [text(statusLabel)] : [])];
13112
+ }, text('get_workspace_uri '), ...getToolCallFileNameDom(fileName, {
13113
+ clickableProps: fileNameClickableProps
13114
+ }), ...(statusLabel ? [text(statusLabel)] : [])];
13089
13115
  };
13090
13116
 
13091
13117
  const getToolCallReadFileVirtualDom = toolCall => {
@@ -13113,12 +13139,9 @@ const getToolCallReadFileVirtualDom = toolCall => {
13113
13139
  childCount: 1,
13114
13140
  className: ToolCallName,
13115
13141
  type: Span
13116
- }, text(toolNameLabel), {
13117
- childCount: 1,
13118
- className: ChatToolCallReadFileLink,
13119
- ...fileNameClickableProps,
13120
- type: Span
13121
- }, ...getToolCallFileNameDom(fileName, fileNameClickableProps), ...(statusLabel ? [text(statusLabel)] : [])];
13142
+ }, text(toolNameLabel), ...getToolCallFileNameDom(fileName, {
13143
+ clickableProps: fileNameClickableProps
13144
+ }), ...(statusLabel ? [text(statusLabel)] : [])];
13122
13145
  };
13123
13146
 
13124
13147
  const maxHtmlLength = 40_000;
@@ -13495,12 +13518,9 @@ const getToolCallWriteFileVirtualDom = toolCall => {
13495
13518
  childCount: 1,
13496
13519
  className: ToolCallName,
13497
13520
  type: Span
13498
- }, text('write_file '), {
13499
- childCount: 1,
13500
- className: ChatToolCallReadFileLink,
13501
- ...fileNameClickableProps,
13502
- type: Span
13503
- }, ...getToolCallFileNameDom(fileName, fileNameClickableProps), ...(showDiffStats ? [{
13521
+ }, text('write_file '), ...getToolCallFileNameDom(fileName, {
13522
+ clickableProps: fileNameClickableProps
13523
+ }), ...(showDiffStats ? [{
13504
13524
  childCount: 1,
13505
13525
  className: Insertion,
13506
13526
  type: Span
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/chat-view",
3
- "version": "6.68.0",
3
+ "version": "6.70.0",
4
4
  "description": "Chat View Worker",
5
5
  "repository": {
6
6
  "type": "git",