@codingame/monaco-vscode-chat-service-override 17.2.1 → 18.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -4
- package/package.json +36 -30
- package/vscode/src/vs/base/common/objectCache.d.ts +2 -2
- package/vscode/src/vs/base/common/objectCache.js +3 -3
- package/vscode/src/vs/platform/browserElements/common/browserElements.d.ts +10 -0
- package/vscode/src/vs/platform/browserElements/common/browserElements.js +9 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +40 -40
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +158 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +13 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +256 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +234 -572
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +29 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolActions.js +107 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.d.ts +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatToolPicker.js +344 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +84 -37
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.d.ts +18 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatAttachInstructionsAction.js +137 -14
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatModeActions.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatModeActions.js +54 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatRunPromptAction.js +40 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatSaveToPromptAction.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/chatSaveToPromptAction.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/promptFilePickers.d.ts +15 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/promptFilePickers.js +171 -101
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/attachInstructions.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/attachInstructions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/dialogs/askToSelectPrompt/utils/runPrompt.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/index.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/promptActions/index.js +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +176 -69
- package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +15 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorAccessibility.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +22 -22
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +35 -29
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +80 -32
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +11 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +12 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +13 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +15 -13
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSessionStorage.js +3 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +10 -9
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +18 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/overlayToolbarDecorator.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/simpleBrowserEditorOverlay.js +118 -33
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +1 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +46 -48
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +31 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +382 -152
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +99 -56
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +11 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +1 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +9 -21
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +10 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +18 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +95 -24
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +92 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/media/github.svg +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/google.svg +6 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/simpleBrowserOverlay.css +10 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +111 -111
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.d.ts +3 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +36 -10
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.d.ts +5 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +91 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/errors.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.d.ts +1 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +4 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.d.ts +1 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/promptToolsCodeLensProvider.js +95 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.d.ts +24 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/tools/toolSetsContribution.js +348 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.d.ts +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatResponseResourceFileSystemProvider.js +93 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +46 -36
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/configMigration.d.ts +5 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/configMigration.js +21 -11
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/index.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/index.js +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptHeaderDiagnosticsProvider.d.ts +4 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptHeaderDiagnosticsProvider.js +12 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkDiagnosticsProvider.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkDiagnosticsProvider.js +1 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptLinkProvider.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/promptPathAutocompletion.js +5 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceBase.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceBase.js +9 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceManagerBase.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/providerInstanceManagerBase.js +12 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.d.ts +21 -10
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +111 -124
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +22 -8
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +159 -97
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.d.ts +15 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.js +2 -14
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +8 -2
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +198 -33
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +7 -7
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +28 -18
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/attachInstructionsCommand.d.ts +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/attachInstructionsCommand.js +0 -73
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterDecoration.d.ts +0 -29
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterDecoration.js +0 -74
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterMarkerDecoration.d.ts +0 -14
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/frontMatterMarkerDecoration.js +0 -40
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/decorationBase.d.ts +0 -23
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/decorationBase.js +0 -40
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/index.d.ts +0 -5
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/index.js +0 -9
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/reactiveDecorationBase.d.ts +0 -23
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/reactiveDecorationBase.js +0 -68
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/decorations/utils/types.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/promptDecorationsProvider.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/promptDecorationsProvider.js +0 -121
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/types.d.ts +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contributions/languageFeatures/providers/decorationsProvider/types.js +0 -13
|
@@ -1,65 +1,49 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { isThenable, DeferredPromise } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
3
|
+
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
4
4
|
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
5
5
|
import { KeyMod, KeyCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
6
|
-
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
7
|
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
8
|
-
import
|
|
9
|
-
import { basename, dirname, extUri } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
8
|
+
import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
|
|
10
9
|
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
10
|
+
import { isObject } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
11
11
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
12
12
|
import { Range } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/core/range';
|
|
13
|
-
import { SymbolKinds } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages';
|
|
14
13
|
import { ITextModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/resolverService.service';
|
|
15
14
|
import { AbstractGotoSymbolQuickAccessProvider } from '@codingame/monaco-vscode-ea14e352-8f1c-5569-b79a-8a96a53e8abe-common/vscode/vs/editor/contrib/quickAccess/browser/gotoSymbolQuickAccess';
|
|
16
15
|
import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
17
16
|
import { registerAction2, Action2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
18
|
-
import { IClipboardService } from '@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
19
|
-
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
20
17
|
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
21
18
|
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
22
19
|
import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
|
|
23
20
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
24
21
|
import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
25
22
|
import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
26
|
-
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
27
23
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
28
|
-
import { MarkerSeverity } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers';
|
|
29
|
-
import { IMarkerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markers/common/markers.service';
|
|
30
24
|
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
31
|
-
import {
|
|
25
|
+
import { ResourceContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
32
26
|
import { EditorResourceAccessor, SideBySideEditor } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
|
|
33
|
-
import { DiffEditorInput } from '@codingame/monaco-vscode-9c72783f-914c-50be-b9ef-da16356d81a8-common/vscode/vs/workbench/common/editor/diffEditorInput';
|
|
34
27
|
import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
35
|
-
import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
|
|
36
|
-
import { VIEW_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/search/common/search';
|
|
37
|
-
import { UntitledTextEditorInput } from '@codingame/monaco-vscode-5945a5e2-a66c-5a82-bd2c-1965724b29eb-common/vscode/vs/workbench/services/untitled/common/untitledTextEditorInput';
|
|
38
28
|
import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
|
|
39
|
-
import {
|
|
40
|
-
import { TEXT_FILE_EDITOR_ID } from '@codingame/monaco-vscode-97284942-b044-5fbb-b53b-3f46d2468746-common/vscode/vs/workbench/contrib/files/common/files';
|
|
41
|
-
import { NotebookEditorInput } from '@codingame/monaco-vscode-324f9a6e-6231-5bfc-af17-e147abd2dfd2-common/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
|
|
29
|
+
import { ExplorerFolderContext } from '@codingame/monaco-vscode-97284942-b044-5fbb-b53b-3f46d2468746-common/vscode/vs/workbench/contrib/files/common/files';
|
|
42
30
|
import { AnythingQuickAccessProvider } from '@codingame/monaco-vscode-64322fa2-7385-5f46-935b-8f243d98004b-common/vscode/vs/workbench/contrib/search/browser/anythingQuickAccess';
|
|
43
|
-
import { isSearchTreeFileMatch, isSearchTreeMatch } from '@codingame/monaco-vscode-
|
|
44
|
-
import { SymbolsQuickAccessProvider } from '@codingame/monaco-vscode-
|
|
45
|
-
import { SearchContext } from '@codingame/monaco-vscode-
|
|
46
|
-
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
31
|
+
import { isSearchTreeFileMatch, isSearchTreeMatch } from '@codingame/monaco-vscode-85f7fb0f-70f5-5a5e-831b-15c743a8bd11-common/vscode/vs/workbench/contrib/search/browser/searchTreeModel/searchTreeCommon';
|
|
32
|
+
import { SymbolsQuickAccessProvider } from '@codingame/monaco-vscode-bc8c28cd-7a80-54a9-af1a-e6b1e7a7f34a-common/vscode/vs/workbench/contrib/search/browser/symbolsQuickAccess';
|
|
33
|
+
import { SearchContext } from '@codingame/monaco-vscode-47472025-cc45-5680-86cd-09ceaba921a1-common/vscode/vs/workbench/contrib/search/common/constants';
|
|
47
34
|
import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
|
|
48
|
-
import {
|
|
49
|
-
import { OmittedState, IDiagnosticVariableEntryFilterData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
50
|
-
import { ChatRequestAgentPart } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatParserTypes';
|
|
35
|
+
import { OmittedState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatModel';
|
|
51
36
|
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
52
|
-
import { showChatView } from '@codingame/monaco-vscode-
|
|
37
|
+
import { showChatView } from '@codingame/monaco-vscode-7adbeffb-8051-54a9-8c9b-b62ce9e5836f-common/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
53
38
|
import { IChatWidgetService, IQuickChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
54
|
-
import {
|
|
39
|
+
import { isChatContextPickerPickItem } from '@codingame/monaco-vscode-f338ac19-278c-5fe1-bec8-b588de04a788-common/vscode/vs/workbench/contrib/chat/browser/chatContextPickService';
|
|
40
|
+
import { IChatContextPickService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatContextPickService.service';
|
|
55
41
|
import { isQuickChat } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/chat/browser/chatWidget';
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import { resizeImage } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/imageUtils';
|
|
59
|
-
import { INSTRUCTIONS_COMMAND_ID } from '../promptSyntax/contributions/attachInstructionsCommand.js';
|
|
60
|
-
import { CHAT_CATEGORY } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
42
|
+
import { resizeImage } from '@codingame/monaco-vscode-1cb11a73-359e-5a2f-9e95-6989cc9858ee-common/vscode/vs/workbench/contrib/chat/browser/imageUtils';
|
|
43
|
+
import { CHAT_CATEGORY } from '@codingame/monaco-vscode-3a35f433-1297-5707-ab58-c261b8180e6d-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
61
44
|
import { registerPromptActions } from './promptActions/index.js';
|
|
62
|
-
import {
|
|
45
|
+
import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
|
|
46
|
+
import { autorun } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/reactions/autorun';
|
|
63
47
|
|
|
64
48
|
function registerChatContextActions() {
|
|
65
49
|
registerAction2(AttachContextAction);
|
|
@@ -67,43 +51,26 @@ function registerChatContextActions() {
|
|
|
67
51
|
registerAction2(AttachFolderToChatAction);
|
|
68
52
|
registerAction2(AttachSelectionToChatAction);
|
|
69
53
|
registerAction2(AttachSearchResultAction);
|
|
54
|
+
registerPromptActions();
|
|
70
55
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'command',
|
|
79
|
-
'screenshot',
|
|
80
|
-
'image',
|
|
81
|
-
'workspaceSymbol',
|
|
82
|
-
'diagnostic',
|
|
83
|
-
'instructions',
|
|
84
|
-
'related-files',
|
|
85
|
-
'folder',
|
|
86
|
-
'open-editors',
|
|
87
|
-
];
|
|
88
|
-
function isIGotoSymbolQuickPickItem(obj) {
|
|
89
|
-
return (typeof obj === 'object'
|
|
90
|
-
&& typeof obj.symbolName === 'string'
|
|
91
|
-
&& !!obj.uri
|
|
92
|
-
&& !!obj.range);
|
|
93
|
-
}
|
|
94
|
-
function isISymbolQuickPickItem(obj) {
|
|
95
|
-
return (typeof obj === 'object'
|
|
96
|
-
&& typeof obj.symbol === 'object'
|
|
97
|
-
&& !!obj.symbol);
|
|
98
|
-
}
|
|
99
|
-
function isIQuickPickItemWithResource(obj) {
|
|
100
|
-
return (typeof obj === 'object'
|
|
101
|
-
&& typeof obj.resource === 'object'
|
|
102
|
-
&& URI.isUri(obj.resource));
|
|
56
|
+
async function withChatView(accessor) {
|
|
57
|
+
const viewsService = accessor.get(IViewsService);
|
|
58
|
+
const chatWidgetService = accessor.get(IChatWidgetService);
|
|
59
|
+
if (chatWidgetService.lastFocusedWidget) {
|
|
60
|
+
return chatWidgetService.lastFocusedWidget;
|
|
61
|
+
}
|
|
62
|
+
return showChatView(viewsService);
|
|
103
63
|
}
|
|
104
|
-
const INSTRUCTION_PICK_ID = 'instructions';
|
|
105
64
|
class AttachResourceAction extends Action2 {
|
|
106
|
-
|
|
65
|
+
async run(accessor, ...args) {
|
|
66
|
+
const instaService = accessor.get(IInstantiationService);
|
|
67
|
+
const widget = await instaService.invokeFunction(withChatView);
|
|
68
|
+
if (!widget) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
return instaService.invokeFunction(this.runWithWidget.bind(this), widget, ...args);
|
|
72
|
+
}
|
|
73
|
+
_getResources(accessor, ...args) {
|
|
107
74
|
const editorService = accessor.get(IEditorService);
|
|
108
75
|
const contexts = Array.isArray(args[1]) ? args[1] : [args[0]];
|
|
109
76
|
const files = [];
|
|
@@ -133,24 +100,36 @@ class AttachFileToChatAction extends AttachResourceAction {
|
|
|
133
100
|
constructor() {
|
|
134
101
|
super({
|
|
135
102
|
id: AttachFileToChatAction.ID,
|
|
136
|
-
title: ( localize2(
|
|
103
|
+
title: ( localize2(4442, "Add File to Chat")),
|
|
137
104
|
category: CHAT_CATEGORY,
|
|
138
105
|
f1: false,
|
|
139
106
|
menu: [{
|
|
140
107
|
id: MenuId.SearchContext,
|
|
141
108
|
group: 'z_chat',
|
|
142
109
|
order: 1,
|
|
143
|
-
when: ( ContextKeyExpr.and(
|
|
110
|
+
when: ( ContextKeyExpr.and(
|
|
111
|
+
ChatContextKeys.enabled,
|
|
112
|
+
SearchContext.FileMatchOrMatchFocusKey,
|
|
113
|
+
( SearchContext.SearchResultHeaderFocused.negate())
|
|
114
|
+
)),
|
|
115
|
+
}, {
|
|
116
|
+
id: MenuId.ChatExplorerMenu,
|
|
117
|
+
group: 'zContext',
|
|
118
|
+
order: 1,
|
|
119
|
+
when: ( ContextKeyExpr.and(ChatContextKeys.enabled, ( ExplorerFolderContext.negate()), ( ContextKeyExpr.or(( ResourceContextKey.Scheme.isEqualTo(Schemas.file)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeRemote)))))),
|
|
120
|
+
}, {
|
|
121
|
+
id: MenuId.ChatTextEditorMenu,
|
|
122
|
+
group: 'zContext',
|
|
123
|
+
order: 2,
|
|
124
|
+
when: ( ContextKeyExpr.and(ChatContextKeys.enabled, ( ContextKeyExpr.or(( ResourceContextKey.Scheme.isEqualTo(Schemas.file)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeRemote)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.untitled)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeUserData))))))
|
|
144
125
|
}]
|
|
145
126
|
});
|
|
146
127
|
}
|
|
147
|
-
async
|
|
148
|
-
const
|
|
149
|
-
const files = this.getResources(accessor, ...args);
|
|
128
|
+
async runWithWidget(accessor, widget, ...args) {
|
|
129
|
+
const files = this._getResources(accessor, ...args);
|
|
150
130
|
if (!files.length) {
|
|
151
131
|
return;
|
|
152
132
|
}
|
|
153
|
-
const widget = await showChatView(viewsService);
|
|
154
133
|
if (widget) {
|
|
155
134
|
widget.focusInput();
|
|
156
135
|
for (const file of files) {
|
|
@@ -164,18 +143,22 @@ class AttachFolderToChatAction extends AttachResourceAction {
|
|
|
164
143
|
constructor() {
|
|
165
144
|
super({
|
|
166
145
|
id: AttachFolderToChatAction.ID,
|
|
167
|
-
title: ( localize2(
|
|
146
|
+
title: ( localize2(4443, "Add Folder to Chat")),
|
|
168
147
|
category: CHAT_CATEGORY,
|
|
169
148
|
f1: false,
|
|
149
|
+
menu: {
|
|
150
|
+
id: MenuId.ChatExplorerMenu,
|
|
151
|
+
group: 'zContext',
|
|
152
|
+
order: 1,
|
|
153
|
+
when: ( ContextKeyExpr.and(ChatContextKeys.enabled, ExplorerFolderContext, ( ContextKeyExpr.or(( ResourceContextKey.Scheme.isEqualTo(Schemas.file)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeRemote))))))
|
|
154
|
+
}
|
|
170
155
|
});
|
|
171
156
|
}
|
|
172
|
-
async
|
|
173
|
-
const
|
|
174
|
-
const folders = this.getResources(accessor, ...args);
|
|
157
|
+
async runWithWidget(accessor, widget, ...args) {
|
|
158
|
+
const folders = this._getResources(accessor, ...args);
|
|
175
159
|
if (!folders.length) {
|
|
176
160
|
return;
|
|
177
161
|
}
|
|
178
|
-
const widget = await showChatView(viewsService);
|
|
179
162
|
if (widget) {
|
|
180
163
|
widget.focusInput();
|
|
181
164
|
for (const folder of folders) {
|
|
@@ -189,15 +172,20 @@ class AttachSelectionToChatAction extends Action2 {
|
|
|
189
172
|
constructor() {
|
|
190
173
|
super({
|
|
191
174
|
id: AttachSelectionToChatAction.ID,
|
|
192
|
-
title: ( localize2(
|
|
175
|
+
title: ( localize2(4444, "Add Selection to Chat")),
|
|
193
176
|
category: CHAT_CATEGORY,
|
|
194
177
|
f1: false,
|
|
178
|
+
menu: {
|
|
179
|
+
id: MenuId.ChatTextEditorMenu,
|
|
180
|
+
group: 'zContext',
|
|
181
|
+
order: 1,
|
|
182
|
+
when: ( ContextKeyExpr.and(ChatContextKeys.enabled, ( ContextKeyExpr.or(( ResourceContextKey.Scheme.isEqualTo(Schemas.file)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeRemote)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.untitled)), ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeUserData))))))
|
|
183
|
+
}
|
|
195
184
|
});
|
|
196
185
|
}
|
|
197
186
|
async run(accessor, ...args) {
|
|
198
187
|
const editorService = accessor.get(IEditorService);
|
|
199
|
-
const
|
|
200
|
-
const widget = await showChatView(viewsService);
|
|
188
|
+
const widget = await accessor.get(IInstantiationService).invokeFunction(withChatView);
|
|
201
189
|
if (!widget) {
|
|
202
190
|
return;
|
|
203
191
|
}
|
|
@@ -244,7 +232,7 @@ class AttachSearchResultAction extends Action2 {
|
|
|
244
232
|
constructor() {
|
|
245
233
|
super({
|
|
246
234
|
id: 'workbench.action.chat.insertSearchResults',
|
|
247
|
-
title: ( localize2(
|
|
235
|
+
title: ( localize2(4445, 'Add Search Results to Chat')),
|
|
248
236
|
category: CHAT_CATEGORY,
|
|
249
237
|
f1: false,
|
|
250
238
|
menu: [{
|
|
@@ -257,7 +245,7 @@ class AttachSearchResultAction extends Action2 {
|
|
|
257
245
|
}
|
|
258
246
|
async run(accessor) {
|
|
259
247
|
const logService = accessor.get(ILogService);
|
|
260
|
-
const widget = await
|
|
248
|
+
const widget = await accessor.get(IInstantiationService).invokeFunction(withChatView);
|
|
261
249
|
if (!widget) {
|
|
262
250
|
logService.trace('InsertSearchResultAction: no chat view available');
|
|
263
251
|
return;
|
|
@@ -291,11 +279,26 @@ class AttachSearchResultAction extends Action2 {
|
|
|
291
279
|
}
|
|
292
280
|
}
|
|
293
281
|
}
|
|
282
|
+
function isIContextPickItemItem(obj) {
|
|
283
|
+
return (isObject(obj)
|
|
284
|
+
&& typeof obj.kind === 'string'
|
|
285
|
+
&& obj.kind === 'contextPick');
|
|
286
|
+
}
|
|
287
|
+
function isIGotoSymbolQuickPickItem(obj) {
|
|
288
|
+
return (isObject(obj)
|
|
289
|
+
&& typeof obj.symbolName === 'string'
|
|
290
|
+
&& !!obj.uri
|
|
291
|
+
&& !!obj.range);
|
|
292
|
+
}
|
|
293
|
+
function isIQuickPickItemWithResource(obj) {
|
|
294
|
+
return (isObject(obj)
|
|
295
|
+
&& URI.isUri(obj.resource));
|
|
296
|
+
}
|
|
294
297
|
class AttachContextAction extends Action2 {
|
|
295
298
|
constructor() {
|
|
296
299
|
super({
|
|
297
300
|
id: 'workbench.action.chat.attachContext',
|
|
298
|
-
title: ( localize2(
|
|
301
|
+
title: ( localize2(4446, "Add Context...")),
|
|
299
302
|
icon: Codicon.attach,
|
|
300
303
|
category: CHAT_CATEGORY,
|
|
301
304
|
keybinding: {
|
|
@@ -311,542 +314,201 @@ class AttachContextAction extends Action2 {
|
|
|
311
314
|
},
|
|
312
315
|
});
|
|
313
316
|
}
|
|
314
|
-
_getFileContextId(item) {
|
|
315
|
-
if ('resource' in item) {
|
|
316
|
-
return ( item.resource.toString());
|
|
317
|
-
}
|
|
318
|
-
return ( item.uri.toString()) + (item.range.startLineNumber !== item.range.endLineNumber ?
|
|
319
|
-
`:${item.range.startLineNumber}-${item.range.endLineNumber}` :
|
|
320
|
-
`:${item.range.startLineNumber}`);
|
|
321
|
-
}
|
|
322
|
-
async _attachContext(accessor, widget, isInBackground, ...picks) {
|
|
323
|
-
const commandService = accessor.get(ICommandService);
|
|
324
|
-
const clipboardService = accessor.get(IClipboardService);
|
|
325
|
-
const editorService = accessor.get(IEditorService);
|
|
326
|
-
const labelService = accessor.get(ILabelService);
|
|
327
|
-
const viewsService = accessor.get(IViewsService);
|
|
328
|
-
const chatEditingService = accessor.get(IChatEditingService);
|
|
329
|
-
const hostService = accessor.get(IHostService);
|
|
330
|
-
const fileService = accessor.get(IFileService);
|
|
331
|
-
const textModelService = accessor.get(ITextModelService);
|
|
332
|
-
const quickInputService = accessor.get(IQuickInputService);
|
|
333
|
-
const toAttach = [];
|
|
334
|
-
for (const pick of picks) {
|
|
335
|
-
if (isIAttachmentQuickPickItem(pick)) {
|
|
336
|
-
if (pick.kind === 'folder-search-result') {
|
|
337
|
-
toAttach.push({
|
|
338
|
-
kind: 'directory',
|
|
339
|
-
id: pick.id,
|
|
340
|
-
value: pick.resource,
|
|
341
|
-
name: basename(pick.resource),
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
else if (pick.kind === 'diagnostic-filter') {
|
|
345
|
-
toAttach.push({
|
|
346
|
-
id: pick.id,
|
|
347
|
-
name: pick.label,
|
|
348
|
-
value: pick.filter,
|
|
349
|
-
kind: 'diagnostic',
|
|
350
|
-
icon: pick.icon,
|
|
351
|
-
...pick.filter,
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
else if (pick.kind === 'open-editors') {
|
|
355
|
-
for (const editor of editorService.editors.filter(e => e instanceof FileEditorInput || e instanceof DiffEditorInput || e instanceof UntitledTextEditorInput || e instanceof NotebookEditorInput)) {
|
|
356
|
-
const uri = editor instanceof DiffEditorInput ? editor.modified.resource : editor.resource;
|
|
357
|
-
if (uri) {
|
|
358
|
-
toAttach.push({
|
|
359
|
-
kind: 'file',
|
|
360
|
-
id: this._getFileContextId({ resource: uri }),
|
|
361
|
-
value: uri,
|
|
362
|
-
name: labelService.getUriBasenameLabel(uri),
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
else if (pick.kind === 'search-results') {
|
|
368
|
-
const searchView = viewsService.getViewWithId(VIEW_ID);
|
|
369
|
-
for (const result of searchView.model.searchResult.matches()) {
|
|
370
|
-
toAttach.push({
|
|
371
|
-
kind: 'file',
|
|
372
|
-
id: this._getFileContextId({ resource: result.resource }),
|
|
373
|
-
value: result.resource,
|
|
374
|
-
name: labelService.getUriBasenameLabel(result.resource),
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
else if (pick.kind === 'related-files') {
|
|
379
|
-
const chatSessionId = widget.viewModel?.sessionId;
|
|
380
|
-
if (!chatSessionId || !chatEditingService) {
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
const relatedFiles = await chatEditingService.getRelatedFiles(chatSessionId, widget.getInput(), widget.attachmentModel.fileAttachments, CancellationToken.None);
|
|
384
|
-
if (!relatedFiles) {
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
const attachments = widget.attachmentModel.getAttachmentIDs();
|
|
388
|
-
const itemsPromise = chatEditingService.getRelatedFiles(chatSessionId, widget.getInput(), widget.attachmentModel.fileAttachments, CancellationToken.None)
|
|
389
|
-
.then((files) => (files ?? []).reduce((acc, cur) => {
|
|
390
|
-
acc.push({ type: 'separator', label: cur.group });
|
|
391
|
-
for (const file of cur.files) {
|
|
392
|
-
acc.push({
|
|
393
|
-
type: 'item',
|
|
394
|
-
label: labelService.getUriBasenameLabel(file.uri),
|
|
395
|
-
description: labelService.getUriLabel(dirname(file.uri), { relative: true }),
|
|
396
|
-
value: file.uri,
|
|
397
|
-
disabled: ( attachments.has(this._getFileContextId({ resource: file.uri }))),
|
|
398
|
-
picked: true
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
return acc;
|
|
402
|
-
}, []));
|
|
403
|
-
const selectedFile = await quickInputService.pick(itemsPromise, { placeHolder: ( localize(4404, 'Add related files to your working set')) });
|
|
404
|
-
if (selectedFile) {
|
|
405
|
-
toAttach.push({
|
|
406
|
-
kind: 'file',
|
|
407
|
-
id: this._getFileContextId({ resource: selectedFile.value }),
|
|
408
|
-
value: selectedFile.value,
|
|
409
|
-
name: selectedFile.label,
|
|
410
|
-
omittedState: OmittedState.NotOmitted
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
else if (pick.kind === 'screenshot') {
|
|
415
|
-
const blob = await hostService.getScreenshot();
|
|
416
|
-
if (blob) {
|
|
417
|
-
toAttach.push(convertBufferToScreenshotVariable(blob));
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
else if (pick.kind === 'command') {
|
|
421
|
-
const selection = await commandService.executeCommand(pick.command.id, ...(pick.command.arguments ?? []));
|
|
422
|
-
if (!selection) {
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
toAttach.push({
|
|
426
|
-
...pick,
|
|
427
|
-
value: pick.value,
|
|
428
|
-
name: `${typeof pick.value === 'string' && pick.value.startsWith('#') ? pick.value.slice(1) : ''}${selection}`,
|
|
429
|
-
fullName: selection
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
else if (pick.kind === 'tool') {
|
|
433
|
-
toAttach.push({
|
|
434
|
-
id: pick.id,
|
|
435
|
-
name: pick.tool.displayName,
|
|
436
|
-
fullName: pick.tool.displayName,
|
|
437
|
-
value: undefined,
|
|
438
|
-
icon: pick.icon,
|
|
439
|
-
kind: 'tool'
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
else if (pick.kind === 'image') {
|
|
443
|
-
const fileBuffer = await clipboardService.readImage();
|
|
444
|
-
toAttach.push({
|
|
445
|
-
id: await imageToHash(fileBuffer),
|
|
446
|
-
name: ( localize(4405, 'Pasted Image')),
|
|
447
|
-
fullName: ( localize(4405, 'Pasted Image')),
|
|
448
|
-
value: fileBuffer,
|
|
449
|
-
kind: 'image',
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
else if (isISymbolQuickPickItem(pick) && pick.symbol) {
|
|
454
|
-
toAttach.push({
|
|
455
|
-
kind: 'symbol',
|
|
456
|
-
id: this._getFileContextId(pick.symbol.location),
|
|
457
|
-
value: pick.symbol.location,
|
|
458
|
-
symbolKind: pick.symbol.kind,
|
|
459
|
-
icon: SymbolKinds.toIcon(pick.symbol.kind),
|
|
460
|
-
fullName: pick.label,
|
|
461
|
-
name: pick.symbol.name,
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
else if (isIQuickPickItemWithResource(pick) && pick.resource) {
|
|
465
|
-
if (/\.(png|jpg|jpeg|bmp|gif|tiff)$/i.test(pick.resource.path)) {
|
|
466
|
-
if (URI.isUri(pick.resource)) {
|
|
467
|
-
const readFile = await fileService.readFile(pick.resource);
|
|
468
|
-
const resizedImage = await resizeImage(readFile.value.buffer);
|
|
469
|
-
toAttach.push({
|
|
470
|
-
id: ( pick.resource.toString()),
|
|
471
|
-
name: pick.label,
|
|
472
|
-
fullName: pick.label,
|
|
473
|
-
value: resizedImage,
|
|
474
|
-
kind: 'image',
|
|
475
|
-
references: [{ reference: pick.resource, kind: 'reference' }]
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
let omittedState = OmittedState.NotOmitted;
|
|
481
|
-
try {
|
|
482
|
-
const createdModel = await textModelService.createModelReference(pick.resource);
|
|
483
|
-
createdModel.dispose();
|
|
484
|
-
}
|
|
485
|
-
catch {
|
|
486
|
-
omittedState = OmittedState.Full;
|
|
487
|
-
}
|
|
488
|
-
toAttach.push({
|
|
489
|
-
kind: 'file',
|
|
490
|
-
id: this._getFileContextId({ resource: pick.resource }),
|
|
491
|
-
value: pick.resource,
|
|
492
|
-
name: pick.label,
|
|
493
|
-
omittedState
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
else if (isIGotoSymbolQuickPickItem(pick) && pick.uri && pick.range) {
|
|
498
|
-
toAttach.push({
|
|
499
|
-
kind: 'generic',
|
|
500
|
-
id: this._getFileContextId({ uri: pick.uri, range: pick.range.decoration }),
|
|
501
|
-
value: { uri: pick.uri, range: pick.range.decoration },
|
|
502
|
-
fullName: pick.label,
|
|
503
|
-
name: pick.symbolName,
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
widget.attachmentModel.addContext(...toAttach);
|
|
508
|
-
if (!isInBackground) {
|
|
509
|
-
widget.focusInput();
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
317
|
async run(accessor, ...args) {
|
|
513
|
-
const
|
|
318
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
514
319
|
const widgetService = accessor.get(IChatWidgetService);
|
|
515
|
-
const clipboardService = accessor.get(IClipboardService);
|
|
516
|
-
const editorService = accessor.get(IEditorService);
|
|
517
320
|
const contextKeyService = accessor.get(IContextKeyService);
|
|
518
|
-
const instantiationService = accessor.get(IInstantiationService);
|
|
519
321
|
const keybindingService = accessor.get(IKeybindingService);
|
|
520
|
-
const
|
|
322
|
+
const contextPickService = accessor.get(IChatContextPickService);
|
|
521
323
|
const context = args[0];
|
|
522
324
|
const widget = context?.widget ?? widgetService.lastFocusedWidget;
|
|
523
325
|
if (!widget) {
|
|
524
326
|
return;
|
|
525
327
|
}
|
|
526
328
|
const quickPickItems = [];
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
quickPickItems.push({
|
|
531
|
-
kind: 'image',
|
|
532
|
-
id: await imageToHash(imageData),
|
|
533
|
-
label: ( localize(4406, 'Image from Clipboard')),
|
|
534
|
-
iconClass: ThemeIcon.asClassName(Codicon.fileMedia),
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
quickPickItems.push({
|
|
538
|
-
kind: 'screenshot',
|
|
539
|
-
id: ScreenshotVariableId,
|
|
540
|
-
icon: ThemeIcon.fromId(Codicon.deviceCamera.id),
|
|
541
|
-
iconClass: ThemeIcon.asClassName(Codicon.deviceCamera),
|
|
542
|
-
label: (isElectron
|
|
543
|
-
? ( localize(4407, 'Screenshot Window'))
|
|
544
|
-
: ( localize(4408, 'Screenshot'))),
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
if (widget.viewModel?.sessionId) {
|
|
548
|
-
const agentPart = widget.parsedInput.parts.find((part) => part instanceof ChatRequestAgentPart);
|
|
549
|
-
if (agentPart) {
|
|
550
|
-
const completions = await chatAgentService.getAgentCompletionItems(agentPart.agent.id, '', CancellationToken.None);
|
|
551
|
-
for (const variable of completions) {
|
|
552
|
-
if (variable.fullName && variable.command) {
|
|
553
|
-
quickPickItems.push({
|
|
554
|
-
kind: 'command',
|
|
555
|
-
label: variable.fullName,
|
|
556
|
-
id: variable.id,
|
|
557
|
-
command: variable.command,
|
|
558
|
-
icon: variable.icon,
|
|
559
|
-
iconClass: variable.icon ? ThemeIcon.asClassName(variable.icon) : undefined,
|
|
560
|
-
value: variable.value,
|
|
561
|
-
name: variable.name
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
}
|
|
329
|
+
for (const item of contextPickService.items) {
|
|
330
|
+
if (item.isEnabled && !(await item.isEnabled(widget))) {
|
|
331
|
+
continue;
|
|
565
332
|
}
|
|
566
|
-
}
|
|
567
|
-
quickPickItems.push({
|
|
568
|
-
kind: 'tools',
|
|
569
|
-
label: ( localize(4409, 'Tools...')),
|
|
570
|
-
iconClass: ThemeIcon.asClassName(Codicon.tools),
|
|
571
|
-
id: 'tools',
|
|
572
|
-
});
|
|
573
|
-
quickPickItems.push({
|
|
574
|
-
kind: 'workspaceSymbol',
|
|
575
|
-
label: ( localize(4410, 'Symbols...')),
|
|
576
|
-
iconClass: ThemeIcon.asClassName(Codicon.symbolField),
|
|
577
|
-
id: 'symbol'
|
|
578
|
-
});
|
|
579
|
-
quickPickItems.push({
|
|
580
|
-
kind: 'folder',
|
|
581
|
-
label: ( localize(4411, 'Files & Folders...')),
|
|
582
|
-
iconClass: ThemeIcon.asClassName(Codicon.folder),
|
|
583
|
-
id: 'folder',
|
|
584
|
-
});
|
|
585
|
-
quickPickItems.push({
|
|
586
|
-
kind: 'diagnostic',
|
|
587
|
-
label: ( localize(4412, 'Problems...')),
|
|
588
|
-
iconClass: ThemeIcon.asClassName(Codicon.error),
|
|
589
|
-
id: 'diagnostic'
|
|
590
|
-
});
|
|
591
|
-
if (widget.location === ChatAgentLocation.Notebook) {
|
|
592
|
-
quickPickItems.push({
|
|
593
|
-
kind: 'command',
|
|
594
|
-
id: 'chatContext.notebook.kernelVariable',
|
|
595
|
-
icon: ThemeIcon.fromId(Codicon.serverEnvironment.id),
|
|
596
|
-
iconClass: ThemeIcon.asClassName(Codicon.serverEnvironment),
|
|
597
|
-
value: 'kernelVariable',
|
|
598
|
-
label: ( localize(4413, 'Kernel Variable...')),
|
|
599
|
-
command: {
|
|
600
|
-
id: 'notebook.chat.selectAndInsertKernelVariable',
|
|
601
|
-
title: ( localize(4414, 'Select and Insert Kernel Variable')),
|
|
602
|
-
arguments: [{ widget, range: undefined }]
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
if (chatEditingService?.hasRelatedFilesProviders() && (widget.getInput() || widget.attachmentModel.fileAttachments.length > 0)) {
|
|
607
|
-
quickPickItems.push({
|
|
608
|
-
kind: 'related-files',
|
|
609
|
-
id: 'related-files',
|
|
610
|
-
label: ( localize(4415, 'Related Files')),
|
|
611
|
-
iconClass: ThemeIcon.asClassName(Codicon.sparkle),
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
if (editorService.editors.filter(e => e instanceof FileEditorInput || e instanceof DiffEditorInput || e instanceof UntitledTextEditorInput).length > 0) {
|
|
615
|
-
quickPickItems.push({
|
|
616
|
-
kind: 'open-editors',
|
|
617
|
-
id: 'open-editors',
|
|
618
|
-
label: ( localize(4416, 'Open Editors')),
|
|
619
|
-
iconClass: ThemeIcon.asClassName(Codicon.files),
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
|
-
if (SearchContext.HasSearchResults.getValue(contextKeyService)) {
|
|
623
333
|
quickPickItems.push({
|
|
624
|
-
kind: '
|
|
625
|
-
|
|
626
|
-
label:
|
|
627
|
-
iconClass: ThemeIcon.asClassName(
|
|
334
|
+
kind: 'contextPick',
|
|
335
|
+
item,
|
|
336
|
+
label: item.label,
|
|
337
|
+
iconClass: ThemeIcon.asClassName(item.icon),
|
|
338
|
+
keybinding: item.commandId ? keybindingService.lookupKeybinding(item.commandId, contextKeyService) : undefined,
|
|
628
339
|
});
|
|
629
340
|
}
|
|
630
|
-
|
|
631
|
-
const keybinding = keybindingService.lookupKeybinding(INSTRUCTIONS_COMMAND_ID, contextKeyService);
|
|
632
|
-
quickPickItems.push({
|
|
633
|
-
id: INSTRUCTION_PICK_ID,
|
|
634
|
-
kind: INSTRUCTION_PICK_ID,
|
|
635
|
-
label: ( localize(4418, 'Instructions...')),
|
|
636
|
-
iconClass: ThemeIcon.asClassName(Codicon.bookmark),
|
|
637
|
-
keybinding,
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
quickPickItems.sort((a, b) => {
|
|
641
|
-
let result = attachmentsOrdinals.indexOf(b.kind) - attachmentsOrdinals.indexOf(a.kind);
|
|
642
|
-
if (result === 0) {
|
|
643
|
-
result = a.label.localeCompare(b.label);
|
|
644
|
-
}
|
|
645
|
-
return result;
|
|
646
|
-
});
|
|
647
|
-
instantiationService.invokeFunction(this._show.bind(this), widget, quickPickItems, '', context?.placeholder);
|
|
341
|
+
instantiationService.invokeFunction(this._show.bind(this), widget, quickPickItems, context?.placeholder);
|
|
648
342
|
}
|
|
649
|
-
|
|
650
|
-
const convert = (item) => ({
|
|
651
|
-
kind: 'diagnostic-filter',
|
|
652
|
-
id: IDiagnosticVariableEntryFilterData.id(item),
|
|
653
|
-
label: IDiagnosticVariableEntryFilterData.label(item),
|
|
654
|
-
icon: IDiagnosticVariableEntryFilterData.icon,
|
|
655
|
-
filter: item,
|
|
656
|
-
});
|
|
657
|
-
const filter = await instantiationService.invokeFunction(createMarkersQuickPick, items => onBackgroundAccept(( items.map(convert))));
|
|
658
|
-
return filter && convert(filter);
|
|
659
|
-
}
|
|
660
|
-
_show(accessor, widget, quickPickItems, query = '', placeholder) {
|
|
343
|
+
_show(accessor, widget, additionPicks, placeholder) {
|
|
661
344
|
const quickInputService = accessor.get(IQuickInputService);
|
|
662
345
|
const quickChatService = accessor.get(IQuickChatService);
|
|
663
|
-
const editorService = accessor.get(IEditorService);
|
|
664
|
-
const commandService = accessor.get(ICommandService);
|
|
665
346
|
const instantiationService = accessor.get(IInstantiationService);
|
|
666
|
-
const attach = (isBackgroundAccept, ...items) => {
|
|
667
|
-
instantiationService.invokeFunction(this._attachContext.bind(this), widget, isBackgroundAccept, ...items);
|
|
668
|
-
};
|
|
669
347
|
const providerOptions = {
|
|
670
|
-
additionPicks
|
|
671
|
-
handleAccept: async (
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
if (item.
|
|
675
|
-
|
|
676
|
-
return;
|
|
348
|
+
additionPicks,
|
|
349
|
+
handleAccept: async (item, isBackgroundAccept) => {
|
|
350
|
+
if (isIContextPickItemItem(item)) {
|
|
351
|
+
let isDone = true;
|
|
352
|
+
if (item.item.type === 'valuePick') {
|
|
353
|
+
this._handleContextPick(item.item, widget);
|
|
677
354
|
}
|
|
678
|
-
else if (item.
|
|
679
|
-
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
if (item.kind === 'folder') {
|
|
683
|
-
item = await this._showFolders(instantiationService);
|
|
684
|
-
}
|
|
685
|
-
else if (item.kind === 'diagnostic') {
|
|
686
|
-
item = await this._showDiagnosticsPick(instantiationService, i => attach(true, ...i));
|
|
355
|
+
else if (item.item.type === 'pickerPick') {
|
|
356
|
+
isDone = await this._handleContextPickerItem(quickInputService, item.item, widget);
|
|
687
357
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
if (!item) {
|
|
692
|
-
instantiationService.invokeFunction(this._show.bind(this), widget, quickPickItems, '', placeholder);
|
|
358
|
+
if (!isDone) {
|
|
359
|
+
instantiationService.invokeFunction(this._show.bind(this), widget, additionPicks, placeholder);
|
|
693
360
|
return;
|
|
694
361
|
}
|
|
695
362
|
}
|
|
696
|
-
|
|
363
|
+
else {
|
|
364
|
+
instantiationService.invokeFunction(this._handleQPPick.bind(this), widget, isBackgroundAccept, item);
|
|
365
|
+
}
|
|
697
366
|
if (isQuickChat(widget)) {
|
|
698
367
|
quickChatService.open();
|
|
699
368
|
}
|
|
700
|
-
},
|
|
701
|
-
filter: (item) => {
|
|
702
|
-
const attachedContext = widget.attachmentModel.getAttachmentIDs();
|
|
703
|
-
if (isIAttachmentQuickPickItem(item) && item.kind === 'open-editors') {
|
|
704
|
-
for (const editor of editorService.editors.filter(e => e instanceof FileEditorInput || e instanceof DiffEditorInput || e instanceof UntitledTextEditorInput)) {
|
|
705
|
-
if (editor.resource && !( attachedContext.has(this._getFileContextId({ resource: editor.resource })))) {
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return false;
|
|
710
|
-
}
|
|
711
|
-
if ('kind' in item && item.kind === 'image') {
|
|
712
|
-
return !( attachedContext.has(item.id));
|
|
713
|
-
}
|
|
714
|
-
if ('symbol' in item && item.symbol) {
|
|
715
|
-
return !( attachedContext.has(this._getFileContextId(item.symbol.location)));
|
|
716
|
-
}
|
|
717
|
-
if (item && typeof item === 'object' && 'resource' in item && URI.isUri(item.resource)) {
|
|
718
|
-
return [Schemas.file, Schemas.vscodeRemote, Schemas.untitled].includes(item.resource.scheme)
|
|
719
|
-
&& !( attachedContext.has(this._getFileContextId({ resource: item.resource })));
|
|
720
|
-
}
|
|
721
|
-
if (item && typeof item === 'object' && 'uri' in item && item.uri && item.range) {
|
|
722
|
-
return !( attachedContext.has(this._getFileContextId({ uri: item.uri, range: item.range.decoration })));
|
|
723
|
-
}
|
|
724
|
-
if (!('command' in item) && item.id) {
|
|
725
|
-
return !( attachedContext.has(item.id));
|
|
726
|
-
}
|
|
727
|
-
return true;
|
|
728
369
|
}
|
|
729
370
|
};
|
|
730
|
-
quickInputService.quickAccess.show(
|
|
371
|
+
quickInputService.quickAccess.show('', {
|
|
731
372
|
enabledProviderPrefixes: [
|
|
732
373
|
AnythingQuickAccessProvider.PREFIX,
|
|
733
374
|
SymbolsQuickAccessProvider.PREFIX,
|
|
734
375
|
AbstractGotoSymbolQuickAccessProvider.PREFIX
|
|
735
376
|
],
|
|
736
|
-
placeholder: placeholder ?? ( localize(
|
|
377
|
+
placeholder: placeholder ?? ( localize(4447, 'Search attachments')),
|
|
737
378
|
providerOptions,
|
|
738
379
|
});
|
|
739
380
|
}
|
|
740
|
-
async
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
const grouped = groupBy(markers, (a, b) => extUri.compare(a.resource, b.resource));
|
|
759
|
-
const severities = ( new Set());
|
|
760
|
-
const items = [];
|
|
761
|
-
for (const group of grouped) {
|
|
762
|
-
const resource = group[0].resource;
|
|
763
|
-
items.push({ type: 'separator', label: labelService.getUriLabel(resource, { relative: true }) });
|
|
764
|
-
for (const marker of group) {
|
|
765
|
-
severities.add(marker.severity);
|
|
766
|
-
items.push({
|
|
767
|
-
type: 'item',
|
|
768
|
-
resource: marker.resource,
|
|
769
|
-
label: marker.message,
|
|
770
|
-
description: ( localize(
|
|
771
|
-
4420,
|
|
772
|
-
"[Ln {0}, Col {1}]",
|
|
773
|
-
'' + marker.startLineNumber,
|
|
774
|
-
'' + marker.startColumn
|
|
775
|
-
)),
|
|
776
|
-
entry: IDiagnosticVariableEntryFilterData.fromMarker(marker),
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
items.unshift({ type: 'item', label: ( localize(4421, 'All Problems')), entry: { filterSeverity: MarkerSeverity.Info } });
|
|
781
|
-
const store = ( new DisposableStore());
|
|
782
|
-
const quickPick = store.add(quickInputService.createQuickPick({ useSeparators: true }));
|
|
783
|
-
quickPick.canAcceptInBackground = !onBackgroundAccept;
|
|
784
|
-
quickPick.placeholder = ( localize(4422, 'Select a problem to attach'));
|
|
785
|
-
quickPick.items = items;
|
|
786
|
-
return ( new Promise(resolve => {
|
|
787
|
-
store.add(quickPick.onDidHide(() => resolve(undefined)));
|
|
788
|
-
store.add(quickPick.onDidAccept(ev => {
|
|
789
|
-
if (ev.inBackground) {
|
|
790
|
-
onBackgroundAccept?.(( quickPick.selectedItems.map(i => i.entry)));
|
|
381
|
+
async _handleQPPick(accessor, widget, isInBackground, pick) {
|
|
382
|
+
const fileService = accessor.get(IFileService);
|
|
383
|
+
const textModelService = accessor.get(ITextModelService);
|
|
384
|
+
const toAttach = [];
|
|
385
|
+
if (isIQuickPickItemWithResource(pick) && pick.resource) {
|
|
386
|
+
if (/\.(png|jpg|jpeg|bmp|gif|tiff)$/i.test(pick.resource.path)) {
|
|
387
|
+
if (URI.isUri(pick.resource)) {
|
|
388
|
+
const readFile = await fileService.readFile(pick.resource);
|
|
389
|
+
const resizedImage = await resizeImage(readFile.value.buffer);
|
|
390
|
+
toAttach.push({
|
|
391
|
+
id: ( pick.resource.toString()),
|
|
392
|
+
name: pick.label,
|
|
393
|
+
fullName: pick.label,
|
|
394
|
+
value: resizedImage,
|
|
395
|
+
kind: 'image',
|
|
396
|
+
references: [{ reference: pick.resource, kind: 'reference' }]
|
|
397
|
+
});
|
|
398
|
+
}
|
|
791
399
|
}
|
|
792
400
|
else {
|
|
793
|
-
|
|
794
|
-
|
|
401
|
+
let omittedState = OmittedState.NotOmitted;
|
|
402
|
+
try {
|
|
403
|
+
const createdModel = await textModelService.createModelReference(pick.resource);
|
|
404
|
+
createdModel.dispose();
|
|
405
|
+
}
|
|
406
|
+
catch {
|
|
407
|
+
omittedState = OmittedState.Full;
|
|
408
|
+
}
|
|
409
|
+
toAttach.push({
|
|
410
|
+
kind: 'file',
|
|
411
|
+
id: ( pick.resource.toString()),
|
|
412
|
+
value: pick.resource,
|
|
413
|
+
name: pick.label,
|
|
414
|
+
omittedState
|
|
415
|
+
});
|
|
795
416
|
}
|
|
796
|
-
}));
|
|
797
|
-
quickPick.show();
|
|
798
|
-
})).finally(() => store.dispose());
|
|
799
|
-
}
|
|
800
|
-
async function showToolsPick(accessor, widget) {
|
|
801
|
-
const quickPickService = accessor.get(IQuickInputService);
|
|
802
|
-
function classify(tool) {
|
|
803
|
-
if (tool.source.type === 'internal' || tool.source.type === 'extension' && !tool.source.isExternalTool) {
|
|
804
|
-
return { ordinal: 1, groupLabel: ( localize(4423, 'Built-In')) };
|
|
805
417
|
}
|
|
806
|
-
else if (
|
|
807
|
-
|
|
418
|
+
else if (isIGotoSymbolQuickPickItem(pick) && pick.uri && pick.range) {
|
|
419
|
+
toAttach.push({
|
|
420
|
+
kind: 'generic',
|
|
421
|
+
id: JSON.stringify({ uri: pick.uri, range: pick.range.decoration }),
|
|
422
|
+
value: { uri: pick.uri, range: pick.range.decoration },
|
|
423
|
+
fullName: pick.label,
|
|
424
|
+
name: pick.symbolName,
|
|
425
|
+
});
|
|
808
426
|
}
|
|
809
|
-
|
|
810
|
-
|
|
427
|
+
widget.attachmentModel.addContext(...toAttach);
|
|
428
|
+
if (!isInBackground) {
|
|
429
|
+
widget.focusInput();
|
|
811
430
|
}
|
|
812
431
|
}
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
if (
|
|
816
|
-
|
|
432
|
+
async _handleContextPick(item, widget) {
|
|
433
|
+
const value = await item.asAttachment(widget);
|
|
434
|
+
if (Array.isArray(value)) {
|
|
435
|
+
widget.attachmentModel.addContext(...value);
|
|
436
|
+
}
|
|
437
|
+
else if (value) {
|
|
438
|
+
widget.attachmentModel.addContext(value);
|
|
817
439
|
}
|
|
818
|
-
const item = {
|
|
819
|
-
tool,
|
|
820
|
-
...classify(tool),
|
|
821
|
-
kind: 'tool',
|
|
822
|
-
label: tool.toolReferenceName ?? tool.id,
|
|
823
|
-
description: (tool.toolReferenceName ?? tool.id) !== tool.displayName ? tool.displayName : undefined,
|
|
824
|
-
id: tool.id,
|
|
825
|
-
};
|
|
826
|
-
items.push(item);
|
|
827
440
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
441
|
+
async _handleContextPickerItem(quickInputService, item, widget) {
|
|
442
|
+
const pickerConfig = item.asPicker(widget);
|
|
443
|
+
const store = ( new DisposableStore());
|
|
444
|
+
const goBackItem = {
|
|
445
|
+
label: ( localize(4448, 'Go back ↩')),
|
|
446
|
+
alwaysShow: true
|
|
447
|
+
};
|
|
448
|
+
const extraPicks = [{ type: 'separator' }, goBackItem];
|
|
449
|
+
const qp = store.add(quickInputService.createQuickPick({ useSeparators: true }));
|
|
450
|
+
const cts = ( new CancellationTokenSource());
|
|
451
|
+
store.add(qp.onDidHide(() => cts.cancel()));
|
|
452
|
+
store.add(toDisposable(() => cts.dispose(true)));
|
|
453
|
+
qp.placeholder = pickerConfig.placeholder;
|
|
454
|
+
qp.matchOnDescription = true;
|
|
455
|
+
qp.matchOnDetail = true;
|
|
456
|
+
qp.canAcceptInBackground = true;
|
|
457
|
+
qp.busy = true;
|
|
458
|
+
qp.show();
|
|
459
|
+
if (isThenable(pickerConfig.picks)) {
|
|
460
|
+
const items = await (pickerConfig.picks.then(value => {
|
|
461
|
+
return [].concat(value, extraPicks);
|
|
462
|
+
}));
|
|
463
|
+
qp.items = items;
|
|
464
|
+
qp.busy = false;
|
|
465
|
+
}
|
|
466
|
+
else {
|
|
467
|
+
const query = observableValue('attachContext.query', qp.value);
|
|
468
|
+
store.add(qp.onDidChangeValue(() => query.set(qp.value, undefined)));
|
|
469
|
+
const picksObservable = pickerConfig.picks(query, cts.token);
|
|
470
|
+
store.add(autorun(reader => {
|
|
471
|
+
const { busy, picks } = picksObservable.read(reader);
|
|
472
|
+
qp.items = [].concat(picks, extraPicks);
|
|
473
|
+
qp.busy = busy;
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
if (cts.token.isCancellationRequested) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
const defer = ( new DeferredPromise());
|
|
480
|
+
const addPromises = [];
|
|
481
|
+
store.add(qp.onDidAccept(e => {
|
|
482
|
+
const [selected] = qp.selectedItems;
|
|
483
|
+
if (isChatContextPickerPickItem(selected)) {
|
|
484
|
+
const attachment = selected.asAttachment();
|
|
485
|
+
if (isThenable(attachment)) {
|
|
486
|
+
addPromises.push(attachment.then(v => widget.attachmentModel.addContext(v)));
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
widget.attachmentModel.addContext(attachment);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (selected === goBackItem) {
|
|
493
|
+
defer.complete(false);
|
|
494
|
+
}
|
|
495
|
+
if (!e.inBackground) {
|
|
496
|
+
defer.complete(true);
|
|
497
|
+
}
|
|
498
|
+
}));
|
|
499
|
+
store.add(qp.onDidHide(() => {
|
|
500
|
+
defer.complete(true);
|
|
501
|
+
}));
|
|
502
|
+
try {
|
|
503
|
+
const result = await defer.p;
|
|
504
|
+
qp.busy = true;
|
|
505
|
+
await Promise.all(addPromises);
|
|
506
|
+
return result;
|
|
832
507
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
let lastGroupLabel;
|
|
836
|
-
const picks = [];
|
|
837
|
-
for (const item of items) {
|
|
838
|
-
if (lastGroupLabel !== item.groupLabel) {
|
|
839
|
-
picks.push({ type: 'separator', label: item.groupLabel });
|
|
840
|
-
lastGroupLabel = item.groupLabel;
|
|
508
|
+
finally {
|
|
509
|
+
store.dispose();
|
|
841
510
|
}
|
|
842
|
-
picks.push(item);
|
|
843
511
|
}
|
|
844
|
-
const result = await quickPickService.pick(picks, {
|
|
845
|
-
placeHolder: ( localize(4426, 'Select a tool')),
|
|
846
|
-
canPickMany: false
|
|
847
|
-
});
|
|
848
|
-
return result;
|
|
849
512
|
}
|
|
850
|
-
registerPromptActions();
|
|
851
513
|
|
|
852
514
|
export { AttachContextAction, AttachSearchResultAction, registerChatContextActions };
|