@codingame/monaco-vscode-chat-service-override 15.0.2 → 16.0.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.
- package/index.js +11 -8
- package/package.json +29 -20
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.d.ts +22 -0
- package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +10 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +9 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +80 -55
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.d.ts +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/chatAttachPromptAction.js +17 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/{askToSelectPrompt.d.ts → askToSelectPrompt/askToSelectPrompt.d.ts} +9 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/askToSelectPrompt.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/constants.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/attachPrompts.js +53 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.d.ts +2 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPlaceholderText.js +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.d.ts +5 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/createPromptPickItem.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.d.ts +13 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt/utils/handleButtonClick.js +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +6 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +163 -72
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +22 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +4 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +17 -17
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +9 -8
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatTransfer.js +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +15 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +242 -74
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditing.js +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.d.ts +47 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingCodeEditorIntegration.js +688 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.d.ts +28 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorActions.js +355 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingEditorOverlay.js +11 -11
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.d.ts +71 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedDocumentEntry.js +395 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.d.ts +98 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +216 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.d.ts +97 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedNotebookEntry.js +831 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.d.ts +7 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingServiceImpl.js +32 -47
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +110 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +985 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.d.ts +20 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +69 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookDiff.js +67 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.d.ts +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingModifiedNotebookSnapshot.js +147 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.d.ts +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookCellEntry.js +284 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.d.ts +38 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookEditorIntegration.js +578 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.d.ts +45 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/chatEditingNotebookFileSystemProvider.js +122 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.d.ts +15 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/helpers.js +320 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.d.ts +31 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/notebook/notebookCellChanges.js +50 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +5 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +22 -5
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +166 -62
- package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +6 -104
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +704 -732
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.d.ts +10 -25
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatus.js +329 -236
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.d.ts +19 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatStatusItemService.js +27 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +4 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +14 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +1 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css +3 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +17 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +217 -18
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css +114 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditorController.css +30 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatSetup.css +56 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css +90 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/createPromptCommand.js +65 -19
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptName.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/dialogs/askForPromptSourceFolder.js +4 -4
- 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 +2 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/createPromptCommand/utils/createPromptFile.js +3 -3
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/contributions/usePromptCommand.js +14 -12
- 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 +5 -3
- package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +16 -8
- package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +175 -57
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.d.ts +66 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSessionStore.js +313 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +3 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +4 -2
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.d.ts +14 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatTransferService.js +30 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.d.ts +2 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/constants.js +6 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +10 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +18 -3
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.d.ts +9 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkDiagnosticsProvider.js +117 -0
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptPathAutocompletion.js +3 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.js +2 -2
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.d.ts +6 -4
- package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.js +157 -65
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +2 -1
- package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +39 -21
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +0 -1
- package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -3
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +4 -4
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +11 -10
- 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 +10 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/inlineDiff/notebookModifiedCellDecorator.js +47 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.d.ts +5 -0
- package/vscode/src/vs/workbench/services/workspaces/common/workspaceUtils.js +26 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAttachPromptAction/dialogs/askToSelectPrompt.js +0 -142
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +0 -52
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +0 -331
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +0 -15
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +0 -110
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatEditingEditorOverlay.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatStatus.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +0 -6
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/chat/common/chatEntitlementsService.js +0 -13
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.d.ts +0 -31
- package/vscode/src/vs/workbench/contrib/chat/common/chatQuotasService.js +0 -85
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +0 -11
- package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +0 -22
|
@@ -1,82 +1,79 @@
|
|
|
1
1
|
|
|
2
2
|
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import './media/
|
|
4
|
-
import { getActiveElement,
|
|
3
|
+
import './media/chatSetup.css';
|
|
4
|
+
import { $, getActiveElement, setVisibility } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
5
5
|
import { ButtonWithDropdown } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/button/button';
|
|
6
6
|
import { renderIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/iconLabel/iconLabels';
|
|
7
|
+
import { mainWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
|
|
7
8
|
import { toAction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
8
|
-
import { timeout
|
|
9
|
-
import { CancellationTokenSource, CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
9
|
+
import { timeout } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
|
|
10
10
|
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
11
|
+
import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
|
|
11
12
|
import { isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
12
|
-
import {
|
|
13
|
+
import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
13
14
|
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
14
15
|
import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
|
|
15
|
-
import { Disposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
16
|
+
import { Disposable, DisposableStore, markAsSingleton, MutableDisposable, combinedDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
17
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
18
|
+
import { StopWatch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stopwatch';
|
|
19
|
+
import { equalsIgnoreCase } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
20
|
+
import { isObject } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
21
|
+
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
16
22
|
import { MarkdownRenderer } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
|
17
23
|
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
18
24
|
import { Action2, MenuId, registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
19
25
|
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
20
26
|
import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
|
|
21
27
|
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
28
|
+
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
22
29
|
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
23
|
-
import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
24
30
|
import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
|
|
25
31
|
import { IDialogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
26
|
-
import { ExtensionIdentifier } from '@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions';
|
|
27
32
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
28
33
|
import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
|
|
34
|
+
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
29
35
|
import product from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/product';
|
|
30
36
|
import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
|
|
31
37
|
import { ProgressLocation } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress';
|
|
32
38
|
import { IProgressService } from '@codingame/monaco-vscode-api/vscode/vs/platform/progress/common/progress.service';
|
|
39
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
33
40
|
import { Registry } from '@codingame/monaco-vscode-api/vscode/vs/platform/registry/common/platform';
|
|
34
|
-
import { asText } from '@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request';
|
|
35
|
-
import { IRequestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request.service';
|
|
36
|
-
import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
|
|
37
|
-
import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
|
|
38
41
|
import { TelemetryLevel } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry';
|
|
39
42
|
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
40
43
|
import { defaultButtonStyles } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/browser/defaultStyles';
|
|
41
|
-
import {
|
|
44
|
+
import { IWorkspaceTrustRequestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
|
|
42
45
|
import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views';
|
|
43
46
|
import { IViewDescriptorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views.service';
|
|
44
47
|
import { ProgressBadge } from '@codingame/monaco-vscode-a7c9ae3c-16d2-5d17-86b2-981be7094566-common/vscode/vs/workbench/services/activity/common/activity';
|
|
45
48
|
import { IActivityService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/activity/common/activity.service';
|
|
46
|
-
import { IAuthenticationService
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
+
import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
|
|
50
|
+
import { ExtensionUrlHandlerOverrideRegistry } from '@codingame/monaco-vscode-8c844347-a703-5de1-9eeb-5e0c7f503a58-common/vscode/vs/workbench/services/extensions/browser/extensionUrlHandler';
|
|
51
|
+
import { nullExtensionDescription } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions';
|
|
52
|
+
import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
|
|
53
|
+
import { Parts } from '@codingame/monaco-vscode-b1110435-a331-5549-ab1e-aa3d763c3a1f-common/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
49
54
|
import { IWorkbenchLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
55
|
+
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
56
|
+
import { IStatusbarService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/statusbar/browser/statusbar.service';
|
|
50
57
|
import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
|
|
51
58
|
import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
|
|
52
59
|
import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
|
|
53
60
|
import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
|
|
54
|
-
import {
|
|
61
|
+
import { ChatEntitlement, ChatEntitlementRequests } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/common/chatEntitlementService';
|
|
62
|
+
import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEntitlementService.service';
|
|
63
|
+
import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService.service';
|
|
64
|
+
import { CHAT_SETUP_ACTION_ID, CHAT_CATEGORY, CHAT_OPEN_ACTION_ID } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
|
|
55
65
|
import { showCopilotView, ensureSideBarChatViewSize, ChatViewId, preferCopilotEditsView, EditsViewId } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chat';
|
|
66
|
+
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
56
67
|
import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/chatViewPane';
|
|
57
68
|
import { ChatViewsWelcomeExtensions } from '@codingame/monaco-vscode-9a6d8b6c-ad4c-5ea3-9558-f43d6dc4c0ad-common/vscode/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcome';
|
|
58
|
-
import {
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import {
|
|
62
|
-
import {
|
|
63
|
-
import
|
|
64
|
-
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
65
|
-
import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
66
|
-
import { ExtensionUrlHandlerOverrideRegistry } from '@codingame/monaco-vscode-8c844347-a703-5de1-9eeb-5e0c7f503a58-common/vscode/vs/workbench/services/extensions/browser/extensionUrlHandler';
|
|
67
|
-
import { IWorkspaceTrustRequestService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
|
|
68
|
-
import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
|
|
69
|
-
import { StopWatch } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stopwatch';
|
|
70
|
-
import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
71
|
-
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
72
|
-
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
73
|
-
import { equalsIgnoreCase } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
|
|
74
|
-
import { IWorkbenchAssignmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service';
|
|
75
|
-
import { ChatEntitlement } from '../common/chatEntitlementsService.js';
|
|
76
|
-
import { IChatEntitlementsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatEntitlementsService.service';
|
|
77
|
-
import { IStatusbarService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/statusbar/browser/statusbar.service';
|
|
69
|
+
import { ChatConfiguration, ChatAgentLocation, validateChatMode } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
70
|
+
import { ILanguageModelsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service';
|
|
71
|
+
import { Dialog } from '@codingame/monaco-vscode-f1bbc6d3-6129-583c-a2ba-c80b832993d2-common/vscode/vs/base/browser/ui/dialog/dialog';
|
|
72
|
+
import { ILayoutService } from '@codingame/monaco-vscode-api/vscode/vs/platform/layout/browser/layoutService.service';
|
|
73
|
+
import { IKeybindingService } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybinding.service';
|
|
74
|
+
import { createWorkbenchDialogOptions } from '@codingame/monaco-vscode-f1bbc6d3-6129-583c-a2ba-c80b832993d2-common/vscode/vs/platform/dialogs/browser/dialog';
|
|
78
75
|
|
|
79
|
-
var
|
|
76
|
+
var SetupChatAgentImplementation_1, ChatSetup_1;
|
|
80
77
|
const defaultChat = {
|
|
81
78
|
extensionId: product.defaultChatAgent?.extensionId ?? '',
|
|
82
79
|
chatExtensionId: product.defaultChatAgent?.chatExtensionId ?? '',
|
|
@@ -86,73 +83,467 @@ const defaultChat = {
|
|
|
86
83
|
skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '',
|
|
87
84
|
publicCodeMatchesUrl: product.defaultChatAgent?.publicCodeMatchesUrl ?? '',
|
|
88
85
|
upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '',
|
|
89
|
-
providerId: product.defaultChatAgent?.providerId ?? '',
|
|
90
86
|
providerName: product.defaultChatAgent?.providerName ?? '',
|
|
91
87
|
enterpriseProviderId: product.defaultChatAgent?.enterpriseProviderId ?? '',
|
|
92
88
|
enterpriseProviderName: product.defaultChatAgent?.enterpriseProviderName ?? '',
|
|
93
|
-
providerSetting: product.defaultChatAgent?.providerSetting ?? '',
|
|
94
89
|
providerUriSetting: product.defaultChatAgent?.providerUriSetting ?? '',
|
|
95
90
|
providerScopes: product.defaultChatAgent?.providerScopes ?? [[]],
|
|
96
|
-
entitlementUrl: product.defaultChatAgent?.entitlementUrl ?? '',
|
|
97
|
-
entitlementSignupLimitedUrl: product.defaultChatAgent?.entitlementSignupLimitedUrl ?? '',
|
|
98
91
|
manageSettingsUrl: product.defaultChatAgent?.manageSettingsUrl ?? '',
|
|
92
|
+
completionsAdvancedSetting: product.defaultChatAgent?.completionsAdvancedSetting ?? '',
|
|
93
|
+
walkthroughCommand: product.defaultChatAgent?.walkthroughCommand ?? '',
|
|
94
|
+
completionsRefreshTokenCommand: product.defaultChatAgent?.completionsRefreshTokenCommand ?? '',
|
|
95
|
+
chatRefreshTokenCommand: product.defaultChatAgent?.chatRefreshTokenCommand ?? '',
|
|
99
96
|
};
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
const ToolsAgentWhen = ( ContextKeyExpr.and(( ContextKeyExpr.equals(`config.${ChatConfiguration.AgentEnabled}`, true)), ( ChatContextKeys.Editing.agentModeDisallowed.negate()),
|
|
98
|
+
ContextKeyExpr.not(`previewFeaturesDisabled`)));
|
|
99
|
+
let SetupChatAgentImplementation = class SetupChatAgentImplementation extends Disposable {
|
|
100
|
+
static { SetupChatAgentImplementation_1 = this; }
|
|
101
|
+
static register(instantiationService, location, isToolsAgent, context, controller) {
|
|
102
|
+
return instantiationService.invokeFunction(accessor => {
|
|
103
|
+
const chatAgentService = accessor.get(IChatAgentService);
|
|
104
|
+
let id;
|
|
105
|
+
let description = ( localize(4785, "Ask Copilot"));
|
|
106
|
+
let welcomeMessageContent;
|
|
107
|
+
const baseMessage = ( localize(
|
|
108
|
+
4786,
|
|
109
|
+
"Copilot is powered by AI, so mistakes are possible. Review output carefully before use."
|
|
110
|
+
));
|
|
111
|
+
switch (location) {
|
|
112
|
+
case ChatAgentLocation.Panel:
|
|
113
|
+
id = 'setup.chat';
|
|
114
|
+
welcomeMessageContent = {
|
|
115
|
+
title: description,
|
|
116
|
+
message: ( new MarkdownString(baseMessage)),
|
|
117
|
+
icon: Codicon.copilotLarge
|
|
118
|
+
};
|
|
119
|
+
break;
|
|
120
|
+
case ChatAgentLocation.EditingSession:
|
|
121
|
+
id = isToolsAgent ? 'setup.agent' : 'setup.edits';
|
|
122
|
+
description = isToolsAgent ? ( localize(4787, "Edit files in your workspace in agent mode")) : ( localize(4788, "Edit files in your workspace"));
|
|
123
|
+
welcomeMessageContent = isToolsAgent ?
|
|
124
|
+
{
|
|
125
|
+
title: ( localize(4789, "Edit with Copilot")),
|
|
126
|
+
message: ( new MarkdownString(( localize(
|
|
127
|
+
4790,
|
|
128
|
+
"Ask Copilot to edit your files in [agent mode]({0}). Copilot will automatically use multiple requests to pick files to edit, run terminal commands, and iterate on errors.",
|
|
129
|
+
`https://aka.ms/vscode-copilot-agent`
|
|
130
|
+
)) + `\n\n${baseMessage}`)),
|
|
131
|
+
icon: Codicon.copilotLarge
|
|
132
|
+
} :
|
|
133
|
+
{
|
|
134
|
+
title: ( localize(4789, "Edit with Copilot")),
|
|
135
|
+
message: ( new MarkdownString(( localize(
|
|
136
|
+
4791,
|
|
137
|
+
"Start your editing session by defining a set of files that you want to work with. Then ask Copilot for the changes you want to make."
|
|
138
|
+
)) + `\n\n${baseMessage}`)),
|
|
139
|
+
icon: Codicon.copilotLarge
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
case ChatAgentLocation.Terminal:
|
|
143
|
+
id = 'setup.terminal';
|
|
144
|
+
break;
|
|
145
|
+
case ChatAgentLocation.Editor:
|
|
146
|
+
id = 'setup.editor';
|
|
147
|
+
break;
|
|
148
|
+
case ChatAgentLocation.Notebook:
|
|
149
|
+
id = 'setup.notebook';
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
const disposable = ( new DisposableStore());
|
|
153
|
+
disposable.add(chatAgentService.registerAgent(id, {
|
|
154
|
+
id,
|
|
155
|
+
name: `${defaultChat.providerName} Copilot`,
|
|
156
|
+
isDefault: true,
|
|
157
|
+
isCore: true,
|
|
158
|
+
isToolsAgent,
|
|
159
|
+
when: isToolsAgent ? ToolsAgentWhen?.serialize() : undefined,
|
|
160
|
+
slashCommands: [],
|
|
161
|
+
disambiguation: [],
|
|
162
|
+
locations: [location],
|
|
163
|
+
metadata: {
|
|
164
|
+
welcomeMessageContent,
|
|
165
|
+
helpTextPrefix: SetupChatAgentImplementation_1.SETUP_NEEDED_MESSAGE
|
|
166
|
+
},
|
|
167
|
+
description,
|
|
168
|
+
extensionId: nullExtensionDescription.identifier,
|
|
169
|
+
extensionDisplayName: nullExtensionDescription.name,
|
|
170
|
+
extensionPublisherId: nullExtensionDescription.publisher
|
|
171
|
+
}));
|
|
172
|
+
const agent = disposable.add(instantiationService.createInstance(SetupChatAgentImplementation_1, context, controller, location));
|
|
173
|
+
disposable.add(chatAgentService.registerAgentImplementation(id, agent));
|
|
174
|
+
return { agent, disposable };
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
static { this.SETUP_NEEDED_MESSAGE = ( new MarkdownString(( localize(4792, "You need to set up Copilot to use Chat.")))); }
|
|
178
|
+
constructor(context, controller, location, instantiationService, logService, configurationService, telemetryService) {
|
|
102
179
|
super();
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
180
|
+
this.context = context;
|
|
181
|
+
this.controller = controller;
|
|
182
|
+
this.location = location;
|
|
183
|
+
this.instantiationService = instantiationService;
|
|
184
|
+
this.logService = logService;
|
|
185
|
+
this.configurationService = configurationService;
|
|
186
|
+
this.telemetryService = telemetryService;
|
|
187
|
+
this._onUnresolvableError = this._register(( new Emitter()));
|
|
188
|
+
this.onUnresolvableError = this._onUnresolvableError.event;
|
|
189
|
+
}
|
|
190
|
+
async invoke(request, progress) {
|
|
191
|
+
return this.instantiationService.invokeFunction(async (accessor) => {
|
|
192
|
+
const chatService = accessor.get(IChatService);
|
|
193
|
+
const languageModelsService = accessor.get(ILanguageModelsService);
|
|
194
|
+
const chatWidgetService = accessor.get(IChatWidgetService);
|
|
195
|
+
const chatAgentService = accessor.get(IChatAgentService);
|
|
196
|
+
return this.doInvoke(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
async doInvoke(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService) {
|
|
200
|
+
if (!this.context.state.installed || this.context.state.entitlement === ChatEntitlement.Available || this.context.state.entitlement === ChatEntitlement.Unknown) {
|
|
201
|
+
return this.doInvokeWithSetup(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService);
|
|
202
|
+
}
|
|
203
|
+
return this.doInvokeWithoutSetup(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService);
|
|
204
|
+
}
|
|
205
|
+
async doInvokeWithoutSetup(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService) {
|
|
206
|
+
const requestModel = chatWidgetService.getWidgetBySessionId(request.sessionId)?.viewModel?.model.getRequests().at(-1);
|
|
207
|
+
if (!requestModel) {
|
|
208
|
+
this.logService.error('[chat setup] Request model not found, cannot redispatch request.');
|
|
209
|
+
return {};
|
|
210
|
+
}
|
|
211
|
+
progress({
|
|
212
|
+
kind: 'progressMessage',
|
|
213
|
+
content: ( new MarkdownString(( localize(4793, "Getting Copilot ready.")))),
|
|
214
|
+
});
|
|
215
|
+
await this.forwardRequestToCopilot(requestModel, progress, chatService, languageModelsService, chatAgentService, chatWidgetService);
|
|
216
|
+
return {};
|
|
217
|
+
}
|
|
218
|
+
async forwardRequestToCopilot(requestModel, progress, chatService, languageModelsService, chatAgentService, chatWidgetService) {
|
|
219
|
+
if (this._handlingForwardedRequest === requestModel.message.text) {
|
|
220
|
+
throw ( new Error('Already handling this request'));
|
|
221
|
+
}
|
|
222
|
+
this._handlingForwardedRequest = requestModel.message.text;
|
|
223
|
+
const whenLanguageModelReady = this.whenLanguageModelReady(languageModelsService);
|
|
224
|
+
const whenAgentReady = this.whenAgentReady(chatAgentService);
|
|
225
|
+
if (whenLanguageModelReady instanceof Promise || whenAgentReady instanceof Promise) {
|
|
226
|
+
const timeoutHandle = setTimeout(() => {
|
|
227
|
+
progress({
|
|
228
|
+
kind: 'progressMessage',
|
|
229
|
+
content: ( new MarkdownString(( localize(4794, "Copilot is almost ready.")))),
|
|
230
|
+
});
|
|
231
|
+
}, 10000);
|
|
232
|
+
try {
|
|
233
|
+
const ready = await Promise.race([
|
|
234
|
+
timeout(20000).then(() => 'timedout'),
|
|
235
|
+
Promise.allSettled([whenLanguageModelReady, whenAgentReady])
|
|
236
|
+
]);
|
|
237
|
+
if (ready === 'timedout') {
|
|
238
|
+
progress({
|
|
239
|
+
kind: 'warning',
|
|
240
|
+
content: ( new MarkdownString(( localize(4795, "Copilot took too long to get ready. Please try again."))))
|
|
241
|
+
});
|
|
242
|
+
this._onUnresolvableError.fire();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
clearTimeout(timeoutHandle);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const widget = chatWidgetService.getWidgetBySessionId(requestModel.session.sessionId);
|
|
251
|
+
chatService.resendRequest(requestModel, {
|
|
252
|
+
mode: widget?.input.currentMode,
|
|
253
|
+
userSelectedModelId: widget?.input.currentLanguageModel,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
whenLanguageModelReady(languageModelsService) {
|
|
257
|
+
for (const id of languageModelsService.getLanguageModelIds()) {
|
|
258
|
+
const model = languageModelsService.lookupLanguageModel(id);
|
|
259
|
+
if (model && model.isDefault) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return Event.toPromise(Event.filter(languageModelsService.onDidChangeLanguageModels, e => e.added?.some(added => added.metadata.isDefault) ?? false));
|
|
264
|
+
}
|
|
265
|
+
whenAgentReady(chatAgentService) {
|
|
266
|
+
const defaultAgent = chatAgentService.getDefaultAgent(this.location);
|
|
267
|
+
if (defaultAgent && !defaultAgent.isCore) {
|
|
106
268
|
return;
|
|
107
269
|
}
|
|
108
|
-
|
|
109
|
-
|
|
270
|
+
return Event.toPromise(Event.filter(chatAgentService.onDidChangeAgents, () => {
|
|
271
|
+
const defaultAgent = chatAgentService.getDefaultAgent(this.location);
|
|
272
|
+
return Boolean(defaultAgent && !defaultAgent.isCore);
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
async doInvokeWithSetup(request, progress, chatService, languageModelsService, chatWidgetService, chatAgentService) {
|
|
276
|
+
this.telemetryService.publicLog2('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'chat' });
|
|
277
|
+
const requestModel = chatWidgetService.getWidgetBySessionId(request.sessionId)?.viewModel?.model.getRequests().at(-1);
|
|
278
|
+
const setupListener = Event.runAndSubscribe(this.controller.value.onDidChange, (() => {
|
|
279
|
+
switch (this.controller.value.step) {
|
|
280
|
+
case ChatSetupStep.SigningIn:
|
|
281
|
+
progress({
|
|
282
|
+
kind: 'progressMessage',
|
|
283
|
+
content: ( new MarkdownString(( localize(
|
|
284
|
+
4796,
|
|
285
|
+
"Signing in to {0}.",
|
|
286
|
+
ChatEntitlementRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName
|
|
287
|
+
)))),
|
|
288
|
+
});
|
|
289
|
+
break;
|
|
290
|
+
case ChatSetupStep.Installing:
|
|
291
|
+
progress({
|
|
292
|
+
kind: 'progressMessage',
|
|
293
|
+
content: ( new MarkdownString(( localize(4797, "Getting Copilot ready.")))),
|
|
294
|
+
});
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}));
|
|
298
|
+
let success = undefined;
|
|
299
|
+
try {
|
|
300
|
+
success = await ChatSetup.getInstance(this.instantiationService, this.context, this.controller).run();
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
this.logService.error(`[chat setup] Error during setup: ${toErrorMessage(error)}`);
|
|
304
|
+
}
|
|
305
|
+
finally {
|
|
306
|
+
setupListener.dispose();
|
|
307
|
+
}
|
|
308
|
+
if (typeof success === 'boolean') {
|
|
309
|
+
if (success) {
|
|
310
|
+
if (requestModel) {
|
|
311
|
+
await this.forwardRequestToCopilot(requestModel, progress, chatService, languageModelsService, chatAgentService, chatWidgetService);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
progress({
|
|
316
|
+
kind: 'warning',
|
|
317
|
+
content: ( new MarkdownString(( localize(4798, "Copilot setup failed."))))
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
progress({
|
|
323
|
+
kind: 'markdownContent',
|
|
324
|
+
content: SetupChatAgentImplementation_1.SETUP_NEEDED_MESSAGE,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
SetupChatAgentImplementation = SetupChatAgentImplementation_1 = ( __decorate([
|
|
331
|
+
( __param(3, IInstantiationService)),
|
|
332
|
+
( __param(4, ILogService)),
|
|
333
|
+
( __param(5, IConfigurationService)),
|
|
334
|
+
( __param(6, ITelemetryService))
|
|
335
|
+
], SetupChatAgentImplementation));
|
|
336
|
+
var ChatSetupStrategy;
|
|
337
|
+
(function (ChatSetupStrategy) {
|
|
338
|
+
ChatSetupStrategy[ChatSetupStrategy["Canceled"] = 0] = "Canceled";
|
|
339
|
+
ChatSetupStrategy[ChatSetupStrategy["DefaultSetup"] = 1] = "DefaultSetup";
|
|
340
|
+
ChatSetupStrategy[ChatSetupStrategy["SetupWithoutEnterpriseProvider"] = 2] = "SetupWithoutEnterpriseProvider";
|
|
341
|
+
ChatSetupStrategy[ChatSetupStrategy["SetupWithEnterpriseProvider"] = 3] = "SetupWithEnterpriseProvider";
|
|
342
|
+
})(ChatSetupStrategy || (ChatSetupStrategy = {}));
|
|
343
|
+
let ChatSetup = class ChatSetup {
|
|
344
|
+
static { ChatSetup_1 = this; }
|
|
345
|
+
static { this.instance = undefined; }
|
|
346
|
+
static getInstance(instantiationService, context, controller) {
|
|
347
|
+
let instance = ChatSetup_1.instance;
|
|
348
|
+
if (!instance) {
|
|
349
|
+
instance = ChatSetup_1.instance = instantiationService.invokeFunction(accessor => {
|
|
350
|
+
return ( new ChatSetup_1(
|
|
351
|
+
context,
|
|
352
|
+
controller,
|
|
353
|
+
instantiationService,
|
|
354
|
+
accessor.get(ITelemetryService),
|
|
355
|
+
accessor.get(IContextMenuService),
|
|
356
|
+
accessor.get(IWorkbenchLayoutService),
|
|
357
|
+
accessor.get(IKeybindingService),
|
|
358
|
+
accessor.get(IChatEntitlementService),
|
|
359
|
+
accessor.get(ILogService)
|
|
360
|
+
));
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
return instance;
|
|
364
|
+
}
|
|
365
|
+
constructor(context, controller, instantiationService, telemetryService, contextMenuService, layoutService, keybindingService, chatEntitlementService, logService) {
|
|
366
|
+
this.context = context;
|
|
367
|
+
this.controller = controller;
|
|
368
|
+
this.instantiationService = instantiationService;
|
|
369
|
+
this.telemetryService = telemetryService;
|
|
370
|
+
this.contextMenuService = contextMenuService;
|
|
371
|
+
this.layoutService = layoutService;
|
|
372
|
+
this.keybindingService = keybindingService;
|
|
373
|
+
this.chatEntitlementService = chatEntitlementService;
|
|
374
|
+
this.logService = logService;
|
|
375
|
+
this.pendingRun = undefined;
|
|
376
|
+
}
|
|
377
|
+
async run() {
|
|
378
|
+
if (this.pendingRun) {
|
|
379
|
+
return this.pendingRun;
|
|
380
|
+
}
|
|
381
|
+
this.pendingRun = this.doRun();
|
|
382
|
+
try {
|
|
383
|
+
return await this.pendingRun;
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
this.pendingRun = undefined;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
async doRun() {
|
|
390
|
+
let setupStrategy;
|
|
391
|
+
if (this.chatEntitlementService.entitlement === ChatEntitlement.Pro || this.chatEntitlementService.entitlement === ChatEntitlement.Limited) {
|
|
392
|
+
setupStrategy = ChatSetupStrategy.DefaultSetup;
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
setupStrategy = await this.showDialog();
|
|
396
|
+
}
|
|
397
|
+
let success = undefined;
|
|
398
|
+
try {
|
|
399
|
+
switch (setupStrategy) {
|
|
400
|
+
case ChatSetupStrategy.SetupWithEnterpriseProvider:
|
|
401
|
+
success = await this.controller.value.setupWithProvider({ setupFromDialog: true, useEnterpriseProvider: true });
|
|
402
|
+
break;
|
|
403
|
+
case ChatSetupStrategy.SetupWithoutEnterpriseProvider:
|
|
404
|
+
success = await this.controller.value.setupWithProvider({ setupFromDialog: true, useEnterpriseProvider: false });
|
|
405
|
+
break;
|
|
406
|
+
case ChatSetupStrategy.DefaultSetup:
|
|
407
|
+
success = await this.controller.value.setup({ setupFromDialog: true });
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
this.logService.error(`[chat setup] Error during setup: ${toErrorMessage(error)}`);
|
|
413
|
+
success = false;
|
|
414
|
+
}
|
|
415
|
+
return success;
|
|
416
|
+
}
|
|
417
|
+
async showDialog() {
|
|
418
|
+
const disposables = ( new DisposableStore());
|
|
419
|
+
let result = undefined;
|
|
420
|
+
const buttons = [this.getPrimaryButton(), ( localize(4799, "Maybe Later"))];
|
|
421
|
+
const dialog = disposables.add(( new Dialog(
|
|
422
|
+
this.layoutService.activeContainer,
|
|
423
|
+
this.getDialogTitle(),
|
|
424
|
+
buttons,
|
|
425
|
+
createWorkbenchDialogOptions({
|
|
426
|
+
type: 'none',
|
|
427
|
+
icon: Codicon.copilotLarge,
|
|
428
|
+
cancelId: buttons.length - 1,
|
|
429
|
+
renderBody: body => body.appendChild(this.createDialog(disposables)),
|
|
430
|
+
primaryButtonDropdown: {
|
|
431
|
+
contextMenuProvider: this.contextMenuService,
|
|
432
|
+
addPrimaryActionToDropdown: false,
|
|
433
|
+
actions: [
|
|
434
|
+
toAction({ id: 'setupWithProvider', label: ( localize(4800, "Sign in with a {0} Account", defaultChat.providerName)), run: () => result = ChatSetupStrategy.SetupWithoutEnterpriseProvider }),
|
|
435
|
+
toAction({ id: 'setupWithEnterpriseProvider', label: ( localize(4801, "Sign in with a {0} Account", defaultChat.enterpriseProviderName)), run: () => result = ChatSetupStrategy.SetupWithEnterpriseProvider }),
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
}, this.keybindingService, this.layoutService)
|
|
439
|
+
)));
|
|
440
|
+
const { button } = await dialog.show();
|
|
441
|
+
disposables.dispose();
|
|
442
|
+
return button === 0 ? result ?? ChatSetupStrategy.DefaultSetup : ChatSetupStrategy.Canceled;
|
|
443
|
+
}
|
|
444
|
+
getPrimaryButton() {
|
|
445
|
+
if (this.context.state.entitlement === ChatEntitlement.Unknown) {
|
|
446
|
+
return localize(4802, "Sign in");
|
|
447
|
+
}
|
|
448
|
+
return localize(4803, "Use Copilot");
|
|
449
|
+
}
|
|
450
|
+
getDialogTitle() {
|
|
451
|
+
if (this.context.state.entitlement === ChatEntitlement.Unknown) {
|
|
452
|
+
return this.context.state.registered ? ( localize(4804, "Sign in to use Copilot")) : ( localize(4805, "Sign in to use Copilot for free"));
|
|
453
|
+
}
|
|
454
|
+
if (this.context.state.entitlement === ChatEntitlement.Pro) {
|
|
455
|
+
return localize(4806, "Start using Copilot Pro");
|
|
456
|
+
}
|
|
457
|
+
return this.context.state.registered ? ( localize(4807, "Start using Copilot")) : ( localize(4808, "Start using Copilot for free"));
|
|
458
|
+
}
|
|
459
|
+
createDialog(disposables) {
|
|
460
|
+
const element = $('.chat-setup-view');
|
|
461
|
+
const markdown = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
462
|
+
const header = ( localize(
|
|
463
|
+
4809,
|
|
464
|
+
"[Copilot]({0}) is your AI pair programmer. Write code faster with completions, fix bugs and build new features across multiple files, and learn about your codebase through chat.",
|
|
465
|
+
defaultChat.documentationUrl
|
|
110
466
|
));
|
|
111
|
-
|
|
112
|
-
|
|
467
|
+
element.appendChild($('p.setup-header', undefined, disposables.add(markdown.render(( new MarkdownString(header, { isTrusted: true })))).element));
|
|
468
|
+
const terms = ( localize(
|
|
469
|
+
4810,
|
|
470
|
+
"By continuing, you agree to the [Terms]({0}) and [Privacy Policy]({1}).",
|
|
471
|
+
defaultChat.termsStatementUrl,
|
|
472
|
+
defaultChat.privacyStatementUrl
|
|
113
473
|
));
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
474
|
+
element.appendChild($('p.setup-legal', undefined, disposables.add(markdown.render(( new MarkdownString(terms, { isTrusted: true })))).element));
|
|
475
|
+
if (this.telemetryService.telemetryLevel !== TelemetryLevel.NONE) {
|
|
476
|
+
const settings = ( localize(
|
|
477
|
+
4811,
|
|
478
|
+
"Copilot Free and Pro may show [public code]({0}) suggestions and we may use your data for product improvement. You can change these [settings]({1}) at any time.",
|
|
479
|
+
defaultChat.publicCodeMatchesUrl,
|
|
480
|
+
defaultChat.manageSettingsUrl
|
|
481
|
+
));
|
|
482
|
+
element.appendChild($('p.setup-settings', undefined, disposables.add(markdown.render(( new MarkdownString(settings, { isTrusted: true })))).element));
|
|
483
|
+
}
|
|
484
|
+
return element;
|
|
117
485
|
}
|
|
118
486
|
};
|
|
119
|
-
|
|
120
|
-
( __param(
|
|
121
|
-
( __param(
|
|
122
|
-
( __param(
|
|
123
|
-
|
|
487
|
+
ChatSetup = ChatSetup_1 = ( __decorate([
|
|
488
|
+
( __param(2, IInstantiationService)),
|
|
489
|
+
( __param(3, ITelemetryService)),
|
|
490
|
+
( __param(4, IContextMenuService)),
|
|
491
|
+
( __param(5, ILayoutService)),
|
|
492
|
+
( __param(6, IKeybindingService)),
|
|
493
|
+
( __param(7, IChatEntitlementService)),
|
|
494
|
+
( __param(8, ILogService))
|
|
495
|
+
], ChatSetup));
|
|
124
496
|
let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
125
|
-
static { this.ID = 'workbench.
|
|
126
|
-
constructor(productService, instantiationService, commandService, telemetryService,
|
|
497
|
+
static { this.ID = 'workbench.contrib.chatSetup'; }
|
|
498
|
+
constructor(productService, instantiationService, commandService, telemetryService, chatEntitlementService, configurationService, logService) {
|
|
127
499
|
super();
|
|
128
500
|
this.productService = productService;
|
|
129
501
|
this.instantiationService = instantiationService;
|
|
130
502
|
this.commandService = commandService;
|
|
131
503
|
this.telemetryService = telemetryService;
|
|
132
|
-
this.
|
|
133
|
-
|
|
134
|
-
const
|
|
504
|
+
this.configurationService = configurationService;
|
|
505
|
+
this.logService = logService;
|
|
506
|
+
const context = chatEntitlementService.context?.value;
|
|
507
|
+
const requests = chatEntitlementService.requests?.value;
|
|
135
508
|
if (!context || !requests) {
|
|
136
509
|
return;
|
|
137
510
|
}
|
|
138
511
|
const controller = ( new Lazy(
|
|
139
512
|
() => this._register(this.instantiationService.createInstance(ChatSetupController, context, requests))
|
|
140
513
|
));
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
514
|
+
this.registerSetupAgents(context, controller);
|
|
515
|
+
this.registerChatWelcome(context, controller);
|
|
516
|
+
this.registerActions(context, requests, controller);
|
|
143
517
|
this.registerUrlLinkHandler();
|
|
144
|
-
this.registerSetting(context);
|
|
145
518
|
}
|
|
146
|
-
|
|
519
|
+
registerSetupAgents(context, controller) {
|
|
520
|
+
const registration = markAsSingleton(( new MutableDisposable()));
|
|
521
|
+
const updateRegistration = () => {
|
|
522
|
+
const disabled = context.state.hidden || !this.configurationService.getValue('chat.setupFromDialog');
|
|
523
|
+
if (!disabled && !registration.value) {
|
|
524
|
+
const { agent: panelAgent, disposable: panelDisposable } = SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.Panel, false, context, controller);
|
|
525
|
+
registration.value = combinedDisposable(panelDisposable, SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.Terminal, false, context, controller).disposable, SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.Notebook, false, context, controller).disposable, SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.Editor, false, context, controller).disposable, SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.EditingSession, false, context, controller).disposable, SetupChatAgentImplementation.register(this.instantiationService, ChatAgentLocation.EditingSession, true, context, controller).disposable, panelAgent.onUnresolvableError(() => {
|
|
526
|
+
this.logService.error('[chat setup] Unresolvable error from Copilot agent registration, clearing registration.');
|
|
527
|
+
panelDisposable.dispose();
|
|
528
|
+
}));
|
|
529
|
+
}
|
|
530
|
+
else if (disabled && registration.value) {
|
|
531
|
+
registration.clear();
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
this._register(Event.runAndSubscribe(Event.any(context.onDidChange, Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('chat.setupFromDialog'))), () => updateRegistration()));
|
|
535
|
+
}
|
|
536
|
+
registerChatWelcome(context, controller) {
|
|
147
537
|
( Registry.as(ChatViewsWelcomeExtensions.ChatViewsWelcomeRegistry)).register({
|
|
148
|
-
title: ( localize(
|
|
538
|
+
title: ( localize(4812, "Welcome to Copilot")),
|
|
149
539
|
when: ChatContextKeys.SetupViewCondition,
|
|
150
540
|
icon: Codicon.copilotLarge,
|
|
151
541
|
content: disposables => disposables.add(this.instantiationService.createInstance(ChatSetupWelcomeContent, controller.value, context)).element,
|
|
152
542
|
});
|
|
153
543
|
}
|
|
154
|
-
registerActions(context, requests) {
|
|
155
|
-
const chatSetupTriggerContext = ( ContextKeyExpr.or(( ChatContextKeys.Setup.installed.negate()), ChatContextKeys.
|
|
544
|
+
registerActions(context, requests, controller) {
|
|
545
|
+
const chatSetupTriggerContext = ( ContextKeyExpr.or(( ChatContextKeys.Setup.installed.negate()), ChatContextKeys.Entitlement.canSignUp));
|
|
546
|
+
const CHAT_SETUP_ACTION_LABEL = ( localize2(4813, "Use AI Features with Copilot for free..."));
|
|
156
547
|
class ChatSetupTriggerAction extends Action2 {
|
|
157
548
|
constructor() {
|
|
158
549
|
super({
|
|
@@ -165,33 +556,59 @@ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
|
165
556
|
id: MenuId.ChatTitleBarMenu,
|
|
166
557
|
group: 'a_last',
|
|
167
558
|
order: 1,
|
|
168
|
-
when: chatSetupTriggerContext
|
|
559
|
+
when: ( ContextKeyExpr.and(chatSetupTriggerContext, ( ContextKeyExpr.or(( ChatContextKeys.Setup.fromDialog.negate()),
|
|
560
|
+
ChatContextKeys.Setup.hidden))))
|
|
169
561
|
}
|
|
170
562
|
});
|
|
171
563
|
}
|
|
172
|
-
async run(accessor) {
|
|
564
|
+
async run(accessor, mode) {
|
|
173
565
|
const viewsService = accessor.get(IViewsService);
|
|
174
566
|
const viewDescriptorService = accessor.get(IViewDescriptorService);
|
|
175
567
|
const configurationService = accessor.get(IConfigurationService);
|
|
176
568
|
const layoutService = accessor.get(IWorkbenchLayoutService);
|
|
177
569
|
const statusbarService = accessor.get(IStatusbarService);
|
|
570
|
+
const instantiationService = accessor.get(IInstantiationService);
|
|
571
|
+
const dialogService = accessor.get(IDialogService);
|
|
572
|
+
const commandService = accessor.get(ICommandService);
|
|
573
|
+
const lifecycleService = accessor.get(ILifecycleService);
|
|
178
574
|
await context.update({ hidden: false });
|
|
179
|
-
showCopilotView(viewsService, layoutService);
|
|
180
|
-
|
|
575
|
+
const chatWidgetPromise = showCopilotView(viewsService, layoutService);
|
|
576
|
+
if (mode) {
|
|
577
|
+
const chatWidget = await chatWidgetPromise;
|
|
578
|
+
chatWidget?.input.setChatMode(mode);
|
|
579
|
+
}
|
|
580
|
+
const setupFromDialog = configurationService.getValue('chat.setupFromDialog');
|
|
581
|
+
if (!setupFromDialog) {
|
|
582
|
+
ensureSideBarChatViewSize(viewDescriptorService, layoutService, viewsService);
|
|
583
|
+
}
|
|
181
584
|
statusbarService.updateEntryVisibility('chat.statusBarEntry', true);
|
|
182
585
|
configurationService.updateValue('chat.commandCenter.enabled', true);
|
|
586
|
+
if (setupFromDialog) {
|
|
587
|
+
const setup = ChatSetup.getInstance(instantiationService, context, controller);
|
|
588
|
+
const result = await setup.run();
|
|
589
|
+
if (result === false && !lifecycleService.willShutdown) {
|
|
590
|
+
const { confirmed } = await dialogService.confirm({
|
|
591
|
+
type: Severity.Error,
|
|
592
|
+
message: ( localize(4814, "Copilot setup failed. Would you like to try again?")),
|
|
593
|
+
primaryButton: ( localize(4815, "Retry")),
|
|
594
|
+
});
|
|
595
|
+
if (confirmed) {
|
|
596
|
+
commandService.executeCommand(CHAT_SETUP_ACTION_ID);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
183
600
|
}
|
|
184
601
|
}
|
|
185
602
|
class ChatSetupHideAction extends Action2 {
|
|
186
603
|
static { this.ID = 'workbench.action.chat.hideSetup'; }
|
|
187
|
-
static { this.TITLE = ( localize2(
|
|
604
|
+
static { this.TITLE = ( localize2(4816, "Hide Copilot")); }
|
|
188
605
|
constructor() {
|
|
189
606
|
super({
|
|
190
607
|
id: ChatSetupHideAction.ID,
|
|
191
608
|
title: ChatSetupHideAction.TITLE,
|
|
192
609
|
f1: true,
|
|
193
610
|
category: CHAT_CATEGORY,
|
|
194
|
-
precondition: ( ChatContextKeys.Setup.installed.negate()),
|
|
611
|
+
precondition: ( ContextKeyExpr.and(( ChatContextKeys.Setup.installed.negate()), ( ChatContextKeys.Setup.hidden.negate()))),
|
|
195
612
|
menu: {
|
|
196
613
|
id: MenuId.ChatTitleBarMenu,
|
|
197
614
|
group: 'z_hide',
|
|
@@ -207,13 +624,13 @@ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
|
207
624
|
const dialogService = accessor.get(IDialogService);
|
|
208
625
|
const statusbarService = accessor.get(IStatusbarService);
|
|
209
626
|
const { confirmed } = await dialogService.confirm({
|
|
210
|
-
message: ( localize(
|
|
627
|
+
message: ( localize(4817, "Are you sure you want to hide Copilot?")),
|
|
211
628
|
detail: ( localize(
|
|
212
|
-
|
|
629
|
+
4818,
|
|
213
630
|
"You can restore Copilot by running the '{0}' command.",
|
|
214
631
|
CHAT_SETUP_ACTION_LABEL.value
|
|
215
632
|
)),
|
|
216
|
-
primaryButton: ( localize(
|
|
633
|
+
primaryButton: ( localize(4819, "Hide Copilot"))
|
|
217
634
|
});
|
|
218
635
|
if (!confirmed) {
|
|
219
636
|
return;
|
|
@@ -235,10 +652,10 @@ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
|
235
652
|
constructor() {
|
|
236
653
|
super({
|
|
237
654
|
id: 'workbench.action.chat.upgradePlan',
|
|
238
|
-
title: ( localize2(
|
|
239
|
-
category: ( localize2(
|
|
655
|
+
title: ( localize2(4820, "Upgrade to Copilot Pro")),
|
|
656
|
+
category: ( localize2(4821, 'Chat')),
|
|
240
657
|
f1: true,
|
|
241
|
-
precondition: ( ContextKeyExpr.or(ChatContextKeys.
|
|
658
|
+
precondition: ( ContextKeyExpr.or(ChatContextKeys.Entitlement.canSignUp, ChatContextKeys.Entitlement.limited)),
|
|
242
659
|
menu: {
|
|
243
660
|
id: MenuId.ChatTitleBarMenu,
|
|
244
661
|
group: 'a_first',
|
|
@@ -250,12 +667,10 @@ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
|
250
667
|
}
|
|
251
668
|
});
|
|
252
669
|
}
|
|
253
|
-
async run(accessor) {
|
|
670
|
+
async run(accessor, from) {
|
|
254
671
|
const openerService = accessor.get(IOpenerService);
|
|
255
|
-
const telemetryService = accessor.get(ITelemetryService);
|
|
256
672
|
const hostService = accessor.get(IHostService);
|
|
257
673
|
const commandService = accessor.get(ICommandService);
|
|
258
|
-
telemetryService.publicLog2('workbenchActionExecuted', { id: this.desc.id, from: 'chat' });
|
|
259
674
|
openerService.open(( URI.parse(defaultChat.upgradePlanUrl)));
|
|
260
675
|
const entitlement = context.state.entitlement;
|
|
261
676
|
if (entitlement !== ChatEntitlement.Pro) {
|
|
@@ -284,368 +699,21 @@ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
|
|
|
284
699
|
handleURL: async (url) => {
|
|
285
700
|
const params = ( new URLSearchParams(url.query));
|
|
286
701
|
this.telemetryService.publicLog2('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'url', detail: params.get('referrer') ?? undefined });
|
|
287
|
-
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID);
|
|
702
|
+
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID, validateChatMode(params.get('mode')));
|
|
288
703
|
return true;
|
|
289
704
|
}
|
|
290
705
|
}));
|
|
291
706
|
}
|
|
292
|
-
registerSetting(context) {
|
|
293
|
-
const configurationRegistry = ( Registry.as(Extensions.Configuration));
|
|
294
|
-
let lastNode;
|
|
295
|
-
const registerSetting = () => {
|
|
296
|
-
const treatmentId = context.state.entitlement === ChatEntitlement.Limited ?
|
|
297
|
-
'chatAgentMaxRequestsFree' :
|
|
298
|
-
'chatAgentMaxRequestsPro';
|
|
299
|
-
this.experimentService.getTreatment(treatmentId).then(value => {
|
|
300
|
-
const defaultValue = value ?? (context.state.entitlement === ChatEntitlement.Limited ? 5 : 15);
|
|
301
|
-
const node = {
|
|
302
|
-
id: 'chatSidebar',
|
|
303
|
-
title: ( localize(4693, "Chat")),
|
|
304
|
-
type: 'object',
|
|
305
|
-
properties: {
|
|
306
|
-
'chat.agent.maxRequests': {
|
|
307
|
-
type: 'number',
|
|
308
|
-
markdownDescription: ( localize(
|
|
309
|
-
4694,
|
|
310
|
-
"The maximum number of requests to allow Copilot Edits to use per-turn in agent mode. When the limit is reached, Copilot will ask the user to confirm that it should keep working. \n\n> **Note**: For users on the Copilot Free plan, note that each agent mode request currently uses one chat request."
|
|
311
|
-
)),
|
|
312
|
-
default: defaultValue,
|
|
313
|
-
tags: ['experimental']
|
|
314
|
-
},
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
configurationRegistry.updateConfigurations({ remove: lastNode ? [lastNode] : [], add: [node] });
|
|
318
|
-
lastNode = node;
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
this._register(Event.runAndSubscribe(Event.debounce(context.onDidChange, () => { }, 1000), () => registerSetting()));
|
|
322
|
-
}
|
|
323
707
|
};
|
|
324
708
|
ChatSetupContribution = ( __decorate([
|
|
325
709
|
( __param(0, IProductService)),
|
|
326
710
|
( __param(1, IInstantiationService)),
|
|
327
711
|
( __param(2, ICommandService)),
|
|
328
712
|
( __param(3, ITelemetryService)),
|
|
329
|
-
( __param(4,
|
|
330
|
-
( __param(5,
|
|
713
|
+
( __param(4, IChatEntitlementService)),
|
|
714
|
+
( __param(5, IConfigurationService)),
|
|
715
|
+
( __param(6, ILogService))
|
|
331
716
|
], ChatSetupContribution));
|
|
332
|
-
let ChatSetupRequests = ChatSetupRequests_1 = class ChatSetupRequests extends Disposable {
|
|
333
|
-
static providerId(configurationService) {
|
|
334
|
-
if (configurationService.getValue(defaultChat.providerSetting) === defaultChat.enterpriseProviderId) {
|
|
335
|
-
return defaultChat.enterpriseProviderId;
|
|
336
|
-
}
|
|
337
|
-
return defaultChat.providerId;
|
|
338
|
-
}
|
|
339
|
-
constructor(context, telemetryService, authenticationService, logService, requestService, chatQuotasService, dialogService, openerService, configurationService) {
|
|
340
|
-
super();
|
|
341
|
-
this.context = context;
|
|
342
|
-
this.telemetryService = telemetryService;
|
|
343
|
-
this.authenticationService = authenticationService;
|
|
344
|
-
this.logService = logService;
|
|
345
|
-
this.requestService = requestService;
|
|
346
|
-
this.chatQuotasService = chatQuotasService;
|
|
347
|
-
this.dialogService = dialogService;
|
|
348
|
-
this.openerService = openerService;
|
|
349
|
-
this.configurationService = configurationService;
|
|
350
|
-
this.state = { entitlement: this.context.state.entitlement };
|
|
351
|
-
this.pendingResolveCts = ( new CancellationTokenSource());
|
|
352
|
-
this.didResolveEntitlements = false;
|
|
353
|
-
this.registerListeners();
|
|
354
|
-
this.resolve();
|
|
355
|
-
}
|
|
356
|
-
registerListeners() {
|
|
357
|
-
this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.resolve()));
|
|
358
|
-
this._register(this.authenticationService.onDidChangeSessions(e => {
|
|
359
|
-
if (e.providerId === ChatSetupRequests_1.providerId(this.configurationService)) {
|
|
360
|
-
this.resolve();
|
|
361
|
-
}
|
|
362
|
-
}));
|
|
363
|
-
this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => {
|
|
364
|
-
if (e.id === ChatSetupRequests_1.providerId(this.configurationService)) {
|
|
365
|
-
this.resolve();
|
|
366
|
-
}
|
|
367
|
-
}));
|
|
368
|
-
this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => {
|
|
369
|
-
if (e.id === ChatSetupRequests_1.providerId(this.configurationService)) {
|
|
370
|
-
this.resolve();
|
|
371
|
-
}
|
|
372
|
-
}));
|
|
373
|
-
this._register(this.context.onDidChange(() => {
|
|
374
|
-
if (!this.context.state.installed || this.context.state.entitlement === ChatEntitlement.Unknown) {
|
|
375
|
-
this.state = { entitlement: this.state.entitlement, quotas: undefined };
|
|
376
|
-
this.chatQuotasService.clearQuotas();
|
|
377
|
-
}
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
async resolve() {
|
|
381
|
-
this.pendingResolveCts.dispose(true);
|
|
382
|
-
const cts = this.pendingResolveCts = ( new CancellationTokenSource());
|
|
383
|
-
const session = await this.findMatchingProviderSession(cts.token);
|
|
384
|
-
if (cts.token.isCancellationRequested) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
let state = undefined;
|
|
388
|
-
if (session) {
|
|
389
|
-
if (this.state.entitlement === ChatEntitlement.Unknown) {
|
|
390
|
-
state = { entitlement: ChatEntitlement.Unresolved };
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
this.didResolveEntitlements = false;
|
|
395
|
-
state = { entitlement: ChatEntitlement.Unknown };
|
|
396
|
-
}
|
|
397
|
-
if (state) {
|
|
398
|
-
this.update(state);
|
|
399
|
-
}
|
|
400
|
-
if (session && !this.didResolveEntitlements) {
|
|
401
|
-
await this.resolveEntitlement(session, cts.token);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
async findMatchingProviderSession(token) {
|
|
405
|
-
const sessions = await this.doGetSessions(ChatSetupRequests_1.providerId(this.configurationService));
|
|
406
|
-
if (token.isCancellationRequested) {
|
|
407
|
-
return undefined;
|
|
408
|
-
}
|
|
409
|
-
for (const session of sessions) {
|
|
410
|
-
for (const scopes of defaultChat.providerScopes) {
|
|
411
|
-
if (this.scopesMatch(session.scopes, scopes)) {
|
|
412
|
-
return session;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return undefined;
|
|
417
|
-
}
|
|
418
|
-
async doGetSessions(providerId) {
|
|
419
|
-
try {
|
|
420
|
-
return await this.authenticationService.getSessions(providerId);
|
|
421
|
-
}
|
|
422
|
-
catch (error) {
|
|
423
|
-
}
|
|
424
|
-
return [];
|
|
425
|
-
}
|
|
426
|
-
scopesMatch(scopes, expectedScopes) {
|
|
427
|
-
return scopes.length === expectedScopes.length && expectedScopes.every(scope => scopes.includes(scope));
|
|
428
|
-
}
|
|
429
|
-
async resolveEntitlement(session, token) {
|
|
430
|
-
const entitlements = await this.doResolveEntitlement(session, token);
|
|
431
|
-
if (typeof entitlements?.entitlement === 'number' && !token.isCancellationRequested) {
|
|
432
|
-
this.didResolveEntitlements = true;
|
|
433
|
-
this.update(entitlements);
|
|
434
|
-
}
|
|
435
|
-
return entitlements;
|
|
436
|
-
}
|
|
437
|
-
async doResolveEntitlement(session, token) {
|
|
438
|
-
if (ChatSetupRequests_1.providerId(this.configurationService) === defaultChat.enterpriseProviderId) {
|
|
439
|
-
this.logService.trace('[chat setup] entitlement: enterprise provider, assuming Pro');
|
|
440
|
-
return { entitlement: ChatEntitlement.Pro };
|
|
441
|
-
}
|
|
442
|
-
if (token.isCancellationRequested) {
|
|
443
|
-
return undefined;
|
|
444
|
-
}
|
|
445
|
-
const response = await this.request(defaultChat.entitlementUrl, 'GET', undefined, session, token);
|
|
446
|
-
if (token.isCancellationRequested) {
|
|
447
|
-
return undefined;
|
|
448
|
-
}
|
|
449
|
-
if (!response) {
|
|
450
|
-
this.logService.trace('[chat setup] entitlement: no response');
|
|
451
|
-
return { entitlement: ChatEntitlement.Unresolved };
|
|
452
|
-
}
|
|
453
|
-
if (response.res.statusCode && response.res.statusCode !== 200) {
|
|
454
|
-
this.logService.trace(`[chat setup] entitlement: unexpected status code ${response.res.statusCode}`);
|
|
455
|
-
return { entitlement: ChatEntitlement.Unresolved };
|
|
456
|
-
}
|
|
457
|
-
let responseText = null;
|
|
458
|
-
try {
|
|
459
|
-
responseText = await asText(response);
|
|
460
|
-
}
|
|
461
|
-
catch (error) {
|
|
462
|
-
}
|
|
463
|
-
if (token.isCancellationRequested) {
|
|
464
|
-
return undefined;
|
|
465
|
-
}
|
|
466
|
-
if (!responseText) {
|
|
467
|
-
this.logService.trace('[chat setup] entitlement: response has no content');
|
|
468
|
-
return { entitlement: ChatEntitlement.Unresolved };
|
|
469
|
-
}
|
|
470
|
-
let entitlementsResponse;
|
|
471
|
-
try {
|
|
472
|
-
entitlementsResponse = JSON.parse(responseText);
|
|
473
|
-
this.logService.trace(`[chat setup] entitlement: parsed result is ${JSON.stringify(entitlementsResponse)}`);
|
|
474
|
-
}
|
|
475
|
-
catch (err) {
|
|
476
|
-
this.logService.trace(`[chat setup] entitlement: error parsing response (${err})`);
|
|
477
|
-
return { entitlement: ChatEntitlement.Unresolved };
|
|
478
|
-
}
|
|
479
|
-
let entitlement;
|
|
480
|
-
if (entitlementsResponse.access_type_sku === 'free_limited_copilot') {
|
|
481
|
-
entitlement = ChatEntitlement.Limited;
|
|
482
|
-
}
|
|
483
|
-
else if (entitlementsResponse.can_signup_for_limited) {
|
|
484
|
-
entitlement = ChatEntitlement.Available;
|
|
485
|
-
}
|
|
486
|
-
else if (entitlementsResponse.chat_enabled) {
|
|
487
|
-
entitlement = ChatEntitlement.Pro;
|
|
488
|
-
}
|
|
489
|
-
else {
|
|
490
|
-
entitlement = ChatEntitlement.Unavailable;
|
|
491
|
-
}
|
|
492
|
-
const entitlements = {
|
|
493
|
-
entitlement,
|
|
494
|
-
quotas: {
|
|
495
|
-
chatTotal: entitlementsResponse.monthly_quotas?.chat,
|
|
496
|
-
completionsTotal: entitlementsResponse.monthly_quotas?.completions,
|
|
497
|
-
chatRemaining: entitlementsResponse.limited_user_quotas?.chat,
|
|
498
|
-
completionsRemaining: entitlementsResponse.limited_user_quotas?.completions,
|
|
499
|
-
resetDate: entitlementsResponse.limited_user_reset_date
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
this.logService.trace(`[chat setup] entitlement: resolved to ${entitlements.entitlement}, quotas: ${JSON.stringify(entitlements.quotas)}`);
|
|
503
|
-
this.telemetryService.publicLog2('chatInstallEntitlement', {
|
|
504
|
-
entitlement: entitlements.entitlement,
|
|
505
|
-
tid: entitlementsResponse.analytics_tracking_id,
|
|
506
|
-
quotaChat: entitlementsResponse.limited_user_quotas?.chat,
|
|
507
|
-
quotaCompletions: entitlementsResponse.limited_user_quotas?.completions,
|
|
508
|
-
quotaResetDate: entitlementsResponse.limited_user_reset_date
|
|
509
|
-
});
|
|
510
|
-
return entitlements;
|
|
511
|
-
}
|
|
512
|
-
async request(url, type, body, session, token) {
|
|
513
|
-
try {
|
|
514
|
-
return await this.requestService.request({
|
|
515
|
-
type,
|
|
516
|
-
url,
|
|
517
|
-
data: type === 'POST' ? JSON.stringify(body) : undefined,
|
|
518
|
-
disableCache: true,
|
|
519
|
-
headers: {
|
|
520
|
-
'Authorization': `Bearer ${session.accessToken}`
|
|
521
|
-
}
|
|
522
|
-
}, token);
|
|
523
|
-
}
|
|
524
|
-
catch (error) {
|
|
525
|
-
this.logService.error(`[chat setup] request: error ${error}`);
|
|
526
|
-
return undefined;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
update(state) {
|
|
530
|
-
this.state = state;
|
|
531
|
-
this.context.update({ entitlement: this.state.entitlement });
|
|
532
|
-
if (state.quotas) {
|
|
533
|
-
this.chatQuotasService.acceptQuotas({
|
|
534
|
-
chatQuotaExceeded: typeof state.quotas.chatRemaining === 'number' ? state.quotas.chatRemaining <= 0 : false,
|
|
535
|
-
completionsQuotaExceeded: typeof state.quotas.completionsRemaining === 'number' ? state.quotas.completionsRemaining <= 0 : false,
|
|
536
|
-
quotaResetDate: state.quotas.resetDate ? ( new Date(state.quotas.resetDate)) : undefined,
|
|
537
|
-
chatTotal: state.quotas.chatTotal,
|
|
538
|
-
completionsTotal: state.quotas.completionsTotal,
|
|
539
|
-
chatRemaining: state.quotas.chatRemaining,
|
|
540
|
-
completionsRemaining: state.quotas.completionsRemaining
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
async forceResolveEntitlement(session, token = CancellationToken.None) {
|
|
545
|
-
if (!session) {
|
|
546
|
-
session = await this.findMatchingProviderSession(token);
|
|
547
|
-
}
|
|
548
|
-
if (!session) {
|
|
549
|
-
return undefined;
|
|
550
|
-
}
|
|
551
|
-
return this.resolveEntitlement(session, token);
|
|
552
|
-
}
|
|
553
|
-
async signUpLimited(session) {
|
|
554
|
-
const body = {
|
|
555
|
-
restricted_telemetry: this.telemetryService.telemetryLevel === TelemetryLevel.NONE ? 'disabled' : 'enabled',
|
|
556
|
-
public_code_suggestions: 'enabled'
|
|
557
|
-
};
|
|
558
|
-
const response = await this.request(defaultChat.entitlementSignupLimitedUrl, 'POST', body, session, CancellationToken.None);
|
|
559
|
-
if (!response) {
|
|
560
|
-
const retry = await this.onUnknownSignUpError(( localize(4695, "No response received.")), '[chat setup] sign-up: no response');
|
|
561
|
-
return retry ? this.signUpLimited(session) : { errorCode: 1 };
|
|
562
|
-
}
|
|
563
|
-
if (response.res.statusCode && response.res.statusCode !== 200) {
|
|
564
|
-
if (response.res.statusCode === 422) {
|
|
565
|
-
try {
|
|
566
|
-
const responseText = await asText(response);
|
|
567
|
-
if (responseText) {
|
|
568
|
-
const responseError = JSON.parse(responseText);
|
|
569
|
-
if (typeof responseError.message === 'string' && responseError.message) {
|
|
570
|
-
this.onUnprocessableSignUpError(`[chat setup] sign-up: unprocessable entity (${responseError.message})`, responseError.message);
|
|
571
|
-
return { errorCode: response.res.statusCode };
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
catch (error) {
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
const retry = await this.onUnknownSignUpError(( localize(4696, "Unexpected status code {0}.", response.res.statusCode)), `[chat setup] sign-up: unexpected status code ${response.res.statusCode}`);
|
|
579
|
-
return retry ? this.signUpLimited(session) : { errorCode: response.res.statusCode };
|
|
580
|
-
}
|
|
581
|
-
let responseText = null;
|
|
582
|
-
try {
|
|
583
|
-
responseText = await asText(response);
|
|
584
|
-
}
|
|
585
|
-
catch (error) {
|
|
586
|
-
}
|
|
587
|
-
if (!responseText) {
|
|
588
|
-
const retry = await this.onUnknownSignUpError(( localize(4697, "Response has no contents.")), '[chat setup] sign-up: response has no content');
|
|
589
|
-
return retry ? this.signUpLimited(session) : { errorCode: 2 };
|
|
590
|
-
}
|
|
591
|
-
let parsedResult = undefined;
|
|
592
|
-
try {
|
|
593
|
-
parsedResult = JSON.parse(responseText);
|
|
594
|
-
this.logService.trace(`[chat setup] sign-up: response is ${responseText}`);
|
|
595
|
-
}
|
|
596
|
-
catch (err) {
|
|
597
|
-
const retry = await this.onUnknownSignUpError(( localize(4698, "Invalid response contents.")), `[chat setup] sign-up: error parsing response (${err})`);
|
|
598
|
-
return retry ? this.signUpLimited(session) : { errorCode: 3 };
|
|
599
|
-
}
|
|
600
|
-
this.update({ entitlement: ChatEntitlement.Limited });
|
|
601
|
-
return Boolean(parsedResult?.subscribed);
|
|
602
|
-
}
|
|
603
|
-
async onUnknownSignUpError(detail, logMessage) {
|
|
604
|
-
this.logService.error(logMessage);
|
|
605
|
-
const { confirmed } = await this.dialogService.confirm({
|
|
606
|
-
type: Severity.Error,
|
|
607
|
-
message: ( localize(
|
|
608
|
-
4699,
|
|
609
|
-
"An error occurred while signing up for Copilot Free. Would you like to try again?"
|
|
610
|
-
)),
|
|
611
|
-
detail,
|
|
612
|
-
primaryButton: ( localize(4700, "Retry"))
|
|
613
|
-
});
|
|
614
|
-
return confirmed;
|
|
615
|
-
}
|
|
616
|
-
onUnprocessableSignUpError(logMessage, logDetails) {
|
|
617
|
-
this.logService.error(logMessage);
|
|
618
|
-
this.dialogService.prompt({
|
|
619
|
-
type: Severity.Error,
|
|
620
|
-
message: ( localize(4701, "An error occurred while signing up for Copilot Free.")),
|
|
621
|
-
detail: logDetails,
|
|
622
|
-
buttons: [
|
|
623
|
-
{
|
|
624
|
-
label: ( localize(4702, "OK")),
|
|
625
|
-
run: () => { }
|
|
626
|
-
},
|
|
627
|
-
{
|
|
628
|
-
label: ( localize(4703, "Learn More")),
|
|
629
|
-
run: () => this.openerService.open(( URI.parse(defaultChat.upgradePlanUrl)))
|
|
630
|
-
}
|
|
631
|
-
]
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
dispose() {
|
|
635
|
-
this.pendingResolveCts.dispose(true);
|
|
636
|
-
super.dispose();
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
ChatSetupRequests = ChatSetupRequests_1 = ( __decorate([
|
|
640
|
-
( __param(1, ITelemetryService)),
|
|
641
|
-
( __param(2, IAuthenticationService)),
|
|
642
|
-
( __param(3, ILogService)),
|
|
643
|
-
( __param(4, IRequestService)),
|
|
644
|
-
( __param(5, IChatQuotasService)),
|
|
645
|
-
( __param(6, IDialogService)),
|
|
646
|
-
( __param(7, IOpenerService)),
|
|
647
|
-
( __param(8, IConfigurationService))
|
|
648
|
-
], ChatSetupRequests));
|
|
649
717
|
var ChatSetupStep;
|
|
650
718
|
(function (ChatSetupStep) {
|
|
651
719
|
ChatSetupStep[ChatSetupStep["Initial"] = 1] = "Initial";
|
|
@@ -654,13 +722,12 @@ var ChatSetupStep;
|
|
|
654
722
|
})(ChatSetupStep || (ChatSetupStep = {}));
|
|
655
723
|
let ChatSetupController = class ChatSetupController extends Disposable {
|
|
656
724
|
get step() { return this._step; }
|
|
657
|
-
constructor(context, requests, telemetryService, authenticationService,
|
|
725
|
+
constructor(context, requests, telemetryService, authenticationService, viewsService, extensionsWorkbenchService, productService, logService, progressService, chatAgentService, activityService, commandService, layoutService, workspaceTrustRequestService, dialogService, configurationService, lifecycleService, quickInputService) {
|
|
658
726
|
super();
|
|
659
727
|
this.context = context;
|
|
660
728
|
this.requests = requests;
|
|
661
729
|
this.telemetryService = telemetryService;
|
|
662
730
|
this.authenticationService = authenticationService;
|
|
663
|
-
this.authenticationExtensionsService = authenticationExtensionsService;
|
|
664
731
|
this.viewsService = viewsService;
|
|
665
732
|
this.extensionsWorkbenchService = extensionsWorkbenchService;
|
|
666
733
|
this.productService = productService;
|
|
@@ -674,15 +741,14 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
674
741
|
this.dialogService = dialogService;
|
|
675
742
|
this.configurationService = configurationService;
|
|
676
743
|
this.lifecycleService = lifecycleService;
|
|
744
|
+
this.quickInputService = quickInputService;
|
|
677
745
|
this._onDidChange = this._register(( new Emitter()));
|
|
678
746
|
this.onDidChange = this._onDidChange.event;
|
|
679
747
|
this._step = ChatSetupStep.Initial;
|
|
680
|
-
this.willShutdown = false;
|
|
681
748
|
this.registerListeners();
|
|
682
749
|
}
|
|
683
750
|
registerListeners() {
|
|
684
751
|
this._register(this.context.onDidChange(() => this._onDidChange.fire()));
|
|
685
|
-
this._register(this.lifecycleService.onWillShutdown(() => this.willShutdown = true));
|
|
686
752
|
}
|
|
687
753
|
setStep(step) {
|
|
688
754
|
if (this._step === step) {
|
|
@@ -693,48 +759,49 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
693
759
|
}
|
|
694
760
|
async setup(options) {
|
|
695
761
|
const watch = ( new StopWatch(false));
|
|
696
|
-
const title = ( localize(
|
|
762
|
+
const title = ( localize(4822, "Getting Copilot ready..."));
|
|
697
763
|
const badge = this.activityService.showViewContainerActivity(preferCopilotEditsView(this.viewsService) ? CHAT_EDITING_SIDEBAR_PANEL_ID : CHAT_SIDEBAR_PANEL_ID, {
|
|
698
764
|
badge: ( new ProgressBadge(() => title)),
|
|
699
765
|
});
|
|
700
766
|
try {
|
|
701
|
-
await this.progressService.withProgress({
|
|
767
|
+
return await this.progressService.withProgress({
|
|
702
768
|
location: ProgressLocation.Window,
|
|
703
|
-
command:
|
|
769
|
+
command: CHAT_OPEN_ACTION_ID,
|
|
704
770
|
title,
|
|
705
|
-
}, () => this.doSetup(options
|
|
771
|
+
}, () => this.doSetup(options ?? {}, watch));
|
|
706
772
|
}
|
|
707
773
|
finally {
|
|
708
774
|
badge.dispose();
|
|
709
775
|
}
|
|
710
776
|
}
|
|
711
|
-
async doSetup(
|
|
777
|
+
async doSetup(options, watch) {
|
|
712
778
|
this.context.suspend();
|
|
713
779
|
let focusChatInput = false;
|
|
780
|
+
let success = false;
|
|
714
781
|
try {
|
|
715
|
-
const providerId =
|
|
782
|
+
const providerId = ChatEntitlementRequests.providerId(this.configurationService);
|
|
716
783
|
let session;
|
|
717
784
|
let entitlement;
|
|
718
|
-
if (this.context.state.entitlement === ChatEntitlement.Unknown || forceSignIn) {
|
|
785
|
+
if (this.context.state.entitlement === ChatEntitlement.Unknown || options.forceSignIn) {
|
|
719
786
|
this.setStep(ChatSetupStep.SigningIn);
|
|
720
|
-
const result = await this.signIn(providerId);
|
|
787
|
+
const result = await this.signIn(providerId, options);
|
|
721
788
|
if (!result.session) {
|
|
722
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', installDuration: watch.elapsed(), signUpErrorCode: undefined });
|
|
723
|
-
return;
|
|
789
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', installDuration: watch.elapsed(), signUpErrorCode: undefined, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
790
|
+
return false;
|
|
724
791
|
}
|
|
725
792
|
session = result.session;
|
|
726
793
|
entitlement = result.entitlement;
|
|
727
794
|
}
|
|
728
795
|
const trusted = await this.workspaceTrustRequestService.requestWorkspaceTrust({
|
|
729
|
-
message: ( localize(
|
|
796
|
+
message: ( localize(4823, "Copilot is currently only supported in trusted workspaces."))
|
|
730
797
|
});
|
|
731
798
|
if (!trusted) {
|
|
732
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotTrusted', installDuration: watch.elapsed(), signUpErrorCode: undefined });
|
|
733
|
-
return;
|
|
799
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotTrusted', installDuration: watch.elapsed(), signUpErrorCode: undefined, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
800
|
+
return false;
|
|
734
801
|
}
|
|
735
802
|
const activeElement = getActiveElement();
|
|
736
803
|
this.setStep(ChatSetupStep.Installing);
|
|
737
|
-
await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch);
|
|
804
|
+
success = await this.install(session, entitlement ?? this.context.state.entitlement, providerId, options, watch);
|
|
738
805
|
const currentActiveElement = getActiveElement();
|
|
739
806
|
focusChatInput = activeElement === currentActiveElement || currentActiveElement === mainWindow.document.body;
|
|
740
807
|
}
|
|
@@ -742,45 +809,47 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
742
809
|
this.setStep(ChatSetupStep.Initial);
|
|
743
810
|
this.context.resume();
|
|
744
811
|
}
|
|
745
|
-
if (focusChatInput) {
|
|
812
|
+
if (focusChatInput && !options.setupFromDialog) {
|
|
746
813
|
(await showCopilotView(this.viewsService, this.layoutService))?.focusInput();
|
|
747
814
|
}
|
|
815
|
+
return success;
|
|
748
816
|
}
|
|
749
|
-
async signIn(providerId) {
|
|
817
|
+
async signIn(providerId, options) {
|
|
750
818
|
let session;
|
|
751
819
|
let entitlements;
|
|
752
820
|
try {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
entitlements = await this.requests.forceResolveEntitlement(session);
|
|
821
|
+
if (!options?.setupFromDialog) {
|
|
822
|
+
showCopilotView(this.viewsService, this.layoutService);
|
|
823
|
+
}
|
|
824
|
+
({ session, entitlements } = await this.requests.signIn());
|
|
758
825
|
}
|
|
759
826
|
catch (e) {
|
|
760
827
|
this.logService.error(`[chat setup] signIn: error ${e}`);
|
|
761
828
|
}
|
|
762
|
-
if (!session && !this.willShutdown) {
|
|
829
|
+
if (!session && !this.lifecycleService.willShutdown) {
|
|
763
830
|
const { confirmed } = await this.dialogService.confirm({
|
|
764
831
|
type: Severity.Error,
|
|
765
832
|
message: ( localize(
|
|
766
|
-
|
|
833
|
+
4824,
|
|
767
834
|
"Failed to sign in to {0}. Would you like to try again?",
|
|
768
|
-
|
|
835
|
+
ChatEntitlementRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName
|
|
769
836
|
)),
|
|
770
|
-
detail: ( localize(
|
|
771
|
-
primaryButton: ( localize(
|
|
837
|
+
detail: ( localize(4825, "You must be signed in to use Copilot.")),
|
|
838
|
+
primaryButton: ( localize(4815, "Retry"))
|
|
772
839
|
});
|
|
773
840
|
if (confirmed) {
|
|
774
|
-
return this.signIn(providerId);
|
|
841
|
+
return this.signIn(providerId, options);
|
|
775
842
|
}
|
|
776
843
|
}
|
|
777
844
|
return { session, entitlement: entitlements?.entitlement };
|
|
778
845
|
}
|
|
779
|
-
async install(session, entitlement, providerId, watch) {
|
|
846
|
+
async install(session, entitlement, providerId, options, watch) {
|
|
780
847
|
const wasInstalled = this.context.state.installed;
|
|
781
848
|
let signUpResult = undefined;
|
|
782
849
|
try {
|
|
783
|
-
|
|
850
|
+
if (!options?.setupFromDialog) {
|
|
851
|
+
showCopilotView(this.viewsService, this.layoutService);
|
|
852
|
+
}
|
|
784
853
|
if (entitlement !== ChatEntitlement.Limited &&
|
|
785
854
|
entitlement !== ChatEntitlement.Pro &&
|
|
786
855
|
entitlement !== ChatEntitlement.Unavailable
|
|
@@ -792,30 +861,33 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
792
861
|
catch (error) {
|
|
793
862
|
}
|
|
794
863
|
if (!session) {
|
|
795
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNoSession', installDuration: watch.elapsed(), signUpErrorCode: undefined });
|
|
796
|
-
return;
|
|
864
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNoSession', installDuration: watch.elapsed(), signUpErrorCode: undefined, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
865
|
+
return false;
|
|
797
866
|
}
|
|
798
867
|
}
|
|
799
868
|
signUpResult = await this.requests.signUpLimited(session);
|
|
800
869
|
if (typeof signUpResult !== 'boolean' ) {
|
|
801
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedSignUp', installDuration: watch.elapsed(), signUpErrorCode: signUpResult.errorCode });
|
|
870
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedSignUp', installDuration: watch.elapsed(), signUpErrorCode: signUpResult.errorCode, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
802
871
|
}
|
|
803
872
|
}
|
|
804
873
|
await this.doInstall();
|
|
805
874
|
}
|
|
806
875
|
catch (error) {
|
|
807
876
|
this.logService.error(`[chat setup] install: error ${error}`);
|
|
808
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: isCancellationError(error) ? 'cancelled' : 'failedInstall', installDuration: watch.elapsed(), signUpErrorCode: undefined });
|
|
809
|
-
return;
|
|
877
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: isCancellationError(error) ? 'cancelled' : 'failedInstall', installDuration: watch.elapsed(), signUpErrorCode: undefined, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
878
|
+
return false;
|
|
810
879
|
}
|
|
811
|
-
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'installed', installDuration: watch.elapsed(), signUpErrorCode: undefined });
|
|
880
|
+
this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: wasInstalled ? 'alreadyInstalled' : 'installed', installDuration: watch.elapsed(), signUpErrorCode: undefined, setupFromDialog: Boolean(options.setupFromDialog) });
|
|
812
881
|
if (wasInstalled && signUpResult === true) {
|
|
813
882
|
refreshTokens(this.commandService);
|
|
814
883
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
884
|
+
if (!options?.setupFromDialog) {
|
|
885
|
+
await Promise.race([
|
|
886
|
+
timeout(5000),
|
|
887
|
+
Event.toPromise(this.chatAgentService.onDidChangeAgents)
|
|
888
|
+
]);
|
|
889
|
+
}
|
|
890
|
+
return true;
|
|
819
891
|
}
|
|
820
892
|
async doInstall() {
|
|
821
893
|
let error;
|
|
@@ -833,15 +905,15 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
833
905
|
error = e;
|
|
834
906
|
}
|
|
835
907
|
if (error) {
|
|
836
|
-
if (!this.willShutdown) {
|
|
908
|
+
if (!this.lifecycleService.willShutdown) {
|
|
837
909
|
const { confirmed } = await this.dialogService.confirm({
|
|
838
910
|
type: Severity.Error,
|
|
839
911
|
message: ( localize(
|
|
840
|
-
|
|
912
|
+
4826,
|
|
841
913
|
"An error occurred while setting up Copilot. Would you like to try again?"
|
|
842
914
|
)),
|
|
843
915
|
detail: error && !isCancellationError(error) ? toErrorMessage(error) : undefined,
|
|
844
|
-
primaryButton: ( localize(
|
|
916
|
+
primaryButton: ( localize(4815, "Retry"))
|
|
845
917
|
});
|
|
846
918
|
if (confirmed) {
|
|
847
919
|
return this.doInstall();
|
|
@@ -850,27 +922,138 @@ let ChatSetupController = class ChatSetupController extends Disposable {
|
|
|
850
922
|
throw error;
|
|
851
923
|
}
|
|
852
924
|
}
|
|
925
|
+
async setupWithProvider(options) {
|
|
926
|
+
const registry = ( Registry.as(Extensions.Configuration));
|
|
927
|
+
registry.registerConfiguration({
|
|
928
|
+
'id': 'copilot.setup',
|
|
929
|
+
'type': 'object',
|
|
930
|
+
'properties': {
|
|
931
|
+
[defaultChat.completionsAdvancedSetting]: {
|
|
932
|
+
'type': 'object',
|
|
933
|
+
'properties': {
|
|
934
|
+
'authProvider': {
|
|
935
|
+
'type': 'string'
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
[defaultChat.providerUriSetting]: {
|
|
940
|
+
'type': 'string'
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
if (options.useEnterpriseProvider) {
|
|
945
|
+
const success = await this.handleEnterpriseInstance();
|
|
946
|
+
if (!success) {
|
|
947
|
+
return false;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
let existingAdvancedSetting = this.configurationService.inspect(defaultChat.completionsAdvancedSetting).user?.value;
|
|
951
|
+
if (!isObject(existingAdvancedSetting)) {
|
|
952
|
+
existingAdvancedSetting = {};
|
|
953
|
+
}
|
|
954
|
+
if (options.useEnterpriseProvider) {
|
|
955
|
+
await this.configurationService.updateValue(`${defaultChat.completionsAdvancedSetting}`, {
|
|
956
|
+
...existingAdvancedSetting,
|
|
957
|
+
'authProvider': defaultChat.enterpriseProviderId
|
|
958
|
+
}, ConfigurationTarget.USER);
|
|
959
|
+
}
|
|
960
|
+
else {
|
|
961
|
+
await this.configurationService.updateValue(`${defaultChat.completionsAdvancedSetting}`, ( Object.keys(existingAdvancedSetting)).length > 0 ? {
|
|
962
|
+
...existingAdvancedSetting,
|
|
963
|
+
'authProvider': undefined
|
|
964
|
+
} : undefined, ConfigurationTarget.USER);
|
|
965
|
+
await this.configurationService.updateValue(defaultChat.providerUriSetting, undefined, ConfigurationTarget.USER);
|
|
966
|
+
}
|
|
967
|
+
return this.setup({ ...options, forceSignIn: true });
|
|
968
|
+
}
|
|
969
|
+
async handleEnterpriseInstance() {
|
|
970
|
+
const domainRegEx = /^[a-zA-Z\-_]+$/;
|
|
971
|
+
const fullUriRegEx = /^(https:\/\/)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.ghe\.com\/?$/;
|
|
972
|
+
const uri = this.configurationService.getValue(defaultChat.providerUriSetting);
|
|
973
|
+
if (typeof uri === 'string' && fullUriRegEx.test(uri)) {
|
|
974
|
+
return true;
|
|
975
|
+
}
|
|
976
|
+
let isSingleWord = false;
|
|
977
|
+
const result = await this.quickInputService.input({
|
|
978
|
+
prompt: ( localize(4827, "What is your {0} instance?", defaultChat.enterpriseProviderName)),
|
|
979
|
+
placeHolder: ( localize(4828, 'i.e. "octocat" or "https://octocat.ghe.com"...')),
|
|
980
|
+
ignoreFocusLost: true,
|
|
981
|
+
value: uri,
|
|
982
|
+
validateInput: async (value) => {
|
|
983
|
+
isSingleWord = false;
|
|
984
|
+
if (!value) {
|
|
985
|
+
return undefined;
|
|
986
|
+
}
|
|
987
|
+
if (domainRegEx.test(value)) {
|
|
988
|
+
isSingleWord = true;
|
|
989
|
+
return {
|
|
990
|
+
content: ( localize(4829, "Will resolve to {0}", `https://${value}.ghe.com`)),
|
|
991
|
+
severity: Severity.Info
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
if (!fullUriRegEx.test(value)) {
|
|
995
|
+
return {
|
|
996
|
+
content: ( localize(
|
|
997
|
+
4830,
|
|
998
|
+
'You must enter a valid {0} instance (i.e. "octocat" or "https://octocat.ghe.com")',
|
|
999
|
+
defaultChat.enterpriseProviderName
|
|
1000
|
+
)),
|
|
1001
|
+
severity: Severity.Error
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
return undefined;
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
if (!result) {
|
|
1008
|
+
const { confirmed } = await this.dialogService.confirm({
|
|
1009
|
+
type: Severity.Error,
|
|
1010
|
+
message: ( localize(
|
|
1011
|
+
4831,
|
|
1012
|
+
"The provided {0} instance is invalid. Would you like to enter it again?",
|
|
1013
|
+
defaultChat.enterpriseProviderName
|
|
1014
|
+
)),
|
|
1015
|
+
primaryButton: ( localize(4815, "Retry"))
|
|
1016
|
+
});
|
|
1017
|
+
if (confirmed) {
|
|
1018
|
+
return this.handleEnterpriseInstance();
|
|
1019
|
+
}
|
|
1020
|
+
return false;
|
|
1021
|
+
}
|
|
1022
|
+
let resolvedUri = result;
|
|
1023
|
+
if (isSingleWord) {
|
|
1024
|
+
resolvedUri = `https://${resolvedUri}.ghe.com`;
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
const normalizedUri = result.toLowerCase();
|
|
1028
|
+
const hasHttps = normalizedUri.startsWith('https://');
|
|
1029
|
+
if (!hasHttps) {
|
|
1030
|
+
resolvedUri = `https://${result}`;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
await this.configurationService.updateValue(defaultChat.providerUriSetting, resolvedUri, ConfigurationTarget.USER);
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
853
1036
|
};
|
|
854
1037
|
ChatSetupController = ( __decorate([
|
|
855
1038
|
( __param(2, ITelemetryService)),
|
|
856
1039
|
( __param(3, IAuthenticationService)),
|
|
857
|
-
( __param(4,
|
|
858
|
-
( __param(5,
|
|
859
|
-
( __param(6,
|
|
860
|
-
( __param(7,
|
|
861
|
-
( __param(8,
|
|
862
|
-
( __param(9,
|
|
863
|
-
( __param(10,
|
|
864
|
-
( __param(11,
|
|
865
|
-
( __param(12,
|
|
866
|
-
( __param(13,
|
|
867
|
-
( __param(14,
|
|
868
|
-
( __param(15,
|
|
869
|
-
( __param(16,
|
|
870
|
-
( __param(17,
|
|
1040
|
+
( __param(4, IViewsService)),
|
|
1041
|
+
( __param(5, IExtensionsWorkbenchService)),
|
|
1042
|
+
( __param(6, IProductService)),
|
|
1043
|
+
( __param(7, ILogService)),
|
|
1044
|
+
( __param(8, IProgressService)),
|
|
1045
|
+
( __param(9, IChatAgentService)),
|
|
1046
|
+
( __param(10, IActivityService)),
|
|
1047
|
+
( __param(11, ICommandService)),
|
|
1048
|
+
( __param(12, IWorkbenchLayoutService)),
|
|
1049
|
+
( __param(13, IWorkspaceTrustRequestService)),
|
|
1050
|
+
( __param(14, IDialogService)),
|
|
1051
|
+
( __param(15, IConfigurationService)),
|
|
1052
|
+
( __param(16, ILifecycleService)),
|
|
1053
|
+
( __param(17, IQuickInputService))
|
|
871
1054
|
], ChatSetupController));
|
|
872
1055
|
let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
873
|
-
constructor(controller, context, instantiationService, contextMenuService, configurationService, telemetryService
|
|
1056
|
+
constructor(controller, context, instantiationService, contextMenuService, configurationService, telemetryService) {
|
|
874
1057
|
super();
|
|
875
1058
|
this.controller = controller;
|
|
876
1059
|
this.context = context;
|
|
@@ -878,8 +1061,6 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
|
878
1061
|
this.contextMenuService = contextMenuService;
|
|
879
1062
|
this.configurationService = configurationService;
|
|
880
1063
|
this.telemetryService = telemetryService;
|
|
881
|
-
this.quickInputService = quickInputService;
|
|
882
|
-
this.dialogService = dialogService;
|
|
883
1064
|
this.element = $('.chat-setup-view');
|
|
884
1065
|
this.create();
|
|
885
1066
|
}
|
|
@@ -887,41 +1068,25 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
|
887
1068
|
const markdown = this.instantiationService.createInstance(MarkdownRenderer, {});
|
|
888
1069
|
{
|
|
889
1070
|
const header = ( localize(
|
|
890
|
-
|
|
1071
|
+
4832,
|
|
891
1072
|
"[Copilot]({0}) is your AI pair programmer.",
|
|
892
|
-
this.context.state.installed ?
|
|
1073
|
+
this.context.state.installed ? `command:${defaultChat.walkthroughCommand}` : defaultChat.documentationUrl
|
|
893
1074
|
));
|
|
894
|
-
this.element.appendChild($('p'
|
|
895
|
-
|
|
896
|
-
this.element.appendChild(featuresParent);
|
|
897
|
-
const featuresContainer = this.element.appendChild($('div'));
|
|
898
|
-
featuresParent.appendChild(featuresContainer);
|
|
899
|
-
const featureChatContainer = featuresContainer.appendChild($('div.chat-feature-container'));
|
|
900
|
-
featureChatContainer.appendChild(renderIcon(Codicon.code));
|
|
901
|
-
const featureChatLabel = featureChatContainer.appendChild($('span'));
|
|
902
|
-
featureChatLabel.textContent = ( localize(4710, "Code faster with Completions"));
|
|
903
|
-
const featureEditsContainer = featuresContainer.appendChild($('div.chat-feature-container'));
|
|
904
|
-
featureEditsContainer.appendChild(renderIcon(Codicon.editSession));
|
|
905
|
-
const featureEditsLabel = featureEditsContainer.appendChild($('span'));
|
|
906
|
-
featureEditsLabel.textContent = ( localize(4711, "Build features with Copilot Edits"));
|
|
907
|
-
const featureExploreContainer = featuresContainer.appendChild($('div.chat-feature-container'));
|
|
908
|
-
featureExploreContainer.appendChild(renderIcon(Codicon.commentDiscussion));
|
|
909
|
-
const featureExploreLabel = featureExploreContainer.appendChild($('span'));
|
|
910
|
-
featureExploreLabel.textContent = ( localize(4712, "Explore your codebase with Chat"));
|
|
1075
|
+
this.element.appendChild($('p', undefined, this._register(markdown.render(( new MarkdownString(header, { isTrusted: true })))).element));
|
|
1076
|
+
this.element.appendChild($('div.chat-features-container', undefined, $('div', undefined, $('div.chat-feature-container', undefined, renderIcon(Codicon.code), $('span', undefined, ( localize(4833, "Code faster with Completions")))), $('div.chat-feature-container', undefined, renderIcon(Codicon.editSession), $('span', undefined, ( localize(4834, "Build features with Copilot Edits")))), $('div.chat-feature-container', undefined, renderIcon(Codicon.commentDiscussion), $('span', undefined, ( localize(4835, "Explore your codebase with Chat")))))));
|
|
911
1077
|
}
|
|
912
1078
|
const free = ( localize(
|
|
913
|
-
|
|
1079
|
+
4836,
|
|
914
1080
|
"$(sparkle-filled) We now offer [Copilot for free]({0}).",
|
|
915
1081
|
defaultChat.skusDocumentationUrl
|
|
916
1082
|
));
|
|
917
|
-
const freeContainer = this.element.appendChild($('p'));
|
|
918
|
-
freeContainer.appendChild(this._register(markdown.render(( new MarkdownString(free, { isTrusted: true, supportThemeIcons: true })))).element);
|
|
1083
|
+
const freeContainer = this.element.appendChild($('p', undefined, this._register(markdown.render(( new MarkdownString(free, { isTrusted: true, supportThemeIcons: true })))).element));
|
|
919
1084
|
const buttonContainer = this.element.appendChild($('p'));
|
|
920
1085
|
buttonContainer.classList.add('button-container');
|
|
921
1086
|
const button = this._register(( new ButtonWithDropdown(buttonContainer, {
|
|
922
1087
|
actions: [
|
|
923
|
-
toAction({ id: 'chatSetup.setupWithProvider', label: ( localize(
|
|
924
|
-
toAction({ id: 'chatSetup.setupWithEnterpriseProvider', label: ( localize(
|
|
1088
|
+
toAction({ id: 'chatSetup.setupWithProvider', label: ( localize(4800, "Sign in with a {0} Account", defaultChat.providerName)), run: () => this.controller.setupWithProvider({ useEnterpriseProvider: false }) }),
|
|
1089
|
+
toAction({ id: 'chatSetup.setupWithEnterpriseProvider', label: ( localize(4801, "Sign in with a {0} Account", defaultChat.enterpriseProviderName)), run: () => this.controller.setupWithProvider({ useEnterpriseProvider: true }) })
|
|
925
1090
|
],
|
|
926
1091
|
addPrimaryActionToDropdown: false,
|
|
927
1092
|
contextMenuProvider: this.contextMenuService,
|
|
@@ -930,20 +1095,19 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
|
930
1095
|
})));
|
|
931
1096
|
this._register(button.onDidClick(() => this.controller.setup()));
|
|
932
1097
|
const terms = ( localize(
|
|
933
|
-
|
|
1098
|
+
4810,
|
|
934
1099
|
"By continuing, you agree to the [Terms]({0}) and [Privacy Policy]({1}).",
|
|
935
1100
|
defaultChat.termsStatementUrl,
|
|
936
1101
|
defaultChat.privacyStatementUrl
|
|
937
1102
|
));
|
|
938
|
-
this.element.appendChild($('p'
|
|
1103
|
+
this.element.appendChild($('p', undefined, this._register(markdown.render(( new MarkdownString(terms, { isTrusted: true })))).element));
|
|
939
1104
|
const settings = ( localize(
|
|
940
|
-
|
|
1105
|
+
4811,
|
|
941
1106
|
"Copilot Free and Pro may show [public code]({0}) suggestions and we may use your data for product improvement. You can change these [settings]({1}) at any time.",
|
|
942
1107
|
defaultChat.publicCodeMatchesUrl,
|
|
943
1108
|
defaultChat.manageSettingsUrl
|
|
944
1109
|
));
|
|
945
|
-
const settingsContainer = this.element.appendChild($('p'));
|
|
946
|
-
settingsContainer.appendChild(this._register(markdown.render(( new MarkdownString(settings, { isTrusted: true })))).element);
|
|
1110
|
+
const settingsContainer = this.element.appendChild($('p', undefined, this._register(markdown.render(( new MarkdownString(settings, { isTrusted: true })))).element));
|
|
947
1111
|
this._register(Event.runAndSubscribe(this.controller.onDidChange, () => this.update(freeContainer, settingsContainer, button)));
|
|
948
1112
|
}
|
|
949
1113
|
update(freeContainer, settingsContainer, button) {
|
|
@@ -953,33 +1117,33 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
|
953
1117
|
switch (this.context.state.entitlement) {
|
|
954
1118
|
case ChatEntitlement.Unknown:
|
|
955
1119
|
showFree = true;
|
|
956
|
-
buttonLabel = this.context.state.registered ? ( localize(
|
|
1120
|
+
buttonLabel = this.context.state.registered ? ( localize(4804, "Sign in to use Copilot")) : ( localize(4805, "Sign in to use Copilot for free"));
|
|
957
1121
|
break;
|
|
958
1122
|
case ChatEntitlement.Unresolved:
|
|
959
1123
|
showFree = true;
|
|
960
|
-
buttonLabel = this.context.state.registered ? ( localize(
|
|
1124
|
+
buttonLabel = this.context.state.registered ? ( localize(4837, "Use Copilot")) : ( localize(4838, "Use Copilot for free"));
|
|
961
1125
|
break;
|
|
962
1126
|
case ChatEntitlement.Available:
|
|
963
1127
|
case ChatEntitlement.Limited:
|
|
964
1128
|
showFree = true;
|
|
965
|
-
buttonLabel = ( localize(
|
|
1129
|
+
buttonLabel = ( localize(4838, "Use Copilot for free"));
|
|
966
1130
|
break;
|
|
967
1131
|
case ChatEntitlement.Pro:
|
|
968
1132
|
case ChatEntitlement.Unavailable:
|
|
969
1133
|
showFree = false;
|
|
970
|
-
buttonLabel = ( localize(
|
|
1134
|
+
buttonLabel = ( localize(4837, "Use Copilot"));
|
|
971
1135
|
break;
|
|
972
1136
|
}
|
|
973
1137
|
switch (this.controller.step) {
|
|
974
1138
|
case ChatSetupStep.SigningIn:
|
|
975
1139
|
buttonLabel = ( localize(
|
|
976
|
-
|
|
1140
|
+
4839,
|
|
977
1141
|
"$(loading~spin) Signing in to {0}...",
|
|
978
|
-
|
|
1142
|
+
ChatEntitlementRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName
|
|
979
1143
|
));
|
|
980
1144
|
break;
|
|
981
1145
|
case ChatSetupStep.Installing:
|
|
982
|
-
buttonLabel = ( localize(
|
|
1146
|
+
buttonLabel = ( localize(4840, "$(loading~spin) Getting Copilot Ready..."));
|
|
983
1147
|
break;
|
|
984
1148
|
}
|
|
985
1149
|
setVisibility(showFree, freeContainer);
|
|
@@ -987,208 +1151,16 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
|
|
|
987
1151
|
button.label = buttonLabel;
|
|
988
1152
|
button.enabled = this.controller.step === ChatSetupStep.Initial;
|
|
989
1153
|
}
|
|
990
|
-
async setupWithProvider(useEnterpriseProvider) {
|
|
991
|
-
const registry = ( Registry.as(Extensions.Configuration));
|
|
992
|
-
registry.registerConfiguration({
|
|
993
|
-
'id': 'copilot.setup',
|
|
994
|
-
'type': 'object',
|
|
995
|
-
'properties': {
|
|
996
|
-
[defaultChat.providerSetting]: {
|
|
997
|
-
'type': 'string'
|
|
998
|
-
},
|
|
999
|
-
[defaultChat.providerUriSetting]: {
|
|
1000
|
-
'type': 'string'
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
if (useEnterpriseProvider) {
|
|
1005
|
-
const success = await this.handleEnterpriseInstance();
|
|
1006
|
-
if (!success) {
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
await this.configurationService.updateValue(defaultChat.providerSetting, defaultChat.enterpriseProviderId, ConfigurationTarget.USER);
|
|
1010
|
-
}
|
|
1011
|
-
else {
|
|
1012
|
-
await this.configurationService.updateValue(defaultChat.providerSetting, undefined, ConfigurationTarget.USER);
|
|
1013
|
-
await this.configurationService.updateValue(defaultChat.providerUriSetting, undefined, ConfigurationTarget.USER);
|
|
1014
|
-
}
|
|
1015
|
-
return this.controller.setup({ forceSignIn: true });
|
|
1016
|
-
}
|
|
1017
|
-
async handleEnterpriseInstance() {
|
|
1018
|
-
const domainRegEx = /^[a-zA-Z\-_]+$/;
|
|
1019
|
-
const fullUriRegEx = /^(https:\/\/)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.ghe\.com\/?$/;
|
|
1020
|
-
const uri = this.configurationService.getValue(defaultChat.providerUriSetting);
|
|
1021
|
-
if (typeof uri === 'string' && fullUriRegEx.test(uri)) {
|
|
1022
|
-
return true;
|
|
1023
|
-
}
|
|
1024
|
-
let isSingleWord = false;
|
|
1025
|
-
const result = await this.quickInputService.input({
|
|
1026
|
-
prompt: ( localize(4724, "What is your {0} instance?", defaultChat.enterpriseProviderName)),
|
|
1027
|
-
placeHolder: ( localize(4725, 'i.e. "octocat" or "https://octocat.ghe.com"...')),
|
|
1028
|
-
value: uri,
|
|
1029
|
-
validateInput: async (value) => {
|
|
1030
|
-
isSingleWord = false;
|
|
1031
|
-
if (!value) {
|
|
1032
|
-
return undefined;
|
|
1033
|
-
}
|
|
1034
|
-
if (domainRegEx.test(value)) {
|
|
1035
|
-
isSingleWord = true;
|
|
1036
|
-
return {
|
|
1037
|
-
content: ( localize(4726, "Will resolve to {0}", `https://${value}.ghe.com`)),
|
|
1038
|
-
severity: Severity.Info
|
|
1039
|
-
};
|
|
1040
|
-
}
|
|
1041
|
-
if (!fullUriRegEx.test(value)) {
|
|
1042
|
-
return {
|
|
1043
|
-
content: ( localize(
|
|
1044
|
-
4727,
|
|
1045
|
-
'Please enter a valid {0} instance (i.e. "octocat" or "https://octocat.ghe.com")',
|
|
1046
|
-
defaultChat.enterpriseProviderName
|
|
1047
|
-
)),
|
|
1048
|
-
severity: Severity.Error
|
|
1049
|
-
};
|
|
1050
|
-
}
|
|
1051
|
-
return undefined;
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
if (!result) {
|
|
1055
|
-
const { confirmed } = await this.dialogService.confirm({
|
|
1056
|
-
type: Severity.Error,
|
|
1057
|
-
message: ( localize(
|
|
1058
|
-
4728,
|
|
1059
|
-
"The provided {0} instance is invalid. Would you like to enter it again?",
|
|
1060
|
-
defaultChat.enterpriseProviderName
|
|
1061
|
-
)),
|
|
1062
|
-
primaryButton: ( localize(4700, "Retry"))
|
|
1063
|
-
});
|
|
1064
|
-
if (confirmed) {
|
|
1065
|
-
return this.handleEnterpriseInstance();
|
|
1066
|
-
}
|
|
1067
|
-
return false;
|
|
1068
|
-
}
|
|
1069
|
-
let resolvedUri = result;
|
|
1070
|
-
if (isSingleWord) {
|
|
1071
|
-
resolvedUri = `https://${resolvedUri}.ghe.com`;
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
const normalizedUri = result.toLowerCase();
|
|
1075
|
-
const hasHttps = normalizedUri.startsWith('https://');
|
|
1076
|
-
if (!hasHttps) {
|
|
1077
|
-
resolvedUri = `https://${result}`;
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
await this.configurationService.updateValue(defaultChat.providerUriSetting, resolvedUri, ConfigurationTarget.USER);
|
|
1081
|
-
return true;
|
|
1082
|
-
}
|
|
1083
1154
|
};
|
|
1084
1155
|
ChatSetupWelcomeContent = ( __decorate([
|
|
1085
1156
|
( __param(2, IInstantiationService)),
|
|
1086
1157
|
( __param(3, IContextMenuService)),
|
|
1087
1158
|
( __param(4, IConfigurationService)),
|
|
1088
|
-
( __param(5, ITelemetryService))
|
|
1089
|
-
( __param(6, IQuickInputService)),
|
|
1090
|
-
( __param(7, IDialogService))
|
|
1159
|
+
( __param(5, ITelemetryService))
|
|
1091
1160
|
], ChatSetupWelcomeContent));
|
|
1092
|
-
let ChatSetupContext = class ChatSetupContext extends Disposable {
|
|
1093
|
-
static { ChatSetupContext_1 = this; }
|
|
1094
|
-
static { this.CHAT_SETUP_CONTEXT_STORAGE_KEY = 'chat.setupContext'; }
|
|
1095
|
-
get state() {
|
|
1096
|
-
return this.suspendedState ?? this._state;
|
|
1097
|
-
}
|
|
1098
|
-
constructor(contextKeyService, storageService, workspaceContextService, extensionEnablementService, logService, extensionsWorkbenchService) {
|
|
1099
|
-
super();
|
|
1100
|
-
this.contextKeyService = contextKeyService;
|
|
1101
|
-
this.storageService = storageService;
|
|
1102
|
-
this.workspaceContextService = workspaceContextService;
|
|
1103
|
-
this.extensionEnablementService = extensionEnablementService;
|
|
1104
|
-
this.logService = logService;
|
|
1105
|
-
this.extensionsWorkbenchService = extensionsWorkbenchService;
|
|
1106
|
-
this.canSignUpContextKey = ChatContextKeys.Setup.canSignUp.bindTo(this.contextKeyService);
|
|
1107
|
-
this.signedOutContextKey = ChatContextKeys.Setup.signedOut.bindTo(this.contextKeyService);
|
|
1108
|
-
this.limitedContextKey = ChatContextKeys.Setup.limited.bindTo(this.contextKeyService);
|
|
1109
|
-
this.proContextKey = ChatContextKeys.Setup.pro.bindTo(this.contextKeyService);
|
|
1110
|
-
this.hiddenContext = ChatContextKeys.Setup.hidden.bindTo(this.contextKeyService);
|
|
1111
|
-
this.installedContext = ChatContextKeys.Setup.installed.bindTo(this.contextKeyService);
|
|
1112
|
-
this._state = this.storageService.getObject(ChatSetupContext_1.CHAT_SETUP_CONTEXT_STORAGE_KEY, StorageScope.PROFILE) ?? { entitlement: ChatEntitlement.Unknown };
|
|
1113
|
-
this.suspendedState = undefined;
|
|
1114
|
-
this._onDidChange = this._register(( new Emitter()));
|
|
1115
|
-
this.onDidChange = this._onDidChange.event;
|
|
1116
|
-
this.updateBarrier = undefined;
|
|
1117
|
-
this.checkExtensionInstallation();
|
|
1118
|
-
this.updateContextSync();
|
|
1119
|
-
}
|
|
1120
|
-
async checkExtensionInstallation() {
|
|
1121
|
-
await this.extensionsWorkbenchService.queryLocal();
|
|
1122
|
-
this._register(Event.runAndSubscribe(this.extensionsWorkbenchService.onChange, e => {
|
|
1123
|
-
if (e && !ExtensionIdentifier.equals(e.identifier.id, defaultChat.extensionId)) {
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
const defaultChatExtension = this.extensionsWorkbenchService.local.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId));
|
|
1127
|
-
this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) });
|
|
1128
|
-
}));
|
|
1129
|
-
}
|
|
1130
|
-
update(context) {
|
|
1131
|
-
this.logService.trace(`[chat setup] update(): ${JSON.stringify(context)}`);
|
|
1132
|
-
if (typeof context.installed === 'boolean') {
|
|
1133
|
-
this._state.installed = context.installed;
|
|
1134
|
-
if (context.installed) {
|
|
1135
|
-
context.hidden = false;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
if (typeof context.hidden === 'boolean') {
|
|
1139
|
-
this._state.hidden = context.hidden;
|
|
1140
|
-
}
|
|
1141
|
-
if (typeof context.entitlement === 'number') {
|
|
1142
|
-
this._state.entitlement = context.entitlement;
|
|
1143
|
-
if (this._state.entitlement === ChatEntitlement.Limited || this._state.entitlement === ChatEntitlement.Pro) {
|
|
1144
|
-
this._state.registered = true;
|
|
1145
|
-
}
|
|
1146
|
-
else if (this._state.entitlement === ChatEntitlement.Available) {
|
|
1147
|
-
this._state.registered = false;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
this.storageService.store(ChatSetupContext_1.CHAT_SETUP_CONTEXT_STORAGE_KEY, this._state, StorageScope.PROFILE, StorageTarget.MACHINE);
|
|
1151
|
-
return this.updateContext();
|
|
1152
|
-
}
|
|
1153
|
-
async updateContext() {
|
|
1154
|
-
await this.updateBarrier?.wait();
|
|
1155
|
-
this.updateContextSync();
|
|
1156
|
-
}
|
|
1157
|
-
updateContextSync() {
|
|
1158
|
-
this.logService.trace(`[chat setup] updateContext(): ${JSON.stringify(this._state)}`);
|
|
1159
|
-
if (!this._state.hidden && !this._state.installed) {
|
|
1160
|
-
this.storageService.remove('chat.welcomeMessageContent.panel', StorageScope.APPLICATION);
|
|
1161
|
-
this.storageService.remove('interactive.sessions', this.workspaceContextService.getWorkspace().folders.length ? StorageScope.WORKSPACE : StorageScope.APPLICATION);
|
|
1162
|
-
}
|
|
1163
|
-
this.signedOutContextKey.set(this._state.entitlement === ChatEntitlement.Unknown);
|
|
1164
|
-
this.canSignUpContextKey.set(this._state.entitlement === ChatEntitlement.Available);
|
|
1165
|
-
this.limitedContextKey.set(this._state.entitlement === ChatEntitlement.Limited);
|
|
1166
|
-
this.proContextKey.set(this._state.entitlement === ChatEntitlement.Pro);
|
|
1167
|
-
this.hiddenContext.set(!!this._state.hidden);
|
|
1168
|
-
this.installedContext.set(!!this._state.installed);
|
|
1169
|
-
this._onDidChange.fire();
|
|
1170
|
-
}
|
|
1171
|
-
suspend() {
|
|
1172
|
-
this.suspendedState = { ...this._state };
|
|
1173
|
-
this.updateBarrier = ( new Barrier());
|
|
1174
|
-
}
|
|
1175
|
-
resume() {
|
|
1176
|
-
this.suspendedState = undefined;
|
|
1177
|
-
this.updateBarrier?.open();
|
|
1178
|
-
this.updateBarrier = undefined;
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
ChatSetupContext = ChatSetupContext_1 = ( __decorate([
|
|
1182
|
-
( __param(0, IContextKeyService)),
|
|
1183
|
-
( __param(1, IStorageService)),
|
|
1184
|
-
( __param(2, IWorkspaceContextService)),
|
|
1185
|
-
( __param(3, IWorkbenchExtensionEnablementService)),
|
|
1186
|
-
( __param(4, ILogService)),
|
|
1187
|
-
( __param(5, IExtensionsWorkbenchService))
|
|
1188
|
-
], ChatSetupContext));
|
|
1189
1161
|
function refreshTokens(commandService) {
|
|
1190
|
-
commandService.executeCommand(
|
|
1191
|
-
commandService.executeCommand(
|
|
1162
|
+
commandService.executeCommand(defaultChat.completionsRefreshTokenCommand);
|
|
1163
|
+
commandService.executeCommand(defaultChat.chatRefreshTokenCommand);
|
|
1192
1164
|
}
|
|
1193
1165
|
|
|
1194
|
-
export {
|
|
1166
|
+
export { ChatSetupContribution };
|