@codingame/monaco-vscode-chat-service-override 11.1.2 → 12.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.
Files changed (110) hide show
  1. package/index.d.ts +2 -1
  2. package/index.js +64 -1
  3. package/package.json +32 -13
  4. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +21 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +73 -60
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +3 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +73 -81
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +9 -0
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +73 -112
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.d.ts +12 -0
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +253 -101
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.d.ts +1 -0
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +8 -8
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.d.ts +1 -0
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +2 -1
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.d.ts +1 -0
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +16 -14
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +23 -0
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +30 -11
  20. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.d.ts +1 -0
  21. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +12 -12
  22. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.d.ts +1 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +22 -20
  24. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.d.ts +2 -0
  25. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +23 -20
  26. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +52 -0
  27. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +50 -47
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.d.ts +1 -0
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +124 -95
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +17 -0
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.js +6 -3
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.d.ts +12 -0
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatEdinputInputContentProvider.js +30 -0
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +69 -0
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +203 -182
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +103 -0
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +458 -165
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +42 -0
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +14 -10
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +26 -0
  41. package/vscode/src/vs/workbench/contrib/chat/browser/{chatParticipantContributions.js → chatParticipant.contribution.js} +101 -92
  42. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +42 -0
  43. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +164 -25
  44. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +26 -0
  45. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +6 -5
  46. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +30 -0
  47. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +10 -7
  48. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +17 -0
  49. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +941 -0
  50. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +26 -0
  51. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +9 -6
  52. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.d.ts +54 -0
  53. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +32 -15
  54. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +9 -0
  55. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.js +1 -0
  56. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.d.ts +1 -0
  57. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +8 -6
  58. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.d.ts +26 -0
  59. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +16 -19
  60. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.d.ts +15 -0
  61. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +108 -0
  62. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.d.ts +7 -0
  63. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/editorHoverWrapper.js +3 -8
  64. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/media/editorHoverWrapper.css.js +1 -1
  65. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +31 -0
  66. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +70 -49
  67. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +6 -0
  68. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.d.ts +7 -0
  69. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/{chatViewsWelcomeContributions.js → chatViewsWelcomeHandler.js} +13 -13
  70. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +44 -0
  71. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +3 -1
  72. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +22 -0
  73. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +1 -0
  74. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +80 -0
  75. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +152 -104
  76. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.d.ts +8 -0
  77. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceTelemetry.js +2 -1
  78. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.d.ts +41 -0
  79. package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +2 -1
  80. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +31 -0
  81. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +6 -4
  82. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.d.ts +13 -0
  83. package/vscode/src/vs/workbench/contrib/chat/common/ignoredFiles.js +1 -0
  84. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.d.ts +24 -0
  85. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +23 -21
  86. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.d.ts +1 -0
  87. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsParametersSchema.js +1 -0
  88. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +39 -0
  89. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +20 -19
  90. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.service.d.ts +7 -0
  91. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.d.ts +1 -0
  92. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +30 -33
  93. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +10 -0
  94. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.js +6 -4
  95. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +10 -0
  96. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.js +9 -7
  97. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.d.ts +44 -0
  98. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +247 -83
  99. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.d.ts +8 -0
  100. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js +5 -4
  101. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +29 -0
  102. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +35 -35
  103. package/chat.js +0 -59
  104. package/vscode/src/vs/editor/common/diff/documentDiffProvider.js +0 -8
  105. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingModifiedFileEntry.js +0 -326
  106. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingTextModelContentProviders.js +0 -76
  107. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorActions.js +0 -110
  108. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorController.js +0 -287
  109. package/vscode/src/vs/workbench/contrib/chat/common/languageModelStats.js +0 -130
  110. package/vscode/src/vs/workbench/contrib/chat/common/languageModels.js +0 -172
@@ -0,0 +1,941 @@
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
3
+ import './media/chatViewSetup.css.js';
4
+ import { getActiveElement, $, setVisibility } from 'vscode/vscode/vs/base/browser/dom';
5
+ import { Button, ButtonWithDropdown } from 'vscode/vscode/vs/base/browser/ui/button/button';
6
+ import { renderIcon } from 'vscode/vscode/vs/base/browser/ui/iconLabel/iconLabels';
7
+ import { toAction } from 'vscode/vscode/vs/base/common/actions';
8
+ import { timeout, Barrier } from 'vscode/vscode/vs/base/common/async';
9
+ import { CancellationTokenSource, CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
10
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
11
+ import { isCancellationError } from 'vscode/vscode/vs/base/common/errors';
12
+ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
13
+ import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
14
+ import { Lazy } from 'vscode/vscode/vs/base/common/lazy';
15
+ import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
16
+ import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
17
+ import { localize2, localize } from 'vscode/vscode/vs/nls';
18
+ import { Action2, MenuId, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
19
+ import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
20
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
21
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
22
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
23
+ import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView.service';
24
+ import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
25
+ import { ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
26
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
27
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
28
+ import product from 'vscode/vscode/vs/platform/product/common/product';
29
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
30
+ import { ProgressLocation } from 'vscode/vscode/vs/platform/progress/common/progress';
31
+ import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
32
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
33
+ import { asText } from 'vscode/vscode/vs/platform/request/common/request';
34
+ import { IRequestService } from 'vscode/vscode/vs/platform/request/common/request.service';
35
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
36
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
37
+ import { TelemetryLevel } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
38
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
39
+ import { defaultButtonStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
40
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
41
+ import { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
42
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
43
+ import { ProgressBadge } from '@codingame/monaco-vscode-a7c9ae3c-16d2-5d17-86b2-981be7094566-common/vscode/vs/workbench/services/activity/common/activity';
44
+ import { IActivityService } from 'vscode/vscode/vs/workbench/services/activity/common/activity.service';
45
+ import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
46
+ import { IWorkbenchExtensionEnablementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.service';
47
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
48
+ import { Parts } from '@codingame/monaco-vscode-e571cbbb-526b-5d8b-92c5-a0437d2dabb3-common/vscode/vs/workbench/services/layout/browser/layoutService';
49
+ import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
50
+ import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
51
+ import { IExtensionsWorkbenchService } from 'vscode/vscode/vs/workbench/contrib/extensions/common/extensions.service';
52
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
53
+ import { ChatContextKeys } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatContextKeys';
54
+ import { CHAT_CATEGORY } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
55
+ import { ensureSideBarChatViewSize, ChatViewId, EditsViewId, showEditsView, showChatView } from '@codingame/monaco-vscode-fab30422-b487-5f4e-8d30-8b4d266e3fcd-common/vscode/vs/workbench/contrib/chat/browser/chat';
56
+ import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
57
+ import { ChatViewsWelcomeExtensions } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcome';
58
+ import { IChatQuotasService } from 'vscode/vscode/vs/workbench/contrib/chat/browser/chatQuotasService.service';
59
+ import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
60
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
61
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
62
+ import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
63
+ import Severity from 'vscode/vscode/vs/base/common/severity';
64
+
65
+ var ChatSetupContext_1;
66
+ const defaultChat = {
67
+ extensionId: product.defaultChatAgent?.extensionId ?? '',
68
+ chatExtensionId: product.defaultChatAgent?.chatExtensionId ?? '',
69
+ documentationUrl: product.defaultChatAgent?.documentationUrl ?? '',
70
+ termsStatementUrl: product.defaultChatAgent?.termsStatementUrl ?? '',
71
+ privacyStatementUrl: product.defaultChatAgent?.privacyStatementUrl ?? '',
72
+ skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '',
73
+ publicCodeMatchesUrl: product.defaultChatAgent?.publicCodeMatchesUrl ?? '',
74
+ upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '',
75
+ providerId: product.defaultChatAgent?.providerId ?? '',
76
+ providerName: product.defaultChatAgent?.providerName ?? '',
77
+ providerScopes: product.defaultChatAgent?.providerScopes ?? [[]],
78
+ entitlementUrl: product.defaultChatAgent?.entitlementUrl ?? '',
79
+ entitlementSignupLimitedUrl: product.defaultChatAgent?.entitlementSignupLimitedUrl ?? '',
80
+ manageSettingsUrl: product.defaultChatAgent?.manageSettingsUrl ?? '',
81
+ };
82
+ var ChatEntitlement;
83
+ (function (ChatEntitlement) {
84
+ ChatEntitlement[ChatEntitlement["Unknown"] = 1] = "Unknown";
85
+ ChatEntitlement[ChatEntitlement["Unresolved"] = 2] = "Unresolved";
86
+ ChatEntitlement[ChatEntitlement["Available"] = 3] = "Available";
87
+ ChatEntitlement[ChatEntitlement["Unavailable"] = 4] = "Unavailable";
88
+ ChatEntitlement[ChatEntitlement["Limited"] = 5] = "Limited";
89
+ ChatEntitlement[ChatEntitlement["Pro"] = 6] = "Pro";
90
+ })(ChatEntitlement || (ChatEntitlement = {}));
91
+ const TRIGGER_SETUP_COMMAND_ID = 'workbench.action.chat.triggerSetup';
92
+ const TRIGGER_SETUP_COMMAND_LABEL = ( localize2(4520, "Use AI Features with Copilot for Free..."));
93
+ const SetupWelcomeViewKeys = ( new Set(
94
+ [ChatContextKeys.Setup.triggered.key, ChatContextKeys.Setup.installed.key, ChatContextKeys.Setup.signedOut.key, ChatContextKeys.Setup.canSignUp.key]
95
+ ));
96
+ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('config.chat.experimental.offerSetup')), ( ContextKeyExpr.or(( ContextKeyExpr.and(ChatContextKeys.Setup.triggered, ( ChatContextKeys.Setup.installed.negate()))), ( ContextKeyExpr.and(ChatContextKeys.Setup.canSignUp, ChatContextKeys.Setup.installed)), ( ContextKeyExpr.and(ChatContextKeys.Setup.signedOut, ChatContextKeys.Setup.installed))))));
97
+ (class ChatSetupContribution extends Disposable {
98
+ static { this.ID = 'workbench.chat.setup'; }
99
+ constructor(productService, instantiationService) {
100
+ super();
101
+ this.productService = productService;
102
+ this.instantiationService = instantiationService;
103
+ this.context = this._register(this.instantiationService.createInstance(ChatSetupContext));
104
+ this.requests = this._register(this.instantiationService.createInstance(ChatSetupRequests, this.context));
105
+ this.controller = ( new Lazy(
106
+ () => this._register(this.instantiationService.createInstance(ChatSetupController, this.context, this.requests))
107
+ ));
108
+ if (!this.productService.defaultChatAgent) {
109
+ return;
110
+ }
111
+ this.registerChatWelcome();
112
+ this.registerActions();
113
+ }
114
+ registerChatWelcome() {
115
+ ( Registry.as(ChatViewsWelcomeExtensions.ChatViewsWelcomeRegistry)).register({
116
+ title: ( localize(4521, "Welcome to Copilot")),
117
+ when: SetupWelcomeViewCondition,
118
+ icon: Codicon.copilotLarge,
119
+ content: disposables => disposables.add(this.instantiationService.createInstance(ChatSetupWelcomeContent, this.controller.value, this.context)).element,
120
+ });
121
+ }
122
+ registerActions() {
123
+ const that = this;
124
+ class ChatSetupTriggerAction extends Action2 {
125
+ constructor() {
126
+ super({
127
+ id: TRIGGER_SETUP_COMMAND_ID,
128
+ title: TRIGGER_SETUP_COMMAND_LABEL,
129
+ category: CHAT_CATEGORY,
130
+ f1: true,
131
+ precondition: ( ContextKeyExpr.and(( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.has('config.chat.experimental.offerSetup')))),
132
+ menu: {
133
+ id: MenuId.ChatCommandCenter,
134
+ group: 'a_last',
135
+ order: 1,
136
+ when: ( ChatContextKeys.Setup.installed.negate())
137
+ }
138
+ });
139
+ }
140
+ async run(accessor, startSetup) {
141
+ const viewsService = accessor.get(IViewsService);
142
+ const viewDescriptorService = accessor.get(IViewDescriptorService);
143
+ const configurationService = accessor.get(IConfigurationService);
144
+ const layoutService = accessor.get(IWorkbenchLayoutService);
145
+ await that.context.update({ triggered: true });
146
+ showCopilotView(viewsService, layoutService);
147
+ ensureSideBarChatViewSize(400, viewDescriptorService, layoutService);
148
+ if (startSetup === true) {
149
+ const controller = that.controller.value;
150
+ controller.setup();
151
+ }
152
+ configurationService.updateValue('chat.commandCenter.enabled', true);
153
+ }
154
+ }
155
+ class ChatSetupHideAction extends Action2 {
156
+ static { this.ID = 'workbench.action.chat.hideSetup'; }
157
+ static { this.TITLE = ( localize2(4522, "Hide Copilot")); }
158
+ constructor() {
159
+ super({
160
+ id: ChatSetupHideAction.ID,
161
+ title: ChatSetupHideAction.TITLE,
162
+ f1: true,
163
+ category: CHAT_CATEGORY,
164
+ precondition: ( ContextKeyExpr.and(( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.has('config.chat.experimental.offerSetup')))),
165
+ menu: {
166
+ id: MenuId.ChatCommandCenter,
167
+ group: 'z_hide',
168
+ order: 1,
169
+ when: ( ChatContextKeys.Setup.installed.negate())
170
+ }
171
+ });
172
+ }
173
+ async run(accessor) {
174
+ const viewsDescriptorService = accessor.get(IViewDescriptorService);
175
+ const layoutService = accessor.get(IWorkbenchLayoutService);
176
+ const configurationService = accessor.get(IConfigurationService);
177
+ const dialogService = accessor.get(IDialogService);
178
+ const { confirmed } = await dialogService.confirm({
179
+ message: ( localize(4523, "Are you sure you want to hide Copilot?")),
180
+ detail: ( localize(
181
+ 4524,
182
+ "You can restore Copilot by running the '{0}' command.",
183
+ TRIGGER_SETUP_COMMAND_LABEL.value
184
+ )),
185
+ primaryButton: ( localize(4525, "Hide Copilot"))
186
+ });
187
+ if (!confirmed) {
188
+ return;
189
+ }
190
+ await hideSetupView(viewsDescriptorService, layoutService);
191
+ configurationService.updateValue('chat.commandCenter.enabled', false);
192
+ }
193
+ }
194
+ const windowFocusListener = this._register(( new MutableDisposable()));
195
+ class UpgradePlanAction extends Action2 {
196
+ constructor() {
197
+ super({
198
+ id: 'workbench.action.chat.upgradePlan',
199
+ title: ( localize2(4526, "Upgrade to Copilot Pro")),
200
+ category: ( localize2(4527, 'Chat')),
201
+ f1: true,
202
+ precondition: ChatContextKeys.enabled,
203
+ menu: {
204
+ id: MenuId.ChatCommandCenter,
205
+ group: 'a_first',
206
+ order: 1,
207
+ when: ( ContextKeyExpr.and(ChatContextKeys.Setup.installed, ( ContextKeyExpr.or(
208
+ ChatContextKeys.chatQuotaExceeded,
209
+ ChatContextKeys.completionsQuotaExceeded
210
+ ))))
211
+ }
212
+ });
213
+ }
214
+ async run(accessor) {
215
+ const openerService = accessor.get(IOpenerService);
216
+ const telemetryService = accessor.get(ITelemetryService);
217
+ const hostService = accessor.get(IHostService);
218
+ const commandService = accessor.get(ICommandService);
219
+ telemetryService.publicLog2('workbenchActionExecuted', { id: this.desc.id, from: 'chat' });
220
+ openerService.open(( URI.parse(defaultChat.upgradePlanUrl)));
221
+ const entitlement = that.context.state.entitlement;
222
+ if (entitlement !== ChatEntitlement.Pro) {
223
+ windowFocusListener.value = hostService.onDidChangeFocus(focus => this.onWindowFocus(focus, commandService));
224
+ }
225
+ }
226
+ async onWindowFocus(focus, commandService) {
227
+ if (focus) {
228
+ windowFocusListener.clear();
229
+ const entitlement = await that.requests.forceResolveEntitlement(undefined);
230
+ if (entitlement === ChatEntitlement.Pro) {
231
+ commandService.executeCommand('github.copilot.refreshToken');
232
+ }
233
+ }
234
+ }
235
+ }
236
+ async function hideSetupView(viewsDescriptorService, layoutService) {
237
+ const location = viewsDescriptorService.getViewLocationById(ChatViewId);
238
+ await that.context.update({ triggered: false });
239
+ if (location === ViewContainerLocation.AuxiliaryBar) {
240
+ const activeContainers = viewsDescriptorService.getViewContainersByLocation(location).filter(container => viewsDescriptorService.getViewContainerModel(container).activeViewDescriptors.length > 0);
241
+ if (activeContainers.length === 0) {
242
+ layoutService.setPartHidden(true, Parts.AUXILIARYBAR_PART);
243
+ }
244
+ }
245
+ }
246
+ registerAction2(ChatSetupTriggerAction);
247
+ registerAction2(ChatSetupHideAction);
248
+ registerAction2(UpgradePlanAction);
249
+ }
250
+ });
251
+ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
252
+ constructor(context, telemetryService, authenticationService, logService, requestService, chatQuotasService, dialogService, openerService) {
253
+ super();
254
+ this.context = context;
255
+ this.telemetryService = telemetryService;
256
+ this.authenticationService = authenticationService;
257
+ this.logService = logService;
258
+ this.requestService = requestService;
259
+ this.chatQuotasService = chatQuotasService;
260
+ this.dialogService = dialogService;
261
+ this.openerService = openerService;
262
+ this.state = { entitlement: this.context.state.entitlement };
263
+ this.pendingResolveCts = ( new CancellationTokenSource());
264
+ this.didResolveEntitlements = false;
265
+ this.registerListeners();
266
+ this.resolve();
267
+ }
268
+ registerListeners() {
269
+ this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.resolve()));
270
+ this._register(this.authenticationService.onDidChangeSessions(e => {
271
+ if (e.providerId === defaultChat.providerId) {
272
+ this.resolve();
273
+ }
274
+ }));
275
+ this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => {
276
+ if (e.id === defaultChat.providerId) {
277
+ this.resolve();
278
+ }
279
+ }));
280
+ this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => {
281
+ if (e.id === defaultChat.providerId) {
282
+ this.resolve();
283
+ }
284
+ }));
285
+ this._register(this.context.onDidChange(() => {
286
+ if (!this.context.state.installed || this.context.state.entitlement === ChatEntitlement.Unknown) {
287
+ this.state = { entitlement: this.state.entitlement, quotas: undefined };
288
+ this.chatQuotasService.clearQuotas();
289
+ }
290
+ }));
291
+ }
292
+ async resolve() {
293
+ this.pendingResolveCts.dispose(true);
294
+ const cts = this.pendingResolveCts = ( new CancellationTokenSource());
295
+ const session = await this.findMatchingProviderSession(cts.token);
296
+ if (cts.token.isCancellationRequested) {
297
+ return;
298
+ }
299
+ let state = undefined;
300
+ if (session) {
301
+ if (this.state.entitlement === ChatEntitlement.Unknown) {
302
+ state = { entitlement: ChatEntitlement.Unresolved };
303
+ }
304
+ }
305
+ else {
306
+ this.didResolveEntitlements = false;
307
+ state = { entitlement: ChatEntitlement.Unknown };
308
+ }
309
+ if (state) {
310
+ this.update(state);
311
+ }
312
+ if (session && !this.didResolveEntitlements) {
313
+ await this.resolveEntitlement(session, cts.token);
314
+ }
315
+ }
316
+ async findMatchingProviderSession(token) {
317
+ const sessions = await this.authenticationService.getSessions(defaultChat.providerId);
318
+ if (token.isCancellationRequested) {
319
+ return undefined;
320
+ }
321
+ for (const session of sessions) {
322
+ for (const scopes of defaultChat.providerScopes) {
323
+ if (this.scopesMatch(session.scopes, scopes)) {
324
+ return session;
325
+ }
326
+ }
327
+ }
328
+ return undefined;
329
+ }
330
+ scopesMatch(scopes, expectedScopes) {
331
+ return scopes.length === expectedScopes.length && expectedScopes.every(scope => scopes.includes(scope));
332
+ }
333
+ async resolveEntitlement(session, token) {
334
+ const entitlements = await this.doResolveEntitlement(session, token);
335
+ if (typeof entitlements?.entitlement === 'number' && !token.isCancellationRequested) {
336
+ this.didResolveEntitlements = true;
337
+ this.update(entitlements);
338
+ }
339
+ return entitlements?.entitlement;
340
+ }
341
+ async doResolveEntitlement(session, token) {
342
+ if (token.isCancellationRequested) {
343
+ return undefined;
344
+ }
345
+ const response = await this.request(defaultChat.entitlementUrl, 'GET', undefined, session, token);
346
+ if (token.isCancellationRequested) {
347
+ return undefined;
348
+ }
349
+ if (!response) {
350
+ this.logService.trace('[chat setup] entitlement: no response');
351
+ return { entitlement: ChatEntitlement.Unresolved };
352
+ }
353
+ if (response.res.statusCode && response.res.statusCode !== 200) {
354
+ this.logService.trace(`[chat setup] entitlement: unexpected status code ${response.res.statusCode}`);
355
+ return { entitlement: ChatEntitlement.Unresolved };
356
+ }
357
+ let responseText = null;
358
+ try {
359
+ responseText = await asText(response);
360
+ }
361
+ catch (error) {
362
+ }
363
+ if (token.isCancellationRequested) {
364
+ return undefined;
365
+ }
366
+ if (!responseText) {
367
+ this.logService.trace('[chat setup] entitlement: response has no content');
368
+ return { entitlement: ChatEntitlement.Unresolved };
369
+ }
370
+ let entitlementsResponse;
371
+ try {
372
+ entitlementsResponse = JSON.parse(responseText);
373
+ this.logService.trace(`[chat setup] entitlement: parsed result is ${JSON.stringify(entitlementsResponse)}`);
374
+ }
375
+ catch (err) {
376
+ this.logService.trace(`[chat setup] entitlement: error parsing response (${err})`);
377
+ return { entitlement: ChatEntitlement.Unresolved };
378
+ }
379
+ let entitlement;
380
+ if (entitlementsResponse.access_type_sku === 'free_limited_copilot') {
381
+ entitlement = ChatEntitlement.Limited;
382
+ }
383
+ else if (entitlementsResponse.can_signup_for_limited) {
384
+ entitlement = ChatEntitlement.Available;
385
+ }
386
+ else if (entitlementsResponse.chat_enabled) {
387
+ entitlement = ChatEntitlement.Pro;
388
+ }
389
+ else {
390
+ entitlement = ChatEntitlement.Unavailable;
391
+ }
392
+ const entitlements = {
393
+ entitlement,
394
+ quotas: {
395
+ chat: entitlementsResponse.limited_user_quotas?.chat,
396
+ completions: entitlementsResponse.limited_user_quotas?.completions,
397
+ resetDate: entitlementsResponse.limited_user_reset_date
398
+ }
399
+ };
400
+ this.logService.trace(`[chat setup] entitlement: resolved to ${entitlements.entitlement}, quotas: ${JSON.stringify(entitlements.quotas)}`);
401
+ this.telemetryService.publicLog2('chatInstallEntitlement', {
402
+ entitlement: entitlements.entitlement,
403
+ quotaChat: entitlementsResponse.limited_user_quotas?.chat,
404
+ quotaCompletions: entitlementsResponse.limited_user_quotas?.completions
405
+ });
406
+ return entitlements;
407
+ }
408
+ async request(url, type, body, session, token) {
409
+ try {
410
+ return await this.requestService.request({
411
+ type,
412
+ url,
413
+ data: type === 'POST' ? JSON.stringify(body) : undefined,
414
+ disableCache: true,
415
+ headers: {
416
+ 'Authorization': `Bearer ${session.accessToken}`
417
+ }
418
+ }, token);
419
+ }
420
+ catch (error) {
421
+ this.logService.error(`[chat setup] request: error ${error}`);
422
+ return undefined;
423
+ }
424
+ }
425
+ update(state) {
426
+ this.state = state;
427
+ this.context.update({ entitlement: this.state.entitlement });
428
+ if (state.quotas) {
429
+ this.chatQuotasService.acceptQuotas({
430
+ chatQuotaExceeded: typeof state.quotas.chat === 'number' ? state.quotas.chat <= 0 : false,
431
+ completionsQuotaExceeded: typeof state.quotas.completions === 'number' ? state.quotas.completions <= 0 : false,
432
+ quotaResetDate: state.quotas.resetDate ? ( new Date(state.quotas.resetDate)) : undefined
433
+ });
434
+ }
435
+ }
436
+ async forceResolveEntitlement(session) {
437
+ if (!session) {
438
+ session = await this.findMatchingProviderSession(CancellationToken.None);
439
+ }
440
+ if (!session) {
441
+ return undefined;
442
+ }
443
+ return this.resolveEntitlement(session, CancellationToken.None);
444
+ }
445
+ async signUpLimited(session) {
446
+ const body = {
447
+ restricted_telemetry: this.telemetryService.telemetryLevel === TelemetryLevel.NONE ? 'disabled' : 'enabled',
448
+ public_code_suggestions: 'enabled'
449
+ };
450
+ const response = await this.request(defaultChat.entitlementSignupLimitedUrl, 'POST', body, session, CancellationToken.None);
451
+ if (!response) {
452
+ this.onUnknownSignUpError('[chat setup] sign-up: no response');
453
+ return false;
454
+ }
455
+ if (response.res.statusCode && response.res.statusCode !== 200) {
456
+ if (response.res.statusCode === 422) {
457
+ try {
458
+ const responseText = await asText(response);
459
+ if (responseText) {
460
+ const responseError = JSON.parse(responseText);
461
+ if (typeof responseError.message === 'string' && responseError.message) {
462
+ this.onUnprocessableSignUpError(`[chat setup] sign-up: unprocessable entity (${responseError.message})`, responseError.message);
463
+ return false;
464
+ }
465
+ }
466
+ }
467
+ catch (error) {
468
+ }
469
+ }
470
+ this.onUnknownSignUpError(`[chat setup] sign-up: unexpected status code ${response.res.statusCode}`);
471
+ return false;
472
+ }
473
+ let responseText = null;
474
+ try {
475
+ responseText = await asText(response);
476
+ }
477
+ catch (error) {
478
+ }
479
+ if (!responseText) {
480
+ this.onUnknownSignUpError('[chat setup] sign-up: response has no content');
481
+ return false;
482
+ }
483
+ let parsedResult = undefined;
484
+ try {
485
+ parsedResult = JSON.parse(responseText);
486
+ this.logService.trace(`[chat setup] sign-up: response is ${responseText}`);
487
+ }
488
+ catch (err) {
489
+ this.onUnknownSignUpError(`[chat setup] sign-up: error parsing response (${err})`);
490
+ }
491
+ const subscribed = Boolean(parsedResult?.subscribed);
492
+ if (subscribed) {
493
+ this.logService.trace('[chat setup] sign-up: successfully subscribed');
494
+ }
495
+ else {
496
+ this.logService.error('[chat setup] sign-up: not subscribed');
497
+ }
498
+ if (subscribed) {
499
+ this.update({ entitlement: ChatEntitlement.Limited });
500
+ }
501
+ return subscribed;
502
+ }
503
+ onUnknownSignUpError(logMessage) {
504
+ this.dialogService.error(( localize(4528, "An error occurred while signing up for Copilot Free.")), ( localize(4529, "Please try again.")));
505
+ this.logService.error(logMessage);
506
+ }
507
+ onUnprocessableSignUpError(logMessage, logDetails) {
508
+ this.dialogService.prompt({
509
+ type: Severity.Error,
510
+ message: ( localize(4530, "An error occurred while signing up for Copilot Free.")),
511
+ detail: logDetails,
512
+ buttons: [
513
+ {
514
+ label: ( localize(4531, "OK")),
515
+ run: () => { }
516
+ },
517
+ {
518
+ label: ( localize(4532, "Learn More")),
519
+ run: () => this.openerService.open(( URI.parse(defaultChat.upgradePlanUrl)))
520
+ }
521
+ ],
522
+ });
523
+ this.logService.error(logMessage);
524
+ }
525
+ dispose() {
526
+ this.pendingResolveCts.dispose(true);
527
+ super.dispose();
528
+ }
529
+ };
530
+ ChatSetupRequests = ( __decorate([
531
+ ( __param(1, ITelemetryService)),
532
+ ( __param(2, IAuthenticationService)),
533
+ ( __param(3, ILogService)),
534
+ ( __param(4, IRequestService)),
535
+ ( __param(5, IChatQuotasService)),
536
+ ( __param(6, IDialogService)),
537
+ ( __param(7, IOpenerService))
538
+ ], ChatSetupRequests));
539
+ var ChatSetupStep;
540
+ (function (ChatSetupStep) {
541
+ ChatSetupStep[ChatSetupStep["Initial"] = 1] = "Initial";
542
+ ChatSetupStep[ChatSetupStep["SigningIn"] = 2] = "SigningIn";
543
+ ChatSetupStep[ChatSetupStep["Installing"] = 3] = "Installing";
544
+ })(ChatSetupStep || (ChatSetupStep = {}));
545
+ let ChatSetupController = class ChatSetupController extends Disposable {
546
+ get step() {
547
+ return this._step;
548
+ }
549
+ constructor(context, requests, telemetryService, authenticationService, viewsService, extensionsWorkbenchService, productService, logService, progressService, chatAgentService, activityService, commandService, layoutService) {
550
+ super();
551
+ this.context = context;
552
+ this.requests = requests;
553
+ this.telemetryService = telemetryService;
554
+ this.authenticationService = authenticationService;
555
+ this.viewsService = viewsService;
556
+ this.extensionsWorkbenchService = extensionsWorkbenchService;
557
+ this.productService = productService;
558
+ this.logService = logService;
559
+ this.progressService = progressService;
560
+ this.chatAgentService = chatAgentService;
561
+ this.activityService = activityService;
562
+ this.commandService = commandService;
563
+ this.layoutService = layoutService;
564
+ this._onDidChange = this._register(( new Emitter()));
565
+ this.onDidChange = this._onDidChange.event;
566
+ this._step = ChatSetupStep.Initial;
567
+ this.registerListeners();
568
+ }
569
+ registerListeners() {
570
+ this._register(this.context.onDidChange(() => this._onDidChange.fire()));
571
+ }
572
+ setStep(step) {
573
+ if (this._step === step) {
574
+ return;
575
+ }
576
+ this._step = step;
577
+ this._onDidChange.fire();
578
+ }
579
+ async setup() {
580
+ const title = ( localize(4533, "Getting Copilot ready..."));
581
+ const badge = this.activityService.showViewContainerActivity(isCopilotEditsViewActive(this.viewsService) ? CHAT_EDITING_SIDEBAR_PANEL_ID : CHAT_SIDEBAR_PANEL_ID, {
582
+ badge: ( new ProgressBadge(() => title)),
583
+ priority: 100
584
+ });
585
+ try {
586
+ await this.progressService.withProgress({
587
+ location: ProgressLocation.Window,
588
+ command: TRIGGER_SETUP_COMMAND_ID,
589
+ title,
590
+ }, () => this.doSetup());
591
+ }
592
+ finally {
593
+ badge.dispose();
594
+ }
595
+ }
596
+ async doSetup() {
597
+ this.context.suspend();
598
+ let focusChatInput = false;
599
+ try {
600
+ let session;
601
+ let entitlement;
602
+ if (this.context.state.entitlement === ChatEntitlement.Unknown) {
603
+ this.setStep(ChatSetupStep.SigningIn);
604
+ const result = await this.signIn();
605
+ if (!result.session) {
606
+ return;
607
+ }
608
+ session = result.session;
609
+ entitlement = result.entitlement;
610
+ }
611
+ if (!session) {
612
+ session = (await this.authenticationService.getSessions(defaultChat.providerId)).at(0);
613
+ if (!session) {
614
+ return;
615
+ }
616
+ }
617
+ const activeElement = getActiveElement();
618
+ this.setStep(ChatSetupStep.Installing);
619
+ await this.install(session, entitlement ?? this.context.state.entitlement);
620
+ const currentActiveElement = getActiveElement();
621
+ focusChatInput = activeElement === currentActiveElement || currentActiveElement === mainWindow.document.body;
622
+ }
623
+ finally {
624
+ this.setStep(ChatSetupStep.Initial);
625
+ this.context.resume();
626
+ }
627
+ if (focusChatInput) {
628
+ (await showCopilotView(this.viewsService, this.layoutService))?.focusInput();
629
+ }
630
+ }
631
+ async signIn() {
632
+ let session;
633
+ let entitlement;
634
+ try {
635
+ showCopilotView(this.viewsService, this.layoutService);
636
+ session = await this.authenticationService.createSession(defaultChat.providerId, defaultChat.providerScopes[0]);
637
+ entitlement = await this.requests.forceResolveEntitlement(session);
638
+ }
639
+ catch (error) {
640
+ }
641
+ if (!session) {
642
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', signedIn: false });
643
+ }
644
+ return { session, entitlement };
645
+ }
646
+ async install(session, entitlement) {
647
+ const signedIn = !!session;
648
+ let installResult = undefined;
649
+ const wasInstalled = this.context.state.installed;
650
+ let didSignUp = false;
651
+ try {
652
+ showCopilotView(this.viewsService, this.layoutService);
653
+ if (entitlement !== ChatEntitlement.Limited && entitlement !== ChatEntitlement.Pro && entitlement !== ChatEntitlement.Unavailable) {
654
+ didSignUp = await this.requests.signUpLimited(session);
655
+ if (!didSignUp) {
656
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedSignUp', signedIn });
657
+ }
658
+ }
659
+ await this.extensionsWorkbenchService.install(defaultChat.extensionId, {
660
+ enable: true,
661
+ isMachineScoped: false,
662
+ installEverywhere: true,
663
+ installPreReleaseVersion: this.productService.quality !== 'stable'
664
+ }, isCopilotEditsViewActive(this.viewsService) ? EditsViewId : ChatViewId);
665
+ installResult = 'installed';
666
+ }
667
+ catch (error) {
668
+ this.logService.error(`[chat setup] install: error ${error}`);
669
+ installResult = isCancellationError(error) ? 'cancelled' : 'failedInstall';
670
+ }
671
+ finally {
672
+ if (wasInstalled && didSignUp) {
673
+ this.commandService.executeCommand('github.copilot.refreshToken');
674
+ }
675
+ if (installResult === 'installed') {
676
+ await Promise.race([
677
+ timeout(5000),
678
+ Event.toPromise(this.chatAgentService.onDidChangeAgents)
679
+ ]);
680
+ }
681
+ }
682
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult, signedIn });
683
+ }
684
+ };
685
+ ChatSetupController = ( __decorate([
686
+ ( __param(2, ITelemetryService)),
687
+ ( __param(3, IAuthenticationService)),
688
+ ( __param(4, IViewsService)),
689
+ ( __param(5, IExtensionsWorkbenchService)),
690
+ ( __param(6, IProductService)),
691
+ ( __param(7, ILogService)),
692
+ ( __param(8, IProgressService)),
693
+ ( __param(9, IChatAgentService)),
694
+ ( __param(10, IActivityService)),
695
+ ( __param(11, ICommandService)),
696
+ ( __param(12, IWorkbenchLayoutService))
697
+ ], ChatSetupController));
698
+ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
699
+ constructor(controller, context, instantiationService, contextMenuService, commandService, telemetryService) {
700
+ super();
701
+ this.controller = controller;
702
+ this.context = context;
703
+ this.instantiationService = instantiationService;
704
+ this.contextMenuService = contextMenuService;
705
+ this.commandService = commandService;
706
+ this.telemetryService = telemetryService;
707
+ this.element = $('.chat-setup-view');
708
+ this.create();
709
+ }
710
+ create() {
711
+ const markdown = this._register(this.instantiationService.createInstance(MarkdownRenderer, {}));
712
+ {
713
+ const header = ( localize(
714
+ 4534,
715
+ "[Copilot]({0}) is your AI pair programmer.",
716
+ this.context.state.installed ? 'command:github.copilot.open.walkthrough' : defaultChat.documentationUrl
717
+ ));
718
+ this.element.appendChild($('p')).appendChild(this._register(markdown.render(( new MarkdownString(header, { isTrusted: true })))).element);
719
+ const features = this.element.appendChild($('div.chat-features-container'));
720
+ this.element.appendChild(features);
721
+ const featureChatContainer = features.appendChild($('div.chat-feature-container'));
722
+ featureChatContainer.appendChild(renderIcon(Codicon.code));
723
+ const featureChatLabel = featureChatContainer.appendChild($('span'));
724
+ featureChatLabel.textContent = ( localize(4535, "Code faster with completions and Inline Chat"));
725
+ const featureEditsContainer = features.appendChild($('div.chat-feature-container'));
726
+ featureEditsContainer.appendChild(renderIcon(Codicon.editSession));
727
+ const featureEditsLabel = featureEditsContainer.appendChild($('span'));
728
+ featureEditsLabel.textContent = ( localize(4536, "Build features and resolve bugs with Copilot Edits"));
729
+ const featureExploreContainer = features.appendChild($('div.chat-feature-container'));
730
+ featureExploreContainer.appendChild(renderIcon(Codicon.commentDiscussion));
731
+ const featureExploreLabel = featureExploreContainer.appendChild($('span'));
732
+ featureExploreLabel.textContent = ( localize(4537, "Explore your codebase with chat"));
733
+ }
734
+ const free = ( localize(
735
+ 4538,
736
+ "$(sparkle-filled) We now offer [Copilot for free]({0}).",
737
+ defaultChat.skusDocumentationUrl
738
+ ));
739
+ const freeContainer = this.element.appendChild($('p'));
740
+ freeContainer.appendChild(this._register(markdown.render(( new MarkdownString(free, { isTrusted: true, supportThemeIcons: true })))).element);
741
+ const actions = [];
742
+ if (this.context.state.installed) {
743
+ actions.push(toAction({ id: 'chatSetup.signInGh', label: ( localize(4539, "Sign in with a GitHub.com Account")), run: () => this.commandService.executeCommand('github.copilotChat.signIn') }));
744
+ actions.push(toAction({ id: 'chatSetup.signInGhe', label: ( localize(4540, "Sign in with a GHE.com Account")), run: () => this.commandService.executeCommand('github.copilotChat.signInGHE') }));
745
+ }
746
+ const buttonContainer = this.element.appendChild($('p'));
747
+ buttonContainer.classList.add('button-container');
748
+ const button = this._register(actions.length === 0 ? ( new Button(buttonContainer, {
749
+ supportIcons: true,
750
+ ...defaultButtonStyles
751
+ })) : ( new ButtonWithDropdown(buttonContainer, {
752
+ actions,
753
+ addPrimaryActionToDropdown: false,
754
+ contextMenuProvider: this.contextMenuService,
755
+ supportIcons: true,
756
+ ...defaultButtonStyles
757
+ })));
758
+ this._register(button.onDidClick(() => this.controller.setup()));
759
+ const terms = ( localize(
760
+ 4541,
761
+ "By continuing, you agree to the [Terms]({0}) and [Privacy Policy]({1}).",
762
+ defaultChat.termsStatementUrl,
763
+ defaultChat.privacyStatementUrl
764
+ ));
765
+ this.element.appendChild($('p')).appendChild(this._register(markdown.render(( new MarkdownString(terms, { isTrusted: true })))).element);
766
+ const settings = ( localize(
767
+ 4542,
768
+ "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.",
769
+ defaultChat.publicCodeMatchesUrl,
770
+ defaultChat.manageSettingsUrl
771
+ ));
772
+ const settingsContainer = this.element.appendChild($('p'));
773
+ settingsContainer.appendChild(this._register(markdown.render(( new MarkdownString(settings, { isTrusted: true })))).element);
774
+ this._register(Event.runAndSubscribe(this.controller.onDidChange, () => this.update(freeContainer, settingsContainer, button)));
775
+ }
776
+ update(freeContainer, settingsContainer, button) {
777
+ const showSettings = this.telemetryService.telemetryLevel !== TelemetryLevel.NONE;
778
+ let showFree;
779
+ let buttonLabel;
780
+ switch (this.context.state.entitlement) {
781
+ case ChatEntitlement.Unknown:
782
+ showFree = true;
783
+ buttonLabel = this.context.state.registered ? ( localize(4543, "Sign in to Use Copilot")) : ( localize(4544, "Sign in to Use Copilot for Free"));
784
+ break;
785
+ case ChatEntitlement.Unresolved:
786
+ showFree = true;
787
+ buttonLabel = this.context.state.registered ? ( localize(4545, "Use Copilot")) : ( localize(4546, "Use Copilot for Free"));
788
+ break;
789
+ case ChatEntitlement.Available:
790
+ case ChatEntitlement.Limited:
791
+ showFree = true;
792
+ buttonLabel = ( localize(4546, "Use Copilot for Free"));
793
+ break;
794
+ case ChatEntitlement.Pro:
795
+ case ChatEntitlement.Unavailable:
796
+ showFree = false;
797
+ buttonLabel = ( localize(4545, "Use Copilot"));
798
+ break;
799
+ }
800
+ switch (this.controller.step) {
801
+ case ChatSetupStep.SigningIn:
802
+ buttonLabel = ( localize(4547, "$(loading~spin) Signing in to {0}...", defaultChat.providerName));
803
+ break;
804
+ case ChatSetupStep.Installing:
805
+ buttonLabel = ( localize(4548, "$(loading~spin) Getting Copilot Ready..."));
806
+ break;
807
+ }
808
+ setVisibility(showFree, freeContainer);
809
+ setVisibility(showSettings, settingsContainer);
810
+ button.label = buttonLabel;
811
+ button.enabled = this.controller.step === ChatSetupStep.Initial;
812
+ }
813
+ };
814
+ ChatSetupWelcomeContent = ( __decorate([
815
+ ( __param(2, IInstantiationService)),
816
+ ( __param(3, IContextMenuService)),
817
+ ( __param(4, ICommandService)),
818
+ ( __param(5, ITelemetryService))
819
+ ], ChatSetupWelcomeContent));
820
+ let ChatSetupContext = class ChatSetupContext extends Disposable {
821
+ static { ChatSetupContext_1 = this; }
822
+ static { this.CHAT_SETUP_CONTEXT_STORAGE_KEY = 'chat.setupContext'; }
823
+ get state() {
824
+ return this.suspendedState ?? this._state;
825
+ }
826
+ constructor(contextKeyService, storageService, workspaceContextService, extensionService, extensionEnablementService, logService, extensionsWorkbenchService) {
827
+ super();
828
+ this.contextKeyService = contextKeyService;
829
+ this.storageService = storageService;
830
+ this.workspaceContextService = workspaceContextService;
831
+ this.extensionService = extensionService;
832
+ this.extensionEnablementService = extensionEnablementService;
833
+ this.logService = logService;
834
+ this.extensionsWorkbenchService = extensionsWorkbenchService;
835
+ this.canSignUpContextKey = ChatContextKeys.Setup.canSignUp.bindTo(this.contextKeyService);
836
+ this.signedOutContextKey = ChatContextKeys.Setup.signedOut.bindTo(this.contextKeyService);
837
+ this.limitedContextKey = ChatContextKeys.Setup.limited.bindTo(this.contextKeyService);
838
+ this.triggeredContext = ChatContextKeys.Setup.triggered.bindTo(this.contextKeyService);
839
+ this.installedContext = ChatContextKeys.Setup.installed.bindTo(this.contextKeyService);
840
+ this._state = this.storageService.getObject(ChatSetupContext_1.CHAT_SETUP_CONTEXT_STORAGE_KEY, StorageScope.PROFILE) ?? { entitlement: ChatEntitlement.Unknown };
841
+ this.suspendedState = undefined;
842
+ this._onDidChange = this._register(( new Emitter()));
843
+ this.onDidChange = this._onDidChange.event;
844
+ this.updateBarrier = undefined;
845
+ this.checkExtensionInstallation();
846
+ this.updateContextSync();
847
+ }
848
+ async checkExtensionInstallation() {
849
+ this._register(this.extensionService.onDidChangeExtensions(result => {
850
+ for (const extension of result.removed) {
851
+ if (ExtensionIdentifier.equals(defaultChat.extensionId, extension.identifier)) {
852
+ this.update({ installed: false });
853
+ break;
854
+ }
855
+ }
856
+ for (const extension of result.added) {
857
+ if (ExtensionIdentifier.equals(defaultChat.extensionId, extension.identifier)) {
858
+ this.update({ installed: true });
859
+ break;
860
+ }
861
+ }
862
+ }));
863
+ const extensions = await this.extensionsWorkbenchService.queryLocal();
864
+ const defaultChatExtension = extensions.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId));
865
+ this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) });
866
+ }
867
+ update(context) {
868
+ this.logService.trace(`[chat setup] update(): ${JSON.stringify(context)}`);
869
+ if (typeof context.installed === 'boolean') {
870
+ this._state.installed = context.installed;
871
+ if (context.installed) {
872
+ context.triggered = true;
873
+ }
874
+ }
875
+ if (typeof context.triggered === 'boolean') {
876
+ this._state.triggered = context.triggered;
877
+ }
878
+ if (typeof context.entitlement === 'number') {
879
+ this._state.entitlement = context.entitlement;
880
+ if (this._state.entitlement === ChatEntitlement.Limited || this._state.entitlement === ChatEntitlement.Pro) {
881
+ this._state.registered = true;
882
+ }
883
+ else if (this._state.entitlement === ChatEntitlement.Available) {
884
+ this._state.registered = false;
885
+ }
886
+ }
887
+ this.storageService.store(ChatSetupContext_1.CHAT_SETUP_CONTEXT_STORAGE_KEY, this._state, StorageScope.PROFILE, StorageTarget.MACHINE);
888
+ return this.updateContext();
889
+ }
890
+ async updateContext() {
891
+ await this.updateBarrier?.wait();
892
+ this.updateContextSync();
893
+ }
894
+ updateContextSync() {
895
+ this.logService.trace(`[chat setup] updateContext(): ${JSON.stringify(this._state)}`);
896
+ if (this._state.triggered && !this._state.installed) {
897
+ this.storageService.remove('chat.welcomeMessageContent.panel', StorageScope.APPLICATION);
898
+ this.storageService.remove('interactive.sessions', this.workspaceContextService.getWorkspace().folders.length ? StorageScope.WORKSPACE : StorageScope.APPLICATION);
899
+ }
900
+ this.signedOutContextKey.set(this._state.entitlement === ChatEntitlement.Unknown);
901
+ this.canSignUpContextKey.set(this._state.entitlement === ChatEntitlement.Available);
902
+ this.limitedContextKey.set(this._state.entitlement === ChatEntitlement.Limited);
903
+ this.triggeredContext.set(!!this._state.triggered);
904
+ this.installedContext.set(!!this._state.installed);
905
+ this._onDidChange.fire();
906
+ }
907
+ suspend() {
908
+ this.suspendedState = { ...this._state };
909
+ this.updateBarrier = ( new Barrier());
910
+ }
911
+ resume() {
912
+ this.suspendedState = undefined;
913
+ this.updateBarrier?.open();
914
+ this.updateBarrier = undefined;
915
+ }
916
+ };
917
+ ChatSetupContext = ChatSetupContext_1 = ( __decorate([
918
+ ( __param(0, IContextKeyService)),
919
+ ( __param(1, IStorageService)),
920
+ ( __param(2, IWorkspaceContextService)),
921
+ ( __param(3, IExtensionService)),
922
+ ( __param(4, IWorkbenchExtensionEnablementService)),
923
+ ( __param(5, ILogService)),
924
+ ( __param(6, IExtensionsWorkbenchService))
925
+ ], ChatSetupContext));
926
+ function isCopilotEditsViewActive(viewsService) {
927
+ return viewsService.getFocusedView()?.id === EditsViewId;
928
+ }
929
+ function showCopilotView(viewsService, layoutService) {
930
+ if (layoutService.activeContainer !== layoutService.mainContainer) {
931
+ layoutService.mainContainer.focus();
932
+ }
933
+ if (isCopilotEditsViewActive(viewsService)) {
934
+ return showEditsView(viewsService);
935
+ }
936
+ else {
937
+ return showChatView(viewsService);
938
+ }
939
+ }
940
+
941
+ export { SetupWelcomeViewCondition, SetupWelcomeViewKeys };