@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,2008 @@
1
+
2
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
+ import { $ as $$1, clearNode, h, append, addStandardDisposableListener, EventType, setVisibility, isKeyboardEvent, getActiveElement, getWindow, addDisposableListener, createElement, Dimension, getTotalWidth, reset } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
4
+ import { DEFAULT_FONT_FAMILY } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/fonts';
5
+ import { hasModifierKeys } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/keyboardEvent';
6
+ import { ActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems';
7
+ import { status } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/aria/aria';
8
+ import { ButtonWithIcon, Button } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/button/button';
9
+ import { createInstantHoverDelegate, getDefaultHoverDelegate } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
10
+ import { renderLabelWithIcons } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/iconLabel/iconLabels';
11
+ import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/arrays';
12
+ import { RunOnceScheduler, DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
13
+ import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
14
+ import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
15
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
16
+ import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
17
+ import { KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
18
+ import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
19
+ import { Disposable, MutableDisposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
20
+ import { ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
21
+ import { MarshalledId } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshallingIds';
22
+ import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
23
+ import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
24
+ import { isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
25
+ import { isEqual } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
26
+ import { ScrollbarVisibility } from '@codingame/monaco-vscode-api/vscode/vs/base/common/scrollable';
27
+ import { assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
28
+ import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
29
+ import { EditorExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/editorExtensions';
30
+ import { CodeEditorWidget } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/codeEditor/codeEditorWidget';
31
+ import { EditorOptions } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/config/editorOptions';
32
+ import { isLocation } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
33
+ import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
34
+ import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
35
+ import { CopyPasteController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
36
+ import { DropIntoEditorController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
37
+ import { ContentHoverController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/hover/browser/contentHoverController';
38
+ import { GlyphHoverController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/hover/browser/glyphHoverController';
39
+ import { LinkDetector } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/links/browser/links';
40
+ import { SuggestController } from '@codingame/monaco-vscode-api/vscode/vs/editor/contrib/suggest/browser/suggestController';
41
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
42
+ import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility.service';
43
+ import { MenuWorkbenchButtonBar } from '../../../../platform/actions/browser/buttonbar.js';
44
+ import { MenuWorkbenchToolBar, HiddenItemStrategy } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/toolbar';
45
+ import { MenuId, MenuItemAction } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
46
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
47
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
48
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
49
+ import { registerAndCreateHistoryNavigationContext } from '@codingame/monaco-vscode-api/vscode/vs/platform/history/browser/contextScopedHistoryWidget';
50
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
51
+ import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
52
+ import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
53
+ import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
54
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
55
+ import { observableMemento } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/observableMemento';
56
+ import { bindContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/observable/common/platformObservableUtils';
57
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
58
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
59
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
60
+ import { ISharedWebContentExtractorService } from '@codingame/monaco-vscode-api/vscode/vs/platform/webContentExtractor/common/webContentExtractor.service';
61
+ import { ResourceLabels } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/labels';
62
+ import { IWorkbenchAssignmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service';
63
+ import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
64
+ import { SIDE_GROUP, ACTIVE_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
65
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
66
+ import { AccessibilityVerbositySettingId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
67
+ import { AccessibilityCommandId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/common/accessibilityCommands';
68
+ import { getSimpleEditorOptions, getSimpleCodeEditorWidgetOptions, setupSimpleEditorSelectionStyling } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
69
+ import { InlineChatConfigKeys } from '../../inlineChat/common/inlineChat.js';
70
+ import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
71
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
72
+ import { ModifiedFileEntryState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEditingService';
73
+ import { ChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes';
74
+ import { IChatModeService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModes.service';
75
+ import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
76
+ import { localChatSessionType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService';
77
+ import { IChatSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatSessionsService.service';
78
+ import { getChatSessionType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatUri';
79
+ import { ChatRequestVariableSet, isImageVariableEntry, isNotebookOutputVariableEntry, isPromptFileVariableEntry, isPromptTextVariableEntry, isElementVariableEntry, isPasteVariableEntry, isSCMHistoryItemVariableEntry, isSCMHistoryItemChangeVariableEntry, isSCMHistoryItemChangeRangeVariableEntry, isStringVariableEntry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatVariableEntries';
80
+ import { ChatHistoryNavigator } from '../common/chatWidgetHistoryService.js';
81
+ import { ChatModeKind, ChatConfiguration, validateChatMode, ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
82
+ import { ILanguageModelChatMetadata } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels';
83
+ import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
84
+ import { ILanguageModelToolsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModelToolsService.service';
85
+ import { ContinueChatInSessionAction, ChatContinueInSessionActionItem, ActionLocation } from './actions/chatContinueInAction.js';
86
+ import { ChatSubmitAction, ChatOpenModelPickerActionId, OpenModePickerAction, ChatSessionPrimaryPickerAction } from './actions/chatExecuteActions.js';
87
+ import { IAgentSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.service';
88
+ import { ImplicitContextAttachmentWidget } from './attachments/implicitContextAttachment.js';
89
+ import { ChatAttachmentModel } from './chatAttachmentModel.js';
90
+ import { ToolSetOrToolItemAttachmentWidget, NotebookCellOutputChatAttachmentWidget, PromptFileAttachmentWidget, PromptTextAttachmentWidget, FileAttachmentWidget, TerminalCommandAttachmentWidget, ImageAttachmentWidget, ElementChatAttachmentWidget, PasteAttachmentWidget, SCMHistoryItemAttachmentWidget, SCMHistoryItemChangeAttachmentWidget, SCMHistoryItemChangeRangeAttachmentWidget, DefaultChatAttachmentWidget } from './chatAttachmentWidgets.js';
91
+ import { CollapsibleListPool } from './chatContentParts/chatReferencesContentPart.js';
92
+ import { ChatTodoListWidget } from './chatContentParts/chatTodoListWidget.js';
93
+ import { IChatContextService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatContextService.service';
94
+ import { ChatDragAndDrop } from './chatDragAndDrop.js';
95
+ import { ChatEditingShowChangesAction, ViewPreviousEditsAction, ViewAllSessionChangesAction } from './chatEditing/chatEditingActions.js';
96
+ import { ChatFollowups } from './chatFollowups.js';
97
+ import { ChatInputPartWidgetController } from './chatInputPartWidgets.js';
98
+ import { ChatSelectedTools } from './chatSelectedTools.js';
99
+ import { ChatSessionPickerActionItem } from './chatSessions/chatSessionPickerActionItem.js';
100
+ import { ChatImplicitContext } from './contrib/chatImplicitContext.js';
101
+ import { ChatRelatedFiles } from './contrib/chatInputRelatedFilesContrib.js';
102
+ import { resizeImage } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/imageUtils';
103
+ import { ModelPickerActionItem } from './modelPicker/modelPickerActionItem.js';
104
+ import { ModePickerActionItem } from './modelPicker/modePickerActionItem.js';
105
+ import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
106
+ import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
107
+ import { derivedOpts, derived } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/derived';
108
+ import { observableFromEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableFromEvent';
109
+
110
+ var ChatInputPart_1;
111
+ const $ = $$1;
112
+ const INPUT_EDITOR_MAX_HEIGHT = 250;
113
+ const emptyInputState = observableMemento({
114
+ defaultValue: undefined,
115
+ key: 'chat.untitledInputState',
116
+ toStorage: JSON.stringify,
117
+ fromStorage: JSON.parse,
118
+ });
119
+ let ChatInputPart = class ChatInputPart extends Disposable {
120
+ static { ChatInputPart_1 = this; }
121
+ static { this._counter = 0; }
122
+ get attachmentModel() {
123
+ return this._attachmentModel;
124
+ }
125
+ getAttachedContext(sessionResource) {
126
+ const contextArr = ( new ChatRequestVariableSet());
127
+ contextArr.add(...this.attachmentModel.attachments, ...this.chatContextService.getWorkspaceContextItems());
128
+ return contextArr;
129
+ }
130
+ getAttachedAndImplicitContext(sessionResource) {
131
+ const contextArr = this.getAttachedContext(sessionResource);
132
+ if ((this.implicitContext?.enabled && this.implicitContext?.value) || (this.implicitContext && !URI.isUri(this.implicitContext.value) && this.configurationService.getValue('chat.implicitContext.suggestedContext'))) {
133
+ const implicitChatVariables = this.implicitContext.toBaseEntries();
134
+ contextArr.add(...implicitChatVariables);
135
+ }
136
+ return contextArr;
137
+ }
138
+ get implicitContext() {
139
+ return this._implicitContext;
140
+ }
141
+ get relatedFiles() {
142
+ return this._relatedFiles;
143
+ }
144
+ get inputPartHeight() {
145
+ return this._inputPartHeight;
146
+ }
147
+ get followupsHeight() {
148
+ return this._followupsHeight;
149
+ }
150
+ get editSessionWidgetHeight() {
151
+ return this._editSessionWidgetHeight;
152
+ }
153
+ get todoListWidgetHeight() {
154
+ return this.chatInputTodoListWidgetContainer.offsetHeight;
155
+ }
156
+ get inputWidgetsHeight() {
157
+ return this.chatInputWidgetsContainer?.offsetHeight ?? 0;
158
+ }
159
+ get attachmentsHeight() {
160
+ return this.attachmentsContainer.offsetHeight + (this.attachmentsContainer.checkVisibility() ? 6 : 0);
161
+ }
162
+ get inputEditor() {
163
+ return this._inputEditor;
164
+ }
165
+ get currentLanguageModel() {
166
+ return this._currentLanguageModel?.identifier;
167
+ }
168
+ get selectedLanguageModel() {
169
+ return this._currentLanguageModel;
170
+ }
171
+ get currentModeKind() {
172
+ const mode = this._currentModeObservable.get();
173
+ return mode.kind === ChatModeKind.Agent && !this.agentService.hasToolsAgent ?
174
+ ChatModeKind.Edit :
175
+ mode.kind;
176
+ }
177
+ get currentModeObs() {
178
+ return this._currentModeObservable;
179
+ }
180
+ get currentModeInfo() {
181
+ const mode = this._currentModeObservable.get();
182
+ const modeId = mode.isBuiltin ? this.currentModeKind : 'custom';
183
+ const modeInstructions = mode.modeInstructions?.get();
184
+ return {
185
+ kind: this.currentModeKind,
186
+ isBuiltin: mode.isBuiltin,
187
+ modeInstructions: modeInstructions ? {
188
+ name: mode.name.get(),
189
+ content: modeInstructions.content,
190
+ toolReferences: this.toolService.toToolReferences(modeInstructions.toolReferences),
191
+ metadata: modeInstructions.metadata,
192
+ } : undefined,
193
+ modeId: modeId,
194
+ applyCodeBlockSuggestionId: undefined,
195
+ };
196
+ }
197
+ get selectedElements() {
198
+ const edits = [];
199
+ const editsList = this._chatEditList?.object;
200
+ const selectedElements = editsList?.getSelectedElements() ?? [];
201
+ for (const element of selectedElements) {
202
+ if (element.kind === 'reference' && URI.isUri(element.reference)) {
203
+ edits.push(element.reference);
204
+ }
205
+ }
206
+ return edits;
207
+ }
208
+ get attemptedWorkingSetEntriesCount() {
209
+ return this._attemptedWorkingSetEntriesCount;
210
+ }
211
+ constructor(
212
+ location, options, styles, inline, modelService, instantiationService, contextKeyService, configurationService, keybindingService, accessibilityService, languageModelsService, logService, fileService, editorService, themeService, textModelResolverService, storageService, labelService, agentService, sharedWebExtracterService, experimentService, entitlementService, chatModeService, toolService, chatService, chatSessionsService, chatContextService, agentSessionsService) {
213
+ super();
214
+ this.location = location;
215
+ this.options = options;
216
+ this.inline = inline;
217
+ this.modelService = modelService;
218
+ this.instantiationService = instantiationService;
219
+ this.contextKeyService = contextKeyService;
220
+ this.configurationService = configurationService;
221
+ this.keybindingService = keybindingService;
222
+ this.accessibilityService = accessibilityService;
223
+ this.languageModelsService = languageModelsService;
224
+ this.logService = logService;
225
+ this.fileService = fileService;
226
+ this.editorService = editorService;
227
+ this.themeService = themeService;
228
+ this.textModelResolverService = textModelResolverService;
229
+ this.storageService = storageService;
230
+ this.labelService = labelService;
231
+ this.agentService = agentService;
232
+ this.sharedWebExtracterService = sharedWebExtracterService;
233
+ this.experimentService = experimentService;
234
+ this.entitlementService = entitlementService;
235
+ this.chatModeService = chatModeService;
236
+ this.toolService = toolService;
237
+ this.chatService = chatService;
238
+ this.chatSessionsService = chatSessionsService;
239
+ this.chatContextService = chatContextService;
240
+ this.agentSessionsService = agentSessionsService;
241
+ this._workingSetCollapsed = observableValue('chatInputPart.workingSetCollapsed', true);
242
+ this._chatInputTodoListWidget = this._register(( new MutableDisposable()));
243
+ this._chatEditingTodosDisposables = this._register(( new DisposableStore()));
244
+ this._onDidLoadInputState = this._register(( new Emitter()));
245
+ this.onDidLoadInputState = this._onDidLoadInputState.event;
246
+ this._onDidChangeHeight = this._register(( new Emitter()));
247
+ this.onDidChangeHeight = this._onDidChangeHeight.event;
248
+ this._onDidFocus = this._register(( new Emitter()));
249
+ this.onDidFocus = this._onDidFocus.event;
250
+ this._onDidBlur = this._register(( new Emitter()));
251
+ this.onDidBlur = this._onDidBlur.event;
252
+ this._onDidChangeContext = this._register(( new Emitter()));
253
+ this.onDidChangeContext = this._onDidChangeContext.event;
254
+ this._onDidAcceptFollowup = this._register(( new Emitter()));
255
+ this.onDidAcceptFollowup = this._onDidAcceptFollowup.event;
256
+ this._onDidClickOverlay = this._register(( new Emitter()));
257
+ this.onDidClickOverlay = this._onDidClickOverlay.event;
258
+ this._indexOfLastAttachedContextDeletedWithKeyboard = -1;
259
+ this._indexOfLastOpenedContext = -1;
260
+ this._onDidChangeVisibility = this._register(( new Emitter()));
261
+ this.inputEditorHeight = 0;
262
+ this.followupsDisposables = this._register(( new DisposableStore()));
263
+ this.overlayClickListener = this._register(( new MutableDisposable()));
264
+ this.attachedContextDisposables = this._register(( new MutableDisposable()));
265
+ this._widgetController = this._register(( new MutableDisposable()));
266
+ this._inputPartHeight = 0;
267
+ this._followupsHeight = 0;
268
+ this._editSessionWidgetHeight = 0;
269
+ this._modelSyncDisposables = this._register(( new DisposableStore()));
270
+ this._isSyncingToOrFromInputModel = false;
271
+ this.chatSessionPickerWidgets = ( new Map());
272
+ this._waitForPersistedLanguageModel = this._register(( new MutableDisposable()));
273
+ this._onDidChangeCurrentLanguageModel = this._register(( new Emitter()));
274
+ this._chatSessionOptionEmitters = ( new Map());
275
+ this._onDidChangeCurrentChatMode = this._register(( new Emitter()));
276
+ this.onDidChangeCurrentChatMode = this._onDidChangeCurrentChatMode.event;
277
+ this.inputUri = ( URI.parse(`${Schemas.vscodeChatInput}:input-${ChatInputPart_1._counter++}`));
278
+ this._workingSetLinesAddedSpan = ( new Lazy(() => $$1('.working-set-lines-added')));
279
+ this._workingSetLinesRemovedSpan = ( new Lazy(() => $$1('.working-set-lines-removed')));
280
+ this._chatEditsActionsDisposables = this._register(( new DisposableStore()));
281
+ this._chatEditsDisposables = this._register(( new DisposableStore()));
282
+ this._renderingChatEdits = this._register(( new MutableDisposable()));
283
+ this._attemptedWorkingSetEntriesCount = 0;
284
+ this._chatSessionIsEmpty = false;
285
+ this._syncTextDebounced = this._register(( new RunOnceScheduler(() => this._syncInputStateToModel(), 150)));
286
+ this._emptyInputState = this._register(emptyInputState(StorageScope.WORKSPACE, StorageTarget.USER, this.storageService));
287
+ this._contextResourceLabels = this._register(this.instantiationService.createInstance(ResourceLabels, { onDidChangeVisibility: this._onDidChangeVisibility.event }));
288
+ this._currentModeObservable = observableValue('currentMode', this.options.defaultMode ?? ChatMode.Agent);
289
+ this._register(this.editorService.onDidActiveEditorChange(() => {
290
+ this._indexOfLastOpenedContext = -1;
291
+ this.refreshChatSessionPickers();
292
+ }));
293
+ this._register(this.chatSessionsService.onDidChangeSessionOptions(e => {
294
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
295
+ if (sessionResource && isEqual(sessionResource, e)) {
296
+ this.refreshChatSessionPickers();
297
+ }
298
+ }));
299
+ this._register(this.chatSessionsService.onDidChangeOptionGroups(chatSessionType => {
300
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
301
+ if (sessionResource) {
302
+ const ctx = this.chatService.getChatSessionFromInternalUri(sessionResource);
303
+ if (ctx?.chatSessionType === chatSessionType) {
304
+ this.refreshChatSessionPickers();
305
+ }
306
+ }
307
+ }));
308
+ this._attachmentModel = this._register(this.instantiationService.createInstance(ChatAttachmentModel));
309
+ this._register(this._attachmentModel.onDidChange(() => this._syncInputStateToModel()));
310
+ this.selectedToolsModel = this._register(this.instantiationService.createInstance(ChatSelectedTools, this.currentModeObs));
311
+ this.dnd = this._register(this.instantiationService.createInstance(ChatDragAndDrop, () => this._widget, this._attachmentModel, styles));
312
+ this.inputEditorMaxHeight = this.options.renderStyle === 'compact' ? INPUT_EDITOR_MAX_HEIGHT / 3 : INPUT_EDITOR_MAX_HEIGHT;
313
+ this.inputEditorHasText = ChatContextKeys.inputHasText.bindTo(contextKeyService);
314
+ this.chatCursorAtTop = ChatContextKeys.inputCursorAtTop.bindTo(contextKeyService);
315
+ this.inputEditorHasFocus = ChatContextKeys.inputHasFocus.bindTo(contextKeyService);
316
+ this.chatModeKindKey = ChatContextKeys.chatModeKind.bindTo(contextKeyService);
317
+ this.withinEditSessionKey = ChatContextKeys.withinEditSessionDiff.bindTo(contextKeyService);
318
+ this.filePartOfEditSessionKey = ChatContextKeys.filePartOfEditSession.bindTo(contextKeyService);
319
+ this.chatSessionHasOptions = ChatContextKeys.chatSessionHasModels.bindTo(contextKeyService);
320
+ const chatToolCount = ChatContextKeys.chatToolCount.bindTo(contextKeyService);
321
+ this._register(autorun(reader => {
322
+ let count = 0;
323
+ const userSelectedTools = this.selectedToolsModel.userSelectedTools.read(reader);
324
+ for (const key in userSelectedTools) {
325
+ if (userSelectedTools[key] === true) {
326
+ count++;
327
+ }
328
+ }
329
+ chatToolCount.set(count);
330
+ }));
331
+ this.history = this._register(this.instantiationService.createInstance(ChatHistoryNavigator, this.location));
332
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
333
+ const newOptions = {};
334
+ if (e.affectsConfiguration(AccessibilityVerbositySettingId.Chat)) {
335
+ newOptions.ariaLabel = this._getAriaLabel();
336
+ }
337
+ if (e.affectsConfiguration('editor.wordSegmenterLocales')) {
338
+ newOptions.wordSegmenterLocales = this.configurationService.getValue('editor.wordSegmenterLocales');
339
+ }
340
+ if (e.affectsConfiguration('editor.autoClosingBrackets')) {
341
+ newOptions.autoClosingBrackets = this.configurationService.getValue('editor.autoClosingBrackets');
342
+ }
343
+ if (e.affectsConfiguration('editor.autoClosingQuotes')) {
344
+ newOptions.autoClosingQuotes = this.configurationService.getValue('editor.autoClosingQuotes');
345
+ }
346
+ if (e.affectsConfiguration('editor.autoSurround')) {
347
+ newOptions.autoSurround = this.configurationService.getValue('editor.autoSurround');
348
+ }
349
+ this.inputEditor.updateOptions(newOptions);
350
+ }));
351
+ this._chatEditsListPool = this._register(this.instantiationService.createInstance(CollapsibleListPool, this._onDidChangeVisibility.event, MenuId.ChatEditingWidgetModifiedFilesToolbar, { verticalScrollMode: ScrollbarVisibility.Visible }));
352
+ this._hasFileAttachmentContextKey = ChatContextKeys.hasFileAttachments.bindTo(contextKeyService);
353
+ this.initSelectedModel();
354
+ this._register(this.languageModelsService.onDidChangeLanguageModels((vendor) => {
355
+ this.storageService.store('chat.cachedLanguageModels', this.storageService.getObject('chat.cachedLanguageModels', StorageScope.APPLICATION, []).filter(m => !m.identifier.startsWith(vendor)), StorageScope.APPLICATION, StorageTarget.MACHINE);
356
+ const selectedModel = this._currentLanguageModel ? this.getModels().find(m => m.identifier === this._currentLanguageModel?.identifier) : undefined;
357
+ const selectedModelNotAvailable = this._currentLanguageModel && (!selectedModel?.metadata.isUserSelectable);
358
+ if (!this.currentLanguageModel || selectedModelNotAvailable) {
359
+ this.setCurrentLanguageModelToDefault();
360
+ }
361
+ }));
362
+ this._register(this.onDidChangeCurrentChatMode(() => {
363
+ this.accessibilityService.alert(this._currentModeObservable.get().label.get());
364
+ if (this._inputEditor) {
365
+ this._inputEditor.updateOptions({ ariaLabel: this._getAriaLabel() });
366
+ }
367
+ this.setImplicitContextEnablement();
368
+ }));
369
+ this._register(this._onDidChangeCurrentLanguageModel.event(() => {
370
+ if (this._currentLanguageModel?.metadata.name) {
371
+ this.accessibilityService.alert(this._currentLanguageModel.metadata.name);
372
+ }
373
+ this._inputEditor?.updateOptions({ ariaLabel: this._getAriaLabel() });
374
+ }));
375
+ this._register(this.chatModeService.onDidChangeChatModes(() => this.validateCurrentChatMode()));
376
+ this._register(autorun(r => {
377
+ const mode = this._currentModeObservable.read(r);
378
+ this.chatModeKindKey.set(mode.kind);
379
+ const model = mode.model?.read(r);
380
+ if (model) {
381
+ this.switchModelByQualifiedName(model);
382
+ }
383
+ }));
384
+ this.validateCurrentChatMode();
385
+ }
386
+ setImplicitContextEnablement() {
387
+ if (this.implicitContext && this.configurationService.getValue('chat.implicitContext.suggestedContext')) {
388
+ this.implicitContext.enabled = this._currentModeObservable.get().kind !== ChatMode.Agent.kind;
389
+ }
390
+ }
391
+ setIsWithinEditSession(inInsideDiff, isFilePartOfEditSession) {
392
+ this.withinEditSessionKey.set(inInsideDiff);
393
+ this.filePartOfEditSessionKey.set(isFilePartOfEditSession);
394
+ }
395
+ getSelectedModelStorageKey() {
396
+ return `chat.currentLanguageModel.${this.location}`;
397
+ }
398
+ getSelectedModelIsDefaultStorageKey() {
399
+ return `chat.currentLanguageModel.${this.location}.isDefault`;
400
+ }
401
+ initSelectedModel() {
402
+ const persistedSelection = this.storageService.get(this.getSelectedModelStorageKey(), StorageScope.APPLICATION);
403
+ const persistedAsDefault = this.storageService.getBoolean(this.getSelectedModelIsDefaultStorageKey(), StorageScope.APPLICATION, persistedSelection === 'copilot/gpt-4.1');
404
+ if (persistedSelection) {
405
+ const model = this.getModels().find(m => m.identifier === persistedSelection);
406
+ if (model) {
407
+ if (!persistedAsDefault || model.metadata.isDefault) {
408
+ this.setCurrentLanguageModel(model);
409
+ this.checkModelSupported();
410
+ }
411
+ }
412
+ else {
413
+ this._waitForPersistedLanguageModel.value = this.languageModelsService.onDidChangeLanguageModels(e => {
414
+ const persistedModel = this.languageModelsService.lookupLanguageModel(persistedSelection);
415
+ if (persistedModel) {
416
+ this._waitForPersistedLanguageModel.clear();
417
+ if (!persistedAsDefault || persistedModel.isDefault) {
418
+ if (persistedModel.isUserSelectable) {
419
+ this.setCurrentLanguageModel({ metadata: persistedModel, identifier: persistedSelection });
420
+ this.checkModelSupported();
421
+ }
422
+ }
423
+ }
424
+ else {
425
+ this.setCurrentLanguageModelToDefault();
426
+ }
427
+ });
428
+ }
429
+ }
430
+ this._register(this._onDidChangeCurrentChatMode.event(() => {
431
+ this.checkModelSupported();
432
+ }));
433
+ this._register(this.configurationService.onDidChangeConfiguration(e => {
434
+ if (e.affectsConfiguration(ChatConfiguration.Edits2Enabled)) {
435
+ this.checkModelSupported();
436
+ }
437
+ }));
438
+ }
439
+ setEditing(enabled) {
440
+ this.currentlyEditingInputKey?.set(enabled);
441
+ }
442
+ switchModel(modelMetadata) {
443
+ const models = this.getModels();
444
+ const model = models.find(m => m.metadata.vendor === modelMetadata.vendor && m.metadata.id === modelMetadata.id && m.metadata.family === modelMetadata.family);
445
+ if (model) {
446
+ this.setCurrentLanguageModel(model);
447
+ }
448
+ }
449
+ switchModelByQualifiedName(qualifiedModelName) {
450
+ const models = this.getModels();
451
+ const model = models.find(m => ILanguageModelChatMetadata.matchesQualifiedName(qualifiedModelName, m.metadata));
452
+ if (model) {
453
+ this.setCurrentLanguageModel(model);
454
+ return true;
455
+ }
456
+ return false;
457
+ }
458
+ switchToNextModel() {
459
+ const models = this.getModels();
460
+ if (models.length > 0) {
461
+ const currentIndex = models.findIndex(model => model.identifier === this._currentLanguageModel?.identifier);
462
+ const nextIndex = (currentIndex + 1) % models.length;
463
+ this.setCurrentLanguageModel(models[nextIndex]);
464
+ }
465
+ }
466
+ openModelPicker() {
467
+ this.modelWidget?.show();
468
+ }
469
+ openModePicker() {
470
+ this.modeWidget?.show();
471
+ }
472
+ openChatSessionPicker() {
473
+ const firstWidget = this.chatSessionPickerWidgets?.values()?.next().value;
474
+ firstWidget?.show();
475
+ }
476
+ createChatSessionPickerWidgets(action) {
477
+ this._lastSessionPickerAction = action;
478
+ const resolveChatSessionContext = () => {
479
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
480
+ if (!sessionResource) {
481
+ return undefined;
482
+ }
483
+ return this.chatService.getChatSessionFromInternalUri(sessionResource);
484
+ };
485
+ const ctx = resolveChatSessionContext();
486
+ const optionGroups = ctx ? this.chatSessionsService.getOptionGroupsForSessionType(ctx.chatSessionType) : undefined;
487
+ if (!optionGroups || optionGroups.length === 0) {
488
+ return [];
489
+ }
490
+ this.disposeSessionPickerWidgets();
491
+ const widgets = [];
492
+ for (const optionGroup of optionGroups) {
493
+ if (!ctx) {
494
+ continue;
495
+ }
496
+ if (!this.chatSessionsService.getSessionOption(ctx.chatSessionResource, optionGroup.id)) {
497
+ continue;
498
+ }
499
+ const initialItem = this.getCurrentOptionForGroup(optionGroup.id);
500
+ const initialState = { group: optionGroup, item: initialItem };
501
+ const itemDelegate = {
502
+ getCurrentOption: () => this.getCurrentOptionForGroup(optionGroup.id),
503
+ onDidChangeOption: this.getOrCreateOptionEmitter(optionGroup.id).event,
504
+ setOption: (option) => {
505
+ const ctx = resolveChatSessionContext();
506
+ if (!ctx) {
507
+ return;
508
+ }
509
+ this.getOrCreateOptionEmitter(optionGroup.id).fire(option);
510
+ this.chatSessionsService.notifySessionOptionsChange(ctx.chatSessionResource, [{ optionId: optionGroup.id, value: option }]).catch(err => this.logService.error(`Failed to notify extension of ${optionGroup.id} change:`, err));
511
+ },
512
+ getAllOptions: () => {
513
+ const ctx = resolveChatSessionContext();
514
+ if (!ctx) {
515
+ return [];
516
+ }
517
+ const groups = this.chatSessionsService.getOptionGroupsForSessionType(ctx.chatSessionType);
518
+ const group = groups?.find(g => g.id === optionGroup.id);
519
+ return group?.items ?? [];
520
+ }
521
+ };
522
+ const widget = this.instantiationService.createInstance(ChatSessionPickerActionItem, action, initialState, itemDelegate);
523
+ this.chatSessionPickerWidgets.set(optionGroup.id, widget);
524
+ widgets.push(widget);
525
+ }
526
+ return widgets;
527
+ }
528
+ setInputModel(model, chatSessionIsEmpty) {
529
+ this._inputModel = model;
530
+ this._modelSyncDisposables.clear();
531
+ this.selectedToolsModel.resetSessionEnablementState();
532
+ this._chatSessionIsEmpty = chatSessionIsEmpty;
533
+ if (chatSessionIsEmpty) {
534
+ this._setEmptyModelState();
535
+ }
536
+ this._modelSyncDisposables.add(autorun(reader => {
537
+ let state = model.state.read(reader);
538
+ if (!state && this._chatSessionIsEmpty) {
539
+ state = this._emptyInputState.read(undefined);
540
+ }
541
+ this._syncFromModel(state);
542
+ }));
543
+ }
544
+ _setEmptyModelState() {
545
+ const storageKey = this.getDefaultModeExperimentStorageKey();
546
+ const hasSetDefaultMode = this.storageService.getBoolean(storageKey, StorageScope.WORKSPACE, false);
547
+ if (!hasSetDefaultMode) {
548
+ const isAnonymous = this.entitlementService.anonymous;
549
+ this.experimentService.getTreatment('chat.defaultMode')
550
+ .then((defaultModeTreatment => {
551
+ if (isAnonymous) {
552
+ defaultModeTreatment = ChatModeKind.Agent;
553
+ }
554
+ if (typeof defaultModeTreatment === 'string') {
555
+ this.storageService.store(storageKey, true, StorageScope.WORKSPACE, StorageTarget.MACHINE);
556
+ const defaultMode = validateChatMode(defaultModeTreatment);
557
+ if (defaultMode) {
558
+ this.logService.trace(`Applying default mode from experiment: ${defaultMode}`);
559
+ this.setChatMode(defaultMode, false);
560
+ this.checkModelSupported();
561
+ }
562
+ }
563
+ }));
564
+ }
565
+ }
566
+ _syncFromModel(state) {
567
+ if (this._isSyncingToOrFromInputModel) {
568
+ return;
569
+ }
570
+ try {
571
+ this._isSyncingToOrFromInputModel = true;
572
+ if (state) {
573
+ const currentMode = this._currentModeObservable.get();
574
+ if (currentMode.id !== state.mode.id) {
575
+ this.setChatMode(state.mode.id, false);
576
+ }
577
+ }
578
+ if (state?.selectedModel) {
579
+ if (!this._currentLanguageModel || this._currentLanguageModel.identifier !== state.selectedModel.identifier) {
580
+ this.setCurrentLanguageModel(state.selectedModel);
581
+ }
582
+ }
583
+ const currentAttachments = this._attachmentModel.attachments;
584
+ if (!state) {
585
+ this._attachmentModel.clear();
586
+ }
587
+ else if (!equals(currentAttachments, state.attachments)) {
588
+ this._attachmentModel.clearAndSetContext(...state.attachments);
589
+ }
590
+ if (this._inputEditor) {
591
+ this._inputEditor.setValue(state?.inputText || '');
592
+ if (state?.selections.length) {
593
+ this._inputEditor.setSelections(state.selections);
594
+ }
595
+ }
596
+ if (state) {
597
+ this._widget?.contribs.forEach(contrib => {
598
+ contrib.setInputState?.(state.contrib);
599
+ });
600
+ }
601
+ }
602
+ finally {
603
+ this._isSyncingToOrFromInputModel = false;
604
+ }
605
+ }
606
+ _syncInputStateToModel() {
607
+ if (this._isSyncingToOrFromInputModel) {
608
+ return;
609
+ }
610
+ this._isSyncingToOrFromInputModel = true;
611
+ const state = this.getCurrentInputState();
612
+ if (this._chatSessionIsEmpty) {
613
+ this._emptyInputState.set(state, undefined);
614
+ }
615
+ this._inputModel?.setState(state);
616
+ this._isSyncingToOrFromInputModel = false;
617
+ }
618
+ setCurrentLanguageModel(model) {
619
+ this._currentLanguageModel = model;
620
+ if (this.cachedDimensions) {
621
+ this.layout(this.cachedDimensions.height, this.cachedDimensions.width);
622
+ }
623
+ this.storageService.store(this.getSelectedModelStorageKey(), model.identifier, StorageScope.APPLICATION, StorageTarget.USER);
624
+ this.storageService.store(this.getSelectedModelIsDefaultStorageKey(), !!model.metadata.isDefault, StorageScope.APPLICATION, StorageTarget.USER);
625
+ this._onDidChangeCurrentLanguageModel.fire(model);
626
+ this._syncInputStateToModel();
627
+ }
628
+ checkModelSupported() {
629
+ if (this._currentLanguageModel && (!this.modelSupportedForDefaultAgent(this._currentLanguageModel) || !this.modelSupportedForInlineChat(this._currentLanguageModel))) {
630
+ this.setCurrentLanguageModelToDefault();
631
+ }
632
+ }
633
+ setChatMode(mode, storeSelection = true) {
634
+ if (!this.options.supportsChangingModes) {
635
+ return;
636
+ }
637
+ const mode2 = this.chatModeService.findModeById(mode) ??
638
+ this.chatModeService.findModeById(ChatModeKind.Agent) ??
639
+ ChatMode.Ask;
640
+ this.setChatMode2(mode2, storeSelection);
641
+ }
642
+ setChatMode2(mode, storeSelection = true) {
643
+ if (!this.options.supportsChangingModes) {
644
+ return;
645
+ }
646
+ this._currentModeObservable.set(mode, undefined);
647
+ this._onDidChangeCurrentChatMode.fire();
648
+ this._syncInputStateToModel();
649
+ }
650
+ modelSupportedForDefaultAgent(model) {
651
+ if (this.currentModeKind === ChatModeKind.Agent || (this.currentModeKind === ChatModeKind.Edit && this.configurationService.getValue(ChatConfiguration.Edits2Enabled))) {
652
+ return ILanguageModelChatMetadata.suitableForAgentMode(model.metadata);
653
+ }
654
+ return true;
655
+ }
656
+ modelSupportedForInlineChat(model) {
657
+ if (this.location !== ChatAgentLocation.EditorInline || !this.configurationService.getValue(InlineChatConfigKeys.EnableV2)) {
658
+ return true;
659
+ }
660
+ return !!model.metadata.capabilities?.toolCalling;
661
+ }
662
+ getModels() {
663
+ const cachedModels = this.storageService.getObject('chat.cachedLanguageModels', StorageScope.APPLICATION, []);
664
+ let models = ( this.languageModelsService.getLanguageModelIds()
665
+ .map(
666
+ modelId => ({ identifier: modelId, metadata: this.languageModelsService.lookupLanguageModel(modelId) })
667
+ ));
668
+ if (models.length === 0 || ( models.some(m => m.metadata.isDefault)) === false) {
669
+ models = cachedModels;
670
+ }
671
+ else {
672
+ this.storageService.store('chat.cachedLanguageModels', models, StorageScope.APPLICATION, StorageTarget.MACHINE);
673
+ }
674
+ models.sort((a, b) => a.metadata.name.localeCompare(b.metadata.name));
675
+ return models.filter(entry => entry.metadata?.isUserSelectable && this.modelSupportedForDefaultAgent(entry) && this.modelSupportedForInlineChat(entry));
676
+ }
677
+ setCurrentLanguageModelToDefault() {
678
+ const allModels = this.getModels();
679
+ const defaultModel = allModels.find(m => m.metadata.isDefault) || allModels.find(m => m.metadata.isUserSelectable);
680
+ if (defaultModel) {
681
+ this.setCurrentLanguageModel(defaultModel);
682
+ }
683
+ }
684
+ getCurrentInputState() {
685
+ const mode = this._currentModeObservable.get();
686
+ const state = {
687
+ inputText: this._inputEditor?.getValue() ?? '',
688
+ attachments: this._attachmentModel.attachments,
689
+ mode: {
690
+ id: mode.id,
691
+ kind: mode.kind
692
+ },
693
+ selectedModel: this._currentLanguageModel,
694
+ selections: this._inputEditor?.getSelections() || [],
695
+ contrib: {},
696
+ };
697
+ for (const contrib of this._widget?.contribs || Iterable.empty()) {
698
+ contrib.getInputState?.(state.contrib);
699
+ }
700
+ return state;
701
+ }
702
+ _getAriaLabel() {
703
+ const verbose = this.configurationService.getValue(AccessibilityVerbositySettingId.Chat);
704
+ let kbLabel;
705
+ if (verbose) {
706
+ kbLabel = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
707
+ }
708
+ const mode = this._currentModeObservable.get();
709
+ const modelName = this._currentLanguageModel?.metadata.name;
710
+ const modelInfo = modelName ? ( localize(5307, ", {0}. ", modelName)) : '';
711
+ let modeLabel = '';
712
+ if (!mode.isBuiltin) {
713
+ const mode = this.currentModeObs.get();
714
+ modeLabel = ( localize(5308, "({0}), {1}", mode.label.get(), mode.description.get()));
715
+ }
716
+ else {
717
+ switch (this.currentModeKind) {
718
+ case ChatModeKind.Agent:
719
+ modeLabel = ( localize(5309, "(Agent), edit files in your workspace."));
720
+ break;
721
+ case ChatModeKind.Edit:
722
+ modeLabel = ( localize(5310, "(Edit), edit files in your workspace."));
723
+ break;
724
+ case ChatModeKind.Ask:
725
+ default:
726
+ modeLabel = ( localize(5311, "(Ask), ask questions or type / for topics."));
727
+ break;
728
+ }
729
+ }
730
+ if (verbose) {
731
+ return kbLabel
732
+ ? ( localize(
733
+ 5312,
734
+ "Chat Input {0}{1} Press Enter to send out the request. Use {2} for Chat Accessibility Help.",
735
+ modeLabel,
736
+ modelInfo,
737
+ kbLabel
738
+ ))
739
+ : ( localize(
740
+ 5313,
741
+ "Chat Input {0}{1} Press Enter to send out the request. Use the Chat Accessibility Help command for more information.",
742
+ modeLabel,
743
+ modelInfo
744
+ ));
745
+ }
746
+ else {
747
+ return localize(5314, "Chat Input {0}{1}.", modeLabel, modelInfo);
748
+ }
749
+ }
750
+ validateCurrentChatMode() {
751
+ const currentMode = this._currentModeObservable.get();
752
+ const validMode = this.chatModeService.findModeById(currentMode.id);
753
+ const isAgentModeEnabled = this.configurationService.getValue(ChatConfiguration.AgentEnabled);
754
+ if (!validMode) {
755
+ this.setChatMode(isAgentModeEnabled ? ChatModeKind.Agent : ChatModeKind.Ask);
756
+ return;
757
+ }
758
+ if (currentMode.kind === ChatModeKind.Agent && !isAgentModeEnabled) {
759
+ this.setChatMode(ChatModeKind.Ask);
760
+ return;
761
+ }
762
+ }
763
+ getDefaultModeExperimentStorageKey() {
764
+ const tag = this.options.widgetViewKindTag;
765
+ return `chat.${tag}.hasSetDefaultModeByExperiment`;
766
+ }
767
+ logInputHistory() {
768
+ const historyStr = ( this.history.values.map(entry => JSON.stringify(entry))).join('\n');
769
+ this.logService.info(`[${this.location}] Chat input history:`, historyStr);
770
+ }
771
+ setVisible(visible) {
772
+ this._onDidChangeVisibility.fire(visible);
773
+ }
774
+ get generating() {
775
+ return this._generating?.defer.p;
776
+ }
777
+ startGenerating() {
778
+ this.logService.trace('ChatWidget#startGenerating');
779
+ if (this._generating) {
780
+ this._generating.rc++;
781
+ }
782
+ else {
783
+ this._generating = { rc: 1, defer: ( new DeferredPromise()) };
784
+ }
785
+ return toDisposable(() => {
786
+ this.logService.trace('ChatWidget#doneGenerating');
787
+ if (this._generating && !--this._generating.rc) {
788
+ this._generating.defer.complete();
789
+ this._generating = undefined;
790
+ }
791
+ });
792
+ }
793
+ get element() {
794
+ return this.container;
795
+ }
796
+ async showPreviousValue() {
797
+ if (this.history.isAtStart()) {
798
+ return;
799
+ }
800
+ const state = this.getCurrentInputState();
801
+ if (state.inputText || state.attachments.length) {
802
+ this.history.overlay(state);
803
+ }
804
+ this.navigateHistory(true);
805
+ }
806
+ async showNextValue() {
807
+ if (this.history.isAtEnd()) {
808
+ return;
809
+ }
810
+ const state = this.getCurrentInputState();
811
+ if (state.inputText || state.attachments.length) {
812
+ this.history.overlay(state);
813
+ }
814
+ this.navigateHistory(false);
815
+ }
816
+ async navigateHistory(previous) {
817
+ const historyEntry = previous ?
818
+ this.history.previous() : this.history.next();
819
+ let historyAttachments = historyEntry?.attachments ?? [];
820
+ if (historyAttachments.length > 0) {
821
+ historyAttachments = (await Promise.all(( historyAttachments.map(async (attachment) => {
822
+ if (isImageVariableEntry(attachment) && attachment.references?.length && URI.isUri(attachment.references[0].reference)) {
823
+ const currReference = attachment.references[0].reference;
824
+ try {
825
+ const imageBinary = ( currReference.toString(true)).startsWith('http') ? await this.sharedWebExtracterService.readImage(currReference, CancellationToken.None) : (await this.fileService.readFile(currReference)).value;
826
+ if (!imageBinary) {
827
+ return undefined;
828
+ }
829
+ const newAttachment = { ...attachment };
830
+ newAttachment.value = (isImageVariableEntry(attachment) && attachment.isPasted) ? imageBinary.buffer : await resizeImage(imageBinary.buffer);
831
+ return newAttachment;
832
+ }
833
+ catch (err) {
834
+ this.logService.error('Failed to fetch and reference.', err);
835
+ return undefined;
836
+ }
837
+ }
838
+ return attachment;
839
+ })))).filter(attachment => attachment !== undefined);
840
+ }
841
+ this._attachmentModel.clearAndSetContext(...historyAttachments);
842
+ const inputText = historyEntry?.inputText ?? '';
843
+ const contribData = historyEntry?.contrib ?? {};
844
+ status(inputText);
845
+ this.setValue(inputText, true);
846
+ this._widget?.contribs.forEach(contrib => {
847
+ contrib.setInputState?.(contribData);
848
+ });
849
+ this._onDidLoadInputState.fire();
850
+ const model = this._inputEditor.getModel();
851
+ if (!model) {
852
+ return;
853
+ }
854
+ if (previous) {
855
+ this._inputEditor.setPosition({ lineNumber: 1, column: 1 });
856
+ }
857
+ else {
858
+ this._inputEditor.setPosition(getLastPosition(model));
859
+ }
860
+ }
861
+ setValue(value, transient) {
862
+ this.inputEditor.setValue(value);
863
+ const model = this.inputEditor.getModel();
864
+ if (model) {
865
+ this.inputEditor.setPosition(getLastPosition(model));
866
+ }
867
+ }
868
+ focus() {
869
+ this._inputEditor.focus();
870
+ }
871
+ hasFocus() {
872
+ return this._inputEditor.hasWidgetFocus();
873
+ }
874
+ async acceptInput(isUserQuery) {
875
+ if (isUserQuery) {
876
+ const userQuery = this.getCurrentInputState();
877
+ this.history.append(this._getFilteredEntry(userQuery));
878
+ }
879
+ if (this._chatSessionIsEmpty) {
880
+ this._chatSessionIsEmpty = false;
881
+ this._emptyInputState.set(undefined, undefined);
882
+ }
883
+ this.attachmentModel.clear();
884
+ this._onDidLoadInputState.fire();
885
+ if (this.accessibilityService.isScreenReaderOptimized() && isMacintosh) {
886
+ this._acceptInputForVoiceover();
887
+ }
888
+ else {
889
+ this._inputEditor.focus();
890
+ this._inputEditor.setValue('');
891
+ }
892
+ }
893
+ validateAgentMode() {
894
+ if (!this.agentService.hasToolsAgent && this._currentModeObservable.get().kind === ChatModeKind.Agent) {
895
+ this.setChatMode(ChatModeKind.Edit);
896
+ }
897
+ }
898
+ _getFilteredEntry(inputState) {
899
+ const attachmentsWithoutImageValues = ( inputState.attachments.map(attachment => {
900
+ if (isImageVariableEntry(attachment) && attachment.references?.length && attachment.value) {
901
+ const newAttachment = { ...attachment };
902
+ newAttachment.value = undefined;
903
+ return newAttachment;
904
+ }
905
+ return attachment;
906
+ }));
907
+ return { ...inputState, attachments: attachmentsWithoutImageValues };
908
+ }
909
+ _acceptInputForVoiceover() {
910
+ const domNode = this._inputEditor.getDomNode();
911
+ if (!domNode) {
912
+ return;
913
+ }
914
+ domNode.remove();
915
+ this._inputEditor.setValue('');
916
+ this._inputEditorElement.appendChild(domNode);
917
+ this._inputEditor.focus();
918
+ }
919
+ _handleAttachedContextChange() {
920
+ this._hasFileAttachmentContextKey.set(Boolean(this._attachmentModel.attachments.find(a => a.kind === 'file')));
921
+ this.renderAttachedContext();
922
+ }
923
+ getOrCreateOptionEmitter(optionGroupId) {
924
+ let emitter = this._chatSessionOptionEmitters.get(optionGroupId);
925
+ if (!emitter) {
926
+ emitter = this._register(( new Emitter()));
927
+ this._chatSessionOptionEmitters.set(optionGroupId, emitter);
928
+ }
929
+ return emitter;
930
+ }
931
+ refreshChatSessionPickers() {
932
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
933
+ const hideAll = () => {
934
+ this.chatSessionHasOptions.set(false);
935
+ this.hideAllSessionPickerWidgets();
936
+ };
937
+ if (!sessionResource) {
938
+ return hideAll();
939
+ }
940
+ const ctx = this.chatService.getChatSessionFromInternalUri(sessionResource);
941
+ if (!ctx) {
942
+ return hideAll();
943
+ }
944
+ const optionGroups = this.chatSessionsService.getOptionGroupsForSessionType(ctx.chatSessionType);
945
+ if (!optionGroups || optionGroups.length === 0) {
946
+ return hideAll();
947
+ }
948
+ if (!this.chatSessionsService.hasAnySessionOptions(ctx.chatSessionResource)) {
949
+ return hideAll();
950
+ }
951
+ this.chatSessionHasOptions.set(true);
952
+ const currentWidgetGroupIds = ( new Set(( this.chatSessionPickerWidgets.keys())));
953
+ const requiredGroupIds = ( new Set(( optionGroups.map(g => g.id))));
954
+ const needsRecreation = currentWidgetGroupIds.size !== requiredGroupIds.size ||
955
+ !Array.from(requiredGroupIds).every(id => ( currentWidgetGroupIds.has(id)));
956
+ if (needsRecreation && this._lastSessionPickerAction && this.chatSessionPickerContainer) {
957
+ const widgets = this.createChatSessionPickerWidgets(this._lastSessionPickerAction);
958
+ clearNode(this.chatSessionPickerContainer);
959
+ for (const widget of widgets) {
960
+ const container = $$1('.action-item.chat-sessionPicker-item');
961
+ widget.render(container);
962
+ this.chatSessionPickerContainer.appendChild(container);
963
+ }
964
+ }
965
+ if (this.chatSessionPickerContainer) {
966
+ this.chatSessionPickerContainer.style.display = '';
967
+ }
968
+ for (const [optionGroupId] of this.chatSessionPickerWidgets.entries()) {
969
+ const currentOption = this.chatSessionsService.getSessionOption(ctx.chatSessionResource, optionGroupId);
970
+ if (currentOption) {
971
+ const optionGroup = optionGroups.find(g => g.id === optionGroupId);
972
+ if (optionGroup) {
973
+ const currentOptionId = typeof currentOption === 'string' ? currentOption : currentOption.id;
974
+ const item = optionGroup.items.find(m => m.id === currentOptionId);
975
+ if (item) {
976
+ if (typeof currentOption === 'string') {
977
+ this.getOrCreateOptionEmitter(optionGroupId).fire(item);
978
+ }
979
+ else {
980
+ this.getOrCreateOptionEmitter(optionGroupId).fire(currentOption);
981
+ }
982
+ }
983
+ }
984
+ }
985
+ }
986
+ }
987
+ hideAllSessionPickerWidgets() {
988
+ if (this.chatSessionPickerContainer) {
989
+ this.chatSessionPickerContainer.style.display = 'none';
990
+ }
991
+ }
992
+ disposeSessionPickerWidgets() {
993
+ for (const widget of ( this.chatSessionPickerWidgets.values())) {
994
+ widget.dispose();
995
+ }
996
+ this.chatSessionPickerWidgets.clear();
997
+ }
998
+ getCurrentOptionForGroup(optionGroupId) {
999
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
1000
+ if (!sessionResource) {
1001
+ return;
1002
+ }
1003
+ const ctx = this.chatService.getChatSessionFromInternalUri(sessionResource);
1004
+ if (!ctx) {
1005
+ return;
1006
+ }
1007
+ const optionGroups = this.chatSessionsService.getOptionGroupsForSessionType(ctx.chatSessionType);
1008
+ const optionGroup = optionGroups?.find(g => g.id === optionGroupId);
1009
+ if (!optionGroup || optionGroup.items.length === 0) {
1010
+ return;
1011
+ }
1012
+ const currentOptionValue = this.chatSessionsService.getSessionOption(ctx.chatSessionResource, optionGroupId);
1013
+ if (!currentOptionValue) {
1014
+ return;
1015
+ }
1016
+ if (typeof currentOptionValue === 'string') {
1017
+ return optionGroup.items.find(m => m.id === currentOptionValue);
1018
+ }
1019
+ else {
1020
+ return currentOptionValue;
1021
+ }
1022
+ }
1023
+ tryUpdateWidgetController() {
1024
+ const sessionResource = this._widget?.viewModel?.model.sessionResource;
1025
+ if (!sessionResource) {
1026
+ return;
1027
+ }
1028
+ const sessionType = getChatSessionType(sessionResource);
1029
+ const isLocalSession = sessionType === localChatSessionType;
1030
+ if (!isLocalSession) {
1031
+ this._widgetController.clear();
1032
+ return;
1033
+ }
1034
+ if (!this._widgetController.value) {
1035
+ this._widgetController.value = this.instantiationService.createInstance(ChatInputPartWidgetController, this.chatInputWidgetsContainer);
1036
+ this._register(this._widgetController.value.onDidChangeHeight(() => this._onDidChangeHeight.fire()));
1037
+ }
1038
+ }
1039
+ render(container, initialValue, widget) {
1040
+ this._widget = widget;
1041
+ this._register(widget.onDidChangeViewModel(() => {
1042
+ this.refreshChatSessionPickers();
1043
+ this.tryUpdateWidgetController();
1044
+ }));
1045
+ let elements;
1046
+ if (this.options.renderStyle === 'compact') {
1047
+ elements = h('.interactive-input-part', [
1048
+ h('.interactive-input-and-edit-session', [
1049
+ h('.chat-input-widgets-container@chatInputWidgetsContainer'),
1050
+ h('.chat-todo-list-widget-container@chatInputTodoListWidgetContainer'),
1051
+ h('.chat-editing-session@chatEditingSessionWidgetContainer'),
1052
+ h('.interactive-input-and-side-toolbar@inputAndSideToolbar', [
1053
+ h('.chat-input-container@inputContainer', [
1054
+ h('.chat-editor-container@editorContainer'),
1055
+ h('.chat-input-toolbars@inputToolbars'),
1056
+ ]),
1057
+ ]),
1058
+ h('.chat-attachments-container@attachmentsContainer', [
1059
+ h('.chat-attachment-toolbar@attachmentToolbar'),
1060
+ h('.chat-attached-context@attachedContextContainer'),
1061
+ h('.chat-related-files@relatedFilesContainer'),
1062
+ ]),
1063
+ h('.interactive-input-followups@followupsContainer'),
1064
+ ])
1065
+ ]);
1066
+ }
1067
+ else {
1068
+ elements = h('.interactive-input-part', [
1069
+ h('.interactive-input-followups@followupsContainer'),
1070
+ h('.chat-input-widgets-container@chatInputWidgetsContainer'),
1071
+ h('.chat-todo-list-widget-container@chatInputTodoListWidgetContainer'),
1072
+ h('.chat-editing-session@chatEditingSessionWidgetContainer'),
1073
+ h('.interactive-input-and-side-toolbar@inputAndSideToolbar', [
1074
+ h('.chat-input-container@inputContainer', [
1075
+ h('.chat-attachments-container@attachmentsContainer', [
1076
+ h('.chat-attachment-toolbar@attachmentToolbar'),
1077
+ h('.chat-related-files@relatedFilesContainer'),
1078
+ h('.chat-attached-context@attachedContextContainer'),
1079
+ ]),
1080
+ h('.chat-editor-container@editorContainer'),
1081
+ h('.chat-input-toolbars@inputToolbars'),
1082
+ ]),
1083
+ ]),
1084
+ ]);
1085
+ }
1086
+ this.container = elements.root;
1087
+ this.chatInputOverlay = $$1('.chat-input-overlay');
1088
+ container.append(this.container);
1089
+ this.container.append(this.chatInputOverlay);
1090
+ this.container.classList.toggle('compact', this.options.renderStyle === 'compact');
1091
+ this.followupsContainer = elements.followupsContainer;
1092
+ const inputAndSideToolbar = elements.inputAndSideToolbar;
1093
+ const inputContainer = elements.inputContainer;
1094
+ const editorContainer = elements.editorContainer;
1095
+ this.attachmentsContainer = elements.attachmentsContainer;
1096
+ this.attachedContextContainer = elements.attachedContextContainer;
1097
+ this.relatedFilesContainer = elements.relatedFilesContainer;
1098
+ const toolbarsContainer = elements.inputToolbars;
1099
+ const attachmentToolbarContainer = elements.attachmentToolbar;
1100
+ this.chatEditingSessionWidgetContainer = elements.chatEditingSessionWidgetContainer;
1101
+ this.chatInputTodoListWidgetContainer = elements.chatInputTodoListWidgetContainer;
1102
+ this.chatInputWidgetsContainer = elements.chatInputWidgetsContainer;
1103
+ if (this.options.enableImplicitContext && !this._implicitContext) {
1104
+ this._implicitContext = this._register(this.instantiationService.createInstance(ChatImplicitContext));
1105
+ this.setImplicitContextEnablement();
1106
+ this._register(this._implicitContext.onDidChangeValue(() => {
1107
+ this._indexOfLastAttachedContextDeletedWithKeyboard = -1;
1108
+ this._handleAttachedContextChange();
1109
+ }));
1110
+ }
1111
+ else if (!this.options.enableImplicitContext && this._implicitContext) {
1112
+ this._implicitContext?.dispose();
1113
+ this._implicitContext = undefined;
1114
+ }
1115
+ this.tryUpdateWidgetController();
1116
+ this.renderAttachedContext();
1117
+ this._register(this._attachmentModel.onDidChange((e) => {
1118
+ if (e.added.length > 0) {
1119
+ this._indexOfLastAttachedContextDeletedWithKeyboard = -1;
1120
+ }
1121
+ this._handleAttachedContextChange();
1122
+ }));
1123
+ this.renderChatEditingSessionState(null);
1124
+ if (this.options.renderWorkingSet) {
1125
+ this._relatedFiles = this._register(( new ChatRelatedFiles()));
1126
+ this._register(this._relatedFiles.onDidChange(() => this.renderChatRelatedFiles()));
1127
+ }
1128
+ this.renderChatRelatedFiles();
1129
+ this.dnd.addOverlay(this.options.dndContainer ?? container, this.options.dndContainer ?? container);
1130
+ const inputScopedContextKeyService = this._register(this.contextKeyService.createScoped(inputContainer));
1131
+ ChatContextKeys.inChatInput.bindTo(inputScopedContextKeyService).set(true);
1132
+ this.currentlyEditingInputKey = ChatContextKeys.currentlyEditingInput.bindTo(inputScopedContextKeyService);
1133
+ const scopedInstantiationService = this._register(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, inputScopedContextKeyService]))));
1134
+ const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(inputScopedContextKeyService, this));
1135
+ this.historyNavigationBackwardsEnablement = historyNavigationBackwardsEnablement;
1136
+ this.historyNavigationForewardsEnablement = historyNavigationForwardsEnablement;
1137
+ const options = getSimpleEditorOptions(this.configurationService);
1138
+ options.overflowWidgetsDomNode = this.options.editorOverflowWidgetsDomNode;
1139
+ options.pasteAs = EditorOptions.pasteAs.defaultValue;
1140
+ options.readOnly = false;
1141
+ options.ariaLabel = this._getAriaLabel();
1142
+ options.fontFamily = DEFAULT_FONT_FAMILY;
1143
+ options.fontSize = 13;
1144
+ options.lineHeight = 20;
1145
+ options.padding = this.options.renderStyle === 'compact' ? { top: 2, bottom: 2 } : { top: 8, bottom: 8 };
1146
+ options.cursorWidth = 1;
1147
+ options.wrappingStrategy = 'advanced';
1148
+ options.bracketPairColorization = { enabled: false };
1149
+ options.autoClosingBrackets = this.configurationService.getValue('editor.autoClosingBrackets');
1150
+ options.autoClosingQuotes = this.configurationService.getValue('editor.autoClosingQuotes');
1151
+ options.autoSurround = this.configurationService.getValue('editor.autoSurround');
1152
+ options.suggest = {
1153
+ showIcons: true,
1154
+ showSnippets: false,
1155
+ showWords: true,
1156
+ showStatusBar: false,
1157
+ insertMode: 'insert',
1158
+ };
1159
+ options.scrollbar = { ...(options.scrollbar ?? {}), vertical: 'hidden' };
1160
+ options.stickyScroll = { enabled: false };
1161
+ this._inputEditorElement = append(editorContainer, $(chatInputEditorContainerSelector));
1162
+ const editorOptions = getSimpleCodeEditorWidgetOptions();
1163
+ editorOptions.contributions?.push(...EditorExtensionsRegistry.getSomeEditorContributions([ContentHoverController.ID, GlyphHoverController.ID, DropIntoEditorController.ID, CopyPasteController.ID, LinkDetector.ID]));
1164
+ this._inputEditor = this._register(scopedInstantiationService.createInstance(CodeEditorWidget, this._inputEditorElement, options, editorOptions));
1165
+ SuggestController.get(this._inputEditor)?.forceRenderingAbove();
1166
+ options.overflowWidgetsDomNode?.classList.add('hideSuggestTextIcons');
1167
+ this._inputEditorElement.classList.add('hideSuggestTextIcons');
1168
+ this._register(this._inputEditor.onKeyDown((e) => {
1169
+ if (e.keyCode === KeyCode.Enter && !hasModifierKeys(e)) {
1170
+ for (const keybinding of this.keybindingService.lookupKeybindings(ChatSubmitAction.ID)) {
1171
+ const chords = keybinding.getDispatchChords();
1172
+ const isPlainEnter = chords.length === 1 && chords[0] === '[Enter]';
1173
+ if (isPlainEnter) {
1174
+ e.preventDefault();
1175
+ break;
1176
+ }
1177
+ }
1178
+ }
1179
+ }));
1180
+ this._register(this._inputEditor.onDidScrollChange(e => {
1181
+ toolbarsContainer.classList.toggle('scroll-top-decoration', e.scrollTop > 0);
1182
+ }));
1183
+ this._register(this._inputEditor.onDidChangeModelContent(() => {
1184
+ const currentHeight = Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight);
1185
+ if (currentHeight !== this.inputEditorHeight) {
1186
+ this.inputEditorHeight = currentHeight;
1187
+ this._onDidChangeHeight.fire();
1188
+ }
1189
+ const model = this._inputEditor.getModel();
1190
+ const inputHasText = !!model && model.getValue().trim().length > 0;
1191
+ this.inputEditorHasText.set(inputHasText);
1192
+ this._syncTextDebounced.schedule();
1193
+ }));
1194
+ this._register(this._inputEditor.onDidContentSizeChange(e => {
1195
+ if (e.contentHeightChanged) {
1196
+ this.inputEditorHeight = !this.inline ? e.contentHeight : this.inputEditorHeight;
1197
+ this._onDidChangeHeight.fire();
1198
+ }
1199
+ }));
1200
+ this._register(this._inputEditor.onDidFocusEditorText(() => {
1201
+ this.inputEditorHasFocus.set(true);
1202
+ this._onDidFocus.fire();
1203
+ inputContainer.classList.toggle('focused', true);
1204
+ }));
1205
+ this._register(this._inputEditor.onDidBlurEditorText(() => {
1206
+ this.inputEditorHasFocus.set(false);
1207
+ inputContainer.classList.toggle('focused', false);
1208
+ this._onDidBlur.fire();
1209
+ }));
1210
+ this._register(this._inputEditor.onDidBlurEditorWidget(() => {
1211
+ CopyPasteController.get(this._inputEditor)?.clearWidgets();
1212
+ DropIntoEditorController.get(this._inputEditor)?.clearWidgets();
1213
+ }));
1214
+ const hoverDelegate = this._register(createInstantHoverDelegate());
1215
+ this._register(addStandardDisposableListener(toolbarsContainer, EventType.CLICK, e => this.inputEditor.focus()));
1216
+ this._register(addStandardDisposableListener(this.attachmentsContainer, EventType.CLICK, e => this.inputEditor.focus()));
1217
+ this.inputActionsToolbar = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, this.options.renderInputToolbarBelowInput ? this.attachmentsContainer : toolbarsContainer, MenuId.ChatInput, {
1218
+ telemetrySource: this.options.menus.telemetrySource,
1219
+ menuOptions: { shouldForwardArgs: true },
1220
+ hiddenItemStrategy: HiddenItemStrategy.NoHide,
1221
+ hoverDelegate,
1222
+ actionViewItemProvider: (action, options) => {
1223
+ if (action.id === ChatOpenModelPickerActionId && action instanceof MenuItemAction) {
1224
+ if (!this._currentLanguageModel) {
1225
+ this.setCurrentLanguageModelToDefault();
1226
+ }
1227
+ const itemDelegate = {
1228
+ getCurrentModel: () => this._currentLanguageModel,
1229
+ onDidChangeModel: this._onDidChangeCurrentLanguageModel.event,
1230
+ setModel: (model) => {
1231
+ this._waitForPersistedLanguageModel.clear();
1232
+ this.setCurrentLanguageModel(model);
1233
+ this.renderAttachedContext();
1234
+ },
1235
+ getModels: () => this.getModels()
1236
+ };
1237
+ return this.modelWidget = this.instantiationService.createInstance(ModelPickerActionItem, action, this._currentLanguageModel, undefined, itemDelegate);
1238
+ }
1239
+ else if (action.id === OpenModePickerAction.ID && action instanceof MenuItemAction) {
1240
+ const delegate = {
1241
+ currentMode: this._currentModeObservable,
1242
+ sessionResource: () => this._widget?.viewModel?.sessionResource,
1243
+ };
1244
+ return this.modeWidget = this.instantiationService.createInstance(ModePickerActionItem, action, delegate);
1245
+ }
1246
+ else if (action.id === ChatSessionPrimaryPickerAction.ID && action instanceof MenuItemAction) {
1247
+ const widgets = this.createChatSessionPickerWidgets(action);
1248
+ if (widgets.length === 0) {
1249
+ return undefined;
1250
+ }
1251
+ return this.instantiationService.createInstance(ChatSessionPickersContainerActionItem, action, widgets);
1252
+ }
1253
+ return undefined;
1254
+ }
1255
+ }));
1256
+ this.inputActionsToolbar.getElement().classList.add('chat-input-toolbar');
1257
+ this.inputActionsToolbar.context = { widget };
1258
+ this._register(this.inputActionsToolbar.onDidChangeMenuItems(() => {
1259
+ const toolbarElement = this.inputActionsToolbar.getElement();
1260
+ const container = toolbarElement.querySelector('.chat-sessionPicker-container');
1261
+ this.chatSessionPickerContainer = container;
1262
+ if (this.cachedDimensions && typeof this.cachedInputToolbarWidth === 'number' && this.cachedInputToolbarWidth !== this.inputActionsToolbar.getItemsWidth()) {
1263
+ this.layout(this.cachedDimensions.height, this.cachedDimensions.width);
1264
+ }
1265
+ }));
1266
+ this.executeToolbar = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, toolbarsContainer, this.options.menus.executeToolbar, {
1267
+ telemetrySource: this.options.menus.telemetrySource,
1268
+ menuOptions: {
1269
+ shouldForwardArgs: true
1270
+ },
1271
+ hoverDelegate,
1272
+ hiddenItemStrategy: HiddenItemStrategy.NoHide,
1273
+ actionViewItemProvider: (action, options) => {
1274
+ if (action.id === ContinueChatInSessionAction.ID && action instanceof MenuItemAction) {
1275
+ return this.instantiationService.createInstance(ChatContinueInSessionActionItem, action, ActionLocation.ChatWidget);
1276
+ }
1277
+ return undefined;
1278
+ }
1279
+ }));
1280
+ this.executeToolbar.getElement().classList.add('chat-execute-toolbar');
1281
+ this.executeToolbar.context = { widget };
1282
+ this._register(this.executeToolbar.onDidChangeMenuItems(() => {
1283
+ if (this.cachedDimensions && typeof this.cachedExecuteToolbarWidth === 'number' && this.cachedExecuteToolbarWidth !== this.executeToolbar.getItemsWidth()) {
1284
+ this.layout(this.cachedDimensions.height, this.cachedDimensions.width);
1285
+ }
1286
+ }));
1287
+ if (this.options.menus.inputSideToolbar) {
1288
+ const toolbarSide = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, inputAndSideToolbar, this.options.menus.inputSideToolbar, {
1289
+ telemetrySource: this.options.menus.telemetrySource,
1290
+ menuOptions: {
1291
+ shouldForwardArgs: true
1292
+ },
1293
+ hoverDelegate
1294
+ }));
1295
+ this.inputSideToolbarContainer = toolbarSide.getElement();
1296
+ toolbarSide.getElement().classList.add('chat-side-toolbar');
1297
+ toolbarSide.context = { widget };
1298
+ }
1299
+ let inputModel = this.modelService.getModel(this.inputUri);
1300
+ if (!inputModel) {
1301
+ inputModel = this.modelService.createModel('', null, this.inputUri, true);
1302
+ }
1303
+ this.textModelResolverService.createModelReference(this.inputUri).then(ref => {
1304
+ if (this._store.isDisposed) {
1305
+ ref.dispose();
1306
+ return;
1307
+ }
1308
+ this._register(ref);
1309
+ });
1310
+ this.inputModel = inputModel;
1311
+ this.inputModel.updateOptions({ bracketColorizationOptions: { enabled: false, independentColorPoolPerBracketType: false } });
1312
+ this._inputEditor.setModel(this.inputModel);
1313
+ if (initialValue) {
1314
+ this.inputModel.setValue(initialValue);
1315
+ const lineNumber = this.inputModel.getLineCount();
1316
+ this._inputEditor.setPosition({ lineNumber, column: this.inputModel.getLineMaxColumn(lineNumber) });
1317
+ }
1318
+ const onDidChangeCursorPosition = () => {
1319
+ const model = this._inputEditor.getModel();
1320
+ if (!model) {
1321
+ return;
1322
+ }
1323
+ const position = this._inputEditor.getPosition();
1324
+ if (!position) {
1325
+ return;
1326
+ }
1327
+ const atTop = position.lineNumber === 1 && position.column === 1;
1328
+ this.chatCursorAtTop.set(atTop);
1329
+ this.historyNavigationBackwardsEnablement.set(atTop);
1330
+ this.historyNavigationForewardsEnablement.set(position.equals(getLastPosition(model)));
1331
+ this._syncInputStateToModel();
1332
+ };
1333
+ this._register(this._inputEditor.onDidChangeCursorPosition(e => onDidChangeCursorPosition()));
1334
+ onDidChangeCursorPosition();
1335
+ this._register(this.themeService.onDidFileIconThemeChange(() => {
1336
+ this.renderAttachedContext();
1337
+ }));
1338
+ this.addFilesToolbar = this._register(this.instantiationService.createInstance(MenuWorkbenchToolBar, attachmentToolbarContainer, MenuId.ChatInputAttachmentToolbar, {
1339
+ telemetrySource: this.options.menus.telemetrySource,
1340
+ label: true,
1341
+ menuOptions: { shouldForwardArgs: true, renderShortTitle: true },
1342
+ hiddenItemStrategy: HiddenItemStrategy.NoHide,
1343
+ hoverDelegate,
1344
+ actionViewItemProvider: (action, options) => {
1345
+ if (action.id === 'workbench.action.chat.attachContext') {
1346
+ const viewItem = this.instantiationService.createInstance(AddFilesButton, this._attachmentModel, action, options);
1347
+ viewItem.setShowLabel(this._attachmentModel.size === 0 && !this.hasImplicitContextBlock());
1348
+ this.addFilesButton = viewItem;
1349
+ return this.addFilesButton;
1350
+ }
1351
+ return undefined;
1352
+ }
1353
+ }));
1354
+ this.addFilesToolbar.context = { widget, placeholder: ( localize(5315, 'Search for files and context to add to your request')) };
1355
+ this._register(this.addFilesToolbar.onDidChangeMenuItems(() => {
1356
+ if (this.cachedDimensions) {
1357
+ this._onDidChangeHeight.fire();
1358
+ }
1359
+ }));
1360
+ }
1361
+ toggleChatInputOverlay(editing) {
1362
+ this.chatInputOverlay.classList.toggle('disabled', editing);
1363
+ if (editing) {
1364
+ this.overlayClickListener.value = addStandardDisposableListener(this.chatInputOverlay, EventType.CLICK, e => {
1365
+ e.preventDefault();
1366
+ e.stopPropagation();
1367
+ this._onDidClickOverlay.fire();
1368
+ });
1369
+ }
1370
+ else {
1371
+ this.overlayClickListener.clear();
1372
+ }
1373
+ }
1374
+ renderAttachedContext() {
1375
+ const container = this.attachedContextContainer;
1376
+ const oldHeight = this.attachmentsContainer.offsetHeight;
1377
+ const store = ( new DisposableStore());
1378
+ this.attachedContextDisposables.value = store;
1379
+ clearNode(container);
1380
+ store.add(addStandardDisposableListener(this.attachmentsContainer, EventType.KEY_DOWN, (e) => {
1381
+ this.handleAttachmentNavigation(e);
1382
+ }));
1383
+ const attachments = [...this.attachmentModel.attachments.entries()];
1384
+ const hasAttachments = Boolean(attachments.length) || Boolean(this.implicitContext?.value);
1385
+ setVisibility(Boolean(this.options.renderInputToolbarBelowInput || hasAttachments || (this.addFilesToolbar && !this.addFilesToolbar.isEmpty())), this.attachmentsContainer);
1386
+ setVisibility(hasAttachments, this.attachedContextContainer);
1387
+ if (!attachments.length) {
1388
+ this._indexOfLastAttachedContextDeletedWithKeyboard = -1;
1389
+ this._indexOfLastOpenedContext = -1;
1390
+ }
1391
+ const isSuggestedEnabled = this.configurationService.getValue('chat.implicitContext.suggestedContext');
1392
+ if (this.implicitContext?.value && !isSuggestedEnabled) {
1393
+ const implicitPart = store.add(this.instantiationService.createInstance(ImplicitContextAttachmentWidget, () => this._widget, this.implicitContext, this._contextResourceLabels, this.attachmentModel));
1394
+ container.appendChild(implicitPart.domNode);
1395
+ }
1396
+ for (const [index, attachment] of attachments) {
1397
+ const resource = URI.isUri(attachment.value) ? attachment.value : isLocation(attachment.value) ? attachment.value.uri : undefined;
1398
+ const range = isLocation(attachment.value) ? attachment.value.range : undefined;
1399
+ const shouldFocusClearButton = index === Math.min(this._indexOfLastAttachedContextDeletedWithKeyboard, this.attachmentModel.size - 1) && this._indexOfLastAttachedContextDeletedWithKeyboard > -1;
1400
+ let attachmentWidget;
1401
+ const options = { shouldFocusClearButton, supportsDeletion: true };
1402
+ if (attachment.kind === 'tool' || attachment.kind === 'toolset') {
1403
+ attachmentWidget = this.instantiationService.createInstance(ToolSetOrToolItemAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1404
+ }
1405
+ else if (resource && isNotebookOutputVariableEntry(attachment)) {
1406
+ attachmentWidget = this.instantiationService.createInstance(NotebookCellOutputChatAttachmentWidget, resource, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1407
+ }
1408
+ else if (isPromptFileVariableEntry(attachment)) {
1409
+ attachmentWidget = this.instantiationService.createInstance(PromptFileAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1410
+ }
1411
+ else if (isPromptTextVariableEntry(attachment)) {
1412
+ attachmentWidget = this.instantiationService.createInstance(PromptTextAttachmentWidget, attachment, undefined, options, container, this._contextResourceLabels);
1413
+ }
1414
+ else if (resource && (attachment.kind === 'file' || attachment.kind === 'directory')) {
1415
+ attachmentWidget = this.instantiationService.createInstance(FileAttachmentWidget, resource, range, attachment, undefined, this._currentLanguageModel, options, container, this._contextResourceLabels);
1416
+ }
1417
+ else if (attachment.kind === 'terminalCommand') {
1418
+ attachmentWidget = this.instantiationService.createInstance(TerminalCommandAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1419
+ }
1420
+ else if (isImageVariableEntry(attachment)) {
1421
+ attachmentWidget = this.instantiationService.createInstance(ImageAttachmentWidget, resource, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1422
+ }
1423
+ else if (isElementVariableEntry(attachment)) {
1424
+ attachmentWidget = this.instantiationService.createInstance(ElementChatAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1425
+ }
1426
+ else if (isPasteVariableEntry(attachment)) {
1427
+ attachmentWidget = this.instantiationService.createInstance(PasteAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1428
+ }
1429
+ else if (isSCMHistoryItemVariableEntry(attachment)) {
1430
+ attachmentWidget = this.instantiationService.createInstance(SCMHistoryItemAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1431
+ }
1432
+ else if (isSCMHistoryItemChangeVariableEntry(attachment)) {
1433
+ attachmentWidget = this.instantiationService.createInstance(SCMHistoryItemChangeAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1434
+ }
1435
+ else if (isSCMHistoryItemChangeRangeVariableEntry(attachment)) {
1436
+ attachmentWidget = this.instantiationService.createInstance(SCMHistoryItemChangeRangeAttachmentWidget, attachment, this._currentLanguageModel, options, container, this._contextResourceLabels);
1437
+ }
1438
+ else {
1439
+ attachmentWidget = this.instantiationService.createInstance(DefaultChatAttachmentWidget, resource, range, attachment, undefined, this._currentLanguageModel, options, container, this._contextResourceLabels);
1440
+ }
1441
+ if (shouldFocusClearButton) {
1442
+ attachmentWidget.element.focus();
1443
+ }
1444
+ if (index === Math.min(this._indexOfLastOpenedContext, this.attachmentModel.size - 1)) {
1445
+ attachmentWidget.element.focus();
1446
+ }
1447
+ store.add(attachmentWidget);
1448
+ store.add(attachmentWidget.onDidDelete(e => {
1449
+ this.handleAttachmentDeletion(e, index, attachment);
1450
+ }));
1451
+ store.add(attachmentWidget.onDidOpen(e => {
1452
+ this.handleAttachmentOpen(index, attachment);
1453
+ }));
1454
+ }
1455
+ const implicitValue = this.implicitContext?.value;
1456
+ if (isSuggestedEnabled && implicitValue) {
1457
+ const targetUri = this.implicitContext.uri;
1458
+ const currentlyAttached = ( attachments.some(([, attachment]) => {
1459
+ let uri;
1460
+ if (URI.isUri(attachment.value)) {
1461
+ uri = attachment.value;
1462
+ }
1463
+ else if (isStringVariableEntry(attachment)) {
1464
+ uri = attachment.uri;
1465
+ }
1466
+ return uri && isEqual(uri, targetUri);
1467
+ }));
1468
+ const shouldShowImplicit = !isLocation(implicitValue) ? !currentlyAttached : implicitValue.range;
1469
+ if (shouldShowImplicit) {
1470
+ const implicitPart = store.add(this.instantiationService.createInstance(ImplicitContextAttachmentWidget, () => this._widget, this.implicitContext, this._contextResourceLabels, this._attachmentModel));
1471
+ container.appendChild(implicitPart.domNode);
1472
+ }
1473
+ }
1474
+ if (oldHeight !== this.attachmentsContainer.offsetHeight) {
1475
+ this._onDidChangeHeight.fire();
1476
+ }
1477
+ this.addFilesButton?.setShowLabel(this._attachmentModel.size === 0 && !this.hasImplicitContextBlock());
1478
+ this._indexOfLastOpenedContext = -1;
1479
+ }
1480
+ hasImplicitContextBlock() {
1481
+ const implicit = this.implicitContext?.value;
1482
+ if (!implicit) {
1483
+ return false;
1484
+ }
1485
+ const isSuggestedEnabled = this.configurationService.getValue('chat.implicitContext.suggestedContext');
1486
+ if (!isSuggestedEnabled) {
1487
+ return true;
1488
+ }
1489
+ const isUri = URI.isUri(implicit);
1490
+ if (isUri || isLocation(implicit)) {
1491
+ const targetUri = isUri ? implicit : implicit.uri;
1492
+ const attachments = [...this._attachmentModel.attachments.entries()];
1493
+ const currentlyAttached = ( attachments.some(([, a]) => URI.isUri(a.value) && isEqual(a.value, targetUri)));
1494
+ const shouldShowImplicit = isUri ? !currentlyAttached : implicit.range;
1495
+ return !!shouldShowImplicit;
1496
+ }
1497
+ return false;
1498
+ }
1499
+ handleAttachmentDeletion(e, index, attachment) {
1500
+ if (isKeyboardEvent(e)) {
1501
+ this._indexOfLastAttachedContextDeletedWithKeyboard = index;
1502
+ }
1503
+ this._attachmentModel.delete(attachment.id);
1504
+ if (this.configurationService.getValue('chat.implicitContext.enableImplicitContext')) {
1505
+ const implicitValue = URI.isUri(this.implicitContext?.value) && URI.isUri(attachment.value) && isEqual(this.implicitContext.value, attachment.value);
1506
+ if (this.implicitContext?.isFile && implicitValue) {
1507
+ this.implicitContext.enabled = false;
1508
+ }
1509
+ }
1510
+ if (this._attachmentModel.size === 0) {
1511
+ this.focus();
1512
+ }
1513
+ this._onDidChangeContext.fire({ removed: [attachment] });
1514
+ this.renderAttachedContext();
1515
+ }
1516
+ handleAttachmentOpen(index, attachment) {
1517
+ this._indexOfLastOpenedContext = index;
1518
+ this._indexOfLastAttachedContextDeletedWithKeyboard = -1;
1519
+ if (this._attachmentModel.size === 0) {
1520
+ this.focus();
1521
+ }
1522
+ }
1523
+ handleAttachmentNavigation(e) {
1524
+ if (!e.equals(KeyCode.LeftArrow) && !e.equals(KeyCode.RightArrow)) {
1525
+ return;
1526
+ }
1527
+ const toolbar = this.addFilesToolbar?.getElement().querySelector('.action-label');
1528
+ if (!toolbar) {
1529
+ return;
1530
+ }
1531
+ const attachments = Array.from(this.attachedContextContainer.querySelectorAll('.chat-attached-context-attachment'));
1532
+ if (!attachments.length) {
1533
+ return;
1534
+ }
1535
+ attachments.unshift(toolbar);
1536
+ const activeElement = getActiveElement(getWindow(this.attachmentsContainer).document);
1537
+ const currentIndex = attachments.findIndex(attachment => attachment === activeElement);
1538
+ let newIndex = currentIndex;
1539
+ if (e.equals(KeyCode.LeftArrow)) {
1540
+ newIndex = currentIndex > 0 ? currentIndex - 1 : attachments.length - 1;
1541
+ }
1542
+ else if (e.equals(KeyCode.RightArrow)) {
1543
+ newIndex = currentIndex < attachments.length - 1 ? currentIndex + 1 : 0;
1544
+ }
1545
+ if (newIndex !== -1) {
1546
+ const nextElement = attachments[newIndex];
1547
+ nextElement.focus();
1548
+ e.preventDefault();
1549
+ e.stopPropagation();
1550
+ }
1551
+ }
1552
+ async renderChatTodoListWidget(chatSessionResource) {
1553
+ const isTodoWidgetEnabled = this.configurationService.getValue(ChatConfiguration.TodosShowWidget) !== false;
1554
+ if (!isTodoWidgetEnabled) {
1555
+ return;
1556
+ }
1557
+ if (!this._chatInputTodoListWidget.value) {
1558
+ const widget = this._chatEditingTodosDisposables.add(this.instantiationService.createInstance(ChatTodoListWidget));
1559
+ this._chatInputTodoListWidget.value = widget;
1560
+ clearNode(this.chatInputTodoListWidgetContainer);
1561
+ append(this.chatInputTodoListWidgetContainer, widget.domNode);
1562
+ this._chatEditingTodosDisposables.add(widget.onDidChangeHeight(() => {
1563
+ this._onDidChangeHeight.fire();
1564
+ }));
1565
+ }
1566
+ this._chatInputTodoListWidget.value.render(chatSessionResource);
1567
+ }
1568
+ clearTodoListWidget(sessionResource, force) {
1569
+ this._chatInputTodoListWidget.value?.clear(sessionResource, force);
1570
+ }
1571
+ renderChatEditingSessionState(chatEditingSession) {
1572
+ setVisibility(Boolean(chatEditingSession), this.chatEditingSessionWidgetContainer);
1573
+ if (chatEditingSession) {
1574
+ if (!isEqual(chatEditingSession.chatSessionResource, this._lastEditingSessionResource)) {
1575
+ this._workingSetCollapsed.set(true, undefined);
1576
+ }
1577
+ this._lastEditingSessionResource = chatEditingSession.chatSessionResource;
1578
+ }
1579
+ const modifiedEntries = derivedOpts({ equalsFn: equals }, r => {
1580
+ return chatEditingSession?.entries.read(r).filter(entry => entry.state.read(r) === ModifiedFileEntryState.Modified) || [];
1581
+ });
1582
+ const editSessionEntries = derived((reader) => {
1583
+ const seenEntries = ( new ResourceSet());
1584
+ const entries = [];
1585
+ for (const entry of modifiedEntries.read(reader)) {
1586
+ if (entry.state.read(reader) !== ModifiedFileEntryState.Modified) {
1587
+ continue;
1588
+ }
1589
+ if (!( seenEntries.has(entry.modifiedURI))) {
1590
+ seenEntries.add(entry.modifiedURI);
1591
+ const linesAdded = entry.linesAdded?.read(reader);
1592
+ const linesRemoved = entry.linesRemoved?.read(reader);
1593
+ entries.push({
1594
+ reference: entry.modifiedURI,
1595
+ state: ModifiedFileEntryState.Modified,
1596
+ kind: 'reference',
1597
+ options: {
1598
+ status: undefined,
1599
+ diffMeta: { added: linesAdded ?? 0, removed: linesRemoved ?? 0 }
1600
+ }
1601
+ });
1602
+ }
1603
+ }
1604
+ entries.sort((a, b) => {
1605
+ if (a.kind === 'reference' && b.kind === 'reference') {
1606
+ if (a.state === b.state || a.state === undefined || b.state === undefined) {
1607
+ return ( a.reference.toString()).localeCompare(( b.reference.toString()));
1608
+ }
1609
+ return a.state - b.state;
1610
+ }
1611
+ return 0;
1612
+ });
1613
+ return entries;
1614
+ });
1615
+ const sessionFileChanges = observableFromEvent(this, this.agentSessionsService.model.onDidChangeSessions, () => {
1616
+ const sessionResource = this._widget?.viewModel?.model?.sessionResource;
1617
+ if (!sessionResource) {
1618
+ return Iterable.empty();
1619
+ }
1620
+ const model = this.agentSessionsService.getSession(sessionResource);
1621
+ return model?.changes instanceof Array ? model.changes : Iterable.empty();
1622
+ });
1623
+ const sessionFiles = derived(reader => ( sessionFileChanges.read(reader).map((entry) => ({
1624
+ reference: entry.modifiedUri,
1625
+ state: ModifiedFileEntryState.Accepted,
1626
+ kind: 'reference',
1627
+ options: {
1628
+ status: undefined,
1629
+ diffMeta: { added: entry.insertions, removed: entry.deletions },
1630
+ originalUri: entry.originalUri,
1631
+ }
1632
+ }))));
1633
+ const shouldRender = derived(reader => editSessionEntries.read(reader).length > 0 || sessionFiles.read(reader).length > 0);
1634
+ this._renderingChatEdits.value = autorun(reader => {
1635
+ if (this.options.renderWorkingSet && shouldRender.read(reader)) {
1636
+ this.renderChatEditingSessionWithEntries(reader.store, chatEditingSession, modifiedEntries, sessionFileChanges, editSessionEntries, sessionFiles);
1637
+ }
1638
+ else {
1639
+ clearNode(this.chatEditingSessionWidgetContainer);
1640
+ this._chatEditsDisposables.clear();
1641
+ this._chatEditList = undefined;
1642
+ }
1643
+ });
1644
+ }
1645
+ renderChatEditingSessionWithEntries(store, chatEditingSession, modifiedEntries, sessionFileChanges, editSessionEntries, sessionEntries) {
1646
+ const innerContainer = this.chatEditingSessionWidgetContainer.querySelector('.chat-editing-session-container.show-file-icons') ?? append(this.chatEditingSessionWidgetContainer, $('.chat-editing-session-container.show-file-icons'));
1647
+ const overviewRegion = innerContainer.querySelector('.chat-editing-session-overview') ?? append(innerContainer, $('.chat-editing-session-overview'));
1648
+ const overviewTitle = overviewRegion.querySelector('.working-set-title') ?? append(overviewRegion, $('.working-set-title'));
1649
+ this._chatEditsActionsDisposables.clear();
1650
+ const actionsContainer = overviewRegion.querySelector('.chat-editing-session-actions') ?? append(overviewRegion, $('.chat-editing-session-actions'));
1651
+ const sessionResource = chatEditingSession?.chatSessionResource || this._widget?.viewModel?.model.sessionResource;
1652
+ const scopedContextKeyService = this._chatEditsActionsDisposables.add(this.contextKeyService.createScoped(actionsContainer));
1653
+ if (sessionResource) {
1654
+ scopedContextKeyService.createKey(ChatContextKeys.agentSessionType.key, getChatSessionType(sessionResource));
1655
+ }
1656
+ this._chatEditsActionsDisposables.add(bindContextKey(ChatContextKeys.hasAgentSessionChanges, scopedContextKeyService, r => !!sessionEntries.read(r)?.length));
1657
+ const scopedInstantiationService = this._chatEditsActionsDisposables.add(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService]))));
1658
+ const workingSetContainer = innerContainer.querySelector('.chat-editing-session-list') ?? append(innerContainer, $('.chat-editing-session-list'));
1659
+ const button = this._chatEditsActionsDisposables.add(( new ButtonWithIcon(overviewTitle, {
1660
+ supportIcons: true,
1661
+ secondary: true,
1662
+ ariaLabel: ( localize(5316, 'Toggle changed files.')),
1663
+ })));
1664
+ const topLevelStats = derived(reader => {
1665
+ let added = 0;
1666
+ let removed = 0;
1667
+ const entries = modifiedEntries.read(reader);
1668
+ for (const entry of entries) {
1669
+ if (entry.linesAdded && entry.linesRemoved) {
1670
+ added += entry.linesAdded.read(reader);
1671
+ removed += entry.linesRemoved.read(reader);
1672
+ }
1673
+ }
1674
+ let baseLabel = entries.length === 1 ? ( localize(5317, '1 file changed')) : ( localize(5318, '{0} files changed', entries.length));
1675
+ let shouldShowEditingSession = added > 0 || removed > 0;
1676
+ let topLevelIsSessionMenu = false;
1677
+ if (added === 0 && removed === 0) {
1678
+ const sessionValue = sessionFileChanges.read(reader) || [];
1679
+ for (const entry of sessionValue) {
1680
+ added += entry.insertions;
1681
+ removed += entry.deletions;
1682
+ }
1683
+ shouldShowEditingSession = sessionValue.length > 0;
1684
+ baseLabel = sessionValue.length === 1 ? ( localize(5319, '1 file ready to merge')) : ( localize(5320, '{0} files ready to merge', sessionValue.length));
1685
+ topLevelIsSessionMenu = true;
1686
+ }
1687
+ button.label = baseLabel;
1688
+ return { added, removed, shouldShowEditingSession, baseLabel, topLevelIsSessionMenu };
1689
+ });
1690
+ const topLevelIsSessionMenu = ( topLevelStats.map(t => t.topLevelIsSessionMenu));
1691
+ store.add(autorun(reader => {
1692
+ const isSessionMenu = topLevelIsSessionMenu.read(reader);
1693
+ reader.store.add(scopedInstantiationService.createInstance(MenuWorkbenchButtonBar, actionsContainer, isSessionMenu ? MenuId.ChatEditingSessionChangesToolbar : MenuId.ChatEditingWidgetToolbar, {
1694
+ telemetrySource: this.options.menus.telemetrySource,
1695
+ menuOptions: {
1696
+ arg: sessionResource && (isSessionMenu ? sessionResource : {
1697
+ $mid: MarshalledId.ChatViewContext,
1698
+ sessionResource,
1699
+ }),
1700
+ },
1701
+ buttonConfigProvider: (action) => {
1702
+ if (action.id === ChatEditingShowChangesAction.ID || action.id === ViewPreviousEditsAction.Id || action.id === ViewAllSessionChangesAction.ID) {
1703
+ return { showIcon: true, showLabel: false, isSecondary: true };
1704
+ }
1705
+ return undefined;
1706
+ }
1707
+ }));
1708
+ }));
1709
+ store.add(autorun(reader => {
1710
+ const { added, removed, shouldShowEditingSession, baseLabel } = topLevelStats.read(reader);
1711
+ button.label = baseLabel;
1712
+ this._workingSetLinesAddedSpan.value.textContent = `+${added}`;
1713
+ this._workingSetLinesRemovedSpan.value.textContent = `-${removed}`;
1714
+ button.element.setAttribute('aria-label', ( localize(5321, '{0}, {1} lines added, {2} lines removed', baseLabel, added, removed)));
1715
+ setVisibility(shouldShowEditingSession, this.chatEditingSessionWidgetContainer);
1716
+ if (!shouldShowEditingSession) {
1717
+ this._onDidChangeHeight.fire();
1718
+ }
1719
+ }));
1720
+ const countsContainer = $$1('.working-set-line-counts');
1721
+ button.element.appendChild(countsContainer);
1722
+ countsContainer.appendChild(this._workingSetLinesAddedSpan.value);
1723
+ countsContainer.appendChild(this._workingSetLinesRemovedSpan.value);
1724
+ const toggleWorkingSet = () => {
1725
+ this._workingSetCollapsed.set(!this._workingSetCollapsed.get(), undefined);
1726
+ };
1727
+ this._chatEditsActionsDisposables.add(button.onDidClick(toggleWorkingSet));
1728
+ this._chatEditsActionsDisposables.add(addDisposableListener(overviewRegion, 'click', e => {
1729
+ if (e.defaultPrevented) {
1730
+ return;
1731
+ }
1732
+ const target = e.target;
1733
+ if (target.closest('.monaco-button')) {
1734
+ return;
1735
+ }
1736
+ toggleWorkingSet();
1737
+ }));
1738
+ this._chatEditsActionsDisposables.add(autorun(reader => {
1739
+ const collapsed = this._workingSetCollapsed.read(reader);
1740
+ button.icon = collapsed ? Codicon.chevronRight : Codicon.chevronDown;
1741
+ workingSetContainer.classList.toggle('collapsed', collapsed);
1742
+ this._onDidChangeHeight.fire();
1743
+ }));
1744
+ if (!this._chatEditList) {
1745
+ this._chatEditList = this._chatEditsListPool.get();
1746
+ const list = this._chatEditList.object;
1747
+ this._chatEditsDisposables.add(this._chatEditList);
1748
+ this._chatEditsDisposables.add(list.onDidFocus(() => {
1749
+ this._onDidFocus.fire();
1750
+ }));
1751
+ this._chatEditsDisposables.add(list.onDidOpen(async (e) => {
1752
+ if (e.element?.kind === 'reference' && URI.isUri(e.element.reference)) {
1753
+ const modifiedFileUri = e.element.reference;
1754
+ const originalUri = e.element.options?.originalUri;
1755
+ if (originalUri) {
1756
+ await this.editorService.openEditor({
1757
+ original: { resource: originalUri },
1758
+ modified: { resource: modifiedFileUri },
1759
+ options: e.editorOptions
1760
+ }, e.sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
1761
+ return;
1762
+ }
1763
+ const entry = chatEditingSession?.getEntry(modifiedFileUri);
1764
+ const pane = await this.editorService.openEditor({
1765
+ resource: modifiedFileUri,
1766
+ options: e.editorOptions
1767
+ }, e.sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
1768
+ if (pane) {
1769
+ entry?.getEditorIntegration(pane).reveal(true, e.editorOptions.preserveFocus);
1770
+ }
1771
+ }
1772
+ }));
1773
+ this._chatEditsDisposables.add(addDisposableListener(list.getHTMLElement(), 'click', e => {
1774
+ if (!this.hasFocus()) {
1775
+ this._onDidFocus.fire();
1776
+ }
1777
+ }, true));
1778
+ append(workingSetContainer, list.getHTMLElement());
1779
+ append(innerContainer, workingSetContainer);
1780
+ }
1781
+ store.add(autorun(reader => {
1782
+ const editEntries = editSessionEntries.read(reader);
1783
+ const sessionFileEntries = sessionEntries.read(reader) ?? [];
1784
+ const allEntries = [...editEntries];
1785
+ if (sessionFileEntries.length > 0) {
1786
+ if (editEntries.length > 0) {
1787
+ allEntries.push({
1788
+ kind: 'divider',
1789
+ label: ( localize(5322, 'Worktree Changes')),
1790
+ menuId: MenuId.ChatEditingSessionChangesToolbar,
1791
+ menuArg: sessionResource,
1792
+ scopedInstantiationService,
1793
+ });
1794
+ }
1795
+ allEntries.push(...sessionFileEntries);
1796
+ }
1797
+ const maxItemsShown = 6;
1798
+ const itemsShown = Math.min(allEntries.length, maxItemsShown);
1799
+ const height = itemsShown * 22;
1800
+ const list = this._chatEditList.object;
1801
+ list.layout(height);
1802
+ list.getHTMLElement().style.height = `${height}px`;
1803
+ list.splice(0, list.length, allEntries);
1804
+ this._onDidChangeHeight.fire();
1805
+ }));
1806
+ }
1807
+ async renderChatRelatedFiles() {
1808
+ const anchor = this.relatedFilesContainer;
1809
+ clearNode(anchor);
1810
+ const shouldRender = this.configurationService.getValue('chat.renderRelatedFiles');
1811
+ setVisibility(Boolean(this.relatedFiles?.value.length && shouldRender), anchor);
1812
+ if (!shouldRender || !this.relatedFiles?.value.length) {
1813
+ return;
1814
+ }
1815
+ const hoverDelegate = getDefaultHoverDelegate('element');
1816
+ for (const { uri, description } of this.relatedFiles.value) {
1817
+ const uriLabel = this._chatEditsActionsDisposables.add(( new Button(anchor, {
1818
+ supportIcons: true,
1819
+ secondary: true,
1820
+ hoverDelegate
1821
+ })));
1822
+ uriLabel.label = this.labelService.getUriBasenameLabel(uri);
1823
+ uriLabel.element.classList.add('monaco-icon-label');
1824
+ uriLabel.element.title = ( localize(
1825
+ 5323,
1826
+ "{0} - {1}",
1827
+ this.labelService.getUriLabel(uri, { relative: true }),
1828
+ description ?? ''
1829
+ ));
1830
+ this._chatEditsActionsDisposables.add(uriLabel.onDidClick(async () => {
1831
+ group.remove();
1832
+ await this._attachmentModel.addFile(uri);
1833
+ this.relatedFiles?.remove(uri);
1834
+ }));
1835
+ const addButton = this._chatEditsActionsDisposables.add(( new Button(anchor, {
1836
+ supportIcons: false,
1837
+ secondary: true,
1838
+ hoverDelegate,
1839
+ ariaLabel: ( localize(
1840
+ 5324,
1841
+ 'Add suggestion {0}',
1842
+ this.labelService.getUriLabel(uri, { relative: true })
1843
+ )),
1844
+ })));
1845
+ addButton.icon = Codicon.add;
1846
+ addButton.setTitle(( localize(5325, 'Add suggestion')));
1847
+ this._chatEditsActionsDisposables.add(addButton.onDidClick(async () => {
1848
+ group.remove();
1849
+ await this._attachmentModel.addFile(uri);
1850
+ this.relatedFiles?.remove(uri);
1851
+ }));
1852
+ const sep = createElement('div');
1853
+ sep.classList.add('separator');
1854
+ const group = createElement('span');
1855
+ group.classList.add('monaco-button-dropdown', 'sidebyside-button');
1856
+ group.appendChild(addButton.element);
1857
+ group.appendChild(sep);
1858
+ group.appendChild(uriLabel.element);
1859
+ append(anchor, group);
1860
+ this._chatEditsActionsDisposables.add(toDisposable(() => {
1861
+ group.remove();
1862
+ }));
1863
+ }
1864
+ this._onDidChangeHeight.fire();
1865
+ }
1866
+ async renderFollowups(items, response) {
1867
+ if (!this.options.renderFollowups) {
1868
+ return;
1869
+ }
1870
+ this.followupsDisposables.clear();
1871
+ clearNode(this.followupsContainer);
1872
+ if (items && items.length > 0) {
1873
+ this.followupsDisposables.add(this.instantiationService.createInstance(ChatFollowups, this.followupsContainer, items, this.location, undefined, followup => this._onDidAcceptFollowup.fire({ followup, response })));
1874
+ }
1875
+ this._onDidChangeHeight.fire();
1876
+ }
1877
+ get contentHeight() {
1878
+ const data = this.getLayoutData();
1879
+ return data.followupsHeight + data.inputPartEditorHeight + data.inputPartVerticalPadding + data.inputEditorBorder + data.attachmentsHeight + data.toolbarsHeight + data.chatEditingStateHeight + data.todoListWidgetContainerHeight + data.inputWidgetsContainerHeight;
1880
+ }
1881
+ layout(height, width) {
1882
+ this.cachedDimensions = new Dimension(width, height);
1883
+ return this._layout(height, width);
1884
+ }
1885
+ _layout(height, width, allowRecurse = true) {
1886
+ const data = this.getLayoutData();
1887
+ const inputEditorHeight = Math.min(data.inputPartEditorHeight, height - data.followupsHeight - data.attachmentsHeight - data.inputPartVerticalPadding - data.toolbarsHeight - data.chatEditingStateHeight - data.todoListWidgetContainerHeight - data.inputWidgetsContainerHeight);
1888
+ const followupsWidth = width - data.inputPartHorizontalPadding;
1889
+ this.followupsContainer.style.width = `${followupsWidth}px`;
1890
+ this._inputPartHeight = data.inputPartVerticalPadding + data.followupsHeight + inputEditorHeight + data.inputEditorBorder + data.attachmentsHeight + data.toolbarsHeight + data.chatEditingStateHeight + data.todoListWidgetContainerHeight + data.inputWidgetsContainerHeight;
1891
+ this._followupsHeight = data.followupsHeight;
1892
+ this._editSessionWidgetHeight = data.chatEditingStateHeight;
1893
+ const initialEditorScrollWidth = this._inputEditor.getScrollWidth();
1894
+ const newEditorWidth = width - data.inputPartHorizontalPadding - data.editorBorder - data.inputPartHorizontalPaddingInside - data.toolbarsWidth - data.sideToolbarWidth;
1895
+ const newDimension = { width: newEditorWidth, height: inputEditorHeight };
1896
+ if (!this.previousInputEditorDimension || (this.previousInputEditorDimension.width !== newDimension.width || this.previousInputEditorDimension.height !== newDimension.height)) {
1897
+ this._inputEditor.layout(newDimension);
1898
+ this.previousInputEditorDimension = newDimension;
1899
+ }
1900
+ if (allowRecurse && initialEditorScrollWidth < 10) {
1901
+ return this._layout(height, width, false);
1902
+ }
1903
+ }
1904
+ getLayoutData() {
1905
+ const executeToolbarWidth = this.cachedExecuteToolbarWidth = this.executeToolbar.getItemsWidth();
1906
+ const inputToolbarWidth = this.cachedInputToolbarWidth = this.inputActionsToolbar.getItemsWidth();
1907
+ const inputSideToolbarWidth = this.inputSideToolbarContainer ? getTotalWidth(this.inputSideToolbarContainer) : 0;
1908
+ const executeToolbarPadding = (this.executeToolbar.getItemsLength() - 1) * 4;
1909
+ const inputToolbarPadding = this.inputActionsToolbar.getItemsLength() ? (this.inputActionsToolbar.getItemsLength() - 1) * 4 : 0;
1910
+ return {
1911
+ inputEditorBorder: 2,
1912
+ followupsHeight: this.followupsContainer.offsetHeight,
1913
+ inputPartEditorHeight: Math.min(this._inputEditor.getContentHeight(), this.inputEditorMaxHeight),
1914
+ inputPartHorizontalPadding: this.options.renderStyle === 'compact' ? 16 : 32,
1915
+ inputPartVerticalPadding: this.options.renderStyle === 'compact' ? 12 : ((16 + 6 + (2 * 4)) ),
1916
+ attachmentsHeight: this.attachmentsHeight,
1917
+ editorBorder: 2,
1918
+ inputPartHorizontalPaddingInside: 12,
1919
+ toolbarsWidth: this.options.renderStyle === 'compact' ? executeToolbarWidth + executeToolbarPadding + (this.options.renderInputToolbarBelowInput ? 0 : inputToolbarWidth + inputToolbarPadding) : 0,
1920
+ toolbarsHeight: this.options.renderStyle === 'compact' ? 0 : 22,
1921
+ chatEditingStateHeight: this.chatEditingSessionWidgetContainer.offsetHeight,
1922
+ sideToolbarWidth: inputSideToolbarWidth > 0 ? inputSideToolbarWidth + 4 : 0,
1923
+ todoListWidgetContainerHeight: this.chatInputTodoListWidgetContainer.offsetHeight,
1924
+ inputWidgetsContainerHeight: this.inputWidgetsHeight,
1925
+ };
1926
+ }
1927
+ };
1928
+ ChatInputPart = ChatInputPart_1 = ( __decorate([
1929
+ ( __param(4, IModelService)),
1930
+ ( __param(5, IInstantiationService)),
1931
+ ( __param(6, IContextKeyService)),
1932
+ ( __param(7, IConfigurationService)),
1933
+ ( __param(8, IKeybindingService)),
1934
+ ( __param(9, IAccessibilityService)),
1935
+ ( __param(10, ILanguageModelsService)),
1936
+ ( __param(11, ILogService)),
1937
+ ( __param(12, IFileService)),
1938
+ ( __param(13, IEditorService)),
1939
+ ( __param(14, IThemeService)),
1940
+ ( __param(15, ITextModelService)),
1941
+ ( __param(16, IStorageService)),
1942
+ ( __param(17, ILabelService)),
1943
+ ( __param(18, IChatAgentService)),
1944
+ ( __param(19, ISharedWebContentExtractorService)),
1945
+ ( __param(20, IWorkbenchAssignmentService)),
1946
+ ( __param(21, IChatEntitlementService)),
1947
+ ( __param(22, IChatModeService)),
1948
+ ( __param(23, ILanguageModelToolsService)),
1949
+ ( __param(24, IChatService)),
1950
+ ( __param(25, IChatSessionsService)),
1951
+ ( __param(26, IChatContextService)),
1952
+ ( __param(27, IAgentSessionsService))
1953
+ ], ChatInputPart));
1954
+ function getLastPosition(model) {
1955
+ return { lineNumber: model.getLineCount(), column: model.getLineLength(model.getLineCount()) + 1 };
1956
+ }
1957
+ const chatInputEditorContainerSelector = '.interactive-input-editor';
1958
+ setupSimpleEditorSelectionStyling(chatInputEditorContainerSelector);
1959
+ class ChatSessionPickersContainerActionItem extends ActionViewItem {
1960
+ constructor(action, widgets, options) {
1961
+ super(null, action, options ?? {});
1962
+ this.widgets = widgets;
1963
+ }
1964
+ render(container) {
1965
+ container.classList.add('chat-sessionPicker-container');
1966
+ for (const widget of this.widgets) {
1967
+ const itemContainer = $$1('.action-item.chat-sessionPicker-item');
1968
+ widget.render(itemContainer);
1969
+ container.appendChild(itemContainer);
1970
+ }
1971
+ }
1972
+ dispose() {
1973
+ for (const widget of this.widgets) {
1974
+ widget.dispose();
1975
+ }
1976
+ super.dispose();
1977
+ }
1978
+ }
1979
+ class AddFilesButton extends ActionViewItem {
1980
+ constructor(context, action, options) {
1981
+ super(context, action, {
1982
+ ...options,
1983
+ icon: false,
1984
+ label: true,
1985
+ keybindingNotRenderedWithLabel: true,
1986
+ });
1987
+ }
1988
+ setShowLabel(show) {
1989
+ this.showLabel = show;
1990
+ this.updateLabel();
1991
+ }
1992
+ render(container) {
1993
+ container.classList.add('chat-attachment-button');
1994
+ super.render(container);
1995
+ this.updateLabel();
1996
+ }
1997
+ updateLabel() {
1998
+ if (!this.label) {
1999
+ return;
2000
+ }
2001
+ assertType(this.label);
2002
+ this.label.classList.toggle('has-label', this.showLabel);
2003
+ const message = this.showLabel ? `$(attach) ${this.action.label}` : `$(attach)`;
2004
+ reset(this.label, ...renderLabelWithIcons(message));
2005
+ }
2006
+ }
2007
+
2008
+ export { ChatInputPart };