@codingame/monaco-vscode-katex-common 24.1.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.
Files changed (262) hide show
  1. package/empty.js +1 -0
  2. package/package.json +45 -0
  3. package/vscode/src/vs/platform/actionWidget/browser/actionWidgetDropdown.d.ts +37 -0
  4. package/vscode/src/vs/platform/actionWidget/browser/actionWidgetDropdown.js +127 -0
  5. package/vscode/src/vs/platform/actions/browser/actionWidgetDropdownActionViewItem.d.ts +27 -0
  6. package/vscode/src/vs/platform/actions/browser/actionWidgetDropdownActionViewItem.js +81 -0
  7. package/vscode/src/vs/platform/actions/browser/buttonbar.d.ts +44 -0
  8. package/vscode/src/vs/platform/actions/browser/buttonbar.js +172 -0
  9. package/vscode/src/vs/platform/editor/browser/editor.d.ts +12 -0
  10. package/vscode/src/vs/platform/editor/browser/editor.js +51 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContinueInAction.d.ts +41 -0
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContinueInAction.js +295 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatElicitationActions.d.ts +2 -0
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatElicitationActions.js +60 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.d.ts +65 -0
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +650 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.d.ts +2 -0
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTitleActions.js +364 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/implicitContextAttachment.d.ts +38 -0
  20. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/implicitContextAttachment.js +207 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityProvider.d.ts +17 -0
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityProvider.js +216 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatAgentHover.d.ts +24 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatAgentHover.js +114 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentModel.d.ts +34 -0
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentModel.js +141 -0
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentWidgets.d.ts +169 -0
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatAttachmentWidgets.js +951 -0
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentMarkdownRenderer.d.ts +19 -0
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentMarkdownRenderer.js +109 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAgentCommandContentPart.d.ts +12 -0
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAgentCommandContentPart.js +47 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAnonymousRateLimitedPart.d.ts +13 -0
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAnonymousRateLimitedPart.js +49 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAttachmentsContentPart.d.ts +27 -0
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatAttachmentsContentPart.js +160 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatChangesSummaryPart.d.ts +40 -0
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatChangesSummaryPart.js +286 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCodeCitationContentPart.d.ts +13 -0
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCodeCitationContentPart.js +49 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCollapsibleContentPart.d.ts +34 -0
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCollapsibleContentPart.js +101 -0
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCollections.d.ts +14 -0
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCollections.js +30 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCommandContentPart.d.ts +11 -0
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatCommandContentPart.js +37 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.d.ts +17 -0
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationContentPart.js +69 -0
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationWidget.d.ts +116 -0
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatConfirmationWidget.js +417 -0
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatContentCodePools.d.ts +20 -0
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatContentCodePools.js +66 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatElicitationContentPart.d.ts +25 -0
  54. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatElicitationContentPart.js +123 -0
  55. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatErrorConfirmationPart.d.ts +18 -0
  56. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatErrorConfirmationPart.js +60 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatErrorContentPart.d.ts +16 -0
  58. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatErrorContentPart.js +46 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatExtensionsContentPart.d.ts +19 -0
  60. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatExtensionsContentPart.js +57 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownContentPart.d.ts +94 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownContentPart.js +567 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMcpServersInteractionContentPart.d.ts +34 -0
  64. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMcpServersInteractionContentPart.js +224 -0
  65. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMultiDiffContentPart.d.ts +34 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMultiDiffContentPart.js +259 -0
  67. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.d.ts +38 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatProgressContentPart.js +160 -0
  69. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatPullRequestContentPart.d.ts +16 -0
  70. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatPullRequestContentPart.js +55 -0
  71. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatQuotaExceededPart.d.ts +17 -0
  72. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatQuotaExceededPart.js +117 -0
  73. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.d.ts +66 -0
  74. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatReferencesContentPart.js +528 -0
  75. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatSuggestNextWidget.d.ts +31 -0
  76. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatSuggestNextWidget.js +160 -0
  77. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.d.ts +17 -0
  78. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTaskContentPart.js +49 -0
  79. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTextEditContentPart.d.ts +18 -0
  80. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTextEditContentPart.js +91 -0
  81. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTextEditContentPart.service.d.ts +13 -0
  82. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTextEditContentPart.service.js +6 -0
  83. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatThinkingContentPart.d.ts +54 -0
  84. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatThinkingContentPart.js +429 -0
  85. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTodoListWidget.d.ts +40 -0
  86. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTodoListWidget.js +347 -0
  87. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInputOutputContentPart.d.ts +56 -0
  88. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolInputOutputContentPart.js +164 -0
  89. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolOutputContentSubPart.d.ts +32 -0
  90. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatToolOutputContentSubPart.js +224 -0
  91. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTreeContentPart.d.ts +35 -0
  92. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatTreeContentPart.js +173 -0
  93. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatConfirmationWidget.css +341 -0
  94. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatExtensionsContent.css +27 -0
  95. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatMarkdownPart.css +23 -0
  96. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatMcpServersInteractionContent.css +14 -0
  97. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatPullRequestContent.css +75 -0
  98. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatTerminalToolProgressPart.css +221 -0
  99. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/media/chatThinkingContent.css +162 -0
  100. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/abstractToolConfirmationSubPart.d.ts +41 -0
  101. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/abstractToolConfirmationSubPart.js +94 -0
  102. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatExtensionsInstallToolSubPart.d.ts +15 -0
  103. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatExtensionsInstallToolSubPart.js +96 -0
  104. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatInputOutputMarkdownProgressPart.d.ts +18 -0
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatInputOutputMarkdownProgressPart.js +147 -0
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatResultListSubPart.d.ts +14 -0
  107. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatResultListSubPart.js +23 -0
  108. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.d.ts +68 -0
  109. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolConfirmationSubPart.js +353 -0
  110. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.d.ts +100 -0
  111. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatTerminalToolProgressPart.js +1085 -0
  112. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.d.ts +39 -0
  113. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolConfirmationSubPart.js +275 -0
  114. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationPart.d.ts +32 -0
  115. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationPart.js +119 -0
  116. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationSubPart.d.ts +19 -0
  117. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolInvocationSubPart.js +36 -0
  118. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolOutputPart.d.ts +21 -0
  119. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolOutputPart.js +130 -0
  120. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolPostExecuteConfirmationPart.d.ts +25 -0
  121. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolPostExecuteConfirmationPart.js +225 -0
  122. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolProgressPart.d.ts +24 -0
  123. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/toolInvocationParts/chatToolProgressPart.js +101 -0
  124. package/vscode/src/vs/workbench/contrib/chat/browser/chatDiffBlockPart.d.ts +42 -0
  125. package/vscode/src/vs/workbench/contrib/chat/browser/chatDiffBlockPart.js +127 -0
  126. package/vscode/src/vs/workbench/contrib/chat/browser/chatDragAndDrop.d.ts +43 -0
  127. package/vscode/src/vs/workbench/contrib/chat/browser/chatDragAndDrop.js +388 -0
  128. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.d.ts +49 -0
  129. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.js +721 -0
  130. package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.d.ts +13 -0
  131. package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +52 -0
  132. package/vscode/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.d.ts +39 -0
  133. package/vscode/src/vs/workbench/contrib/chat/browser/chatInlineAnchorWidget.js +409 -0
  134. package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.d.ts +334 -0
  135. package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +2008 -0
  136. package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPartWidgets.d.ts +52 -0
  137. package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPartWidgets.js +93 -0
  138. package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.d.ts +217 -0
  139. package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1573 -0
  140. package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.d.ts +43 -0
  141. package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +249 -0
  142. package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.d.ts +50 -0
  143. package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +84 -0
  144. package/vscode/src/vs/workbench/contrib/chat/browser/chatSelectedTools.d.ts +32 -0
  145. package/vscode/src/vs/workbench/contrib/chat/browser/chatSelectedTools.js +174 -0
  146. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionPickerActionItem.d.ts +31 -0
  147. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/chatSessionPickerActionItem.js +101 -0
  148. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/common.d.ts +19 -0
  149. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/common.js +76 -0
  150. package/vscode/src/vs/workbench/contrib/chat/browser/chatSessions/media/chatSessionAction.css +39 -0
  151. package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.d.ts +292 -0
  152. package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +2014 -0
  153. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css +171 -0
  154. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.d.ts +173 -0
  155. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +797 -0
  156. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatImplicitContext.d.ts +54 -0
  157. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatImplicitContext.js +345 -0
  158. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.d.ts +10 -0
  159. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.js +1069 -0
  160. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +34 -0
  161. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +139 -0
  162. package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css +2880 -0
  163. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatAgentHover.css +87 -0
  164. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatCodeBlockPill.css +139 -0
  165. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatInlineAnchorWidget.css +61 -0
  166. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewWelcome.css +209 -0
  167. package/vscode/src/vs/workbench/contrib/chat/browser/modelPicker/modePickerActionItem.d.ts +28 -0
  168. package/vscode/src/vs/workbench/contrib/chat/browser/modelPicker/modePickerActionItem.js +135 -0
  169. package/vscode/src/vs/workbench/contrib/chat/browser/modelPicker/modelPickerActionItem.d.ts +28 -0
  170. package/vscode/src/vs/workbench/contrib/chat/browser/modelPicker/modelPickerActionItem.js +147 -0
  171. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.d.ts +71 -0
  172. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewWelcomeController.js +279 -0
  173. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcome.d.ts +28 -0
  174. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcome.js +28 -0
  175. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.d.ts +13 -0
  176. package/vscode/src/vs/workbench/contrib/chat/common/chatColors.js +38 -0
  177. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +55 -0
  178. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +176 -0
  179. package/vscode/src/vs/workbench/contrib/chat/common/codeBlockModelCollection.d.ts +45 -0
  180. package/vscode/src/vs/workbench/contrib/chat/common/codeBlockModelCollection.js +207 -0
  181. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.d.ts +48 -0
  182. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.js +373 -0
  183. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.d.ts +171 -0
  184. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +1442 -0
  185. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.d.ts +199 -0
  186. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +482 -0
  187. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.d.ts +28 -0
  188. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.js +37 -0
  189. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.d.ts +95 -0
  190. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js +497 -0
  191. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.d.ts +76 -0
  192. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +464 -0
  193. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.d.ts +124 -0
  194. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +562 -0
  195. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.d.ts +42 -0
  196. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatZoneWidget.js +279 -0
  197. package/vscode/src/vs/workbench/contrib/inlineChat/browser/media/inlineChat.css +411 -0
  198. package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.d.ts +13 -0
  199. package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +66 -0
  200. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.d.ts +61 -0
  201. package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +154 -0
  202. package/vscode/src/vs/workbench/contrib/markdown/browser/markedKatexSupport.d.ts +19 -0
  203. package/vscode/src/vs/workbench/contrib/markdown/browser/markedKatexSupport.js +201 -0
  204. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.d.ts +41 -0
  205. package/vscode/src/vs/workbench/contrib/mcp/browser/mcpPromptArgumentPick.js +372 -0
  206. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.d.ts +4 -0
  207. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/chat/notebookChatUtils.js +58 -0
  208. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.d.ts +26 -0
  209. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +594 -0
  210. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.d.ts +8 -0
  211. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +55 -0
  212. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.d.ts +273 -0
  213. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +1746 -0
  214. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.d.ts +50 -0
  215. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +269 -0
  216. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.d.ts +258 -0
  217. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +806 -0
  218. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.d.ts +41 -0
  219. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +116 -0
  220. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.d.ts +17 -0
  221. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/editorHeightCalculator.js +62 -0
  222. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.d.ts +27 -0
  223. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +40 -0
  224. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.d.ts +23 -0
  225. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookCellDiffDecorator.js +295 -0
  226. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.d.ts +51 -0
  227. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookDeletedCellDecorator.js +241 -0
  228. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.d.ts +24 -0
  229. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiff.js +146 -0
  230. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.d.ts +28 -0
  231. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInlineDiffWidget.js +90 -0
  232. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.d.ts +10 -0
  233. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookInsertedCellDecorator.js +41 -0
  234. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.d.ts +21 -0
  235. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalCellModelFactory.js +42 -0
  236. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.d.ts +25 -0
  237. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookOriginalModelRefFactory.js +77 -0
  238. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css +469 -0
  239. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.d.ts +149 -0
  240. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +823 -0
  241. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.d.ts +180 -0
  242. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +29 -0
  243. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.d.ts +102 -0
  244. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +567 -0
  245. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.d.ts +30 -0
  246. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +189 -0
  247. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.d.ts +75 -0
  248. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.js +439 -0
  249. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +57 -0
  250. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +263 -0
  251. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.d.ts +22 -0
  252. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditorInput.js +48 -0
  253. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.d.ts +13 -0
  254. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/unchangedEditorRegions.js +39 -0
  255. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.d.ts +19 -0
  256. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookMetadataTextModel.js +89 -0
  257. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.d.ts +26 -0
  258. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiff.js +92 -0
  259. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.d.ts +33 -0
  260. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +108 -0
  261. package/vscode/src/vs/workbench/contrib/terminal/browser/chatTerminalCommandMirror.d.ts +34 -0
  262. package/vscode/src/vs/workbench/contrib/terminal/browser/chatTerminalCommandMirror.js +145 -0
@@ -0,0 +1,1442 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { renderAsPlaintext } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/markdownRenderer';
4
+ import { alert } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/aria/aria';
5
+ import { Barrier, DeferredPromise, Queue, raceCancellation } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
6
+ import { CancellationTokenSource, CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
7
+ import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
8
+ import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
9
+ import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
10
+ import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
11
+ import { DisposableStore, MutableDisposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
12
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
13
+ import { MovingAverage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/numbers';
14
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
15
+ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
16
+ import { StopWatch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stopwatch';
17
+ import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
18
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
19
+ import { generateUuid } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uuid';
20
+ import { isCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorBrowser';
21
+ import { observableCodeEditor } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/observableCodeEditor';
22
+ import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service';
23
+ import { EditorOption } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
24
+ import { Position } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/position';
25
+ import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
26
+ import { Selection, SelectionDirection } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/selection';
27
+ import { TextEdit, VersionedExtensionId } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
28
+ import { IEditorWorkerService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/editorWorker.service';
29
+ import { IMarkerDecorationsService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/markerDecorations.service';
30
+ import { DefaultModelSHA1Computer } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/modelService';
31
+ import { InlineCompletionsController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController';
32
+ import { MessageController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/message/browser/messageController';
33
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
34
+ import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
35
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
36
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
37
+ import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
38
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
39
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
40
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
41
+ import { observableConfigValue } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
42
+ import { ISharedWebContentExtractorService } from '@codingame/monaco-vscode-api/vscode/vs/platform/webContentExtractor/common/webContentExtractor.service';
43
+ import { SIDE_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
44
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
45
+ import { IChatAttachmentResolveService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatAttachmentResolveService.service';
46
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
47
+ import { ModifiedFileEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
48
+ import { ChatRequestRemovalReason } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel';
49
+ import { ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes';
50
+ import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
51
+ import { IDiagnosticVariableEntryFilterData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariableEntries';
52
+ import { isResponseVM } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatViewModel';
53
+ import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
54
+ import { isILanguageModelChatSelector } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
55
+ import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
56
+ import { isNotebookContainingCellEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/notebookEditor';
57
+ import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
58
+ import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
59
+ import { InlineChatConfigKeys, INLINE_CHAT_ID, CTX_INLINE_CHAT_VISIBLE, CTX_INLINE_CHAT_EDITING, CTX_INLINE_CHAT_RESPONSE_TYPE, CTX_INLINE_CHAT_REQUEST_IN_PROGRESS, InlineChatResponseType } from '../common/inlineChat.js';
60
+ import { Session } from './inlineChatSession.js';
61
+ import { moveToPanelChat } from './inlineChatSessionService.js';
62
+ import { IInlineChatSessionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatSessionService.service';
63
+ import { InlineChatError } from './inlineChatSessionServiceImpl.js';
64
+ import { LiveStrategy, HunkAction } from './inlineChatStrategies.js';
65
+ import { InlineChatZoneWidget } from './inlineChatZoneWidget.js';
66
+ import { derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
67
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
68
+ import { observableSignalFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableSignalFromEvent';
69
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
70
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
71
+ import { waitForState } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/utils/utilsCancellation';
72
+
73
+ var InlineChatController_1, InlineChatController1_1, InlineChatController2_1;
74
+ var State;
75
+ (function (State) {
76
+ State["CREATE_SESSION"] = "CREATE_SESSION";
77
+ State["INIT_UI"] = "INIT_UI";
78
+ State["WAIT_FOR_INPUT"] = "WAIT_FOR_INPUT";
79
+ State["SHOW_REQUEST"] = "SHOW_REQUEST";
80
+ State["PAUSE"] = "PAUSE";
81
+ State["CANCEL"] = "CANCEL";
82
+ State["ACCEPT"] = "DONE";
83
+ })(State || (State = {}));
84
+ var Message;
85
+ (function (Message) {
86
+ Message[Message["NONE"] = 0] = "NONE";
87
+ Message[Message["ACCEPT_SESSION"] = 1] = "ACCEPT_SESSION";
88
+ Message[Message["CANCEL_SESSION"] = 2] = "CANCEL_SESSION";
89
+ Message[Message["PAUSE_SESSION"] = 4] = "PAUSE_SESSION";
90
+ Message[Message["CANCEL_REQUEST"] = 8] = "CANCEL_REQUEST";
91
+ Message[Message["CANCEL_INPUT"] = 16] = "CANCEL_INPUT";
92
+ Message[Message["ACCEPT_INPUT"] = 32] = "ACCEPT_INPUT";
93
+ })(Message || (Message = {}));
94
+ class InlineChatRunOptions {
95
+ static isInlineChatRunOptions(options) {
96
+ if (typeof options !== 'object' || options === null) {
97
+ return false;
98
+ }
99
+ const { initialSelection, initialRange, message, autoSend, position, existingSession, attachments, modelSelector, blockOnResponse } = options;
100
+ if (typeof message !== 'undefined' && typeof message !== 'string'
101
+ || typeof autoSend !== 'undefined' && typeof autoSend !== 'boolean'
102
+ || typeof initialRange !== 'undefined' && !Range.isIRange(initialRange)
103
+ || typeof initialSelection !== 'undefined' && !Selection.isISelection(initialSelection)
104
+ || typeof position !== 'undefined' && !Position.isIPosition(position)
105
+ || typeof existingSession !== 'undefined' && !(existingSession instanceof Session)
106
+ || typeof attachments !== 'undefined' && (!Array.isArray(attachments) || !attachments.every(item => item instanceof URI))
107
+ || typeof modelSelector !== 'undefined' && !isILanguageModelChatSelector(modelSelector)
108
+ || typeof blockOnResponse !== 'undefined' && typeof blockOnResponse !== 'boolean') {
109
+ return false;
110
+ }
111
+ return true;
112
+ }
113
+ }
114
+ let InlineChatController = class InlineChatController {
115
+ static { InlineChatController_1 = this; }
116
+ static { this.ID = 'editor.contrib.inlineChatController'; }
117
+ static get(editor) {
118
+ return editor.getContribution(InlineChatController_1.ID);
119
+ }
120
+ constructor(editor, configurationService, _notebookEditorService) {
121
+ this._notebookEditorService = _notebookEditorService;
122
+ const notebookAgent = observableConfigValue(InlineChatConfigKeys.notebookAgent, false, configurationService);
123
+ this._delegate = derived(r => {
124
+ const isNotebookCell = !!this._notebookEditorService.getNotebookForPossibleCell(editor);
125
+ if (!isNotebookCell || notebookAgent.read(r)) {
126
+ return InlineChatController2.get(editor);
127
+ }
128
+ else {
129
+ return InlineChatController1.get(editor);
130
+ }
131
+ });
132
+ }
133
+ dispose() {
134
+ }
135
+ get isActive() {
136
+ return this._delegate.get().isActive;
137
+ }
138
+ async run(arg) {
139
+ return this._delegate.get().run(arg);
140
+ }
141
+ focus() {
142
+ return this._delegate.get().focus();
143
+ }
144
+ get widget() {
145
+ return this._delegate.get().widget;
146
+ }
147
+ getWidgetPosition() {
148
+ return this._delegate.get().getWidgetPosition();
149
+ }
150
+ acceptSession() {
151
+ return this._delegate.get().acceptSession();
152
+ }
153
+ };
154
+ InlineChatController = InlineChatController_1 = ( __decorate([
155
+ ( __param(1, IConfigurationService)),
156
+ ( __param(2, INotebookEditorService))
157
+ ], InlineChatController));
158
+ function getEditorId(editor, model) {
159
+ return `${editor.getId()},${model.id}`;
160
+ }
161
+ let InlineChatController1 = InlineChatController1_1 = class InlineChatController1 {
162
+ static get(editor) {
163
+ return editor.getContribution(INLINE_CHAT_ID);
164
+ }
165
+ get chatWidget() {
166
+ return this._ui.value.widget.chatWidget;
167
+ }
168
+ constructor(_editor, _instaService, _inlineChatSessionService, _editorWorkerService, _logService, _configurationService, _dialogService, contextKeyService, _chatService, _editorService, notebookEditorService, _webContentExtractorService, _fileService, _chatAttachmentResolveService) {
169
+ this._editor = _editor;
170
+ this._instaService = _instaService;
171
+ this._inlineChatSessionService = _inlineChatSessionService;
172
+ this._editorWorkerService = _editorWorkerService;
173
+ this._logService = _logService;
174
+ this._configurationService = _configurationService;
175
+ this._dialogService = _dialogService;
176
+ this._chatService = _chatService;
177
+ this._editorService = _editorService;
178
+ this._webContentExtractorService = _webContentExtractorService;
179
+ this._fileService = _fileService;
180
+ this._chatAttachmentResolveService = _chatAttachmentResolveService;
181
+ this._isDisposed = false;
182
+ this._store = ( new DisposableStore());
183
+ this._messages = this._store.add(( new Emitter()));
184
+ this._onDidEnterState = this._store.add(( new Emitter()));
185
+ this._sessionStore = this._store.add(( new DisposableStore()));
186
+ this._stashedSession = this._store.add(( new MutableDisposable()));
187
+ this._ctxVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
188
+ this._ctxEditing = CTX_INLINE_CHAT_EDITING.bindTo(contextKeyService);
189
+ this._ctxResponseType = CTX_INLINE_CHAT_RESPONSE_TYPE.bindTo(contextKeyService);
190
+ this._ctxRequestInProgress = CTX_INLINE_CHAT_REQUEST_IN_PROGRESS.bindTo(contextKeyService);
191
+ this._ctxResponse = ChatContextKeys.isResponse.bindTo(contextKeyService);
192
+ ChatContextKeys.responseHasError.bindTo(contextKeyService);
193
+ this._ui = ( new Lazy(() => {
194
+ const location = {
195
+ location: ChatAgentLocation.EditorInline,
196
+ resolveData: () => {
197
+ assertType(this._editor.hasModel());
198
+ assertType(this._session);
199
+ return {
200
+ type: ChatAgentLocation.EditorInline,
201
+ id: getEditorId(this._editor, this._session.textModelN),
202
+ selection: this._editor.getSelection(),
203
+ document: this._session.textModelN.uri,
204
+ wholeRange: this._session?.wholeRange.trackedInitialRange,
205
+ close: () => this.cancelSession(),
206
+ delegateSessionResource: this._delegateSession?.chatSessionResource,
207
+ };
208
+ }
209
+ };
210
+ const notebookEditor = notebookEditorService.getNotebookForPossibleCell(this._editor);
211
+ if (!!notebookEditor) {
212
+ location.location = ChatAgentLocation.Notebook;
213
+ }
214
+ const clear = async () => {
215
+ const r = this.joinCurrentRun();
216
+ this.cancelSession();
217
+ await r;
218
+ this.run();
219
+ };
220
+ const zone = _instaService.createInstance(InlineChatZoneWidget, location, undefined, { editor: this._editor, notebookEditor }, clear);
221
+ this._store.add(zone);
222
+ return zone;
223
+ }));
224
+ this._store.add(this._editor.onDidChangeModel(async (e) => {
225
+ if (this._session || !e.newModelUrl) {
226
+ return;
227
+ }
228
+ const existingSession = this._inlineChatSessionService.getSession(this._editor, e.newModelUrl);
229
+ if (!existingSession) {
230
+ return;
231
+ }
232
+ this._log('session RESUMING after model change', e);
233
+ await this.run({ existingSession });
234
+ }));
235
+ this._store.add(this._inlineChatSessionService.onDidEndSession(e => {
236
+ if (e.session === this._session && e.endedByExternalCause) {
237
+ this._log('session ENDED by external cause');
238
+ this.acceptSession();
239
+ }
240
+ }));
241
+ this._store.add(this._inlineChatSessionService.onDidMoveSession(async (e) => {
242
+ if (e.editor === this._editor) {
243
+ this._log('session RESUMING after move', e);
244
+ await this.run({ existingSession: e.session });
245
+ }
246
+ }));
247
+ this._log(`NEW controller`);
248
+ }
249
+ dispose() {
250
+ if (this._currentRun) {
251
+ this._messages.fire(this._session?.chatModel.hasRequests
252
+ ? Message.PAUSE_SESSION
253
+ : Message.CANCEL_SESSION);
254
+ }
255
+ this._store.dispose();
256
+ this._isDisposed = true;
257
+ this._log('DISPOSED controller');
258
+ }
259
+ _log(message, ...more) {
260
+ if (message instanceof Error) {
261
+ this._logService.error(message, ...more);
262
+ }
263
+ else {
264
+ this._logService.trace(`[IE] (editor:${this._editor.getId()}) ${message}`, ...more);
265
+ }
266
+ }
267
+ get widget() {
268
+ return this._ui.value.widget;
269
+ }
270
+ getId() {
271
+ return INLINE_CHAT_ID;
272
+ }
273
+ getWidgetPosition() {
274
+ return this._ui.value.position;
275
+ }
276
+ async run(options = {}) {
277
+ let lastState;
278
+ const d = this._onDidEnterState.event(e => lastState = e);
279
+ try {
280
+ this.acceptSession();
281
+ if (this._currentRun) {
282
+ await this._currentRun;
283
+ }
284
+ if (options.initialSelection) {
285
+ this._editor.setSelection(options.initialSelection);
286
+ }
287
+ this._stashedSession.clear();
288
+ this._currentRun = this._nextState(State.CREATE_SESSION, options);
289
+ await this._currentRun;
290
+ }
291
+ catch (error) {
292
+ this._log('error during run', error);
293
+ onUnexpectedError(error);
294
+ if (this._session) {
295
+ this._inlineChatSessionService.releaseSession(this._session);
296
+ }
297
+ this[State.PAUSE]();
298
+ }
299
+ finally {
300
+ this._currentRun = undefined;
301
+ d.dispose();
302
+ }
303
+ return lastState !== State.CANCEL;
304
+ }
305
+ async _nextState(state, options) {
306
+ let nextState = state;
307
+ while (nextState && !this._isDisposed) {
308
+ this._log('setState to ', nextState);
309
+ const p = this[nextState](options);
310
+ this._onDidEnterState.fire(nextState);
311
+ nextState = await p;
312
+ }
313
+ }
314
+ async [State.CREATE_SESSION](options) {
315
+ assertType(this._session === undefined);
316
+ assertType(this._editor.hasModel());
317
+ let session = options.existingSession;
318
+ let initPosition;
319
+ if (options.position) {
320
+ initPosition = Position.lift(options.position).delta(-1);
321
+ delete options.position;
322
+ }
323
+ const widgetPosition = this._showWidget(session?.headless, true, initPosition);
324
+ let errorMessage = ( localize(8300, "Failed to start editor chat"));
325
+ if (!session) {
326
+ const createSessionCts = ( new CancellationTokenSource());
327
+ const msgListener = Event.once(this._messages.event)(m => {
328
+ this._log('state=_createSession) message received', m);
329
+ if (m === Message.ACCEPT_INPUT) {
330
+ options.autoSend = true;
331
+ this._ui.value.widget.updateInfo(( localize(8301, "Getting ready...")));
332
+ }
333
+ else {
334
+ createSessionCts.cancel();
335
+ }
336
+ });
337
+ try {
338
+ session = await this._inlineChatSessionService.createSession(this._editor, { wholeRange: options.initialRange }, createSessionCts.token);
339
+ }
340
+ catch (error) {
341
+ if (error instanceof InlineChatError || error?.name === InlineChatError.code) {
342
+ errorMessage = error.message;
343
+ }
344
+ }
345
+ createSessionCts.dispose();
346
+ msgListener.dispose();
347
+ if (createSessionCts.token.isCancellationRequested) {
348
+ if (session) {
349
+ this._inlineChatSessionService.releaseSession(session);
350
+ }
351
+ return State.CANCEL;
352
+ }
353
+ }
354
+ delete options.initialRange;
355
+ delete options.existingSession;
356
+ if (!session) {
357
+ MessageController.get(this._editor)?.showMessage(errorMessage, widgetPosition);
358
+ this._log('Failed to start editor chat');
359
+ return State.CANCEL;
360
+ }
361
+ this._strategy = this._instaService.createInstance(LiveStrategy, session, this._editor, this._ui.value, session.headless);
362
+ this._session = session;
363
+ return State.INIT_UI;
364
+ }
365
+ async [State.INIT_UI](options) {
366
+ assertType(this._session);
367
+ assertType(this._strategy);
368
+ InlineCompletionsController.get(this._editor)?.reject();
369
+ this._sessionStore.clear();
370
+ const wholeRangeDecoration = this._editor.createDecorationsCollection();
371
+ const handleWholeRangeChange = () => {
372
+ const newDecorations = this._strategy?.getWholeRangeDecoration() ?? [];
373
+ wholeRangeDecoration.set(newDecorations);
374
+ this._ctxEditing.set(!this._session?.wholeRange.trackedInitialRange.isEmpty());
375
+ };
376
+ this._sessionStore.add(toDisposable(() => {
377
+ wholeRangeDecoration.clear();
378
+ this._ctxEditing.reset();
379
+ }));
380
+ this._sessionStore.add(this._session.wholeRange.onDidChange(handleWholeRangeChange));
381
+ handleWholeRangeChange();
382
+ this._ui.value.widget.setChatModel(this._session.chatModel);
383
+ this._updatePlaceholder();
384
+ const isModelEmpty = !this._session.chatModel.hasRequests;
385
+ this._ui.value.widget.updateToolbar(true);
386
+ this._ui.value.widget.toggleStatus(!isModelEmpty);
387
+ this._showWidget(this._session.headless, isModelEmpty);
388
+ this._sessionStore.add(this._editor.onDidChangeModel((e) => {
389
+ const msg = this._session?.chatModel.hasRequests
390
+ ? Message.PAUSE_SESSION
391
+ : Message.CANCEL_SESSION;
392
+ this._log('model changed, pause or cancel session', msg, e);
393
+ this._messages.fire(msg);
394
+ }));
395
+ const filePartOfEditSessions = this._chatService.editingSessions.filter(session => ( session.entries.get().some(e => e.state.get() === ModifiedFileEntryState.Modified && ( e.modifiedURI.toString()) === ( this._session.textModelN.uri.toString()))));
396
+ const withinEditSession = filePartOfEditSessions.find(session => ( session.entries.get().some(
397
+ e => e.state.get() === ModifiedFileEntryState.Modified && e.hasModificationAt({
398
+ range: this._session.wholeRange.trackedInitialRange,
399
+ uri: this._session.textModelN.uri
400
+ })
401
+ )));
402
+ const chatWidget = this._ui.value.widget.chatWidget;
403
+ this._delegateSession = withinEditSession || filePartOfEditSessions[0];
404
+ chatWidget.input.setIsWithinEditSession(!!withinEditSession, filePartOfEditSessions.length > 0);
405
+ this._sessionStore.add(this._editor.onDidChangeModelContent(e => {
406
+ if (this._session?.hunkData.ignoreTextModelNChanges || this._ui.value.widget.hasFocus()) {
407
+ return;
408
+ }
409
+ const wholeRange = this._session.wholeRange;
410
+ let shouldFinishSession = false;
411
+ if (this._configurationService.getValue(InlineChatConfigKeys.FinishOnType)) {
412
+ for (const { range } of e.changes) {
413
+ shouldFinishSession = !Range.areIntersectingOrTouching(range, wholeRange.value);
414
+ }
415
+ }
416
+ this._session.recordExternalEditOccurred(shouldFinishSession);
417
+ if (shouldFinishSession) {
418
+ this._log('text changed outside of whole range, FINISH session');
419
+ this.acceptSession();
420
+ }
421
+ }));
422
+ this._sessionStore.add(this._session.chatModel.onDidChange(async (e) => {
423
+ if (e.kind === 'removeRequest') {
424
+ await this._session.undoChangesUntil(e.requestId);
425
+ }
426
+ }));
427
+ const editState = this._createChatTextEditGroupState();
428
+ let didEdit = false;
429
+ for (const request of this._session.chatModel.getRequests()) {
430
+ if (!request.response || request.response.result?.errorDetails) {
431
+ break;
432
+ }
433
+ for (const part of request.response.response.value) {
434
+ if (part.kind !== 'textEditGroup' || !isEqual(part.uri, this._session.textModelN.uri)) {
435
+ continue;
436
+ }
437
+ if (part.state?.applied) {
438
+ continue;
439
+ }
440
+ for (const edit of part.edits) {
441
+ this._makeChanges(edit, undefined, !didEdit);
442
+ didEdit = true;
443
+ }
444
+ part.state ??= editState;
445
+ }
446
+ }
447
+ if (didEdit) {
448
+ const diff = await this._editorWorkerService.computeDiff(this._session.textModel0.uri, this._session.textModelN.uri, { computeMoves: false, maxComputationTimeMs: Number.MAX_SAFE_INTEGER, ignoreTrimWhitespace: false }, 'advanced');
449
+ this._session.wholeRange.fixup(diff?.changes ?? []);
450
+ await this._session.hunkData.recompute(editState, diff);
451
+ this._updateCtxResponseType();
452
+ }
453
+ options.position = await this._strategy.renderChanges();
454
+ if (this._session.chatModel.requestInProgress.get()) {
455
+ return State.SHOW_REQUEST;
456
+ }
457
+ else {
458
+ return State.WAIT_FOR_INPUT;
459
+ }
460
+ }
461
+ async [State.WAIT_FOR_INPUT](options) {
462
+ assertType(this._session);
463
+ assertType(this._strategy);
464
+ this._updatePlaceholder();
465
+ if (options.message) {
466
+ this._updateInput(options.message);
467
+ alert(options.message);
468
+ delete options.message;
469
+ this._showWidget(this._session.headless, false);
470
+ }
471
+ let message = Message.NONE;
472
+ let request;
473
+ const barrier = ( new Barrier());
474
+ const store = ( new DisposableStore());
475
+ store.add(this._session.chatModel.onDidChange(e => {
476
+ if (e.kind === 'addRequest') {
477
+ request = e.request;
478
+ message = Message.ACCEPT_INPUT;
479
+ barrier.open();
480
+ }
481
+ }));
482
+ store.add(this._strategy.onDidAccept(() => this.acceptSession()));
483
+ store.add(this._strategy.onDidDiscard(() => this.cancelSession()));
484
+ store.add(this.chatWidget.onDidHide(() => this.cancelSession()));
485
+ store.add(Event.once(this._messages.event)(m => {
486
+ this._log('state=_waitForInput) message received', m);
487
+ message = m;
488
+ barrier.open();
489
+ }));
490
+ if (options.attachments) {
491
+ await Promise.all(( options.attachments.map(async (attachment) => {
492
+ await this._ui.value.widget.chatWidget.attachmentModel.addFile(attachment);
493
+ })));
494
+ delete options.attachments;
495
+ }
496
+ if (options.autoSend) {
497
+ delete options.autoSend;
498
+ this._showWidget(this._session.headless, false);
499
+ this._ui.value.widget.chatWidget.acceptInput();
500
+ }
501
+ await barrier.wait();
502
+ store.dispose();
503
+ if (message & (Message.CANCEL_INPUT | Message.CANCEL_SESSION)) {
504
+ return State.CANCEL;
505
+ }
506
+ if (message & Message.PAUSE_SESSION) {
507
+ return State.PAUSE;
508
+ }
509
+ if (message & Message.ACCEPT_SESSION) {
510
+ this._ui.value.widget.selectAll();
511
+ return State.ACCEPT;
512
+ }
513
+ if (!request?.message.text) {
514
+ return State.WAIT_FOR_INPUT;
515
+ }
516
+ return State.SHOW_REQUEST;
517
+ }
518
+ async [State.SHOW_REQUEST](options) {
519
+ assertType(this._session);
520
+ assertType(this._strategy);
521
+ assertType(this._session.chatModel.requestInProgress.get());
522
+ this._ctxRequestInProgress.set(true);
523
+ const { chatModel } = this._session;
524
+ const request = chatModel.lastRequest;
525
+ assertType(request);
526
+ assertType(request.response);
527
+ this._showWidget(this._session.headless, false);
528
+ this._ui.value.widget.selectAll();
529
+ this._ui.value.widget.updateInfo('');
530
+ this._ui.value.widget.toggleStatus(true);
531
+ const { response } = request;
532
+ const responsePromise = ( new DeferredPromise());
533
+ const store = ( new DisposableStore());
534
+ const progressiveEditsCts = store.add(( new CancellationTokenSource()));
535
+ const progressiveEditsAvgDuration = ( new MovingAverage());
536
+ const progressiveEditsClock = StopWatch.create();
537
+ const progressiveEditsQueue = ( new Queue());
538
+ const origDeco = this._editor.getOption(EditorOption.renderValidationDecorations);
539
+ this._editor.updateOptions({
540
+ renderValidationDecorations: 'off'
541
+ });
542
+ store.add(toDisposable(() => {
543
+ this._editor.updateOptions({
544
+ renderValidationDecorations: origDeco
545
+ });
546
+ }));
547
+ let next = State.WAIT_FOR_INPUT;
548
+ store.add(Event.once(this._messages.event)(message => {
549
+ this._log('state=_makeRequest) message received', message);
550
+ this._chatService.cancelCurrentRequestForSession(chatModel.sessionResource);
551
+ if (message & Message.CANCEL_SESSION) {
552
+ next = State.CANCEL;
553
+ }
554
+ else if (message & Message.PAUSE_SESSION) {
555
+ next = State.PAUSE;
556
+ }
557
+ else if (message & Message.ACCEPT_SESSION) {
558
+ next = State.ACCEPT;
559
+ }
560
+ }));
561
+ store.add(chatModel.onDidChange(async (e) => {
562
+ if (e.kind === 'removeRequest' && e.requestId === request.id) {
563
+ progressiveEditsCts.cancel();
564
+ responsePromise.complete();
565
+ if (e.reason === ChatRequestRemovalReason.Resend) {
566
+ next = State.SHOW_REQUEST;
567
+ }
568
+ else {
569
+ next = State.CANCEL;
570
+ }
571
+ return;
572
+ }
573
+ if (e.kind === 'move') {
574
+ assertType(this._session);
575
+ const log = (msg, ...args) => this._log('state=_showRequest) moving inline chat', msg, ...args);
576
+ log('move was requested', e.target, e.range);
577
+ const initialSelection = Selection.fromRange(Range.lift(e.range), SelectionDirection.LTR);
578
+ const editorPane = await this._editorService.openEditor({ resource: e.target, options: { selection: initialSelection } }, SIDE_GROUP);
579
+ if (!editorPane) {
580
+ log('opening editor failed');
581
+ return;
582
+ }
583
+ const newEditor = editorPane.getControl();
584
+ if (!isCodeEditor(newEditor) || !newEditor.hasModel()) {
585
+ log('new editor is either missing or not a code editor or does not have a model');
586
+ return;
587
+ }
588
+ if (this._inlineChatSessionService.getSession(newEditor, e.target)) {
589
+ log('new editor ALREADY has a session');
590
+ return;
591
+ }
592
+ const newSession = await this._inlineChatSessionService.createSession(newEditor, {
593
+ session: this._session,
594
+ }, CancellationToken.None);
595
+ InlineChatController1_1.get(newEditor)?.run({ existingSession: newSession });
596
+ next = State.CANCEL;
597
+ responsePromise.complete();
598
+ return;
599
+ }
600
+ }));
601
+ store.add(this._ui.value.widget.chatWidget.inputEditor.onDidChangeModelContent(() => {
602
+ this._chatService.cancelCurrentRequestForSession(chatModel.sessionResource);
603
+ }));
604
+ let lastLength = 0;
605
+ let isFirstChange = true;
606
+ const editState = this._createChatTextEditGroupState();
607
+ let localEditGroup;
608
+ const handleResponse = () => {
609
+ this._updateCtxResponseType();
610
+ if (!localEditGroup) {
611
+ localEditGroup = response.response.value.find(part => part.kind === 'textEditGroup' && isEqual(part.uri, this._session?.textModelN.uri));
612
+ }
613
+ if (localEditGroup) {
614
+ localEditGroup.state ??= editState;
615
+ const edits = localEditGroup.edits;
616
+ const newEdits = edits.slice(lastLength);
617
+ if (newEdits.length > 0) {
618
+ this._log(`${this._session?.textModelN.uri.toString()} received ${newEdits.length} edits`);
619
+ lastLength = edits.length;
620
+ progressiveEditsAvgDuration.update(progressiveEditsClock.elapsed());
621
+ progressiveEditsClock.reset();
622
+ progressiveEditsQueue.queue(async () => {
623
+ const startThen = this._session.wholeRange.value.getStartPosition();
624
+ for (const edits of newEdits) {
625
+ await this._makeChanges(edits, {
626
+ duration: progressiveEditsAvgDuration.value,
627
+ token: progressiveEditsCts.token
628
+ }, isFirstChange);
629
+ isFirstChange = false;
630
+ }
631
+ const startNow = this._session.wholeRange.value.getStartPosition();
632
+ if (!startNow.equals(startThen) || !this._ui.value.position?.equals(startNow)) {
633
+ this._showWidget(this._session.headless, false, startNow.delta(-1));
634
+ }
635
+ });
636
+ }
637
+ }
638
+ if (response.isCanceled) {
639
+ progressiveEditsCts.cancel();
640
+ responsePromise.complete();
641
+ }
642
+ else if (response.isComplete) {
643
+ responsePromise.complete();
644
+ }
645
+ };
646
+ store.add(response.onDidChange(handleResponse));
647
+ handleResponse();
648
+ await responsePromise.p;
649
+ await progressiveEditsQueue.whenIdle();
650
+ if (response.result?.errorDetails && !response.result.errorDetails.responseIsFiltered) {
651
+ await this._session.undoChangesUntil(response.requestId);
652
+ }
653
+ store.dispose();
654
+ const diff = await this._editorWorkerService.computeDiff(this._session.textModel0.uri, this._session.textModelN.uri, { computeMoves: false, maxComputationTimeMs: Number.MAX_SAFE_INTEGER, ignoreTrimWhitespace: false }, 'advanced');
655
+ this._session.wholeRange.fixup(diff?.changes ?? []);
656
+ await this._session.hunkData.recompute(editState, diff);
657
+ this._ctxRequestInProgress.set(false);
658
+ let newPosition;
659
+ if (response.result?.errorDetails) {
660
+ alert(response.result.errorDetails.message);
661
+ }
662
+ else if (response.response.value.length === 0) {
663
+ const status = ( localize(8302, "No results, please refine your input and try again"));
664
+ this._ui.value.widget.updateStatus(status, { classes: ['warn'] });
665
+ alert(status);
666
+ }
667
+ else {
668
+ this._ui.value.widget.updateStatus('');
669
+ alert(( localize(8303, "Response was empty")));
670
+ }
671
+ const position = await this._strategy.renderChanges();
672
+ if (position) {
673
+ const selection = this._editor.getSelection();
674
+ if (selection?.containsPosition(position)) {
675
+ if (position.lineNumber - selection.startLineNumber > 8) {
676
+ newPosition = position;
677
+ }
678
+ }
679
+ else {
680
+ newPosition = position;
681
+ }
682
+ }
683
+ this._showWidget(this._session.headless, false, newPosition);
684
+ return next;
685
+ }
686
+ async [State.PAUSE]() {
687
+ this._resetWidget();
688
+ this._strategy?.dispose?.();
689
+ this._session = undefined;
690
+ }
691
+ async [State.ACCEPT]() {
692
+ assertType(this._session);
693
+ assertType(this._strategy);
694
+ this._sessionStore.clear();
695
+ try {
696
+ await this._strategy.apply();
697
+ }
698
+ catch (err) {
699
+ this._dialogService.error(( localize(8304, "Failed to apply changes.", toErrorMessage(err))));
700
+ this._log('FAILED to apply changes');
701
+ this._log(err);
702
+ }
703
+ this._resetWidget();
704
+ this._inlineChatSessionService.releaseSession(this._session);
705
+ this._strategy?.dispose();
706
+ this._strategy = undefined;
707
+ this._session = undefined;
708
+ }
709
+ async [State.CANCEL]() {
710
+ this._resetWidget();
711
+ if (this._session) {
712
+ assertType(this._strategy);
713
+ this._sessionStore.clear();
714
+ const shouldStash = !this._session.isUnstashed && this._session.chatModel.hasRequests && this._session.hunkData.size === this._session.hunkData.pending;
715
+ let undoCancelEdits = [];
716
+ try {
717
+ undoCancelEdits = this._strategy.cancel();
718
+ }
719
+ catch (err) {
720
+ this._dialogService.error(( localize(8305, "Failed to discard changes.", toErrorMessage(err))));
721
+ this._log('FAILED to discard changes');
722
+ this._log(err);
723
+ }
724
+ this._stashedSession.clear();
725
+ if (shouldStash) {
726
+ this._stashedSession.value = this._inlineChatSessionService.stashSession(this._session, this._editor, undoCancelEdits);
727
+ }
728
+ else {
729
+ this._inlineChatSessionService.releaseSession(this._session);
730
+ }
731
+ }
732
+ this._strategy?.dispose();
733
+ this._strategy = undefined;
734
+ this._session = undefined;
735
+ }
736
+ _showWidget(headless = false, initialRender = false, position) {
737
+ assertType(this._editor.hasModel());
738
+ this._ctxVisible.set(true);
739
+ let widgetPosition;
740
+ if (position) {
741
+ widgetPosition = position;
742
+ }
743
+ else if (this._ui.rawValue?.position) {
744
+ if (this._ui.rawValue?.position.lineNumber === 1) {
745
+ widgetPosition = this._ui.rawValue?.position.delta(-1);
746
+ }
747
+ else {
748
+ widgetPosition = this._ui.rawValue?.position;
749
+ }
750
+ }
751
+ else {
752
+ widgetPosition = this._editor.getSelection().getStartPosition().delta(-1);
753
+ }
754
+ if (this._session && !position && (this._session.hasChangedText || this._session.chatModel.hasRequests)) {
755
+ widgetPosition = this._session.wholeRange.trackedInitialRange.getStartPosition().delta(-1);
756
+ }
757
+ if (initialRender && (this._editor.getOption(EditorOption.stickyScroll)).enabled) {
758
+ this._editor.revealLine(widgetPosition.lineNumber);
759
+ }
760
+ if (!headless) {
761
+ if (this._ui.rawValue?.position) {
762
+ this._ui.value.updatePositionAndHeight(widgetPosition);
763
+ }
764
+ else {
765
+ this._ui.value.show(widgetPosition);
766
+ }
767
+ }
768
+ return widgetPosition;
769
+ }
770
+ _resetWidget() {
771
+ this._sessionStore.clear();
772
+ this._ctxVisible.reset();
773
+ this._ui.rawValue?.hide();
774
+ if (this._editor.hasWidgetFocus()) {
775
+ this._editor.focus();
776
+ }
777
+ }
778
+ _updateCtxResponseType() {
779
+ if (!this._session) {
780
+ this._ctxResponseType.set(InlineChatResponseType.None);
781
+ return;
782
+ }
783
+ const hasLocalEdit = (response) => {
784
+ return ( response.value.some(
785
+ part => part.kind === 'textEditGroup' && isEqual(part.uri, this._session?.textModelN.uri)
786
+ ));
787
+ };
788
+ let responseType = InlineChatResponseType.None;
789
+ for (const request of this._session.chatModel.getRequests()) {
790
+ if (!request.response) {
791
+ continue;
792
+ }
793
+ responseType = InlineChatResponseType.Messages;
794
+ if (hasLocalEdit(request.response.response)) {
795
+ responseType = InlineChatResponseType.MessagesAndEdits;
796
+ break;
797
+ }
798
+ }
799
+ this._ctxResponseType.set(responseType);
800
+ this._ctxResponse.set(responseType !== InlineChatResponseType.None);
801
+ }
802
+ _createChatTextEditGroupState() {
803
+ assertType(this._session);
804
+ const sha1 = ( new DefaultModelSHA1Computer());
805
+ const textModel0Sha1 = sha1.canComputeSHA1(this._session.textModel0)
806
+ ? sha1.computeSHA1(this._session.textModel0)
807
+ : generateUuid();
808
+ return {
809
+ sha1: textModel0Sha1,
810
+ applied: 0
811
+ };
812
+ }
813
+ async _makeChanges(edits, opts, undoStopBefore) {
814
+ assertType(this._session);
815
+ assertType(this._strategy);
816
+ const moreMinimalEdits = await raceCancellation(this._editorWorkerService.computeMoreMinimalEdits(this._session.textModelN.uri, edits), opts?.token || CancellationToken.None);
817
+ this._log('edits from PROVIDER and after making them MORE MINIMAL', this._session.agent.extensionId, edits, moreMinimalEdits);
818
+ if (moreMinimalEdits?.length === 0) {
819
+ return;
820
+ }
821
+ const actualEdits = !opts && moreMinimalEdits ? moreMinimalEdits : edits;
822
+ const editOperations = ( actualEdits.map(TextEdit.asEditOperation));
823
+ const editsObserver = {
824
+ start: () => this._session.hunkData.ignoreTextModelNChanges = true,
825
+ stop: () => this._session.hunkData.ignoreTextModelNChanges = false,
826
+ };
827
+ const metadata = this._getMetadata();
828
+ if (opts) {
829
+ await this._strategy.makeProgressiveChanges(editOperations, editsObserver, opts, undoStopBefore, metadata);
830
+ }
831
+ else {
832
+ await this._strategy.makeChanges(editOperations, editsObserver, undoStopBefore, metadata);
833
+ }
834
+ }
835
+ _getMetadata() {
836
+ const lastRequest = this._session?.chatModel.lastRequest;
837
+ return {
838
+ extensionId: VersionedExtensionId.tryCreate(this._session?.agent.extensionId.value, this._session?.agent.extensionVersion),
839
+ modelId: lastRequest?.modelId,
840
+ requestId: lastRequest?.id,
841
+ };
842
+ }
843
+ _updatePlaceholder() {
844
+ this._ui.value.widget.placeholder = this._session?.agent.description ?? ( localize(8306, 'Ask or edit in context'));
845
+ }
846
+ _updateInput(text, selectAll = true) {
847
+ this._ui.value.widget.chatWidget.setInput(text);
848
+ if (selectAll) {
849
+ const newSelection = ( new Selection(1, 1, Number.MAX_SAFE_INTEGER, 1));
850
+ this._ui.value.widget.chatWidget.inputEditor.setSelection(newSelection);
851
+ }
852
+ }
853
+ arrowOut(up) {
854
+ if (this._ui.value.position && this._editor.hasModel()) {
855
+ const { column } = this._editor.getPosition();
856
+ const { lineNumber } = this._ui.value.position;
857
+ const newLine = up ? lineNumber : lineNumber + 1;
858
+ this._editor.setPosition({ lineNumber: newLine, column });
859
+ this._editor.focus();
860
+ }
861
+ }
862
+ focus() {
863
+ this._ui.value.widget.focus();
864
+ }
865
+ async viewInChat() {
866
+ if (!this._strategy || !this._session) {
867
+ return;
868
+ }
869
+ let someApplied = false;
870
+ let lastEdit;
871
+ const uri = this._editor.getModel()?.uri;
872
+ const requests = this._session.chatModel.getRequests();
873
+ for (const request of requests) {
874
+ if (!request.response) {
875
+ continue;
876
+ }
877
+ for (const part of request.response.response.value) {
878
+ if (part.kind === 'textEditGroup' && isEqual(part.uri, uri)) {
879
+ someApplied = someApplied || Boolean(part.state?.applied);
880
+ lastEdit = part;
881
+ part.edits = [];
882
+ part.state = undefined;
883
+ }
884
+ }
885
+ }
886
+ const doEdits = this._strategy.cancel();
887
+ if (someApplied) {
888
+ assertType(lastEdit);
889
+ lastEdit.edits = [doEdits];
890
+ }
891
+ await this._instaService.invokeFunction(moveToPanelChat, this._session?.chatModel, false);
892
+ this.cancelSession();
893
+ }
894
+ acceptSession() {
895
+ const response = this._session?.chatModel.getRequests().at(-1)?.response;
896
+ if (response) {
897
+ this._chatService.notifyUserAction({
898
+ sessionResource: response.session.sessionResource,
899
+ requestId: response.requestId,
900
+ agentId: response.agent?.id,
901
+ command: response.slashCommand?.name,
902
+ result: response.result,
903
+ action: {
904
+ kind: 'inlineChat',
905
+ action: 'accepted'
906
+ }
907
+ });
908
+ }
909
+ this._messages.fire(Message.ACCEPT_SESSION);
910
+ }
911
+ acceptHunk(hunkInfo) {
912
+ return this._strategy?.performHunkAction(hunkInfo, HunkAction.Accept);
913
+ }
914
+ discardHunk(hunkInfo) {
915
+ return this._strategy?.performHunkAction(hunkInfo, HunkAction.Discard);
916
+ }
917
+ toggleDiff(hunkInfo) {
918
+ return this._strategy?.performHunkAction(hunkInfo, HunkAction.ToggleDiff);
919
+ }
920
+ moveHunk(next) {
921
+ this.focus();
922
+ this._strategy?.performHunkAction(undefined, next ? HunkAction.MoveNext : HunkAction.MovePrev);
923
+ }
924
+ async cancelSession() {
925
+ const response = this._session?.chatModel.lastRequest?.response;
926
+ if (response) {
927
+ this._chatService.notifyUserAction({
928
+ sessionResource: response.session.sessionResource,
929
+ requestId: response.requestId,
930
+ agentId: response.agent?.id,
931
+ command: response.slashCommand?.name,
932
+ result: response.result,
933
+ action: {
934
+ kind: 'inlineChat',
935
+ action: 'discarded'
936
+ }
937
+ });
938
+ }
939
+ this._resetWidget();
940
+ this._messages.fire(Message.CANCEL_SESSION);
941
+ }
942
+ reportIssue() {
943
+ const response = this._session?.chatModel.lastRequest?.response;
944
+ if (response) {
945
+ this._chatService.notifyUserAction({
946
+ sessionResource: response.session.sessionResource,
947
+ requestId: response.requestId,
948
+ agentId: response.agent?.id,
949
+ command: response.slashCommand?.name,
950
+ result: response.result,
951
+ action: { kind: 'bug' }
952
+ });
953
+ }
954
+ }
955
+ unstashLastSession() {
956
+ const result = this._stashedSession.value?.unstash();
957
+ return result;
958
+ }
959
+ joinCurrentRun() {
960
+ return this._currentRun;
961
+ }
962
+ get isActive() {
963
+ return Boolean(this._currentRun);
964
+ }
965
+ async createImageAttachment(attachment) {
966
+ if (attachment.scheme === Schemas.file) {
967
+ if (await this._fileService.canHandleResource(attachment)) {
968
+ return await this._chatAttachmentResolveService.resolveImageEditorAttachContext(attachment);
969
+ }
970
+ }
971
+ else if (attachment.scheme === Schemas.http || attachment.scheme === Schemas.https) {
972
+ const extractedImages = await this._webContentExtractorService.readImage(attachment, CancellationToken.None);
973
+ if (extractedImages) {
974
+ return await this._chatAttachmentResolveService.resolveImageEditorAttachContext(attachment, extractedImages);
975
+ }
976
+ }
977
+ return undefined;
978
+ }
979
+ };
980
+ InlineChatController1 = InlineChatController1_1 = ( __decorate([
981
+ ( __param(1, IInstantiationService)),
982
+ ( __param(2, IInlineChatSessionService)),
983
+ ( __param(3, IEditorWorkerService)),
984
+ ( __param(4, ILogService)),
985
+ ( __param(5, IConfigurationService)),
986
+ ( __param(6, IDialogService)),
987
+ ( __param(7, IContextKeyService)),
988
+ ( __param(8, IChatService)),
989
+ ( __param(9, IEditorService)),
990
+ ( __param(10, INotebookEditorService)),
991
+ ( __param(11, ISharedWebContentExtractorService)),
992
+ ( __param(12, IFileService)),
993
+ ( __param(13, IChatAttachmentResolveService))
994
+ ], InlineChatController1));
995
+ let InlineChatController2 = class InlineChatController2 {
996
+ static { InlineChatController2_1 = this; }
997
+ static { this.ID = 'editor.contrib.inlineChatController2'; }
998
+ static get(editor) {
999
+ return editor.getContribution(InlineChatController2_1.ID) ?? undefined;
1000
+ }
1001
+ get widget() {
1002
+ return this._zone.value.widget;
1003
+ }
1004
+ get isActive() {
1005
+ return Boolean(this._currentSession.get());
1006
+ }
1007
+ constructor(_editor, _instaService, _notebookEditorService, _inlineChatSessionService, codeEditorService, contextKeyService, _webContentExtractorService, _fileService, _chatAttachmentResolveService, _editorService, _markerDecorationsService, _languageModelService, chatService) {
1008
+ this._editor = _editor;
1009
+ this._instaService = _instaService;
1010
+ this._notebookEditorService = _notebookEditorService;
1011
+ this._inlineChatSessionService = _inlineChatSessionService;
1012
+ this._webContentExtractorService = _webContentExtractorService;
1013
+ this._fileService = _fileService;
1014
+ this._chatAttachmentResolveService = _chatAttachmentResolveService;
1015
+ this._editorService = _editorService;
1016
+ this._markerDecorationsService = _markerDecorationsService;
1017
+ this._languageModelService = _languageModelService;
1018
+ this._store = ( new DisposableStore());
1019
+ this._isActiveController = observableValue(this, false);
1020
+ const ctxInlineChatVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
1021
+ this._zone = ( new Lazy(() => {
1022
+ const location = {
1023
+ location: ChatAgentLocation.EditorInline,
1024
+ resolveData: () => {
1025
+ assertType(this._editor.hasModel());
1026
+ const wholeRange = this._editor.getSelection();
1027
+ const document = this._editor.getModel().uri;
1028
+ return {
1029
+ type: ChatAgentLocation.EditorInline,
1030
+ id: getEditorId(this._editor, this._editor.getModel()),
1031
+ selection: this._editor.getSelection(),
1032
+ document,
1033
+ wholeRange,
1034
+ close: () => { },
1035
+ delegateSessionResource: chatService.editingSessions.find(session => ( session.entries.get().some(e => e.hasModificationAt({
1036
+ range: wholeRange,
1037
+ uri: document
1038
+ }))))?.chatSessionResource,
1039
+ };
1040
+ }
1041
+ };
1042
+ const notebookEditor = this._notebookEditorService.getNotebookForPossibleCell(this._editor);
1043
+ if (!!notebookEditor) {
1044
+ location.location = ChatAgentLocation.Notebook;
1045
+ location.resolveData = () => {
1046
+ assertType(this._editor.hasModel());
1047
+ return {
1048
+ type: ChatAgentLocation.Notebook,
1049
+ sessionInputUri: this._editor.getModel().uri,
1050
+ };
1051
+ };
1052
+ }
1053
+ const result = this._instaService.createInstance(InlineChatZoneWidget, location, {
1054
+ enableWorkingSet: 'implicit',
1055
+ enableImplicitContext: false,
1056
+ renderInputOnTop: false,
1057
+ renderInputToolbarBelowInput: true,
1058
+ filter: item => {
1059
+ if (!isResponseVM(item)) {
1060
+ return false;
1061
+ }
1062
+ return !!item.model.isPendingConfirmation.get();
1063
+ },
1064
+ menus: {
1065
+ telemetrySource: 'inlineChatWidget',
1066
+ executeToolbar: MenuId.ChatEditorInlineExecute,
1067
+ inputSideToolbar: MenuId.ChatEditorInlineInputSide
1068
+ },
1069
+ defaultMode: ChatMode.Ask
1070
+ }, { editor: this._editor, notebookEditor }, () => Promise.resolve());
1071
+ result.domNode.classList.add('inline-chat-2');
1072
+ return result;
1073
+ }));
1074
+ const editorObs = observableCodeEditor(_editor);
1075
+ const sessionsSignal = observableSignalFromEvent(this, _inlineChatSessionService.onDidChangeSessions);
1076
+ this._currentSession = derived(r => {
1077
+ sessionsSignal.read(r);
1078
+ const model = editorObs.model.read(r);
1079
+ const session = model && _inlineChatSessionService.getSession2(model.uri);
1080
+ return session ?? undefined;
1081
+ });
1082
+ let lastSession = undefined;
1083
+ this._store.add(autorun(r => {
1084
+ const session = this._currentSession.read(r);
1085
+ if (!session) {
1086
+ this._isActiveController.set(false, undefined);
1087
+ if (lastSession && !lastSession.chatModel.hasRequests) {
1088
+ const state = lastSession.chatModel.inputModel.state.read(undefined);
1089
+ if (!state || (!state.inputText && state.attachments.length === 0)) {
1090
+ lastSession.dispose();
1091
+ lastSession = undefined;
1092
+ }
1093
+ }
1094
+ return;
1095
+ }
1096
+ lastSession = session;
1097
+ let foundOne = false;
1098
+ for (const editor of codeEditorService.listCodeEditors()) {
1099
+ if (Boolean(InlineChatController2_1.get(editor)?._isActiveController.read(undefined))) {
1100
+ foundOne = true;
1101
+ break;
1102
+ }
1103
+ }
1104
+ if (!foundOne && editorObs.isFocused.read(r)) {
1105
+ this._isActiveController.set(true, undefined);
1106
+ }
1107
+ }));
1108
+ const visibleSessionObs = observableValue(this, undefined);
1109
+ this._store.add(autorun(r => {
1110
+ const model = editorObs.model.read(r);
1111
+ const session = this._currentSession.read(r);
1112
+ const isActive = this._isActiveController.read(r);
1113
+ if (!session || !isActive || !model) {
1114
+ visibleSessionObs.set(undefined, undefined);
1115
+ }
1116
+ else {
1117
+ visibleSessionObs.set(session, undefined);
1118
+ }
1119
+ }));
1120
+ const defaultPlaceholderObs = ( visibleSessionObs.map((session, r) => {
1121
+ return session?.initialSelection.isEmpty()
1122
+ ? ( localize(8307, "Generate code"))
1123
+ : ( localize(8308, "Modify selected code"));
1124
+ }));
1125
+ this._store.add(autorun(r => {
1126
+ const session = visibleSessionObs.read(r);
1127
+ if (!session) {
1128
+ this._zone.rawValue?.hide();
1129
+ this._zone.rawValue?.widget.chatWidget.setModel(undefined);
1130
+ _editor.focus();
1131
+ ctxInlineChatVisible.reset();
1132
+ }
1133
+ else {
1134
+ ctxInlineChatVisible.set(true);
1135
+ this._zone.value.widget.chatWidget.setModel(session.chatModel);
1136
+ if (!this._zone.value.position) {
1137
+ this._zone.value.widget.chatWidget.setInputPlaceholder(defaultPlaceholderObs.read(r));
1138
+ this._zone.value.widget.chatWidget.input.renderAttachedContext();
1139
+ this._zone.value.show(session.initialPosition);
1140
+ }
1141
+ this._zone.value.reveal(this._zone.value.position);
1142
+ this._zone.value.widget.focus();
1143
+ }
1144
+ }));
1145
+ this._store.add(autorun(r => {
1146
+ const session = visibleSessionObs.read(r);
1147
+ if (session) {
1148
+ const entries = session.editingSession.entries.read(r);
1149
+ const otherEntries = entries.filter(entry => !isEqual(entry.modifiedURI, session.uri));
1150
+ for (const entry of otherEntries) {
1151
+ this._editorService.openEditor({ resource: entry.modifiedURI }, SIDE_GROUP).catch(onUnexpectedError);
1152
+ }
1153
+ }
1154
+ }));
1155
+ const lastResponseObs = ( visibleSessionObs.map((session, r) => {
1156
+ if (!session) {
1157
+ return;
1158
+ }
1159
+ const lastRequest = observableFromEvent(this, session.chatModel.onDidChange, () => session.chatModel.getRequests().at(-1)).read(r);
1160
+ return lastRequest?.response;
1161
+ }));
1162
+ const lastResponseProgressObs = ( lastResponseObs.map((response, r) => {
1163
+ if (!response) {
1164
+ return;
1165
+ }
1166
+ return observableFromEvent(this, response.onDidChange, () => response.response.value.findLast(part => part.kind === 'progressMessage')).read(r);
1167
+ }));
1168
+ this._store.add(autorun(r => {
1169
+ const response = lastResponseObs.read(r);
1170
+ this._zone.rawValue?.widget.updateInfo('');
1171
+ if (!response?.isInProgress.read(r)) {
1172
+ if (response?.result?.errorDetails) {
1173
+ this._zone.rawValue?.widget.updateInfo(`$(error) ${response.result.errorDetails.message}`);
1174
+ alert(response.result.errorDetails.message);
1175
+ }
1176
+ this._zone.rawValue?.widget.domNode.classList.toggle('request-in-progress', false);
1177
+ this._zone.rawValue?.widget.chatWidget.setInputPlaceholder(defaultPlaceholderObs.read(r));
1178
+ }
1179
+ else {
1180
+ this._zone.rawValue?.widget.domNode.classList.toggle('request-in-progress', true);
1181
+ let placeholder = response.request?.message.text;
1182
+ const lastProgress = lastResponseProgressObs.read(r);
1183
+ if (lastProgress) {
1184
+ placeholder = renderAsPlaintext(lastProgress.content);
1185
+ }
1186
+ this._zone.rawValue?.widget.chatWidget.setInputPlaceholder(placeholder || ( localize(8309, "Working...")));
1187
+ }
1188
+ }));
1189
+ this._store.add(autorun(r => {
1190
+ const session = visibleSessionObs.read(r);
1191
+ if (!session) {
1192
+ return;
1193
+ }
1194
+ const entry = session.editingSession.readEntry(session.uri, r);
1195
+ if (entry?.state.read(r) === ModifiedFileEntryState.Modified) {
1196
+ entry?.enableReviewModeUntilSettled();
1197
+ }
1198
+ }));
1199
+ this._store.add(autorun(r => {
1200
+ const session = visibleSessionObs.read(r);
1201
+ const entry = session?.editingSession.readEntry(session.uri, r);
1202
+ const pane = this._editorService.visibleEditorPanes.find(candidate => candidate.getControl() === this._editor || isNotebookContainingCellEditor(candidate, this._editor));
1203
+ if (pane && entry) {
1204
+ entry?.getEditorIntegration(pane);
1205
+ }
1206
+ if (entry?.diffInfo && this._zone.value.position) {
1207
+ const { position } = this._zone.value;
1208
+ const diff = entry.diffInfo.read(r);
1209
+ for (const change of diff.changes) {
1210
+ if (change.modified.contains(position.lineNumber)) {
1211
+ this._zone.value.updatePositionAndHeight(( new Position(change.modified.startLineNumber - 1, 1)));
1212
+ break;
1213
+ }
1214
+ }
1215
+ }
1216
+ }));
1217
+ }
1218
+ dispose() {
1219
+ this._store.dispose();
1220
+ }
1221
+ getWidgetPosition() {
1222
+ return this._zone.rawValue?.position;
1223
+ }
1224
+ focus() {
1225
+ this._zone.rawValue?.widget.focus();
1226
+ }
1227
+ async run(arg) {
1228
+ assertType(this._editor.hasModel());
1229
+ const uri = this._editor.getModel().uri;
1230
+ const existingSession = this._inlineChatSessionService.getSession2(uri);
1231
+ if (existingSession) {
1232
+ await existingSession.editingSession.accept();
1233
+ existingSession.dispose();
1234
+ }
1235
+ this._isActiveController.set(true, undefined);
1236
+ const session = await this._inlineChatSessionService.createSession2(this._editor, uri, CancellationToken.None);
1237
+ const entries = [];
1238
+ for (const [range, marker] of this._markerDecorationsService.getLiveMarkers(uri)) {
1239
+ if (range.intersectRanges(this._editor.getSelection())) {
1240
+ const filter = IDiagnosticVariableEntryFilterData.fromMarker(marker);
1241
+ entries.push(IDiagnosticVariableEntryFilterData.toEntry(filter));
1242
+ }
1243
+ }
1244
+ if (entries.length > 0) {
1245
+ this._zone.value.widget.chatWidget.attachmentModel.addContext(...entries);
1246
+ this._zone.value.widget.chatWidget.input.setValue(entries.length > 1
1247
+ ? ( localize(8310, "Fix the attached problems"))
1248
+ : ( localize(8311, "Fix the attached problem")), true);
1249
+ this._zone.value.widget.chatWidget.inputEditor.setSelection(( new Selection(1, 1, Number.MAX_SAFE_INTEGER, 1)));
1250
+ }
1251
+ if (arg && InlineChatRunOptions.isInlineChatRunOptions(arg)) {
1252
+ if (arg.initialRange) {
1253
+ this._editor.revealRange(arg.initialRange);
1254
+ }
1255
+ if (arg.initialSelection) {
1256
+ this._editor.setSelection(arg.initialSelection);
1257
+ }
1258
+ if (arg.attachments) {
1259
+ await Promise.all(( arg.attachments.map(async (attachment) => {
1260
+ await this._zone.value.widget.chatWidget.attachmentModel.addFile(attachment);
1261
+ })));
1262
+ delete arg.attachments;
1263
+ }
1264
+ if (arg.modelSelector) {
1265
+ const id = (await this._languageModelService.selectLanguageModels(arg.modelSelector, false)).sort().at(0);
1266
+ if (!id) {
1267
+ throw ( new Error(
1268
+ `No language models found matching selector: ${JSON.stringify(arg.modelSelector)}.`
1269
+ ));
1270
+ }
1271
+ const model = this._languageModelService.lookupLanguageModel(id);
1272
+ if (!model) {
1273
+ throw ( new Error(`Language model not loaded: ${id}.`));
1274
+ }
1275
+ this._zone.value.widget.chatWidget.input.setCurrentLanguageModel({ metadata: model, identifier: id });
1276
+ }
1277
+ if (arg.message) {
1278
+ this._zone.value.widget.chatWidget.setInput(arg.message);
1279
+ if (arg.autoSend) {
1280
+ await this._zone.value.widget.chatWidget.acceptInput();
1281
+ }
1282
+ }
1283
+ }
1284
+ await Event.toPromise(session.editingSession.onDidDispose);
1285
+ const rejected = session.editingSession.getEntry(uri)?.state.get() === ModifiedFileEntryState.Rejected;
1286
+ return !rejected;
1287
+ }
1288
+ async acceptSession() {
1289
+ const session = this._currentSession.get();
1290
+ if (!session) {
1291
+ return;
1292
+ }
1293
+ await session.editingSession.accept();
1294
+ session.dispose();
1295
+ }
1296
+ async rejectSession() {
1297
+ const session = this._currentSession.get();
1298
+ if (!session) {
1299
+ return;
1300
+ }
1301
+ await session.editingSession.reject();
1302
+ session.dispose();
1303
+ }
1304
+ async createImageAttachment(attachment) {
1305
+ const value = this._currentSession.get();
1306
+ if (!value) {
1307
+ return undefined;
1308
+ }
1309
+ if (attachment.scheme === Schemas.file) {
1310
+ if (await this._fileService.canHandleResource(attachment)) {
1311
+ return await this._chatAttachmentResolveService.resolveImageEditorAttachContext(attachment);
1312
+ }
1313
+ }
1314
+ else if (attachment.scheme === Schemas.http || attachment.scheme === Schemas.https) {
1315
+ const extractedImages = await this._webContentExtractorService.readImage(attachment, CancellationToken.None);
1316
+ if (extractedImages) {
1317
+ return await this._chatAttachmentResolveService.resolveImageEditorAttachContext(attachment, extractedImages);
1318
+ }
1319
+ }
1320
+ return undefined;
1321
+ }
1322
+ };
1323
+ InlineChatController2 = InlineChatController2_1 = ( __decorate([
1324
+ ( __param(1, IInstantiationService)),
1325
+ ( __param(2, INotebookEditorService)),
1326
+ ( __param(3, IInlineChatSessionService)),
1327
+ ( __param(4, ICodeEditorService)),
1328
+ ( __param(5, IContextKeyService)),
1329
+ ( __param(6, ISharedWebContentExtractorService)),
1330
+ ( __param(7, IFileService)),
1331
+ ( __param(8, IChatAttachmentResolveService)),
1332
+ ( __param(9, IEditorService)),
1333
+ ( __param(10, IMarkerDecorationsService)),
1334
+ ( __param(11, ILanguageModelsService)),
1335
+ ( __param(12, IChatService))
1336
+ ], InlineChatController2));
1337
+ async function reviewEdits(accessor, editor, stream, token, applyCodeBlockSuggestionId) {
1338
+ if (!editor.hasModel()) {
1339
+ return false;
1340
+ }
1341
+ const chatService = accessor.get(IChatService);
1342
+ const uri = editor.getModel().uri;
1343
+ const chatModelRef = chatService.startSession(ChatAgentLocation.EditorInline);
1344
+ const chatModel = chatModelRef.object;
1345
+ chatModel.startEditingSession(true);
1346
+ const store = ( new DisposableStore());
1347
+ store.add(chatModelRef);
1348
+ const chatRequest = chatModel?.addRequest({ text: '', parts: [] }, { variables: [] }, 0, {
1349
+ kind: undefined,
1350
+ modeId: 'applyCodeBlock',
1351
+ modeInstructions: undefined,
1352
+ isBuiltin: true,
1353
+ applyCodeBlockSuggestionId,
1354
+ });
1355
+ assertType(chatRequest.response);
1356
+ chatRequest.response.updateContent({ kind: 'textEdit', uri, edits: [], done: false });
1357
+ for await (const chunk of stream) {
1358
+ if (token.isCancellationRequested) {
1359
+ chatRequest.response.cancel();
1360
+ break;
1361
+ }
1362
+ chatRequest.response.updateContent({ kind: 'textEdit', uri, edits: chunk, done: false });
1363
+ }
1364
+ chatRequest.response.updateContent({ kind: 'textEdit', uri, edits: [], done: true });
1365
+ if (!token.isCancellationRequested) {
1366
+ chatRequest.response.complete();
1367
+ }
1368
+ const isSettled = derived(r => {
1369
+ const entry = chatModel.editingSession?.readEntry(uri, r);
1370
+ if (!entry) {
1371
+ return false;
1372
+ }
1373
+ const state = entry.state.read(r);
1374
+ return state === ModifiedFileEntryState.Accepted || state === ModifiedFileEntryState.Rejected;
1375
+ });
1376
+ const whenDecided = waitForState(isSettled, Boolean);
1377
+ await raceCancellation(whenDecided, token);
1378
+ store.dispose();
1379
+ return true;
1380
+ }
1381
+ async function reviewNotebookEdits(accessor, uri, stream, token) {
1382
+ const chatService = accessor.get(IChatService);
1383
+ const notebookService = accessor.get(INotebookService);
1384
+ const isNotebook = notebookService.hasSupportedNotebooks(uri);
1385
+ const chatModelRef = chatService.startSession(ChatAgentLocation.EditorInline);
1386
+ const chatModel = chatModelRef.object;
1387
+ chatModel.startEditingSession(true);
1388
+ const store = ( new DisposableStore());
1389
+ store.add(chatModelRef);
1390
+ const chatRequest = chatModel?.addRequest({ text: '', parts: [] }, { variables: [] }, 0);
1391
+ assertType(chatRequest.response);
1392
+ if (isNotebook) {
1393
+ chatRequest.response.updateContent({ kind: 'notebookEdit', uri, edits: [], done: false });
1394
+ }
1395
+ else {
1396
+ chatRequest.response.updateContent({ kind: 'textEdit', uri, edits: [], done: false });
1397
+ }
1398
+ for await (const chunk of stream) {
1399
+ if (token.isCancellationRequested) {
1400
+ chatRequest.response.cancel();
1401
+ break;
1402
+ }
1403
+ if (chunk.every(isCellEditOperation)) {
1404
+ chatRequest.response.updateContent({ kind: 'notebookEdit', uri, edits: chunk, done: false });
1405
+ }
1406
+ else {
1407
+ chatRequest.response.updateContent({ kind: 'textEdit', uri: chunk[0], edits: chunk[1], done: false });
1408
+ }
1409
+ }
1410
+ if (isNotebook) {
1411
+ chatRequest.response.updateContent({ kind: 'notebookEdit', uri, edits: [], done: true });
1412
+ }
1413
+ else {
1414
+ chatRequest.response.updateContent({ kind: 'textEdit', uri, edits: [], done: true });
1415
+ }
1416
+ if (!token.isCancellationRequested) {
1417
+ chatRequest.response.complete();
1418
+ }
1419
+ const isSettled = derived(r => {
1420
+ const entry = chatModel.editingSession?.readEntry(uri, r);
1421
+ if (!entry) {
1422
+ return false;
1423
+ }
1424
+ const state = entry.state.read(r);
1425
+ return state === ModifiedFileEntryState.Accepted || state === ModifiedFileEntryState.Rejected;
1426
+ });
1427
+ const whenDecided = waitForState(isSettled, Boolean);
1428
+ await raceCancellation(whenDecided, token);
1429
+ store.dispose();
1430
+ return true;
1431
+ }
1432
+ function isCellEditOperation(edit) {
1433
+ if (URI.isUri(edit)) {
1434
+ return false;
1435
+ }
1436
+ if (Array.isArray(edit)) {
1437
+ return false;
1438
+ }
1439
+ return true;
1440
+ }
1441
+
1442
+ export { InlineChatController, InlineChatController1, InlineChatController2, InlineChatRunOptions, State, reviewEdits, reviewNotebookEdits };