@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,2014 @@
1
+
2
+ import { registerCss } from '@codingame/monaco-vscode-api/css';
3
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
+ import * as chat from './media/chat.css';
5
+ import * as chatAgentHover from './media/chatAgentHover.css';
6
+ import * as chatViewWelcome from './media/chatViewWelcome.css';
7
+ import { $ as $$1, findParentWithClass, getTopLeftOffset, append, addStandardDisposableListener, EventType, setVisibility, clearNode, scheduleAtNextAnimationFrame, getWindow, createElement, Dimension } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
8
+ import { Button } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/button/button';
9
+ import { timeout, disposableTimeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
10
+ import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
11
+ import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
12
+ import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
13
+ import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
14
+ import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
15
+ import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
16
+ import { Disposable, MutableDisposable, DisposableStore, thenIfNotDisposed } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
17
+ import { ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
18
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
19
+ import { filter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
20
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
21
+ import { isEqual, extUri, basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
22
+ import { MicrotaskDelay } from '@codingame/monaco-vscode-api/vscode/vs/base/common/symbols';
23
+ import { isDefined } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
24
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
25
+ import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service';
26
+ import { OffsetRange } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/ranges/offsetRange';
27
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
28
+ import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
29
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
30
+ import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
31
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
32
+ import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
33
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
34
+ import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
35
+ import { WorkbenchObjectTree } from '@codingame/monaco-vscode-api/vscode/vs/platform/list/browser/listService';
36
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
37
+ import { bindContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
38
+ import product from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/product';
39
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
40
+ import { asCssVariable } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
41
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
42
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
43
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
44
+ import { buttonSecondaryHoverBackground, buttonSecondaryForeground, buttonSecondaryBackground } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
45
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
46
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
47
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
48
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
49
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
50
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
51
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
52
+ import { WorkbenchState } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace';
53
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
54
+ import { EditorResourceAccessor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
55
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
56
+ import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
57
+ import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
58
+ import { katexContainerClassName } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/markdown/common/markedKatexExtension';
59
+ import { checkModeOption } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chat';
60
+ import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
61
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
62
+ import { decidedChatEditingResourceContextKey, ModifiedFileEntryState, hasUndecidedChatEditingResourceContextKey, hasAppliedChatEditsContextKey, inChatEditingSessionContextKey, applyingChatEditsFailedContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
63
+ import { IChatEditingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService.service';
64
+ import { IChatLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatLayoutService.service';
65
+ import { ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes';
66
+ import { IChatModeService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes.service';
67
+ import { ChatRequestToolPart, ChatRequestToolSetPart, ChatRequestDynamicVariablePart, chatAgentLeader, chatSubcommandLeader, ChatRequestSlashPromptPart, formatChatQuestion, ChatRequestAgentPart } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
68
+ import { ChatRequestParser } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatRequestParser';
69
+ import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
70
+ import { IChatSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService.service';
71
+ import { IChatSlashCommandService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSlashCommands.service';
72
+ import { IChatTodoListService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatTodoListService.service';
73
+ import { isWorkspaceVariableEntry, isPromptFileVariableEntry, isPromptTextVariableEntry, toPromptFileVariableEntry, PromptFileVariableKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariableEntries';
74
+ import { isResponseVM, isRequestVM, ChatViewModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatViewModel';
75
+ import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js';
76
+ import { ChatConfiguration, ChatModeKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
77
+ import { ToolSet } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService';
78
+ import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
79
+ import { ComputeAutomaticInstructions } from '../common/promptSyntax/computeAutomaticInstructions.js';
80
+ import { PromptsConfig } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/config/config';
81
+ import { Target } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/promptFileParser';
82
+ import { IPromptsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.service';
83
+ import { handleModeSwitch } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
84
+ import { isIChatResourceViewContext, isIChatViewViewContext } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat';
85
+ import { IChatWidgetService, IChatAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
86
+ import { ChatAccessibilityProvider } from './chatAccessibilityProvider.js';
87
+ import { ChatSuggestNextWidget } from './chatContentParts/chatSuggestNextWidget.js';
88
+ import { ChatInputPart } from './chatInputPart.js';
89
+ import { ChatListDelegate, ChatListItemRenderer } from './chatListRenderer.js';
90
+ import { ChatEditorOptions } from './chatOptions.js';
91
+ import { ChatViewWelcomePart } from './viewsWelcome/chatViewWelcomeController.js';
92
+ import { IAgentSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.service';
93
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
94
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
95
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
96
+
97
+ var ChatWidget_1;
98
+ registerCss(chat);
99
+ registerCss(chatAgentHover);
100
+ registerCss(chatViewWelcome);
101
+ const $ = $$1;
102
+ function isQuickChat(widget) {
103
+ return isIChatResourceViewContext(widget.viewContext) && Boolean(widget.viewContext.isQuickChat);
104
+ }
105
+ function isInlineChat(widget) {
106
+ return isIChatResourceViewContext(widget.viewContext) && Boolean(widget.viewContext.isInlineChat);
107
+ }
108
+ const supportsAllAttachments = {
109
+ supportsFileAttachments: true,
110
+ supportsToolAttachments: true,
111
+ supportsMCPAttachments: true,
112
+ supportsImageAttachments: true,
113
+ supportsSearchResultAttachments: true,
114
+ supportsInstructionAttachments: true,
115
+ supportsSourceControlAttachments: true,
116
+ supportsProblemAttachments: true,
117
+ supportsSymbolAttachments: true,
118
+ supportsTerminalAttachments: true,
119
+ };
120
+ const DISCLAIMER = ( localize(5653, "AI responses may be inaccurate."));
121
+ let ChatWidget = class ChatWidget extends Disposable {
122
+ static { ChatWidget_1 = this; }
123
+ static { this.CONTRIBS = []; }
124
+ get domNode() { return this.container; }
125
+ get visible() { return this._visible; }
126
+ set viewModel(viewModel) {
127
+ if (this._viewModel === viewModel) {
128
+ return;
129
+ }
130
+ this.viewModelDisposables.clear();
131
+ this._viewModel = viewModel;
132
+ if (viewModel) {
133
+ this.viewModelDisposables.add(viewModel);
134
+ this.logService.debug('ChatWidget#setViewModel: have viewModel');
135
+ }
136
+ else {
137
+ this.logService.debug('ChatWidget#setViewModel: no viewModel');
138
+ }
139
+ this._onDidChangeViewModel.fire();
140
+ }
141
+ get viewModel() {
142
+ return this._viewModel;
143
+ }
144
+ get parsedInput() {
145
+ if (this.parsedChatRequest === undefined) {
146
+ if (!this.viewModel) {
147
+ return { text: '', parts: [] };
148
+ }
149
+ this.parsedChatRequest = this.instantiationService.createInstance(ChatRequestParser)
150
+ .parseChatRequest(this.viewModel.sessionResource, this.getInput(), this.location, {
151
+ selectedAgent: this._lastSelectedAgent,
152
+ mode: this.input.currentModeKind,
153
+ forcedAgent: this._lockedAgent?.id ? this.chatAgentService.getAgent(this._lockedAgent.id) : undefined
154
+ });
155
+ this._onDidChangeParsedInput.fire();
156
+ }
157
+ return this.parsedChatRequest;
158
+ }
159
+ get scopedContextKeyService() {
160
+ return this.contextKeyService;
161
+ }
162
+ get location() {
163
+ return this._location.location;
164
+ }
165
+ get supportsChangingModes() {
166
+ return !!this.viewOptions.supportsChangingModes;
167
+ }
168
+ get locationData() {
169
+ return this._location.resolveData?.();
170
+ }
171
+ constructor(location, viewContext, viewOptions, styles, codeEditorService, editorService, configurationService, contextKeyService, instantiationService, chatService, chatAgentService, chatWidgetService, contextMenuService, chatAccessibilityService, logService, themeService, chatSlashCommandService, chatEditingService, telemetryService, promptsService, toolsService, chatModeService, chatLayoutService, chatEntitlementService, chatSessionsService, agentSessionsService, chatTodoListService, contextService, lifecycleService) {
172
+ super();
173
+ this.viewOptions = viewOptions;
174
+ this.styles = styles;
175
+ this.codeEditorService = codeEditorService;
176
+ this.editorService = editorService;
177
+ this.configurationService = configurationService;
178
+ this.contextKeyService = contextKeyService;
179
+ this.instantiationService = instantiationService;
180
+ this.chatService = chatService;
181
+ this.chatAgentService = chatAgentService;
182
+ this.chatWidgetService = chatWidgetService;
183
+ this.contextMenuService = contextMenuService;
184
+ this.chatAccessibilityService = chatAccessibilityService;
185
+ this.logService = logService;
186
+ this.themeService = themeService;
187
+ this.chatSlashCommandService = chatSlashCommandService;
188
+ this.telemetryService = telemetryService;
189
+ this.promptsService = promptsService;
190
+ this.toolsService = toolsService;
191
+ this.chatModeService = chatModeService;
192
+ this.chatLayoutService = chatLayoutService;
193
+ this.chatEntitlementService = chatEntitlementService;
194
+ this.chatSessionsService = chatSessionsService;
195
+ this.agentSessionsService = agentSessionsService;
196
+ this.chatTodoListService = chatTodoListService;
197
+ this.contextService = contextService;
198
+ this.lifecycleService = lifecycleService;
199
+ this._onDidSubmitAgent = this._register(( new Emitter()));
200
+ this.onDidSubmitAgent = this._onDidSubmitAgent.event;
201
+ this._onDidChangeAgent = this._register(( new Emitter()));
202
+ this.onDidChangeAgent = this._onDidChangeAgent.event;
203
+ this._onDidFocus = this._register(( new Emitter()));
204
+ this.onDidFocus = this._onDidFocus.event;
205
+ this._onDidChangeViewModel = this._register(( new Emitter()));
206
+ this.onDidChangeViewModel = this._onDidChangeViewModel.event;
207
+ this._onDidScroll = this._register(( new Emitter()));
208
+ this.onDidScroll = this._onDidScroll.event;
209
+ this._onDidAcceptInput = this._register(( new Emitter()));
210
+ this.onDidAcceptInput = this._onDidAcceptInput.event;
211
+ this._onDidHide = this._register(( new Emitter()));
212
+ this.onDidHide = this._onDidHide.event;
213
+ this._onDidShow = this._register(( new Emitter()));
214
+ this.onDidShow = this._onDidShow.event;
215
+ this._onDidChangeParsedInput = this._register(( new Emitter()));
216
+ this.onDidChangeParsedInput = this._onDidChangeParsedInput.event;
217
+ this._onWillMaybeChangeHeight = ( new Emitter());
218
+ this.onWillMaybeChangeHeight = this._onWillMaybeChangeHeight.event;
219
+ this._onDidChangeHeight = this._register(( new Emitter()));
220
+ this.onDidChangeHeight = this._onDidChangeHeight.event;
221
+ this._onDidChangeContentHeight = ( new Emitter());
222
+ this.onDidChangeContentHeight = this._onDidChangeContentHeight.event;
223
+ this._onDidChangeEmptyState = this._register(( new Emitter()));
224
+ this.onDidChangeEmptyState = this._onDidChangeEmptyState.event;
225
+ this.contribs = [];
226
+ this.visibilityTimeoutDisposable = this._register(( new MutableDisposable()));
227
+ this.inputPartDisposable = this._register(( new MutableDisposable()));
228
+ this.inlineInputPartDisposable = this._register(( new MutableDisposable()));
229
+ this.recentlyRestoredCheckpoint = false;
230
+ this.settingChangeCounter = 0;
231
+ this.welcomePart = this._register(( new MutableDisposable()));
232
+ this.visibleChangeCount = 0;
233
+ this._visible = false;
234
+ this.previousTreeScrollHeight = 0;
235
+ this.scrollLock = true;
236
+ this._isRenderingWelcome = false;
237
+ this._attachmentCapabilities = supportsAllAttachments;
238
+ this.promptDescriptionsCache = ( new Map());
239
+ this.promptUriCache = ( new Map());
240
+ this._isLoadingPromptDescriptions = false;
241
+ this._mostRecentlyFocusedItemIndex = -1;
242
+ this.viewModelDisposables = this._register(( new DisposableStore()));
243
+ this._editingSession = observableValue(this, undefined);
244
+ this._lockedToCodingAgentContextKey = ChatContextKeys.lockedToCodingAgent.bindTo(this.contextKeyService);
245
+ this._agentSupportsAttachmentsContextKey = ChatContextKeys.agentSupportsAttachments.bindTo(this.contextKeyService);
246
+ this._sessionIsEmptyContextKey = ChatContextKeys.chatSessionIsEmpty.bindTo(this.contextKeyService);
247
+ this.viewContext = viewContext ?? {};
248
+ const viewModelObs = observableFromEvent(this, this.onDidChangeViewModel, () => this.viewModel);
249
+ if (typeof location === 'object') {
250
+ this._location = location;
251
+ }
252
+ else {
253
+ this._location = { location };
254
+ }
255
+ ChatContextKeys.inChatSession.bindTo(contextKeyService).set(true);
256
+ ChatContextKeys.location.bindTo(contextKeyService).set(this._location.location);
257
+ ChatContextKeys.inQuickChat.bindTo(contextKeyService).set(isQuickChat(this));
258
+ this.agentInInput = ChatContextKeys.inputHasAgent.bindTo(contextKeyService);
259
+ this.requestInProgress = ChatContextKeys.requestInProgress.bindTo(contextKeyService);
260
+ this._register(this.chatEntitlementService.onDidChangeAnonymous(() => this.renderWelcomeViewContentIfNeeded()));
261
+ this._register(bindContextKey(decidedChatEditingResourceContextKey, contextKeyService, (reader) => {
262
+ const currentSession = this._editingSession.read(reader);
263
+ if (!currentSession) {
264
+ return;
265
+ }
266
+ const entries = currentSession.entries.read(reader);
267
+ const decidedEntries = entries.filter(entry => entry.state.read(reader) !== ModifiedFileEntryState.Modified);
268
+ return ( decidedEntries.map(entry => entry.entryId));
269
+ }));
270
+ this._register(bindContextKey(hasUndecidedChatEditingResourceContextKey, contextKeyService, (reader) => {
271
+ const currentSession = this._editingSession.read(reader);
272
+ const entries = currentSession?.entries.read(reader) ?? [];
273
+ const decidedEntries = entries.filter(entry => entry.state.read(reader) === ModifiedFileEntryState.Modified);
274
+ return decidedEntries.length > 0;
275
+ }));
276
+ this._register(bindContextKey(hasAppliedChatEditsContextKey, contextKeyService, (reader) => {
277
+ const currentSession = this._editingSession.read(reader);
278
+ if (!currentSession) {
279
+ return false;
280
+ }
281
+ const entries = currentSession.entries.read(reader);
282
+ return entries.length > 0;
283
+ }));
284
+ this._register(bindContextKey(inChatEditingSessionContextKey, contextKeyService, (reader) => {
285
+ return this._editingSession.read(reader) !== null;
286
+ }));
287
+ this._register(bindContextKey(ChatContextKeys.chatEditingCanUndo, contextKeyService, (r) => {
288
+ return this._editingSession.read(r)?.canUndo.read(r) || false;
289
+ }));
290
+ this._register(bindContextKey(ChatContextKeys.chatEditingCanRedo, contextKeyService, (r) => {
291
+ return this._editingSession.read(r)?.canRedo.read(r) || false;
292
+ }));
293
+ this._register(bindContextKey(applyingChatEditsFailedContextKey, contextKeyService, (r) => {
294
+ const chatModel = viewModelObs.read(r)?.model;
295
+ const editingSession = this._editingSession.read(r);
296
+ if (!editingSession || !chatModel) {
297
+ return false;
298
+ }
299
+ const lastResponse = observableFromEvent(this, chatModel.onDidChange, () => chatModel.getRequests().at(-1)?.response).read(r);
300
+ return lastResponse?.result?.errorDetails && !lastResponse?.result?.errorDetails.responseIsIncomplete;
301
+ }));
302
+ this._codeBlockModelCollection = this._register(instantiationService.createInstance(CodeBlockModelCollection, undefined));
303
+ this.chatSuggestNextWidget = this._register(this.instantiationService.createInstance(ChatSuggestNextWidget));
304
+ this._register(this.configurationService.onDidChangeConfiguration((e) => {
305
+ if (e.affectsConfiguration('chat.renderRelatedFiles')) {
306
+ this.input.renderChatRelatedFiles();
307
+ }
308
+ if (e.affectsConfiguration(ChatConfiguration.EditRequests) || e.affectsConfiguration(ChatConfiguration.CheckpointsEnabled)) {
309
+ this.settingChangeCounter++;
310
+ this.onDidChangeItems();
311
+ }
312
+ }));
313
+ this._register(autorun(r => {
314
+ const viewModel = viewModelObs.read(r);
315
+ const sessions = chatEditingService.editingSessionsObs.read(r);
316
+ const session = sessions.find(candidate => isEqual(candidate.chatSessionResource, viewModel?.sessionResource));
317
+ this._editingSession.set(undefined, undefined);
318
+ this.renderChatEditingSessionState();
319
+ if (!session) {
320
+ return;
321
+ }
322
+ const entries = session.entries.read(r);
323
+ for (const entry of entries) {
324
+ entry.state.read(r);
325
+ }
326
+ this._editingSession.set(session, undefined);
327
+ r.store.add(session.onDidDispose(() => {
328
+ this._editingSession.set(undefined, undefined);
329
+ this.renderChatEditingSessionState();
330
+ }));
331
+ r.store.add(this.onDidChangeParsedInput(() => {
332
+ this.renderChatEditingSessionState();
333
+ }));
334
+ r.store.add(this.inputEditor.onDidChangeModelContent(() => {
335
+ if (this.getInput() === '') {
336
+ this.refreshParsedInput();
337
+ this.renderChatEditingSessionState();
338
+ }
339
+ }));
340
+ this.renderChatEditingSessionState();
341
+ }));
342
+ this._register(codeEditorService.registerCodeEditorOpenHandler(async (input, _source, _sideBySide) => {
343
+ const resource = input.resource;
344
+ if (resource.scheme !== Schemas.vscodeChatCodeBlock) {
345
+ return null;
346
+ }
347
+ const responseId = resource.path.split('/').at(1);
348
+ if (!responseId) {
349
+ return null;
350
+ }
351
+ const item = this.viewModel?.getItems().find(item => item.id === responseId);
352
+ if (!item) {
353
+ return null;
354
+ }
355
+ this.reveal(item);
356
+ await timeout(0);
357
+ for (const codeBlockPart of this.renderer.editorsInUse()) {
358
+ if (extUri.isEqual(codeBlockPart.uri, resource, true)) {
359
+ const editor = codeBlockPart.editor;
360
+ let relativeTop = 0;
361
+ const editorDomNode = editor.getDomNode();
362
+ if (editorDomNode) {
363
+ const row = findParentWithClass(editorDomNode, 'monaco-list-row');
364
+ if (row) {
365
+ relativeTop = getTopLeftOffset(editorDomNode).top - getTopLeftOffset(row).top;
366
+ }
367
+ }
368
+ if (input.options?.selection) {
369
+ const editorSelectionTopOffset = editor.getTopForPosition(input.options.selection.startLineNumber, input.options.selection.startColumn);
370
+ relativeTop += editorSelectionTopOffset;
371
+ editor.focus();
372
+ editor.setSelection({
373
+ startLineNumber: input.options.selection.startLineNumber,
374
+ startColumn: input.options.selection.startColumn,
375
+ endLineNumber: input.options.selection.endLineNumber ?? input.options.selection.startLineNumber,
376
+ endColumn: input.options.selection.endColumn ?? input.options.selection.startColumn
377
+ });
378
+ }
379
+ this.reveal(item, relativeTop);
380
+ return editor;
381
+ }
382
+ }
383
+ return null;
384
+ }));
385
+ this._register(this.onDidChangeParsedInput(() => this.updateChatInputContext()));
386
+ this._register(this.chatTodoListService.onDidUpdateTodos((sessionResource) => {
387
+ if (isEqual(this.viewModel?.sessionResource, sessionResource)) {
388
+ this.inputPart.renderChatTodoListWidget(sessionResource);
389
+ }
390
+ }));
391
+ }
392
+ set lastSelectedAgent(agent) {
393
+ this.parsedChatRequest = undefined;
394
+ this._lastSelectedAgent = agent;
395
+ this._updateAgentCapabilitiesContextKeys(agent);
396
+ this._onDidChangeParsedInput.fire();
397
+ }
398
+ get lastSelectedAgent() {
399
+ return this._lastSelectedAgent;
400
+ }
401
+ _updateAgentCapabilitiesContextKeys(agent) {
402
+ const capabilities = agent?.capabilities ?? (this._lockedAgent ? this.chatSessionsService.getCapabilitiesForSessionType(this._lockedAgent.id) : undefined);
403
+ this._attachmentCapabilities = capabilities ?? supportsAllAttachments;
404
+ const supportsAttachments = ( Object.keys(filter(this._attachmentCapabilities, (key, value) => value === true))).length > 0;
405
+ this._agentSupportsAttachmentsContextKey.set(supportsAttachments);
406
+ }
407
+ get supportsFileReferences() {
408
+ return !!this.viewOptions.supportsFileReferences;
409
+ }
410
+ get attachmentCapabilities() {
411
+ return this._attachmentCapabilities;
412
+ }
413
+ get input() {
414
+ return this.viewModel?.editing && this.configurationService.getValue('chat.editRequests') !== 'input' ? this.inlineInputPart : this.inputPart;
415
+ }
416
+ get inputPart() {
417
+ return this.inputPartDisposable.value;
418
+ }
419
+ get inlineInputPart() {
420
+ return this.inlineInputPartDisposable.value;
421
+ }
422
+ get inputEditor() {
423
+ return this.input.inputEditor;
424
+ }
425
+ get contentHeight() {
426
+ return this.input.contentHeight + this.tree.contentHeight + this.chatSuggestNextWidget.height;
427
+ }
428
+ get attachmentModel() {
429
+ return this.input.attachmentModel;
430
+ }
431
+ render(parent) {
432
+ const viewId = isIChatViewViewContext(this.viewContext) ? this.viewContext.viewId : undefined;
433
+ this.editorOptions = this._register(this.instantiationService.createInstance(ChatEditorOptions, viewId, this.styles.listForeground, this.styles.inputEditorBackground, this.styles.resultEditorBackground));
434
+ const renderInputOnTop = this.viewOptions.renderInputOnTop ?? false;
435
+ const renderFollowups = this.viewOptions.renderFollowups ?? !renderInputOnTop;
436
+ const renderStyle = this.viewOptions.renderStyle;
437
+ const renderInputToolbarBelowInput = this.viewOptions.renderInputToolbarBelowInput ?? false;
438
+ this.container = append(parent, $('.interactive-session'));
439
+ this.welcomeMessageContainer = append(this.container, $('.chat-welcome-view-container', { style: 'display: none' }));
440
+ this._register(addStandardDisposableListener(this.welcomeMessageContainer, EventType.CLICK, () => this.focusInput()));
441
+ this._register(this.chatSuggestNextWidget.onDidChangeHeight(() => {
442
+ if (this.bodyDimension) {
443
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
444
+ }
445
+ }));
446
+ this._register(this.chatSuggestNextWidget.onDidSelectPrompt(({ handoff, agentId }) => {
447
+ this.handleNextPromptSelection(handoff, agentId);
448
+ }));
449
+ if (renderInputOnTop) {
450
+ this.createInput(this.container, { renderFollowups, renderStyle, renderInputToolbarBelowInput });
451
+ this.listContainer = append(this.container, $(`.interactive-list`));
452
+ }
453
+ else {
454
+ this.listContainer = append(this.container, $(`.interactive-list`));
455
+ append(this.container, this.chatSuggestNextWidget.domNode);
456
+ this.createInput(this.container, { renderFollowups, renderStyle, renderInputToolbarBelowInput });
457
+ }
458
+ this.renderWelcomeViewContentIfNeeded();
459
+ this.createList(this.listContainer, { editable: !isInlineChat(this) && !isQuickChat(this), ...this.viewOptions.rendererOptions, renderStyle });
460
+ const scrollDownButton = this._register(( new Button(this.listContainer, {
461
+ supportIcons: true,
462
+ buttonBackground: asCssVariable(buttonSecondaryBackground),
463
+ buttonForeground: asCssVariable(buttonSecondaryForeground),
464
+ buttonHoverBackground: asCssVariable(buttonSecondaryHoverBackground),
465
+ })));
466
+ scrollDownButton.element.classList.add('chat-scroll-down');
467
+ scrollDownButton.label = `$(${Codicon.chevronDown.id})`;
468
+ scrollDownButton.setTitle(( localize(5654, "Scroll down")));
469
+ this._register(scrollDownButton.onDidClick(() => {
470
+ this.scrollLock = true;
471
+ this.scrollToEnd();
472
+ }));
473
+ this._register(autorun(reader => {
474
+ const fontFamily = this.chatLayoutService.fontFamily.read(reader);
475
+ const fontSize = this.chatLayoutService.fontSize.read(reader);
476
+ this.container.style.setProperty('--vscode-chat-font-family', fontFamily);
477
+ this.container.style.fontSize = `${fontSize}px`;
478
+ if (this.visible) {
479
+ this.tree.rerender();
480
+ }
481
+ }));
482
+ this._register(this.editorOptions.onDidChange(() => this.onDidStyleChange()));
483
+ this.onDidStyleChange();
484
+ if (this.viewModel) {
485
+ this.onDidChangeItems();
486
+ this.scrollToEnd();
487
+ }
488
+ this.contribs = ( ChatWidget_1.CONTRIBS.map(contrib => {
489
+ try {
490
+ return this._register(this.instantiationService.createInstance(contrib, this));
491
+ }
492
+ catch (err) {
493
+ this.logService.error('Failed to instantiate chat widget contrib', toErrorMessage(err));
494
+ return undefined;
495
+ }
496
+ })).filter(isDefined);
497
+ this._register(this.chatWidgetService.register(this));
498
+ const parsedInput = observableFromEvent(this.onDidChangeParsedInput, () => this.parsedInput);
499
+ this._register(autorun(r => {
500
+ const input = parsedInput.read(r);
501
+ const newPromptAttachments = ( new Map());
502
+ const oldPromptAttachments = ( new Set());
503
+ for (const attachment of this.attachmentModel.attachments) {
504
+ if (attachment.range) {
505
+ oldPromptAttachments.add(attachment.id);
506
+ }
507
+ }
508
+ for (const part of input.parts) {
509
+ if (part instanceof ChatRequestToolPart || part instanceof ChatRequestToolSetPart || part instanceof ChatRequestDynamicVariablePart) {
510
+ const entry = part.toVariableEntry();
511
+ newPromptAttachments.set(entry.id, entry);
512
+ oldPromptAttachments.delete(entry.id);
513
+ }
514
+ }
515
+ this.attachmentModel.updateContext(oldPromptAttachments, ( newPromptAttachments.values()));
516
+ }));
517
+ if (!this.focusedInputDOM) {
518
+ this.focusedInputDOM = this.container.appendChild($$1('.focused-input-dom'));
519
+ }
520
+ }
521
+ scrollToEnd() {
522
+ if (this.lastItem) {
523
+ const offset = Math.max(this.lastItem.currentRenderedHeight ?? 0, 1e6);
524
+ if (this.tree.hasElement(this.lastItem)) {
525
+ this.tree.reveal(this.lastItem, offset);
526
+ }
527
+ }
528
+ }
529
+ focusInput() {
530
+ this.input.focus();
531
+ this._onDidFocus.fire();
532
+ }
533
+ hasInputFocus() {
534
+ return this.input.hasFocus();
535
+ }
536
+ refreshParsedInput() {
537
+ if (!this.viewModel) {
538
+ return;
539
+ }
540
+ this.parsedChatRequest = this.instantiationService.createInstance(ChatRequestParser).parseChatRequest(this.viewModel.sessionResource, this.getInput(), this.location, { selectedAgent: this._lastSelectedAgent, mode: this.input.currentModeKind });
541
+ this._onDidChangeParsedInput.fire();
542
+ }
543
+ getSibling(item, type) {
544
+ if (!isResponseVM(item)) {
545
+ return;
546
+ }
547
+ const items = this.viewModel?.getItems();
548
+ if (!items) {
549
+ return;
550
+ }
551
+ const responseItems = items.filter(i => isResponseVM(i));
552
+ const targetIndex = responseItems.indexOf(item);
553
+ if (targetIndex === undefined) {
554
+ return;
555
+ }
556
+ const indexToFocus = type === 'next' ? targetIndex + 1 : targetIndex - 1;
557
+ if (indexToFocus < 0 || indexToFocus > responseItems.length - 1) {
558
+ return;
559
+ }
560
+ return responseItems[indexToFocus];
561
+ }
562
+ async clear() {
563
+ this.logService.debug('ChatWidget#clear');
564
+ if (this._dynamicMessageLayoutData) {
565
+ this._dynamicMessageLayoutData.enabled = true;
566
+ }
567
+ if (this.viewModel?.editing) {
568
+ this.finishedEditing();
569
+ }
570
+ if (this.viewModel) {
571
+ this.viewModel.resetInputPlaceholder();
572
+ }
573
+ if (this._lockedAgent) {
574
+ this.lockToCodingAgent(this._lockedAgent.name, this._lockedAgent.displayName, this._lockedAgent.id);
575
+ }
576
+ else {
577
+ this.unlockFromCodingAgent();
578
+ }
579
+ this.inputPart.clearTodoListWidget(this.viewModel?.sessionResource, true);
580
+ this.chatSuggestNextWidget.hide();
581
+ await this.viewOptions.clear?.();
582
+ }
583
+ onDidChangeItems(skipDynamicLayout) {
584
+ if (this._visible || !this.viewModel) {
585
+ const treeItems = ( (this.viewModel?.getItems() ?? [])
586
+ .map((item) => {
587
+ return {
588
+ element: item,
589
+ collapsed: false,
590
+ collapsible: false
591
+ };
592
+ }));
593
+ if (treeItems.length > 0) {
594
+ this.updateChatViewVisibility();
595
+ }
596
+ else {
597
+ this.renderWelcomeViewContentIfNeeded();
598
+ }
599
+ this._onWillMaybeChangeHeight.fire();
600
+ this.lastItem = treeItems.at(-1)?.element;
601
+ ChatContextKeys.lastItemId.bindTo(this.contextKeyService).set(this.lastItem ? [this.lastItem.id] : []);
602
+ this.tree.setChildren(null, treeItems, {
603
+ diffIdentityProvider: {
604
+ getId: (element) => {
605
+ return element.dataId +
606
+ `${(isRequestVM(element)) }` +
607
+ `${isResponseVM(element) && element.renderData ? `_${this.visibleChangeCount}` : ''}` +
608
+ (isResponseVM(element) ? `_${element.contentReferences.length}` : '') +
609
+ `_${element.shouldBeRemovedOnSend ? `${element.shouldBeRemovedOnSend.afterUndoStop || '1'}` : '0'}` +
610
+ `_${element.shouldBeBlocked ? '1' : '0'}` +
611
+ `_${this.viewModel?.editing ? '1' : '0'}` +
612
+ `_${this.viewModel?.model.checkpoint ? '1' : '0'}` +
613
+ `_setting${this.settingChangeCounter || '0'}` +
614
+ (isRequestVM(element) && element.contentReferences ? `_${element.contentReferences?.length}` : '');
615
+ },
616
+ }
617
+ });
618
+ if (!skipDynamicLayout && this._dynamicMessageLayoutData) {
619
+ this.layoutDynamicChatTreeItemMode();
620
+ }
621
+ this.renderFollowups();
622
+ }
623
+ }
624
+ updateChatViewVisibility() {
625
+ if (!this.viewModel) {
626
+ return;
627
+ }
628
+ const numItems = this.viewModel.getItems().length;
629
+ setVisibility(numItems === 0, this.welcomeMessageContainer);
630
+ setVisibility(numItems !== 0, this.listContainer);
631
+ this._onDidChangeEmptyState.fire();
632
+ }
633
+ isEmpty() {
634
+ return (this.viewModel?.getItems().length ?? 0) === 0;
635
+ }
636
+ renderWelcomeViewContentIfNeeded() {
637
+ if (this._isRenderingWelcome) {
638
+ return;
639
+ }
640
+ this._isRenderingWelcome = true;
641
+ try {
642
+ if (this.viewOptions.renderStyle === 'compact' || this.viewOptions.renderStyle === 'minimal' || this.lifecycleService.willShutdown) {
643
+ return;
644
+ }
645
+ const numItems = this.viewModel?.getItems().length ?? 0;
646
+ if (!numItems) {
647
+ const defaultAgent = this.chatAgentService.getDefaultAgent(this.location, this.input.currentModeKind);
648
+ let additionalMessage;
649
+ if (this.chatEntitlementService.anonymous && !this.chatEntitlementService.sentiment.installed) {
650
+ const providers = product.defaultChatAgent.provider;
651
+ additionalMessage = ( new MarkdownString(( localize(
652
+ 5655,
653
+ "By continuing with {0} Copilot, you agree to {1}'s [Terms]({2}) and [Privacy Statement]({3}).",
654
+ providers.default.name,
655
+ providers.default.name,
656
+ product.defaultChatAgent.termsStatementUrl,
657
+ product.defaultChatAgent.privacyStatementUrl
658
+ )), { isTrusted: true }));
659
+ }
660
+ else {
661
+ additionalMessage = defaultAgent?.metadata.additionalWelcomeMessage;
662
+ }
663
+ if (!additionalMessage && !this._lockedAgent) {
664
+ additionalMessage = this._getGenerateInstructionsMessage();
665
+ }
666
+ const welcomeContent = this.getWelcomeViewContent(additionalMessage);
667
+ if (!this.welcomePart.value || this.welcomePart.value.needsRerender(welcomeContent)) {
668
+ clearNode(this.welcomeMessageContainer);
669
+ this.welcomePart.value = this.instantiationService.createInstance(ChatViewWelcomePart, welcomeContent, {
670
+ location: this.location,
671
+ isWidgetAgentWelcomeViewContent: this.input?.currentModeKind === ChatModeKind.Agent
672
+ });
673
+ append(this.welcomeMessageContainer, this.welcomePart.value.element);
674
+ }
675
+ }
676
+ this.updateChatViewVisibility();
677
+ }
678
+ finally {
679
+ this._isRenderingWelcome = false;
680
+ }
681
+ }
682
+ _getGenerateInstructionsMessage() {
683
+ if (!this._instructionFilesCheckPromise) {
684
+ this._instructionFilesCheckPromise = this._checkForAgentInstructionFiles();
685
+ this._register(thenIfNotDisposed(this._instructionFilesCheckPromise, hasFiles => {
686
+ this._instructionFilesExist = hasFiles;
687
+ const hasViewModelItems = this.viewModel?.getItems().length ?? 0;
688
+ if (hasViewModelItems === 0) {
689
+ this.renderWelcomeViewContentIfNeeded();
690
+ }
691
+ }));
692
+ }
693
+ if (this._instructionFilesExist === true) {
694
+ return ( new MarkdownString(''));
695
+ }
696
+ else if (this._instructionFilesExist === false) {
697
+ const generateInstructionsCommand = 'workbench.action.chat.generateInstructions';
698
+ return (new MarkdownString(localize(
699
+ 5656,
700
+ "[Generate Agent Instructions]({0}) to onboard AI onto your codebase.",
701
+ `command:${generateInstructionsCommand}`
702
+ ), { isTrusted: { enabledCommands: [generateInstructionsCommand] } }));
703
+ }
704
+ return ( new MarkdownString(''));
705
+ }
706
+ async _checkForAgentInstructionFiles() {
707
+ try {
708
+ const useCopilotInstructionsFiles = this.configurationService.getValue(PromptsConfig.USE_COPILOT_INSTRUCTION_FILES);
709
+ const useAgentMd = this.configurationService.getValue(PromptsConfig.USE_AGENT_MD);
710
+ if (!useCopilotInstructionsFiles && !useAgentMd) {
711
+ return true;
712
+ }
713
+ return ((await this.promptsService.listCopilotInstructionsMDs(CancellationToken.None)).length > 0 ||
714
+ (await this.promptsService.listAgentMDs(CancellationToken.None, false)).length > 0);
715
+ }
716
+ catch (error) {
717
+ this.logService.warn('[ChatWidget] Error checking for instruction files:', error);
718
+ return false;
719
+ }
720
+ }
721
+ getWelcomeViewContent(additionalMessage) {
722
+ if (this.isLockedToCodingAgent) {
723
+ const providerIcon = this._lockedAgent ? this.chatSessionsService.getIconForSessionType(this._lockedAgent.id) : undefined;
724
+ const providerTitle = this._lockedAgent ? this.chatSessionsService.getWelcomeTitleForSessionType(this._lockedAgent.id) : undefined;
725
+ const providerMessage = this._lockedAgent ? this.chatSessionsService.getWelcomeMessageForSessionType(this._lockedAgent.id) : undefined;
726
+ const message = providerMessage
727
+ ? ( new MarkdownString(providerMessage))
728
+ : (this._lockedAgent?.prefix === '@copilot '
729
+ ? ( new MarkdownString(( localize(
730
+ 5657,
731
+ "This chat session will be forwarded to the {0} [coding agent]({1}) where work is completed in the background. ",
732
+ this._lockedAgent.prefix,
733
+ 'https://aka.ms/coding-agent-docs'
734
+ )) + DISCLAIMER, { isTrusted: true }))
735
+ : ( new MarkdownString(( localize(
736
+ 5658,
737
+ "This chat session will be forwarded to the {0} coding agent where work is completed in the background. ",
738
+ this._lockedAgent?.prefix
739
+ )) + DISCLAIMER)));
740
+ return {
741
+ title: providerTitle ?? ( localize(5659, "Delegate to {0}", this._lockedAgent?.prefix)),
742
+ message,
743
+ icon: providerIcon ?? Codicon.sendToRemoteAgent,
744
+ additionalMessage,
745
+ useLargeIcon: !!providerIcon,
746
+ };
747
+ }
748
+ let title;
749
+ if (this.input.currentModeKind === ChatModeKind.Ask) {
750
+ title = ( localize(5660, "Ask about your code"));
751
+ }
752
+ else if (this.input.currentModeKind === ChatModeKind.Edit) {
753
+ title = ( localize(5661, "Edit in context"));
754
+ }
755
+ else {
756
+ title = ( localize(5662, "Build with Agent"));
757
+ }
758
+ return {
759
+ title,
760
+ message: ( new MarkdownString(DISCLAIMER)),
761
+ icon: Codicon.chatSparkle,
762
+ additionalMessage,
763
+ suggestedPrompts: this.getPromptFileSuggestions()
764
+ };
765
+ }
766
+ getPromptFileSuggestions() {
767
+ if (!this.chatEntitlementService.sentiment.installed) {
768
+ const isEmpty = this.contextService.getWorkbenchState() === WorkbenchState.EMPTY;
769
+ if (isEmpty) {
770
+ return [
771
+ {
772
+ icon: Codicon.vscode,
773
+ label: ( localize(5663, "Ask @vscode")),
774
+ prompt: ( localize(5664, "@vscode How do I change the theme to light mode?")),
775
+ },
776
+ {
777
+ icon: Codicon.newFolder,
778
+ label: ( localize(5665, "Create Project")),
779
+ prompt: ( localize(5666, "Create a #new Hello World project in TypeScript")),
780
+ }
781
+ ];
782
+ }
783
+ else {
784
+ return [
785
+ {
786
+ icon: Codicon.debugAlt,
787
+ label: ( localize(5667, "Build Workspace")),
788
+ prompt: ( localize(5668, "How do I build this workspace?")),
789
+ },
790
+ {
791
+ icon: Codicon.gear,
792
+ label: ( localize(5669, "Show Config")),
793
+ prompt: ( localize(5670, "Where is the configuration for this project defined?")),
794
+ }
795
+ ];
796
+ }
797
+ }
798
+ const activeEditor = this.editorService.activeEditor;
799
+ const resource = activeEditor ? EditorResourceAccessor.getOriginalUri(activeEditor) : undefined;
800
+ const suggestions = PromptsConfig.getPromptFilesRecommendationsValue(this.configurationService, resource);
801
+ if (!suggestions) {
802
+ return [];
803
+ }
804
+ const result = [];
805
+ const promptsToLoad = [];
806
+ for (const [promptName] of Object.entries(suggestions)) {
807
+ const description = this.promptDescriptionsCache.get(promptName);
808
+ if (description === undefined) {
809
+ promptsToLoad.push(promptName);
810
+ }
811
+ }
812
+ if (promptsToLoad.length > 0 && !this._isLoadingPromptDescriptions) {
813
+ this.loadPromptDescriptions(promptsToLoad);
814
+ return [];
815
+ }
816
+ const promptsWithScores = [];
817
+ for (const [promptName, condition] of Object.entries(suggestions)) {
818
+ let score = 0;
819
+ if (typeof condition === 'boolean') {
820
+ score = condition ? 1 : 0;
821
+ }
822
+ else if (typeof condition === 'string') {
823
+ try {
824
+ const whenClause = ContextKeyExpr.deserialize(condition);
825
+ if (whenClause) {
826
+ const allEditors = this.codeEditorService.listCodeEditors();
827
+ if (allEditors.length > 0) {
828
+ score = allEditors.reduce((count, editor) => {
829
+ try {
830
+ const editorContext = this.contextKeyService.getContext(editor.getDomNode());
831
+ return count + (whenClause.evaluate(editorContext) ? 1 : 0);
832
+ }
833
+ catch (error) {
834
+ this.logService.warn('Failed to evaluate when clause for editor:', error);
835
+ return count;
836
+ }
837
+ }, 0);
838
+ }
839
+ else {
840
+ score = this.contextKeyService.contextMatchesRules(whenClause) ? 1 : 0;
841
+ }
842
+ }
843
+ else {
844
+ score = 0;
845
+ }
846
+ }
847
+ catch (error) {
848
+ this.logService.warn('Failed to parse when clause for prompt file suggestion:', condition, error);
849
+ score = 0;
850
+ }
851
+ }
852
+ if (score > 0) {
853
+ promptsWithScores.push({ promptName, condition, score });
854
+ }
855
+ }
856
+ promptsWithScores.sort((a, b) => b.score - a.score);
857
+ const topPrompts = promptsWithScores.slice(0, 5);
858
+ for (const { promptName } of topPrompts) {
859
+ const description = this.promptDescriptionsCache.get(promptName);
860
+ const commandLabel = ( localize(5671, "{0}", promptName));
861
+ const uri = this.promptUriCache.get(promptName);
862
+ const descriptionText = description?.trim() ? description : undefined;
863
+ result.push({
864
+ icon: Codicon.run,
865
+ label: commandLabel,
866
+ description: descriptionText,
867
+ prompt: `/${promptName} `,
868
+ uri: uri
869
+ });
870
+ }
871
+ return result;
872
+ }
873
+ async loadPromptDescriptions(promptNames) {
874
+ if (this._store.isDisposed) {
875
+ return;
876
+ }
877
+ this._isLoadingPromptDescriptions = true;
878
+ try {
879
+ const promptCommands = await this.promptsService.getPromptSlashCommands(CancellationToken.None);
880
+ let cacheUpdated = false;
881
+ for (const promptCommand of promptCommands) {
882
+ if (promptNames.includes(promptCommand.name)) {
883
+ const description = promptCommand.description;
884
+ if (description) {
885
+ this.promptDescriptionsCache.set(promptCommand.name, description);
886
+ cacheUpdated = true;
887
+ }
888
+ else {
889
+ this.promptDescriptionsCache.set(promptCommand.name, '');
890
+ cacheUpdated = true;
891
+ }
892
+ }
893
+ }
894
+ if (cacheUpdated) {
895
+ this.renderWelcomeViewContentIfNeeded();
896
+ }
897
+ }
898
+ catch (error) {
899
+ this.logService.warn('Failed to load specific prompt descriptions:', error);
900
+ }
901
+ finally {
902
+ this._isLoadingPromptDescriptions = false;
903
+ }
904
+ }
905
+ async renderChatEditingSessionState() {
906
+ if (!this.input) {
907
+ return;
908
+ }
909
+ this.input.renderChatEditingSessionState(this._editingSession.get() ?? null);
910
+ if (this.bodyDimension) {
911
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
912
+ }
913
+ }
914
+ async renderFollowups() {
915
+ if (this.lastItem && isResponseVM(this.lastItem) && this.lastItem.isComplete && this.input.currentModeKind === ChatModeKind.Ask) {
916
+ this.input.renderFollowups(this.lastItem.replyFollowups, this.lastItem);
917
+ }
918
+ else {
919
+ this.input.renderFollowups(undefined, undefined);
920
+ }
921
+ if (this.bodyDimension) {
922
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
923
+ }
924
+ }
925
+ renderChatSuggestNextWidget() {
926
+ if (this.lifecycleService.willShutdown) {
927
+ return;
928
+ }
929
+ if (this.isLockedToCodingAgent) {
930
+ this.chatSuggestNextWidget.hide();
931
+ return;
932
+ }
933
+ const items = this.viewModel?.getItems() ?? [];
934
+ if (!items.length) {
935
+ return;
936
+ }
937
+ const lastItem = items[items.length - 1];
938
+ const lastResponseComplete = lastItem && isResponseVM(lastItem) && lastItem.isComplete;
939
+ if (!lastResponseComplete) {
940
+ return;
941
+ }
942
+ const currentMode = this.input.currentModeObs.get();
943
+ const handoffs = currentMode?.handOffs?.get();
944
+ const shouldShow = currentMode && handoffs && handoffs.length > 0;
945
+ if (shouldShow) {
946
+ const wasHidden = this.chatSuggestNextWidget.domNode.style.display === 'none';
947
+ this.chatSuggestNextWidget.render(currentMode);
948
+ if (wasHidden) {
949
+ this.telemetryService.publicLog2('chat.handoffWidgetShown', {
950
+ agent: currentMode.id,
951
+ handoffCount: handoffs.length
952
+ });
953
+ }
954
+ }
955
+ else {
956
+ this.chatSuggestNextWidget.hide();
957
+ }
958
+ if (this.bodyDimension) {
959
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
960
+ }
961
+ }
962
+ handleNextPromptSelection(handoff, agentId) {
963
+ this.chatSuggestNextWidget.hide();
964
+ const promptToUse = handoff.prompt;
965
+ const currentMode = this.input.currentModeObs.get();
966
+ const fromAgent = currentMode?.id ?? '';
967
+ this.telemetryService.publicLog2('chat.handoffClicked', {
968
+ fromAgent: fromAgent,
969
+ toAgent: agentId || handoff.agent || '',
970
+ hasPrompt: Boolean(promptToUse),
971
+ autoSend: Boolean(handoff.send)
972
+ });
973
+ if (agentId) {
974
+ this.input.setValue(`@${agentId} ${promptToUse}`, false);
975
+ this.input.focus();
976
+ this.acceptInput().catch(e => this.logService.error('Failed to handle handoff continueOn', e));
977
+ }
978
+ else if (handoff.agent) {
979
+ this._switchToAgentByName(handoff.agent);
980
+ this.input.setValue(promptToUse, false);
981
+ this.input.focus();
982
+ if (handoff.send) {
983
+ this.acceptInput();
984
+ }
985
+ }
986
+ }
987
+ async handleDelegationExitIfNeeded(sourceAgent, targetAgent) {
988
+ if (!this._shouldExitAfterDelegation(sourceAgent, targetAgent)) {
989
+ return;
990
+ }
991
+ try {
992
+ await this._handleDelegationExit();
993
+ }
994
+ catch (e) {
995
+ this.logService.error('Failed to handle delegation exit', e);
996
+ }
997
+ }
998
+ _shouldExitAfterDelegation(sourceAgent, targetAgent) {
999
+ if (!targetAgent) {
1000
+ return false;
1001
+ }
1002
+ if (!this.configurationService.getValue(ChatConfiguration.ExitAfterDelegation)) {
1003
+ return false;
1004
+ }
1005
+ if (sourceAgent && sourceAgent.id === targetAgent.id) {
1006
+ return false;
1007
+ }
1008
+ if (!isIChatViewViewContext(this.viewContext)) {
1009
+ return false;
1010
+ }
1011
+ const contribution = this.chatSessionsService.getChatSessionContribution(targetAgent.id);
1012
+ if (!contribution) {
1013
+ return false;
1014
+ }
1015
+ if (contribution.canDelegate !== true) {
1016
+ return false;
1017
+ }
1018
+ return true;
1019
+ }
1020
+ async _handleDelegationExit() {
1021
+ const viewModel = this.viewModel;
1022
+ if (!viewModel) {
1023
+ return;
1024
+ }
1025
+ const parentSessionResource = viewModel.sessionResource;
1026
+ const checkIfShouldClear = () => {
1027
+ const items = viewModel.getItems();
1028
+ const lastItem = items[items.length - 1];
1029
+ if (lastItem && isResponseVM(lastItem) && lastItem.model && lastItem.isComplete && !lastItem.model.isPendingConfirmation.get()) {
1030
+ const hasError = Boolean(lastItem.result?.errorDetails);
1031
+ return !hasError;
1032
+ }
1033
+ return false;
1034
+ };
1035
+ if (checkIfShouldClear()) {
1036
+ await this.clear();
1037
+ this.archiveLocalParentSession(parentSessionResource);
1038
+ return;
1039
+ }
1040
+ const shouldClear = await ( new Promise(resolve => {
1041
+ const disposable = viewModel.onDidChange(() => {
1042
+ const result = checkIfShouldClear();
1043
+ if (result) {
1044
+ cleanup();
1045
+ resolve(true);
1046
+ }
1047
+ });
1048
+ const timeout = setTimeout(() => {
1049
+ cleanup();
1050
+ resolve(false);
1051
+ }, 30_000);
1052
+ const cleanup = () => {
1053
+ clearTimeout(timeout);
1054
+ disposable.dispose();
1055
+ };
1056
+ }));
1057
+ if (shouldClear) {
1058
+ await this.clear();
1059
+ this.archiveLocalParentSession(parentSessionResource);
1060
+ }
1061
+ }
1062
+ async archiveLocalParentSession(sessionResource) {
1063
+ if (sessionResource.scheme !== Schemas.vscodeLocalChatSession) {
1064
+ return;
1065
+ }
1066
+ await this.chatService.getSession(sessionResource)?.editingSession?.accept();
1067
+ const session = this.agentSessionsService.getSession(sessionResource);
1068
+ session?.setArchived(true);
1069
+ }
1070
+ setVisible(visible) {
1071
+ const wasVisible = this._visible;
1072
+ this._visible = visible;
1073
+ this.visibleChangeCount++;
1074
+ this.renderer.setVisible(visible);
1075
+ this.input.setVisible(visible);
1076
+ if (visible) {
1077
+ if (!wasVisible) {
1078
+ this.visibilityTimeoutDisposable.value = disposableTimeout(() => {
1079
+ if (this._visible) {
1080
+ this.onDidChangeItems(true);
1081
+ }
1082
+ }, 0);
1083
+ this._register(scheduleAtNextAnimationFrame(getWindow(this.listContainer), () => {
1084
+ this._onDidShow.fire();
1085
+ }));
1086
+ }
1087
+ }
1088
+ else if (wasVisible) {
1089
+ this._onDidHide.fire();
1090
+ }
1091
+ }
1092
+ createList(listContainer, options) {
1093
+ const scopedInstantiationService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, this.contextKeyService]))));
1094
+ const delegate = scopedInstantiationService.createInstance(ChatListDelegate, this.viewOptions.defaultElementHeight ?? 200);
1095
+ const rendererDelegate = {
1096
+ getListLength: () => this.tree.getNode(null).visibleChildrenCount,
1097
+ onDidScroll: this.onDidScroll,
1098
+ container: listContainer,
1099
+ currentChatMode: () => this.input.currentModeKind,
1100
+ };
1101
+ const overflowWidgetsContainer = createElement('div');
1102
+ overflowWidgetsContainer.classList.add('chat-overflow-widget-container', 'monaco-editor');
1103
+ listContainer.append(overflowWidgetsContainer);
1104
+ this.renderer = this._register(scopedInstantiationService.createInstance(ChatListItemRenderer, this.editorOptions, options, rendererDelegate, this._codeBlockModelCollection, overflowWidgetsContainer, this.viewModel));
1105
+ this._register(this.renderer.onDidClickRequest(async (item) => {
1106
+ this.clickedRequest(item);
1107
+ }));
1108
+ this._register(this.renderer.onDidRerender(item => {
1109
+ if (isRequestVM(item.currentElement) && this.configurationService.getValue('chat.editRequests') !== 'input') {
1110
+ if (!item.rowContainer.contains(this.inputContainer)) {
1111
+ item.rowContainer.appendChild(this.inputContainer);
1112
+ }
1113
+ this.input.focus();
1114
+ }
1115
+ }));
1116
+ this._register(this.renderer.onDidDispose((item) => {
1117
+ this.focusedInputDOM.appendChild(this.inputContainer);
1118
+ this.input.focus();
1119
+ }));
1120
+ this._register(this.renderer.onDidFocusOutside(() => {
1121
+ this.finishedEditing();
1122
+ }));
1123
+ this._register(this.renderer.onDidClickFollowup(item => {
1124
+ this.acceptInput(item.message);
1125
+ }));
1126
+ this._register(this.renderer.onDidClickRerunWithAgentOrCommandDetection(e => {
1127
+ const request = this.chatService.getSession(e.sessionResource)?.getRequests().find(candidate => candidate.id === e.requestId);
1128
+ if (request) {
1129
+ const options = {
1130
+ noCommandDetection: true,
1131
+ attempt: request.attempt + 1,
1132
+ location: this.location,
1133
+ userSelectedModelId: this.input.currentLanguageModel,
1134
+ modeInfo: this.input.currentModeInfo,
1135
+ };
1136
+ this.chatService.resendRequest(request, options).catch(e => this.logService.error('FAILED to rerun request', e));
1137
+ }
1138
+ }));
1139
+ this.tree = this._register(scopedInstantiationService.createInstance((WorkbenchObjectTree), 'Chat', listContainer, delegate, [this.renderer], {
1140
+ identityProvider: { getId: (e) => e.id },
1141
+ horizontalScrolling: false,
1142
+ alwaysConsumeMouseWheel: false,
1143
+ supportDynamicHeights: true,
1144
+ hideTwistiesOfChildlessElements: true,
1145
+ accessibilityProvider: this.instantiationService.createInstance(ChatAccessibilityProvider),
1146
+ keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e) => isRequestVM(e) ? e.message : isResponseVM(e) ? e.response.value : '' },
1147
+ setRowLineHeight: false,
1148
+ filter: this.viewOptions.filter ? { filter: this.viewOptions.filter.bind(this.viewOptions), } : undefined,
1149
+ scrollToActiveElement: true,
1150
+ overrideStyles: {
1151
+ listFocusBackground: this.styles.listBackground,
1152
+ listInactiveFocusBackground: this.styles.listBackground,
1153
+ listActiveSelectionBackground: this.styles.listBackground,
1154
+ listFocusAndSelectionBackground: this.styles.listBackground,
1155
+ listInactiveSelectionBackground: this.styles.listBackground,
1156
+ listHoverBackground: this.styles.listBackground,
1157
+ listBackground: this.styles.listBackground,
1158
+ listFocusForeground: this.styles.listForeground,
1159
+ listHoverForeground: this.styles.listForeground,
1160
+ listInactiveFocusForeground: this.styles.listForeground,
1161
+ listInactiveSelectionForeground: this.styles.listForeground,
1162
+ listActiveSelectionForeground: this.styles.listForeground,
1163
+ listFocusAndSelectionForeground: this.styles.listForeground,
1164
+ listActiveSelectionIconForeground: undefined,
1165
+ listInactiveSelectionIconForeground: undefined,
1166
+ }
1167
+ }));
1168
+ this._register(this.tree.onDidChangeFocus(() => {
1169
+ const focused = this.tree.getFocus();
1170
+ if (focused && focused.length > 0) {
1171
+ const focusedItem = focused[0];
1172
+ const items = this.tree.getNode(null).children;
1173
+ const idx = items.findIndex(i => i.element === focusedItem);
1174
+ if (idx !== -1) {
1175
+ this._mostRecentlyFocusedItemIndex = idx;
1176
+ }
1177
+ }
1178
+ }));
1179
+ this._register(this.tree.onContextMenu(e => this.onContextMenu(e)));
1180
+ this._register(this.tree.onDidChangeContentHeight(() => {
1181
+ this.onDidChangeTreeContentHeight();
1182
+ }));
1183
+ this._register(this.renderer.onDidChangeItemHeight(e => {
1184
+ if (this.tree.hasElement(e.element) && this.visible) {
1185
+ this.tree.updateElementHeight(e.element, e.height);
1186
+ }
1187
+ }));
1188
+ this._register(this.tree.onDidFocus(() => {
1189
+ this._onDidFocus.fire();
1190
+ }));
1191
+ this._register(this.tree.onDidScroll(() => {
1192
+ this._onDidScroll.fire();
1193
+ const isScrolledDown = this.tree.scrollTop >= this.tree.scrollHeight - this.tree.renderHeight - 2;
1194
+ this.container.classList.toggle('show-scroll-down', !isScrolledDown && !this.scrollLock);
1195
+ }));
1196
+ }
1197
+ startEditing(requestId) {
1198
+ const editedRequest = this.renderer.getTemplateDataForRequestId(requestId);
1199
+ if (editedRequest) {
1200
+ this.clickedRequest(editedRequest);
1201
+ }
1202
+ }
1203
+ clickedRequest(item) {
1204
+ const currentElement = item.currentElement;
1205
+ if (isRequestVM(currentElement) && !this.viewModel?.editing) {
1206
+ const requests = this.viewModel?.model.getRequests();
1207
+ if (!requests || !this.viewModel?.sessionResource) {
1208
+ return;
1209
+ }
1210
+ if (this.viewModel?.model.checkpoint) {
1211
+ this.recentlyRestoredCheckpoint = true;
1212
+ }
1213
+ this.viewModel?.model.setCheckpoint(currentElement.id);
1214
+ const currentContext = [];
1215
+ for (let i = requests.length - 1; i >= 0; i -= 1) {
1216
+ const request = requests[i];
1217
+ if (request.id === currentElement.id) {
1218
+ request.shouldBeBlocked = false;
1219
+ if (request.attachedContext) {
1220
+ const context = request.attachedContext.filter(entry => !isWorkspaceVariableEntry(entry) && (!(isPromptFileVariableEntry(entry) || isPromptTextVariableEntry(entry)) || !entry.automaticallyAdded));
1221
+ currentContext.push(...context);
1222
+ }
1223
+ }
1224
+ }
1225
+ this.viewModel?.setEditing(currentElement);
1226
+ if (item?.contextKeyService) {
1227
+ ChatContextKeys.currentlyEditing.bindTo(item.contextKeyService).set(true);
1228
+ }
1229
+ const isInput = this.configurationService.getValue('chat.editRequests') === 'input';
1230
+ this.inputPart?.setEditing(!!this.viewModel?.editing && isInput);
1231
+ if (!isInput) {
1232
+ const rowContainer = item.rowContainer;
1233
+ this.inputContainer = $$1('.chat-edit-input-container');
1234
+ rowContainer.appendChild(this.inputContainer);
1235
+ this.createInput(this.inputContainer);
1236
+ this.input.setChatMode(this.inputPart.currentModeKind);
1237
+ }
1238
+ else {
1239
+ this.inputPart.element.classList.add('editing');
1240
+ }
1241
+ this.inputPart.toggleChatInputOverlay(!isInput);
1242
+ if (currentContext.length > 0) {
1243
+ this.input.attachmentModel.addContext(...currentContext);
1244
+ }
1245
+ this.inputPart.dnd.setDisabledOverlay(!isInput);
1246
+ this.input.renderAttachedContext();
1247
+ this.input.setValue(currentElement.messageText, false);
1248
+ this.renderer.updateItemHeightOnRender(currentElement, item);
1249
+ this.onDidChangeItems();
1250
+ this.input.inputEditor.focus();
1251
+ this._register(this.inputPart.onDidClickOverlay(() => {
1252
+ if (this.viewModel?.editing && this.configurationService.getValue('chat.editRequests') !== 'input') {
1253
+ this.finishedEditing();
1254
+ }
1255
+ }));
1256
+ if (!isInput) {
1257
+ this._register(this.inlineInputPart.inputEditor.onDidChangeModelContent(() => {
1258
+ this.scrollToCurrentItem(currentElement);
1259
+ }));
1260
+ this._register(this.inlineInputPart.inputEditor.onDidChangeCursorSelection((e) => {
1261
+ this.scrollToCurrentItem(currentElement);
1262
+ }));
1263
+ }
1264
+ }
1265
+ this.telemetryService.publicLog2('chat.startEditingRequests', {
1266
+ editRequestType: this.configurationService.getValue('chat.editRequests'),
1267
+ });
1268
+ }
1269
+ finishedEditing(completedEdit) {
1270
+ const editedRequest = this.renderer.getTemplateDataForRequestId(this.viewModel?.editing?.id);
1271
+ if (this.recentlyRestoredCheckpoint) {
1272
+ this.recentlyRestoredCheckpoint = false;
1273
+ }
1274
+ else {
1275
+ this.viewModel?.model.setCheckpoint(undefined);
1276
+ }
1277
+ this.inputPart.dnd.setDisabledOverlay(false);
1278
+ if (editedRequest?.contextKeyService) {
1279
+ ChatContextKeys.currentlyEditing.bindTo(editedRequest.contextKeyService).set(false);
1280
+ }
1281
+ const isInput = this.configurationService.getValue('chat.editRequests') === 'input';
1282
+ if (!isInput) {
1283
+ this.inputPart.setChatMode(this.input.currentModeKind);
1284
+ const currentModel = this.input.selectedLanguageModel;
1285
+ if (currentModel) {
1286
+ this.inputPart.switchModel(currentModel.metadata);
1287
+ }
1288
+ this.inputPart?.toggleChatInputOverlay(false);
1289
+ try {
1290
+ if (editedRequest?.rowContainer?.contains(this.inputContainer)) {
1291
+ editedRequest.rowContainer.removeChild(this.inputContainer);
1292
+ }
1293
+ else if (this.inputContainer.parentElement) {
1294
+ this.inputContainer.parentElement.removeChild(this.inputContainer);
1295
+ }
1296
+ }
1297
+ catch (e) {
1298
+ this.logService.error('Error occurred while finishing editing:', e);
1299
+ }
1300
+ this.inputContainer = $$1('.empty-chat-state');
1301
+ this.input.dispose();
1302
+ }
1303
+ if (isInput) {
1304
+ this.inputPart.element.classList.remove('editing');
1305
+ }
1306
+ this.viewModel?.setEditing(undefined);
1307
+ this.inputPart?.setEditing(!!this.viewModel?.editing && isInput);
1308
+ this.onDidChangeItems();
1309
+ if (editedRequest?.currentElement) {
1310
+ this.renderer.updateItemHeightOnRender(editedRequest.currentElement, editedRequest);
1311
+ }
1312
+ this.telemetryService.publicLog2('chat.editRequestsFinished', {
1313
+ editRequestType: this.configurationService.getValue('chat.editRequests'),
1314
+ editCanceled: !completedEdit
1315
+ });
1316
+ this.inputPart.focus();
1317
+ }
1318
+ scrollToCurrentItem(currentElement) {
1319
+ if (this.viewModel?.editing && currentElement) {
1320
+ const element = currentElement;
1321
+ if (!this.tree.hasElement(element)) {
1322
+ return;
1323
+ }
1324
+ const relativeTop = this.tree.getRelativeTop(element);
1325
+ if (relativeTop === null || relativeTop < 0 || relativeTop > 1) {
1326
+ this.tree.reveal(element, 0);
1327
+ }
1328
+ }
1329
+ }
1330
+ onContextMenu(e) {
1331
+ e.browserEvent.preventDefault();
1332
+ e.browserEvent.stopPropagation();
1333
+ const selected = e.element;
1334
+ const target = e.browserEvent.target;
1335
+ const isKatexElement = target.closest(`.${katexContainerClassName}`) !== null;
1336
+ const scopedContextKeyService = this.contextKeyService.createOverlay([
1337
+ [ChatContextKeys.responseIsFiltered.key, isResponseVM(selected) && !!selected.errorDetails?.responseIsFiltered],
1338
+ [ChatContextKeys.isKatexMathElement.key, isKatexElement]
1339
+ ]);
1340
+ this.contextMenuService.showContextMenu({
1341
+ menuId: MenuId.ChatContext,
1342
+ menuActionOptions: { shouldForwardArgs: true },
1343
+ contextKeyService: scopedContextKeyService,
1344
+ getAnchor: () => e.anchor,
1345
+ getActionsContext: () => selected,
1346
+ });
1347
+ }
1348
+ onDidChangeTreeContentHeight() {
1349
+ if (this.tree.scrollHeight !== this.previousTreeScrollHeight) {
1350
+ const lastItem = this.viewModel?.getItems().at(-1);
1351
+ const lastResponseIsRendering = isResponseVM(lastItem) && lastItem.renderData;
1352
+ if (!lastResponseIsRendering || this.scrollLock) {
1353
+ const lastElementWasVisible = this.tree.scrollTop + this.tree.renderHeight >= this.previousTreeScrollHeight - 2;
1354
+ if (lastElementWasVisible) {
1355
+ this._register(scheduleAtNextAnimationFrame(getWindow(this.listContainer), () => {
1356
+ this.scrollToEnd();
1357
+ }, 0));
1358
+ }
1359
+ }
1360
+ }
1361
+ this.previousTreeScrollHeight = this.tree.scrollHeight;
1362
+ this._onDidChangeContentHeight.fire();
1363
+ }
1364
+ getWidgetViewKindTag() {
1365
+ if (!this.viewContext) {
1366
+ return 'editor';
1367
+ }
1368
+ else if (isIChatViewViewContext(this.viewContext)) {
1369
+ return 'view';
1370
+ }
1371
+ else {
1372
+ return 'quick';
1373
+ }
1374
+ }
1375
+ createInput(container, options) {
1376
+ const commonConfig = {
1377
+ renderFollowups: options?.renderFollowups ?? true,
1378
+ renderStyle: options?.renderStyle === 'minimal' ? 'compact' : options?.renderStyle,
1379
+ renderInputToolbarBelowInput: options?.renderInputToolbarBelowInput ?? false,
1380
+ menus: {
1381
+ executeToolbar: MenuId.ChatExecute,
1382
+ telemetrySource: 'chatWidget',
1383
+ ...this.viewOptions.menus
1384
+ },
1385
+ editorOverflowWidgetsDomNode: this.viewOptions.editorOverflowWidgetsDomNode,
1386
+ enableImplicitContext: this.viewOptions.enableImplicitContext,
1387
+ renderWorkingSet: this.viewOptions.enableWorkingSet === 'explicit',
1388
+ supportsChangingModes: this.viewOptions.supportsChangingModes,
1389
+ dndContainer: this.viewOptions.dndContainer,
1390
+ widgetViewKindTag: this.getWidgetViewKindTag(),
1391
+ defaultMode: this.viewOptions.defaultMode
1392
+ };
1393
+ if (this.viewModel?.editing) {
1394
+ const editedRequest = this.renderer.getTemplateDataForRequestId(this.viewModel?.editing?.id);
1395
+ const scopedInstantiationService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, editedRequest?.contextKeyService]))));
1396
+ this.inlineInputPartDisposable.value = scopedInstantiationService.createInstance(ChatInputPart, this.location, commonConfig, this.styles, true);
1397
+ }
1398
+ else {
1399
+ this.inputPartDisposable.value = this.instantiationService.createInstance(ChatInputPart, this.location, commonConfig, this.styles, false);
1400
+ }
1401
+ this.input.render(container, '', this);
1402
+ this._register(this.input.onDidLoadInputState(() => {
1403
+ this.refreshParsedInput();
1404
+ }));
1405
+ this._register(this.input.onDidFocus(() => this._onDidFocus.fire()));
1406
+ this._register(this.input.onDidAcceptFollowup(e => {
1407
+ if (!this.viewModel) {
1408
+ return;
1409
+ }
1410
+ let msg = '';
1411
+ if (e.followup.agentId && e.followup.agentId !== this.chatAgentService.getDefaultAgent(this.location, this.input.currentModeKind)?.id) {
1412
+ const agent = this.chatAgentService.getAgent(e.followup.agentId);
1413
+ if (!agent) {
1414
+ return;
1415
+ }
1416
+ this.lastSelectedAgent = agent;
1417
+ msg = `${chatAgentLeader}${agent.name} `;
1418
+ if (e.followup.subCommand) {
1419
+ msg += `${chatSubcommandLeader}${e.followup.subCommand} `;
1420
+ }
1421
+ }
1422
+ else if (!e.followup.agentId && e.followup.subCommand && this.chatSlashCommandService.hasCommand(e.followup.subCommand)) {
1423
+ msg = `${chatSubcommandLeader}${e.followup.subCommand} `;
1424
+ }
1425
+ msg += e.followup.message;
1426
+ this.acceptInput(msg);
1427
+ if (!e.response) {
1428
+ return;
1429
+ }
1430
+ this.chatService.notifyUserAction({
1431
+ sessionResource: this.viewModel.sessionResource,
1432
+ requestId: e.response.requestId,
1433
+ agentId: e.response.agent?.id,
1434
+ command: e.response.slashCommand?.name,
1435
+ result: e.response.result,
1436
+ action: {
1437
+ kind: 'followUp',
1438
+ followup: e.followup
1439
+ },
1440
+ });
1441
+ }));
1442
+ this._register(this.input.onDidChangeHeight(() => {
1443
+ const editedRequest = this.renderer.getTemplateDataForRequestId(this.viewModel?.editing?.id);
1444
+ if (isRequestVM(editedRequest?.currentElement) && this.viewModel?.editing) {
1445
+ this.renderer.updateItemHeightOnRender(editedRequest?.currentElement, editedRequest);
1446
+ }
1447
+ if (this.bodyDimension) {
1448
+ this.layout(this.bodyDimension.height, this.bodyDimension.width);
1449
+ }
1450
+ this._onDidChangeContentHeight.fire();
1451
+ }));
1452
+ this._register(this.inputEditor.onDidChangeModelContent(() => {
1453
+ this.parsedChatRequest = undefined;
1454
+ this.updateChatInputContext();
1455
+ }));
1456
+ this._register(this.chatAgentService.onDidChangeAgents(() => {
1457
+ this.parsedChatRequest = undefined;
1458
+ this.renderWelcomeViewContentIfNeeded();
1459
+ }));
1460
+ this._register(this.input.onDidChangeCurrentChatMode(() => {
1461
+ this.renderWelcomeViewContentIfNeeded();
1462
+ this.refreshParsedInput();
1463
+ this.renderFollowups();
1464
+ this.renderChatSuggestNextWidget();
1465
+ }));
1466
+ this._register(autorun(r => {
1467
+ const toolSetIds = ( new Set());
1468
+ const toolIds = ( new Set());
1469
+ for (const [entry, enabled] of this.input.selectedToolsModel.entriesMap.read(r)) {
1470
+ if (enabled) {
1471
+ if (entry instanceof ToolSet) {
1472
+ toolSetIds.add(entry.id);
1473
+ }
1474
+ else {
1475
+ toolIds.add(entry.id);
1476
+ }
1477
+ }
1478
+ }
1479
+ const disabledTools = ( this.input.attachmentModel.attachments
1480
+ .filter(a => a.kind === 'tool' && !( toolIds.has(a.id)) || a.kind === 'toolset' && !( toolSetIds.has(a.id)))
1481
+ .map(a => a.id));
1482
+ this.input.attachmentModel.updateContext(disabledTools, Iterable.empty());
1483
+ this.refreshParsedInput();
1484
+ }));
1485
+ }
1486
+ onDidStyleChange() {
1487
+ this.container.style.setProperty('--vscode-interactive-result-editor-background-color', this.editorOptions.configuration.resultEditor.backgroundColor?.toString() ?? '');
1488
+ this.container.style.setProperty('--vscode-interactive-session-foreground', this.editorOptions.configuration.foreground?.toString() ?? '');
1489
+ this.container.style.setProperty('--vscode-chat-list-background', this.themeService.getColorTheme().getColor(this.styles.listBackground)?.toString() ?? '');
1490
+ }
1491
+ setModel(model) {
1492
+ if (!this.container) {
1493
+ throw ( new Error('Call render() before setModel()'));
1494
+ }
1495
+ if (!model) {
1496
+ this.viewModel = undefined;
1497
+ this.onDidChangeItems();
1498
+ return;
1499
+ }
1500
+ if (isEqual(model.sessionResource, this.viewModel?.sessionResource)) {
1501
+ return;
1502
+ }
1503
+ this.inputPart.clearTodoListWidget(model.sessionResource, false);
1504
+ this.chatSuggestNextWidget.hide();
1505
+ this._codeBlockModelCollection.clear();
1506
+ this.container.setAttribute('data-session-id', model.sessionId);
1507
+ this.viewModel = this.instantiationService.createInstance(ChatViewModel, model, this._codeBlockModelCollection);
1508
+ this.inputPart.setInputModel(model.inputModel, model.getRequests().length === 0);
1509
+ if (this._lockedAgent) {
1510
+ let placeholder = this.chatSessionsService.getInputPlaceholderForSessionType(this._lockedAgent.id);
1511
+ if (!placeholder) {
1512
+ placeholder = ( localize(5672, "Chat with {0}", this._lockedAgent.id));
1513
+ }
1514
+ this.viewModel.setInputPlaceholder(placeholder);
1515
+ this.inputEditor.updateOptions({ placeholder });
1516
+ }
1517
+ else if (this.viewModel.inputPlaceholder) {
1518
+ this.inputEditor.updateOptions({ placeholder: this.viewModel.inputPlaceholder });
1519
+ }
1520
+ const renderImmediately = this.configurationService.getValue('chat.experimental.renderMarkdownImmediately');
1521
+ const delay = renderImmediately ? MicrotaskDelay : 0;
1522
+ this.viewModelDisposables.add(Event.runAndSubscribe(Event.accumulate(this.viewModel.onDidChange, delay), (events => {
1523
+ if (!this.viewModel || this._store.isDisposed) {
1524
+ return;
1525
+ }
1526
+ this.requestInProgress.set(this.viewModel.model.requestInProgress.get());
1527
+ if (events?.some(e => e?.kind === 'changePlaceholder')) {
1528
+ this.inputEditor.updateOptions({ placeholder: this.viewModel.inputPlaceholder });
1529
+ }
1530
+ this.onDidChangeItems();
1531
+ if (events?.some(e => e?.kind === 'addRequest') && this.visible) {
1532
+ this.scrollToEnd();
1533
+ }
1534
+ })));
1535
+ this.viewModelDisposables.add(autorun(reader => {
1536
+ this._editingSession.read(reader);
1537
+ this.renderChatEditingSessionState();
1538
+ }));
1539
+ this.viewModelDisposables.add(this.viewModel.onDidDisposeModel(() => {
1540
+ if (this.viewModel?.editing) {
1541
+ this.finishedEditing();
1542
+ }
1543
+ this.viewModel = undefined;
1544
+ this.onDidChangeItems();
1545
+ }));
1546
+ this._sessionIsEmptyContextKey.set(model.getRequests().length === 0);
1547
+ this.refreshParsedInput();
1548
+ this.viewModelDisposables.add(model.onDidChange((e) => {
1549
+ if (e.kind === 'setAgent') {
1550
+ this._onDidChangeAgent.fire({ agent: e.agent, slashCommand: e.command });
1551
+ this._updateAgentCapabilitiesContextKeys(e.agent);
1552
+ }
1553
+ if (e.kind === 'addRequest') {
1554
+ this.inputPart.clearTodoListWidget(this.viewModel?.sessionResource, false);
1555
+ this._sessionIsEmptyContextKey.set(false);
1556
+ }
1557
+ if (e.kind === 'removeRequest') {
1558
+ this.inputPart.clearTodoListWidget(this.viewModel?.sessionResource, true);
1559
+ this.chatSuggestNextWidget.hide();
1560
+ this._sessionIsEmptyContextKey.set((this.viewModel?.model.getRequests().length ?? 0) === 0);
1561
+ }
1562
+ if (e.kind === 'completedRequest') {
1563
+ const lastRequest = this.viewModel?.model.getRequests().at(-1);
1564
+ const wasCancelled = lastRequest?.response?.isCanceled ?? false;
1565
+ if (wasCancelled) {
1566
+ this.inputPart.clearTodoListWidget(this.viewModel?.sessionResource, true);
1567
+ }
1568
+ this.renderChatSuggestNextWidget();
1569
+ }
1570
+ }));
1571
+ if (this.tree && this.visible) {
1572
+ this.onDidChangeItems();
1573
+ this.scrollToEnd();
1574
+ }
1575
+ this.renderer.updateViewModel(this.viewModel);
1576
+ this.updateChatInputContext();
1577
+ this.input.renderChatTodoListWidget(this.viewModel.sessionResource);
1578
+ }
1579
+ getFocus() {
1580
+ return this.tree.getFocus()[0] ?? undefined;
1581
+ }
1582
+ reveal(item, relativeTop) {
1583
+ this.tree.reveal(item, relativeTop);
1584
+ }
1585
+ focus(item) {
1586
+ const items = this.tree.getNode(null).children;
1587
+ const node = items.find(i => i.element?.id === item.id);
1588
+ if (!node) {
1589
+ return;
1590
+ }
1591
+ this._mostRecentlyFocusedItemIndex = items.indexOf(node);
1592
+ this.tree.setFocus([node.element]);
1593
+ this.tree.domFocus();
1594
+ }
1595
+ setInputPlaceholder(placeholder) {
1596
+ this.viewModel?.setInputPlaceholder(placeholder);
1597
+ }
1598
+ resetInputPlaceholder() {
1599
+ this.viewModel?.resetInputPlaceholder();
1600
+ }
1601
+ setInput(value = '') {
1602
+ this.input.setValue(value, false);
1603
+ this.refreshParsedInput();
1604
+ }
1605
+ getInput() {
1606
+ return this.input.inputEditor.getValue();
1607
+ }
1608
+ getContrib(id) {
1609
+ return this.contribs.find(c => c.id === id);
1610
+ }
1611
+ lockToCodingAgent(name, displayName, agentId) {
1612
+ this._lockedAgent = {
1613
+ id: agentId,
1614
+ name,
1615
+ prefix: `@${name} `,
1616
+ displayName
1617
+ };
1618
+ this._lockedToCodingAgentContextKey.set(true);
1619
+ this.renderWelcomeViewContentIfNeeded();
1620
+ const agent = this.chatAgentService.getAgent(agentId);
1621
+ this._updateAgentCapabilitiesContextKeys(agent);
1622
+ this.renderer.updateOptions({ restorable: false, editable: false, noFooter: true, progressMessageAtBottomOfResponse: true });
1623
+ if (this.visible) {
1624
+ this.tree.rerender();
1625
+ }
1626
+ }
1627
+ unlockFromCodingAgent() {
1628
+ this._lockedAgent = undefined;
1629
+ this._lockedToCodingAgentContextKey.set(false);
1630
+ this._updateAgentCapabilitiesContextKeys(undefined);
1631
+ this.renderWelcomeViewContentIfNeeded();
1632
+ if (this.viewModel) {
1633
+ this.viewModel.resetInputPlaceholder();
1634
+ }
1635
+ this.inputEditor.updateOptions({ placeholder: undefined });
1636
+ this.renderer.updateOptions({ restorable: true, editable: true, noFooter: false, progressMessageAtBottomOfResponse: mode => mode !== ChatModeKind.Ask });
1637
+ if (this.visible) {
1638
+ this.tree.rerender();
1639
+ }
1640
+ }
1641
+ get isLockedToCodingAgent() {
1642
+ return !!this._lockedAgent;
1643
+ }
1644
+ get lockedAgentId() {
1645
+ return this._lockedAgent?.id;
1646
+ }
1647
+ logInputHistory() {
1648
+ this.input.logInputHistory();
1649
+ }
1650
+ async acceptInput(query, options) {
1651
+ return this._acceptInput(query ? { query } : undefined, options);
1652
+ }
1653
+ async rerunLastRequest() {
1654
+ if (!this.viewModel) {
1655
+ return;
1656
+ }
1657
+ const sessionResource = this.viewModel.sessionResource;
1658
+ const lastRequest = this.chatService.getSession(sessionResource)?.getRequests().at(-1);
1659
+ if (!lastRequest) {
1660
+ return;
1661
+ }
1662
+ const options = {
1663
+ attempt: lastRequest.attempt + 1,
1664
+ location: this.location,
1665
+ userSelectedModelId: this.input.currentLanguageModel
1666
+ };
1667
+ return await this.chatService.resendRequest(lastRequest, options);
1668
+ }
1669
+ async _applyPromptFileIfSet(requestInput) {
1670
+ const agentSlashPromptPart = this.parsedInput.parts.find((r) => r instanceof ChatRequestSlashPromptPart);
1671
+ if (!agentSlashPromptPart) {
1672
+ return;
1673
+ }
1674
+ const slashCommand = await this.promptsService.resolvePromptSlashCommand(agentSlashPromptPart.name, CancellationToken.None);
1675
+ if (!slashCommand) {
1676
+ return;
1677
+ }
1678
+ const parseResult = slashCommand.parsedPromptFile;
1679
+ const refs = parseResult.body?.variableReferences.map(({ name, offset }) => ({ name, range: ( new OffsetRange(offset, offset + name.length + 1)) })) ?? [];
1680
+ const toolReferences = this.toolsService.toToolReferences(refs);
1681
+ requestInput.attachedContext.insertFirst(toPromptFileVariableEntry(parseResult.uri, PromptFileVariableKind.PromptFile, undefined, true, toolReferences));
1682
+ requestInput.input = ( this.parsedInput.parts.filter(part => !(part instanceof ChatRequestSlashPromptPart)).map(part => part.text)).join('').trim();
1683
+ const input = requestInput.input.trim();
1684
+ requestInput.input = `Follow instructions in [${basename(parseResult.uri)}](${( parseResult.uri.toString())}).`;
1685
+ if (input) {
1686
+ requestInput.input += `\n${input}`;
1687
+ }
1688
+ if (parseResult.header) {
1689
+ await this._applyPromptMetadata(parseResult.header, requestInput);
1690
+ }
1691
+ }
1692
+ async _acceptInput(query, options) {
1693
+ if (this.viewModel?.model.requestInProgress.get()) {
1694
+ return;
1695
+ }
1696
+ if (!query && this.input.generating) {
1697
+ const generatingAutoSubmitWindow = 500;
1698
+ const start = Date.now();
1699
+ await this.input.generating;
1700
+ if (Date.now() - start > generatingAutoSubmitWindow) {
1701
+ return;
1702
+ }
1703
+ }
1704
+ while (!this._viewModel && !this._store.isDisposed) {
1705
+ await Event.toPromise(this.onDidChangeViewModel, this._store);
1706
+ }
1707
+ if (!this.viewModel) {
1708
+ return;
1709
+ }
1710
+ this._onDidAcceptInput.fire();
1711
+ this.scrollLock = this.isLockedToCodingAgent || !!checkModeOption(this.input.currentModeKind, this.viewOptions.autoScroll);
1712
+ const editorValue = this.getInput();
1713
+ const requestId = this.chatAccessibilityService.acceptRequest();
1714
+ const requestInputs = {
1715
+ input: !query ? editorValue : query.query,
1716
+ attachedContext: options?.enableImplicitContext === false ? this.input.getAttachedContext(this.viewModel.sessionResource) : this.input.getAttachedAndImplicitContext(this.viewModel.sessionResource),
1717
+ };
1718
+ const isUserQuery = !query;
1719
+ if (this.viewModel?.editing) {
1720
+ this.finishedEditing(true);
1721
+ this.viewModel.model?.setCheckpoint(undefined);
1722
+ }
1723
+ await this._applyPromptFileIfSet(requestInputs);
1724
+ await this._autoAttachInstructions(requestInputs);
1725
+ if (this.viewOptions.enableWorkingSet !== undefined && this.input.currentModeKind === ChatModeKind.Edit && !this.chatService.edits2Enabled) {
1726
+ const uniqueWorkingSetEntries = ( new ResourceSet());
1727
+ const editingSessionAttachedContext = requestInputs.attachedContext;
1728
+ const previousRequests = this.viewModel.model.getRequests();
1729
+ for (const request of previousRequests) {
1730
+ for (const variable of request.variableData.variables) {
1731
+ if (URI.isUri(variable.value) && variable.kind === 'file') {
1732
+ const uri = variable.value;
1733
+ if (!( uniqueWorkingSetEntries.has(uri))) {
1734
+ editingSessionAttachedContext.add(variable);
1735
+ uniqueWorkingSetEntries.add(variable.value);
1736
+ }
1737
+ }
1738
+ }
1739
+ }
1740
+ requestInputs.attachedContext = editingSessionAttachedContext;
1741
+ this.telemetryService.publicLog2('chatEditing/workingSetSize', { originalSize: uniqueWorkingSetEntries.size, actualSize: uniqueWorkingSetEntries.size });
1742
+ }
1743
+ this.chatService.cancelCurrentRequestForSession(this.viewModel.sessionResource);
1744
+ if (this.currentRequest) {
1745
+ await Promise.race([this.currentRequest, timeout(1000)]);
1746
+ }
1747
+ this.input.validateAgentMode();
1748
+ if (this.viewModel.model.checkpoint) {
1749
+ const requests = this.viewModel.model.getRequests();
1750
+ for (let i = requests.length - 1; i >= 0; i -= 1) {
1751
+ const request = requests[i];
1752
+ if (request.shouldBeBlocked) {
1753
+ this.chatService.removeRequest(this.viewModel.sessionResource, request.id);
1754
+ }
1755
+ }
1756
+ }
1757
+ const result = await this.chatService.sendRequest(this.viewModel.sessionResource, requestInputs.input, {
1758
+ userSelectedModelId: this.input.currentLanguageModel,
1759
+ location: this.location,
1760
+ locationData: this._location.resolveData?.(),
1761
+ parserContext: { selectedAgent: this._lastSelectedAgent, mode: this.input.currentModeKind },
1762
+ attachedContext: requestInputs.attachedContext.asArray(),
1763
+ noCommandDetection: options?.noCommandDetection,
1764
+ ...this.getModeRequestOptions(),
1765
+ modeInfo: this.input.currentModeInfo,
1766
+ agentIdSilent: this._lockedAgent?.id,
1767
+ });
1768
+ if (!result) {
1769
+ this.chatAccessibilityService.disposeRequest(requestId);
1770
+ return;
1771
+ }
1772
+ this.updateChatViewVisibility();
1773
+ this.input.acceptInput(isUserQuery);
1774
+ this._onDidSubmitAgent.fire({ agent: result.agent, slashCommand: result.slashCommand });
1775
+ this.handleDelegationExitIfNeeded(this._lockedAgent, result.agent);
1776
+ this.currentRequest = result.responseCompletePromise.then(() => {
1777
+ const responses = this.viewModel?.getItems().filter(isResponseVM);
1778
+ const lastResponse = responses?.[responses.length - 1];
1779
+ this.chatAccessibilityService.acceptResponse(this, this.container, lastResponse, requestId, options?.isVoiceInput);
1780
+ if (lastResponse?.result?.nextQuestion) {
1781
+ const { prompt, participant, command } = lastResponse.result.nextQuestion;
1782
+ const question = formatChatQuestion(this.chatAgentService, this.location, prompt, participant, command);
1783
+ if (question) {
1784
+ this.input.setValue(question, false);
1785
+ }
1786
+ }
1787
+ this.currentRequest = undefined;
1788
+ });
1789
+ return result.responseCreatedPromise;
1790
+ }
1791
+ getModeRequestOptions() {
1792
+ return {
1793
+ modeInfo: this.input.currentModeInfo,
1794
+ userSelectedTools: this.input.selectedToolsModel.userSelectedTools,
1795
+ };
1796
+ }
1797
+ getCodeBlockInfosForResponse(response) {
1798
+ return this.renderer.getCodeBlockInfosForResponse(response);
1799
+ }
1800
+ getCodeBlockInfoForEditor(uri) {
1801
+ return this.renderer.getCodeBlockInfoForEditor(uri);
1802
+ }
1803
+ getFileTreeInfosForResponse(response) {
1804
+ return this.renderer.getFileTreeInfosForResponse(response);
1805
+ }
1806
+ getLastFocusedFileTreeForResponse(response) {
1807
+ return this.renderer.getLastFocusedFileTreeForResponse(response);
1808
+ }
1809
+ focusResponseItem(lastFocused) {
1810
+ if (!this.viewModel) {
1811
+ return;
1812
+ }
1813
+ const items = this.tree.getNode(null).children;
1814
+ let item;
1815
+ if (lastFocused) {
1816
+ item = items[this._mostRecentlyFocusedItemIndex] ?? items[items.length - 1];
1817
+ }
1818
+ else {
1819
+ item = items[items.length - 1];
1820
+ }
1821
+ if (!item) {
1822
+ return;
1823
+ }
1824
+ this.tree.setFocus([item.element]);
1825
+ this.tree.domFocus();
1826
+ }
1827
+ layout(height, width) {
1828
+ width = Math.min(width, this.viewOptions.renderStyle === 'minimal' ? width : 950);
1829
+ const heightUpdated = this.bodyDimension && this.bodyDimension.height !== height;
1830
+ this.bodyDimension = new Dimension(width, height);
1831
+ const layoutHeight = this._dynamicMessageLayoutData?.enabled ? this._dynamicMessageLayoutData.maxHeight : height;
1832
+ if (this.viewModel?.editing) {
1833
+ this.inlineInputPart?.layout(layoutHeight, width);
1834
+ }
1835
+ this.inputPart.layout(layoutHeight, width);
1836
+ const inputHeight = this.inputPart.inputPartHeight;
1837
+ const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;
1838
+ const lastElementVisible = this.tree.scrollTop + this.tree.renderHeight >= this.tree.scrollHeight - 2;
1839
+ const lastItem = this.viewModel?.getItems().at(-1);
1840
+ const contentHeight = Math.max(0, height - inputHeight - chatSuggestNextWidgetHeight);
1841
+ if (this.viewOptions.renderStyle === 'compact' || this.viewOptions.renderStyle === 'minimal') {
1842
+ this.listContainer.style.removeProperty('--chat-current-response-min-height');
1843
+ }
1844
+ else {
1845
+ this.listContainer.style.setProperty('--chat-current-response-min-height', contentHeight * .75 + 'px');
1846
+ if (heightUpdated && lastItem && this.visible && this.tree.hasElement(lastItem)) {
1847
+ this.tree.updateElementHeight(lastItem, undefined);
1848
+ }
1849
+ }
1850
+ this.tree.layout(contentHeight, width);
1851
+ this.welcomeMessageContainer.style.height = `${contentHeight}px`;
1852
+ this.renderer.layout(width);
1853
+ const lastResponseIsRendering = isResponseVM(lastItem) && lastItem.renderData;
1854
+ if (lastElementVisible && (!lastResponseIsRendering || checkModeOption(this.input.currentModeKind, this.viewOptions.autoScroll))) {
1855
+ this.scrollToEnd();
1856
+ }
1857
+ this.listContainer.style.height = `${contentHeight}px`;
1858
+ this._onDidChangeHeight.fire(height);
1859
+ }
1860
+ setDynamicChatTreeItemLayout(numOfChatTreeItems, maxHeight) {
1861
+ this._dynamicMessageLayoutData = { numOfMessages: numOfChatTreeItems, maxHeight, enabled: true };
1862
+ this._register(this.renderer.onDidChangeItemHeight(() => this.layoutDynamicChatTreeItemMode()));
1863
+ const mutableDisposable = this._register(( new MutableDisposable()));
1864
+ this._register(this.tree.onDidScroll((e) => {
1865
+ if (!this._dynamicMessageLayoutData?.enabled) {
1866
+ return;
1867
+ }
1868
+ mutableDisposable.value = scheduleAtNextAnimationFrame(getWindow(this.listContainer), () => {
1869
+ if (!e.scrollTopChanged || e.heightChanged || e.scrollHeightChanged) {
1870
+ return;
1871
+ }
1872
+ const renderHeight = e.height;
1873
+ const diff = e.scrollHeight - renderHeight - e.scrollTop;
1874
+ if (diff === 0) {
1875
+ return;
1876
+ }
1877
+ const possibleMaxHeight = (this._dynamicMessageLayoutData?.maxHeight ?? maxHeight);
1878
+ const width = this.bodyDimension?.width ?? this.container.offsetWidth;
1879
+ this.input.layout(possibleMaxHeight, width);
1880
+ const inputPartHeight = this.input.inputPartHeight;
1881
+ const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;
1882
+ const newHeight = Math.min(renderHeight + diff, possibleMaxHeight - inputPartHeight - chatSuggestNextWidgetHeight);
1883
+ this.layout(newHeight + inputPartHeight + chatSuggestNextWidgetHeight, width);
1884
+ });
1885
+ }));
1886
+ }
1887
+ updateDynamicChatTreeItemLayout(numOfChatTreeItems, maxHeight) {
1888
+ this._dynamicMessageLayoutData = { numOfMessages: numOfChatTreeItems, maxHeight, enabled: true };
1889
+ let hasChanged = false;
1890
+ let height = this.bodyDimension.height;
1891
+ let width = this.bodyDimension.width;
1892
+ if (maxHeight < this.bodyDimension.height) {
1893
+ height = maxHeight;
1894
+ hasChanged = true;
1895
+ }
1896
+ const containerWidth = this.container.offsetWidth;
1897
+ if (this.bodyDimension?.width !== containerWidth) {
1898
+ width = containerWidth;
1899
+ hasChanged = true;
1900
+ }
1901
+ if (hasChanged) {
1902
+ this.layout(height, width);
1903
+ }
1904
+ }
1905
+ get isDynamicChatTreeItemLayoutEnabled() {
1906
+ return this._dynamicMessageLayoutData?.enabled ?? false;
1907
+ }
1908
+ set isDynamicChatTreeItemLayoutEnabled(value) {
1909
+ if (!this._dynamicMessageLayoutData) {
1910
+ return;
1911
+ }
1912
+ this._dynamicMessageLayoutData.enabled = value;
1913
+ }
1914
+ layoutDynamicChatTreeItemMode() {
1915
+ if (!this.viewModel || !this._dynamicMessageLayoutData?.enabled) {
1916
+ return;
1917
+ }
1918
+ const width = this.bodyDimension?.width ?? this.container.offsetWidth;
1919
+ this.input.layout(this._dynamicMessageLayoutData.maxHeight, width);
1920
+ const inputHeight = this.input.inputPartHeight;
1921
+ const chatSuggestNextWidgetHeight = this.chatSuggestNextWidget.height;
1922
+ const totalMessages = this.viewModel.getItems();
1923
+ const messages = totalMessages.slice(-this._dynamicMessageLayoutData.numOfMessages);
1924
+ const needsRerender = ( messages.some(m => m.currentRenderedHeight === undefined));
1925
+ const listHeight = needsRerender
1926
+ ? this._dynamicMessageLayoutData.maxHeight
1927
+ : messages.reduce((acc, message) => acc + message.currentRenderedHeight, 0);
1928
+ this.layout(Math.min(
1929
+ inputHeight + chatSuggestNextWidgetHeight + listHeight + (totalMessages.length > 2 ? 18 : 0), this._dynamicMessageLayoutData.maxHeight), width);
1930
+ if (needsRerender || !listHeight) {
1931
+ this.scrollToEnd();
1932
+ }
1933
+ }
1934
+ saveState() {
1935
+ }
1936
+ getViewState() {
1937
+ return this.input.getCurrentInputState();
1938
+ }
1939
+ updateChatInputContext() {
1940
+ const currentAgent = this.parsedInput.parts.find(part => part instanceof ChatRequestAgentPart);
1941
+ this.agentInInput.set(!!currentAgent);
1942
+ }
1943
+ async _switchToAgentByName(agentName) {
1944
+ const currentAgent = this.input.currentModeObs.get();
1945
+ if (agentName !== currentAgent.name.get()) {
1946
+ const agent = this.chatModeService.findModeByName(agentName);
1947
+ if (agent) {
1948
+ if (currentAgent.kind !== agent.kind) {
1949
+ const chatModeCheck = await this.instantiationService.invokeFunction(handleModeSwitch, currentAgent.kind, agent.kind, this.viewModel?.model.getRequests().length ?? 0, this.viewModel?.model);
1950
+ if (!chatModeCheck) {
1951
+ return;
1952
+ }
1953
+ if (chatModeCheck.needToClearSession) {
1954
+ await this.clear();
1955
+ }
1956
+ }
1957
+ this.input.setChatMode(agent.id);
1958
+ }
1959
+ }
1960
+ }
1961
+ async _applyPromptMetadata({ agent, tools, model }, requestInput) {
1962
+ if (tools !== undefined && !agent && this.input.currentModeKind !== ChatModeKind.Agent) {
1963
+ agent = ChatMode.Agent.name.get();
1964
+ }
1965
+ if (agent) {
1966
+ this._switchToAgentByName(agent);
1967
+ }
1968
+ if (tools !== undefined && this.input.currentModeKind === ChatModeKind.Agent) {
1969
+ const enablementMap = this.toolsService.toToolAndToolSetEnablementMap(tools, Target.VSCode);
1970
+ this.input.selectedToolsModel.set(enablementMap, true);
1971
+ }
1972
+ if (model !== undefined) {
1973
+ this.input.switchModelByQualifiedName(model);
1974
+ }
1975
+ }
1976
+ async _autoAttachInstructions({ attachedContext }) {
1977
+ this.logService.debug(`ChatWidget#_autoAttachInstructions: prompt files are always enabled`);
1978
+ const enabledTools = this.input.currentModeKind === ChatModeKind.Agent ? this.input.selectedToolsModel.entriesMap.get() : undefined;
1979
+ const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, enabledTools);
1980
+ await computer.collect(attachedContext, CancellationToken.None);
1981
+ }
1982
+ delegateScrollFromMouseWheelEvent(browserEvent) {
1983
+ this.tree.delegateScrollFromMouseWheelEvent(browserEvent);
1984
+ }
1985
+ };
1986
+ ChatWidget = ChatWidget_1 = ( __decorate([
1987
+ ( __param(4, ICodeEditorService)),
1988
+ ( __param(5, IEditorService)),
1989
+ ( __param(6, IConfigurationService)),
1990
+ ( __param(7, IContextKeyService)),
1991
+ ( __param(8, IInstantiationService)),
1992
+ ( __param(9, IChatService)),
1993
+ ( __param(10, IChatAgentService)),
1994
+ ( __param(11, IChatWidgetService)),
1995
+ ( __param(12, IContextMenuService)),
1996
+ ( __param(13, IChatAccessibilityService)),
1997
+ ( __param(14, ILogService)),
1998
+ ( __param(15, IThemeService)),
1999
+ ( __param(16, IChatSlashCommandService)),
2000
+ ( __param(17, IChatEditingService)),
2001
+ ( __param(18, ITelemetryService)),
2002
+ ( __param(19, IPromptsService)),
2003
+ ( __param(20, ILanguageModelToolsService)),
2004
+ ( __param(21, IChatModeService)),
2005
+ ( __param(22, IChatLayoutService)),
2006
+ ( __param(23, IChatEntitlementService)),
2007
+ ( __param(24, IChatSessionsService)),
2008
+ ( __param(25, IAgentSessionsService)),
2009
+ ( __param(26, IChatTodoListService)),
2010
+ ( __param(27, IWorkspaceContextService)),
2011
+ ( __param(28, ILifecycleService))
2012
+ ], ChatWidget));
2013
+
2014
+ export { ChatWidget, isQuickChat };