@codingame/monaco-vscode-chat-service-override 13.1.6 → 14.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 (78) hide show
  1. package/index.js +9 -9
  2. package/package.json +20 -20
  3. package/vscode/src/vs/base/common/objectCache.d.ts +13 -0
  4. package/vscode/src/vs/base/common/objectCache.js +39 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.d.ts +12 -5
  6. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +95 -23
  7. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.d.ts +10 -1
  8. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.js +81 -19
  9. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContextActions.js +144 -66
  10. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatCopyActions.js +4 -4
  11. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.js +1 -1
  12. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatFileTreeActions.js +4 -4
  13. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.d.ts +6 -3
  14. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatGettingStarted.js +17 -11
  15. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatImportExport.js +6 -6
  16. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.js +8 -7
  17. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +10 -10
  18. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.d.ts +11 -8
  19. package/vscode/src/vs/workbench/contrib/chat/browser/actions/codeBlockOperations.js +168 -167
  20. package/vscode/src/vs/workbench/contrib/chat/browser/chat.contribution.js +116 -54
  21. package/vscode/src/vs/workbench/contrib/chat/browser/chatAccessibilityService.d.ts +1 -1
  22. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.d.ts +11 -0
  23. package/vscode/src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownAnchorService.js +34 -0
  24. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.d.ts +11 -11
  25. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingService.js +105 -70
  26. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.d.ts +17 -16
  27. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingSession.js +154 -83
  28. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.d.ts +3 -3
  29. package/vscode/src/vs/workbench/contrib/chat/browser/chatEditor.js +5 -5
  30. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.d.ts +0 -4
  31. package/vscode/src/vs/workbench/contrib/chat/browser/chatParticipant.contribution.js +150 -130
  32. package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +13 -7
  33. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.d.ts +1 -1
  34. package/vscode/src/vs/workbench/contrib/chat/browser/chatQuick.js +1 -1
  35. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.d.ts +3 -3
  36. package/vscode/src/vs/workbench/contrib/chat/browser/chatResponseAccessibleView.js +1 -1
  37. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.d.ts +11 -6
  38. package/vscode/src/vs/workbench/contrib/chat/browser/chatSetup.js +449 -229
  39. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.d.ts +2 -2
  40. package/vscode/src/vs/workbench/contrib/chat/browser/chatVariables.js +2 -2
  41. package/vscode/src/vs/workbench/contrib/chat/browser/chatViewPane.js +7 -6
  42. package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockContextProviderService.d.ts +1 -1
  43. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorHover.js +2 -2
  45. package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatInputRelatedFilesContrib.js +11 -9
  46. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.d.ts +7 -1
  47. package/vscode/src/vs/workbench/contrib/chat/browser/languageModelToolsService.js +76 -13
  48. package/vscode/src/vs/workbench/contrib/chat/browser/media/chatViewSetup.css.js +1 -1
  49. package/vscode/src/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcomeHandler.js +5 -5
  50. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.d.ts +5 -18
  51. package/vscode/src/vs/workbench/contrib/chat/common/chatCodeMapperService.js +4 -122
  52. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.d.ts +3 -1
  53. package/vscode/src/vs/workbench/contrib/chat/common/chatProgressTypes/chatToolInvocation.js +5 -4
  54. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.d.ts +6 -3
  55. package/vscode/src/vs/workbench/contrib/chat/common/chatServiceImpl.js +42 -11
  56. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.d.ts +13 -0
  57. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.js +49 -0
  58. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.d.ts +14 -0
  59. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/languageFeatures/promptLinkProvider.js +69 -0
  60. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.d.ts +10 -0
  61. package/vscode/src/vs/workbench/contrib/chat/common/promptSyntax/parsers/textModelPromptParser.js +24 -0
  62. package/vscode/src/vs/workbench/contrib/chat/common/tools/languageModelToolsContribution.js +73 -17
  63. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.d.ts +11 -0
  64. package/vscode/src/vs/workbench/contrib/chat/common/tools/tools.js +22 -0
  65. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.d.ts +1 -1
  66. package/vscode/src/vs/workbench/contrib/chat/common/voiceChatService.js +2 -2
  67. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.contribution.js +9 -6
  68. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibilityHelp.d.ts +2 -2
  69. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatAccessibleView.d.ts +2 -2
  70. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.d.ts +39 -0
  71. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController2.js +314 -0
  72. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatCurrentLine.js +34 -19
  73. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.d.ts +0 -3
  74. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatClearActions.js +0 -334
  75. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.d.ts +0 -31
  76. package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +0 -46
  77. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.d.ts +0 -29
  78. package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSavingServiceImpl.js +0 -168
@@ -2,14 +2,14 @@
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
3
  import './media/chatViewSetup.css.js';
4
4
  import { getActiveElement, $, setVisibility } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
5
- import { Button, ButtonWithDropdown } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/button/button';
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
7
  import { toAction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
8
8
  import { timeout, Barrier } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
9
9
  import { CancellationTokenSource, CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
10
10
  import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
11
11
  import { isCancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
12
- import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
12
+ import { Event, Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
13
13
  import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
14
14
  import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
15
15
  import { Disposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
@@ -17,6 +17,7 @@ import { MarkdownRenderer } from '@codingame/monaco-vscode-api/vscode/vs/editor/
17
17
  import { localize2, localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
18
18
  import { Action2, MenuId, registerAction2 } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
19
19
  import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
20
+ import { ConfigurationTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration';
20
21
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
21
22
  import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
22
23
  import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
@@ -42,17 +43,16 @@ import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/wo
42
43
  import { IViewDescriptorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views.service';
43
44
  import { ProgressBadge } from '@codingame/monaco-vscode-a7c9ae3c-16d2-5d17-86b2-981be7094566-common/vscode/vs/workbench/services/activity/common/activity';
44
45
  import { IActivityService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/activity/common/activity.service';
45
- import { IAuthenticationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
46
+ import { IAuthenticationService, IAuthenticationExtensionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/authentication/common/authentication.service';
46
47
  import { IWorkbenchExtensionEnablementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionManagement.service';
47
- import { IExtensionService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensions.service';
48
- import { Parts } from '@codingame/monaco-vscode-e7080bda-ce3e-5243-9a35-98cd9634dbda-common/vscode/vs/workbench/services/layout/browser/layoutService';
48
+ import { Parts } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService';
49
49
  import { IWorkbenchLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService.service';
50
50
  import { IViewsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/views/common/viewsService.service';
51
51
  import { IExtensionsWorkbenchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/extensions/common/extensions.service';
52
52
  import { IChatAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
53
53
  import { ChatContextKeys } from '@codingame/monaco-vscode-api/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';
54
+ import { CHAT_CATEGORY } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
55
+ import { showCopilotView, ensureSideBarChatViewSize, ChatViewId, preferCopilotEditsView, EditsViewId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat';
56
56
  import { CHAT_EDITING_SIDEBAR_PANEL_ID, CHAT_SIDEBAR_PANEL_ID } from './chatViewPane.js';
57
57
  import { ChatViewsWelcomeExtensions } from '@codingame/monaco-vscode-c465110a-57c0-59d7-a6b2-be0a4db7e517-common/vscode/vs/workbench/contrib/chat/browser/viewsWelcome/chatViewsWelcome';
58
58
  import { IChatQuotasService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatQuotasService.service';
@@ -61,18 +61,34 @@ import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/
61
61
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
62
62
  import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
63
63
  import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
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';
64
75
 
65
- var ChatSetupContext_1;
76
+ var ChatSetupRequests_1, ChatSetupContext_1;
66
77
  const defaultChat = {
67
78
  extensionId: product.defaultChatAgent?.extensionId ?? '',
79
+ chatExtensionId: product.defaultChatAgent?.chatExtensionId ?? '',
68
80
  documentationUrl: product.defaultChatAgent?.documentationUrl ?? '',
69
81
  termsStatementUrl: product.defaultChatAgent?.termsStatementUrl ?? '',
70
82
  privacyStatementUrl: product.defaultChatAgent?.privacyStatementUrl ?? '',
71
83
  skusDocumentationUrl: product.defaultChatAgent?.skusDocumentationUrl ?? '',
72
84
  publicCodeMatchesUrl: product.defaultChatAgent?.publicCodeMatchesUrl ?? '',
73
85
  upgradePlanUrl: product.defaultChatAgent?.upgradePlanUrl ?? '',
74
- providerIds: [product.defaultChatAgent?.providerId ?? '', 'github-enterprise'],
86
+ providerId: product.defaultChatAgent?.providerId ?? '',
75
87
  providerName: product.defaultChatAgent?.providerName ?? '',
88
+ enterpriseProviderId: product.defaultChatAgent?.enterpriseProviderId ?? '',
89
+ enterpriseProviderName: product.defaultChatAgent?.enterpriseProviderName ?? '',
90
+ providerSetting: product.defaultChatAgent?.providerSetting ?? '',
91
+ providerUriSetting: product.defaultChatAgent?.providerUriSetting ?? '',
76
92
  providerScopes: product.defaultChatAgent?.providerScopes ?? [[]],
77
93
  entitlementUrl: product.defaultChatAgent?.entitlementUrl ?? '',
78
94
  entitlementSignupLimitedUrl: product.defaultChatAgent?.entitlementSignupLimitedUrl ?? '',
@@ -88,38 +104,42 @@ var ChatEntitlement;
88
104
  ChatEntitlement[ChatEntitlement["Pro"] = 6] = "Pro";
89
105
  })(ChatEntitlement || (ChatEntitlement = {}));
90
106
  const TRIGGER_SETUP_COMMAND_ID = 'workbench.action.chat.triggerSetup';
91
- const TRIGGER_SETUP_COMMAND_LABEL = ( localize2(4538, "Use AI Features with Copilot for Free..."));
92
- const SetupWelcomeViewKeys = ( new Set(
93
- [ChatContextKeys.Setup.triggered.key, ChatContextKeys.Setup.installed.key, ChatContextKeys.Setup.signedOut.key, ChatContextKeys.Setup.canSignUp.key]
94
- ));
95
- 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))))));
96
- (class ChatSetupContribution extends Disposable {
107
+ const TRIGGER_SETUP_COMMAND_LABEL = ( localize2(4635, "Use AI Features with Copilot for Free..."));
108
+ let ChatSetupContribution = class ChatSetupContribution extends Disposable {
97
109
  static { this.ID = 'workbench.chat.setup'; }
98
- constructor(productService, instantiationService) {
110
+ constructor(productService, instantiationService, environmentService, commandService, telemetryService, experimentService) {
99
111
  super();
100
112
  this.productService = productService;
101
113
  this.instantiationService = instantiationService;
102
- this.context = this._register(this.instantiationService.createInstance(ChatSetupContext));
103
- this.requests = this._register(this.instantiationService.createInstance(ChatSetupRequests, this.context));
104
- this.controller = ( new Lazy(
105
- () => this._register(this.instantiationService.createInstance(ChatSetupController, this.context, this.requests))
106
- ));
107
- if (!this.productService.defaultChatAgent) {
114
+ this.environmentService = environmentService;
115
+ this.commandService = commandService;
116
+ this.telemetryService = telemetryService;
117
+ this.experimentService = experimentService;
118
+ if (!this.productService.defaultChatAgent ||
119
+ (isWeb && !this.environmentService.remoteAuthority)
120
+ ) {
108
121
  return;
109
122
  }
110
- this.registerChatWelcome();
111
- this.registerActions();
123
+ const context = this._register(this.instantiationService.createInstance(ChatSetupContext));
124
+ const requests = this._register(this.instantiationService.createInstance(ChatSetupRequests, context));
125
+ const controller = ( new Lazy(
126
+ () => this._register(this.instantiationService.createInstance(ChatSetupController, context, requests))
127
+ ));
128
+ this.registerChatWelcome(controller, context);
129
+ this.registerActions(context, requests);
130
+ this.registerUrlLinkHandler();
131
+ this.registerSetting(context);
112
132
  }
113
- registerChatWelcome() {
133
+ registerChatWelcome(controller, context) {
114
134
  ( Registry.as(ChatViewsWelcomeExtensions.ChatViewsWelcomeRegistry)).register({
115
- title: ( localize(4539, "Welcome to Copilot")),
116
- when: SetupWelcomeViewCondition,
135
+ title: ( localize(4636, "Welcome to Copilot")),
136
+ when: ChatContextKeys.SetupViewCondition,
117
137
  icon: Codicon.copilotLarge,
118
- content: disposables => disposables.add(this.instantiationService.createInstance(ChatSetupWelcomeContent, this.controller.value, this.context)).element,
138
+ content: disposables => disposables.add(this.instantiationService.createInstance(ChatSetupWelcomeContent, controller.value, context)).element,
119
139
  });
120
140
  }
121
- registerActions() {
122
- const that = this;
141
+ registerActions(context, requests) {
142
+ const chatSetupTriggerContext = ( ContextKeyExpr.or(( ChatContextKeys.Setup.installed.negate()), ChatContextKeys.Setup.canSignUp));
123
143
  class ChatSetupTriggerAction extends Action2 {
124
144
  constructor() {
125
145
  super({
@@ -127,40 +147,36 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
127
147
  title: TRIGGER_SETUP_COMMAND_LABEL,
128
148
  category: CHAT_CATEGORY,
129
149
  f1: true,
130
- precondition: ( ContextKeyExpr.and(( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.has('config.chat.experimental.offerSetup')))),
150
+ precondition: chatSetupTriggerContext,
131
151
  menu: {
132
152
  id: MenuId.ChatCommandCenter,
133
153
  group: 'a_last',
134
154
  order: 1,
135
- when: ( ChatContextKeys.Setup.installed.negate())
155
+ when: chatSetupTriggerContext
136
156
  }
137
157
  });
138
158
  }
139
- async run(accessor, startSetup) {
159
+ async run(accessor) {
140
160
  const viewsService = accessor.get(IViewsService);
141
161
  const viewDescriptorService = accessor.get(IViewDescriptorService);
142
162
  const configurationService = accessor.get(IConfigurationService);
143
163
  const layoutService = accessor.get(IWorkbenchLayoutService);
144
- await that.context.update({ triggered: true });
164
+ await context.update({ hidden: false });
145
165
  showCopilotView(viewsService, layoutService);
146
- ensureSideBarChatViewSize(400, viewDescriptorService, layoutService);
147
- if (startSetup === true) {
148
- const controller = that.controller.value;
149
- controller.setup();
150
- }
166
+ ensureSideBarChatViewSize(viewDescriptorService, layoutService, viewsService);
151
167
  configurationService.updateValue('chat.commandCenter.enabled', true);
152
168
  }
153
169
  }
154
170
  class ChatSetupHideAction extends Action2 {
155
171
  static { this.ID = 'workbench.action.chat.hideSetup'; }
156
- static { this.TITLE = ( localize2(4540, "Hide Copilot")); }
172
+ static { this.TITLE = ( localize2(4637, "Hide Copilot")); }
157
173
  constructor() {
158
174
  super({
159
175
  id: ChatSetupHideAction.ID,
160
176
  title: ChatSetupHideAction.TITLE,
161
177
  f1: true,
162
178
  category: CHAT_CATEGORY,
163
- precondition: ( ContextKeyExpr.and(( ChatContextKeys.Setup.installed.negate()), ( ContextKeyExpr.has('config.chat.experimental.offerSetup')))),
179
+ precondition: ( ChatContextKeys.Setup.installed.negate()),
164
180
  menu: {
165
181
  id: MenuId.ChatCommandCenter,
166
182
  group: 'z_hide',
@@ -175,13 +191,13 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
175
191
  const configurationService = accessor.get(IConfigurationService);
176
192
  const dialogService = accessor.get(IDialogService);
177
193
  const { confirmed } = await dialogService.confirm({
178
- message: ( localize(4541, "Are you sure you want to hide Copilot?")),
194
+ message: ( localize(4638, "Are you sure you want to hide Copilot?")),
179
195
  detail: ( localize(
180
- 4542,
196
+ 4639,
181
197
  "You can restore Copilot by running the '{0}' command.",
182
198
  TRIGGER_SETUP_COMMAND_LABEL.value
183
199
  )),
184
- primaryButton: ( localize(4543, "Hide Copilot"))
200
+ primaryButton: ( localize(4640, "Hide Copilot"))
185
201
  });
186
202
  if (!confirmed) {
187
203
  return;
@@ -195,18 +211,18 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
195
211
  constructor() {
196
212
  super({
197
213
  id: 'workbench.action.chat.upgradePlan',
198
- title: ( localize2(4544, "Upgrade to Copilot Pro")),
199
- category: ( localize2(4545, 'Chat')),
214
+ title: ( localize2(4641, "Upgrade to Copilot Pro")),
215
+ category: ( localize2(4642, 'Chat')),
200
216
  f1: true,
201
- precondition: ChatContextKeys.enabled,
217
+ precondition: ( ContextKeyExpr.or(ChatContextKeys.Setup.canSignUp, ChatContextKeys.Setup.limited)),
202
218
  menu: {
203
219
  id: MenuId.ChatCommandCenter,
204
220
  group: 'a_first',
205
221
  order: 1,
206
- when: ( ContextKeyExpr.and(ChatContextKeys.Setup.installed, ( ContextKeyExpr.or(
222
+ when: ( ContextKeyExpr.or(
207
223
  ChatContextKeys.chatQuotaExceeded,
208
224
  ChatContextKeys.completionsQuotaExceeded
209
- ))))
225
+ ))
210
226
  }
211
227
  });
212
228
  }
@@ -217,7 +233,7 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
217
233
  const commandService = accessor.get(ICommandService);
218
234
  telemetryService.publicLog2('workbenchActionExecuted', { id: this.desc.id, from: 'chat' });
219
235
  openerService.open(( URI.parse(defaultChat.upgradePlanUrl)));
220
- const entitlement = that.context.state.entitlement;
236
+ const entitlement = context.state.entitlement;
221
237
  if (entitlement !== ChatEntitlement.Pro) {
222
238
  windowFocusListener.value = hostService.onDidChangeFocus(focus => this.onWindowFocus(focus, commandService));
223
239
  }
@@ -225,16 +241,16 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
225
241
  async onWindowFocus(focus, commandService) {
226
242
  if (focus) {
227
243
  windowFocusListener.clear();
228
- const entitlement = await that.requests.forceResolveEntitlement(undefined);
244
+ const entitlement = await requests.forceResolveEntitlement(undefined);
229
245
  if (entitlement === ChatEntitlement.Pro) {
230
- commandService.executeCommand('github.copilot.refreshToken');
246
+ refreshTokens(commandService);
231
247
  }
232
248
  }
233
249
  }
234
250
  }
235
251
  async function hideSetupView(viewsDescriptorService, layoutService) {
236
252
  const location = viewsDescriptorService.getViewLocationById(ChatViewId);
237
- await that.context.update({ triggered: false });
253
+ await context.update({ hidden: true });
238
254
  if (location === ViewContainerLocation.AuxiliaryBar) {
239
255
  const activeContainers = viewsDescriptorService.getViewContainersByLocation(location).filter(container => viewsDescriptorService.getViewContainerModel(container).activeViewDescriptors.length > 0);
240
256
  if (activeContainers.length === 0) {
@@ -246,8 +262,66 @@ const SetupWelcomeViewCondition = ( ContextKeyExpr.and(( ContextKeyExpr.has('con
246
262
  registerAction2(ChatSetupHideAction);
247
263
  registerAction2(UpgradePlanAction);
248
264
  }
249
- });
250
- let ChatSetupRequests = class ChatSetupRequests extends Disposable {
265
+ registerUrlLinkHandler() {
266
+ this._register(ExtensionUrlHandlerOverrideRegistry.registerHandler({
267
+ canHandleURL: url => {
268
+ return url.scheme === this.productService.urlProtocol && equalsIgnoreCase(url.authority, defaultChat.chatExtensionId);
269
+ },
270
+ handleURL: async (url) => {
271
+ const params = ( new URLSearchParams(url.query));
272
+ this.telemetryService.publicLog2('workbenchActionExecuted', { id: TRIGGER_SETUP_COMMAND_ID, from: 'url', detail: params.get('referrer') ?? undefined });
273
+ await this.commandService.executeCommand(TRIGGER_SETUP_COMMAND_ID);
274
+ return true;
275
+ }
276
+ }));
277
+ }
278
+ registerSetting(context) {
279
+ const configurationRegistry = ( Registry.as(Extensions.Configuration));
280
+ let lastNode;
281
+ const registerSetting = () => {
282
+ const treatmentId = context.state.entitlement === ChatEntitlement.Limited ?
283
+ 'chatAgentMaxRequestsFree' :
284
+ 'chatAgentMaxRequestsPro';
285
+ this.experimentService.getTreatment(treatmentId).then(value => {
286
+ const defaultValue = value ?? (context.state.entitlement === ChatEntitlement.Limited ? 5 : 15);
287
+ const node = {
288
+ id: 'chatSidebar',
289
+ title: ( localize(4643, "Chat")),
290
+ type: 'object',
291
+ properties: {
292
+ 'chat.agent.maxRequests': {
293
+ type: 'number',
294
+ description: ( localize(
295
+ 4644,
296
+ "The maximum number of requests to allow Copilot Edits to use in agent mode."
297
+ )),
298
+ default: defaultValue,
299
+ tags: ['experimental']
300
+ },
301
+ }
302
+ };
303
+ configurationRegistry.updateConfigurations({ remove: lastNode ? [lastNode] : [], add: [node] });
304
+ lastNode = node;
305
+ });
306
+ };
307
+ this._register(Event.runAndSubscribe(Event.debounce(context.onDidChange, () => { }, 1000), () => registerSetting()));
308
+ }
309
+ };
310
+ ChatSetupContribution = ( __decorate([
311
+ ( __param(0, IProductService)),
312
+ ( __param(1, IInstantiationService)),
313
+ ( __param(2, IWorkbenchEnvironmentService)),
314
+ ( __param(3, ICommandService)),
315
+ ( __param(4, ITelemetryService)),
316
+ ( __param(5, IWorkbenchAssignmentService))
317
+ ], ChatSetupContribution));
318
+ let ChatSetupRequests = ChatSetupRequests_1 = class ChatSetupRequests extends Disposable {
319
+ static providerId(configurationService) {
320
+ if (configurationService.getValue(defaultChat.providerSetting) === defaultChat.enterpriseProviderId) {
321
+ return defaultChat.enterpriseProviderId;
322
+ }
323
+ return defaultChat.providerId;
324
+ }
251
325
  constructor(context, telemetryService, authenticationService, logService, requestService, chatQuotasService, dialogService, openerService, configurationService) {
252
326
  super();
253
327
  this.context = context;
@@ -268,17 +342,17 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
268
342
  registerListeners() {
269
343
  this._register(this.authenticationService.onDidChangeDeclaredProviders(() => this.resolve()));
270
344
  this._register(this.authenticationService.onDidChangeSessions(e => {
271
- if (defaultChat.providerIds.includes(e.providerId)) {
345
+ if (e.providerId === ChatSetupRequests_1.providerId(this.configurationService)) {
272
346
  this.resolve();
273
347
  }
274
348
  }));
275
349
  this._register(this.authenticationService.onDidRegisterAuthenticationProvider(e => {
276
- if (defaultChat.providerIds.includes(e.id)) {
350
+ if (e.id === ChatSetupRequests_1.providerId(this.configurationService)) {
277
351
  this.resolve();
278
352
  }
279
353
  }));
280
354
  this._register(this.authenticationService.onDidUnregisterAuthenticationProvider(e => {
281
- if (defaultChat.providerIds.includes(e.id)) {
355
+ if (e.id === ChatSetupRequests_1.providerId(this.configurationService)) {
282
356
  this.resolve();
283
357
  }
284
358
  }));
@@ -314,21 +388,9 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
314
388
  }
315
389
  }
316
390
  async findMatchingProviderSession(token) {
317
- let sessions = [];
318
- const authProviderConfigValue = this.configurationService.getValue('github.copilot.advanced.authProvider');
319
- if (authProviderConfigValue) {
320
- sessions = await this.authenticationService.getSessions(authProviderConfigValue);
321
- }
322
- else {
323
- for (const providerId of defaultChat.providerIds) {
324
- if (token.isCancellationRequested) {
325
- return undefined;
326
- }
327
- sessions = await this.authenticationService.getSessions(providerId);
328
- if (sessions.length) {
329
- break;
330
- }
331
- }
391
+ const sessions = await this.doGetSessions(ChatSetupRequests_1.providerId(this.configurationService));
392
+ if (token.isCancellationRequested) {
393
+ return undefined;
332
394
  }
333
395
  for (const session of sessions) {
334
396
  for (const scopes of defaultChat.providerScopes) {
@@ -339,6 +401,14 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
339
401
  }
340
402
  return undefined;
341
403
  }
404
+ async doGetSessions(providerId) {
405
+ try {
406
+ return await this.authenticationService.getSessions(providerId);
407
+ }
408
+ catch (error) {
409
+ }
410
+ return [];
411
+ }
342
412
  scopesMatch(scopes, expectedScopes) {
343
413
  return scopes.length === expectedScopes.length && expectedScopes.every(scope => scopes.includes(scope));
344
414
  }
@@ -351,6 +421,10 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
351
421
  return entitlements?.entitlement;
352
422
  }
353
423
  async doResolveEntitlement(session, token) {
424
+ if (ChatSetupRequests_1.providerId(this.configurationService) === defaultChat.enterpriseProviderId) {
425
+ this.logService.trace('[chat setup] entitlement: enterprise provider, assuming Pro');
426
+ return { entitlement: ChatEntitlement.Pro };
427
+ }
354
428
  if (token.isCancellationRequested) {
355
429
  return undefined;
356
430
  }
@@ -412,8 +486,10 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
412
486
  this.logService.trace(`[chat setup] entitlement: resolved to ${entitlements.entitlement}, quotas: ${JSON.stringify(entitlements.quotas)}`);
413
487
  this.telemetryService.publicLog2('chatInstallEntitlement', {
414
488
  entitlement: entitlements.entitlement,
489
+ tid: entitlementsResponse.analytics_tracking_id,
415
490
  quotaChat: entitlementsResponse.limited_user_quotas?.chat,
416
- quotaCompletions: entitlementsResponse.limited_user_quotas?.completions
491
+ quotaCompletions: entitlementsResponse.limited_user_quotas?.completions,
492
+ quotaResetDate: entitlementsResponse.limited_user_reset_date
417
493
  });
418
494
  return entitlements;
419
495
  }
@@ -461,8 +537,8 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
461
537
  };
462
538
  const response = await this.request(defaultChat.entitlementSignupLimitedUrl, 'POST', body, session, CancellationToken.None);
463
539
  if (!response) {
464
- this.onUnknownSignUpError('[chat setup] sign-up: no response');
465
- return false;
540
+ const retry = await this.onUnknownSignUpError(( localize(4645, "No response received.")), '[chat setup] sign-up: no response');
541
+ return retry ? this.signUpLimited(session) : { errorCode: 1 };
466
542
  }
467
543
  if (response.res.statusCode && response.res.statusCode !== 200) {
468
544
  if (response.res.statusCode === 422) {
@@ -472,15 +548,15 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
472
548
  const responseError = JSON.parse(responseText);
473
549
  if (typeof responseError.message === 'string' && responseError.message) {
474
550
  this.onUnprocessableSignUpError(`[chat setup] sign-up: unprocessable entity (${responseError.message})`, responseError.message);
475
- return false;
551
+ return { errorCode: response.res.statusCode };
476
552
  }
477
553
  }
478
554
  }
479
555
  catch (error) {
480
556
  }
481
557
  }
482
- this.onUnknownSignUpError(`[chat setup] sign-up: unexpected status code ${response.res.statusCode}`);
483
- return false;
558
+ const retry = await this.onUnknownSignUpError(( localize(4646, "Unexpected status code {0}.", response.res.statusCode)), `[chat setup] sign-up: unexpected status code ${response.res.statusCode}`);
559
+ return retry ? this.signUpLimited(session) : { errorCode: response.res.statusCode };
484
560
  }
485
561
  let responseText = null;
486
562
  try {
@@ -489,8 +565,8 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
489
565
  catch (error) {
490
566
  }
491
567
  if (!responseText) {
492
- this.onUnknownSignUpError('[chat setup] sign-up: response has no content');
493
- return false;
568
+ const retry = await this.onUnknownSignUpError(( localize(4647, "Response has no contents.")), '[chat setup] sign-up: response has no content');
569
+ return retry ? this.signUpLimited(session) : { errorCode: 2 };
494
570
  }
495
571
  let parsedResult = undefined;
496
572
  try {
@@ -498,48 +574,49 @@ let ChatSetupRequests = class ChatSetupRequests extends Disposable {
498
574
  this.logService.trace(`[chat setup] sign-up: response is ${responseText}`);
499
575
  }
500
576
  catch (err) {
501
- this.onUnknownSignUpError(`[chat setup] sign-up: error parsing response (${err})`);
502
- }
503
- const subscribed = Boolean(parsedResult?.subscribed);
504
- if (subscribed) {
505
- this.logService.trace('[chat setup] sign-up: successfully subscribed');
506
- }
507
- else {
508
- this.logService.error('[chat setup] sign-up: not subscribed');
509
- }
510
- if (subscribed) {
511
- this.update({ entitlement: ChatEntitlement.Limited });
577
+ const retry = await this.onUnknownSignUpError(( localize(4648, "Invalid response contents.")), `[chat setup] sign-up: error parsing response (${err})`);
578
+ return retry ? this.signUpLimited(session) : { errorCode: 3 };
512
579
  }
513
- return subscribed;
580
+ this.update({ entitlement: ChatEntitlement.Limited });
581
+ return Boolean(parsedResult?.subscribed);
514
582
  }
515
- onUnknownSignUpError(logMessage) {
516
- this.dialogService.error(( localize(4546, "An error occurred while signing up for Copilot Free.")), ( localize(4547, "Please try again.")));
583
+ async onUnknownSignUpError(detail, logMessage) {
517
584
  this.logService.error(logMessage);
585
+ const { confirmed } = await this.dialogService.confirm({
586
+ type: Severity.Error,
587
+ message: ( localize(
588
+ 4649,
589
+ "An error occurred while signing up for Copilot Free. Would you like to try again?"
590
+ )),
591
+ detail,
592
+ primaryButton: ( localize(4650, "Retry"))
593
+ });
594
+ return confirmed;
518
595
  }
519
596
  onUnprocessableSignUpError(logMessage, logDetails) {
597
+ this.logService.error(logMessage);
520
598
  this.dialogService.prompt({
521
599
  type: Severity.Error,
522
- message: ( localize(4548, "An error occurred while signing up for Copilot Free.")),
600
+ message: ( localize(4651, "An error occurred while signing up for Copilot Free.")),
523
601
  detail: logDetails,
524
602
  buttons: [
525
603
  {
526
- label: ( localize(4549, "OK")),
604
+ label: ( localize(4652, "OK")),
527
605
  run: () => { }
528
606
  },
529
607
  {
530
- label: ( localize(4550, "Learn More")),
608
+ label: ( localize(4653, "Learn More")),
531
609
  run: () => this.openerService.open(( URI.parse(defaultChat.upgradePlanUrl)))
532
610
  }
533
- ],
611
+ ]
534
612
  });
535
- this.logService.error(logMessage);
536
613
  }
537
614
  dispose() {
538
615
  this.pendingResolveCts.dispose(true);
539
616
  super.dispose();
540
617
  }
541
618
  };
542
- ChatSetupRequests = ( __decorate([
619
+ ChatSetupRequests = ChatSetupRequests_1 = ( __decorate([
543
620
  ( __param(1, ITelemetryService)),
544
621
  ( __param(2, IAuthenticationService)),
545
622
  ( __param(3, ILogService)),
@@ -556,15 +633,14 @@ var ChatSetupStep;
556
633
  ChatSetupStep[ChatSetupStep["Installing"] = 3] = "Installing";
557
634
  })(ChatSetupStep || (ChatSetupStep = {}));
558
635
  let ChatSetupController = class ChatSetupController extends Disposable {
559
- get step() {
560
- return this._step;
561
- }
562
- constructor(context, requests, telemetryService, authenticationService, viewsService, extensionsWorkbenchService, productService, logService, progressService, chatAgentService, activityService, commandService, layoutService) {
636
+ get step() { return this._step; }
637
+ constructor(context, requests, telemetryService, authenticationService, authenticationExtensionsService, viewsService, extensionsWorkbenchService, productService, logService, progressService, chatAgentService, activityService, commandService, layoutService, workspaceTrustRequestService, dialogService, configurationService, lifecycleService) {
563
638
  super();
564
639
  this.context = context;
565
640
  this.requests = requests;
566
641
  this.telemetryService = telemetryService;
567
642
  this.authenticationService = authenticationService;
643
+ this.authenticationExtensionsService = authenticationExtensionsService;
568
644
  this.viewsService = viewsService;
569
645
  this.extensionsWorkbenchService = extensionsWorkbenchService;
570
646
  this.productService = productService;
@@ -574,13 +650,19 @@ let ChatSetupController = class ChatSetupController extends Disposable {
574
650
  this.activityService = activityService;
575
651
  this.commandService = commandService;
576
652
  this.layoutService = layoutService;
653
+ this.workspaceTrustRequestService = workspaceTrustRequestService;
654
+ this.dialogService = dialogService;
655
+ this.configurationService = configurationService;
656
+ this.lifecycleService = lifecycleService;
577
657
  this._onDidChange = this._register(( new Emitter()));
578
658
  this.onDidChange = this._onDidChange.event;
579
659
  this._step = ChatSetupStep.Initial;
660
+ this.willShutdown = false;
580
661
  this.registerListeners();
581
662
  }
582
663
  registerListeners() {
583
664
  this._register(this.context.onDidChange(() => this._onDidChange.fire()));
665
+ this._register(this.lifecycleService.onWillShutdown(() => this.willShutdown = true));
584
666
  }
585
667
  setStep(step) {
586
668
  if (this._step === step) {
@@ -589,47 +671,50 @@ let ChatSetupController = class ChatSetupController extends Disposable {
589
671
  this._step = step;
590
672
  this._onDidChange.fire();
591
673
  }
592
- async setup() {
593
- const title = ( localize(4551, "Getting Copilot ready..."));
594
- const badge = this.activityService.showViewContainerActivity(isCopilotEditsViewActive(this.viewsService) ? CHAT_EDITING_SIDEBAR_PANEL_ID : CHAT_SIDEBAR_PANEL_ID, {
674
+ async setup(options) {
675
+ const watch = ( new StopWatch(false));
676
+ const title = ( localize(4654, "Getting Copilot ready..."));
677
+ const badge = this.activityService.showViewContainerActivity(preferCopilotEditsView(this.viewsService) ? CHAT_EDITING_SIDEBAR_PANEL_ID : CHAT_SIDEBAR_PANEL_ID, {
595
678
  badge: ( new ProgressBadge(() => title)),
596
- priority: 100
597
679
  });
598
680
  try {
599
681
  await this.progressService.withProgress({
600
682
  location: ProgressLocation.Window,
601
683
  command: TRIGGER_SETUP_COMMAND_ID,
602
684
  title,
603
- }, () => this.doSetup());
685
+ }, () => this.doSetup(options?.forceSignIn ?? false, watch));
604
686
  }
605
687
  finally {
606
688
  badge.dispose();
607
689
  }
608
690
  }
609
- async doSetup() {
691
+ async doSetup(forceSignIn, watch) {
610
692
  this.context.suspend();
611
693
  let focusChatInput = false;
612
694
  try {
695
+ const providerId = ChatSetupRequests.providerId(this.configurationService);
613
696
  let session;
614
697
  let entitlement;
615
- if (this.context.state.entitlement === ChatEntitlement.Unknown) {
698
+ if (this.context.state.entitlement === ChatEntitlement.Unknown || forceSignIn) {
616
699
  this.setStep(ChatSetupStep.SigningIn);
617
- const result = await this.signIn();
700
+ const result = await this.signIn(providerId);
618
701
  if (!result.session) {
702
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', installDuration: watch.elapsed(), signUpErrorCode: undefined });
619
703
  return;
620
704
  }
621
705
  session = result.session;
622
706
  entitlement = result.entitlement;
623
707
  }
624
- if (!session) {
625
- session = (await this.authenticationService.getSessions(defaultChat.providerIds[0])).at(0);
626
- if (!session) {
627
- return;
628
- }
708
+ const trusted = await this.workspaceTrustRequestService.requestWorkspaceTrust({
709
+ message: ( localize(4655, "Copilot is currently only supported in trusted workspaces."))
710
+ });
711
+ if (!trusted) {
712
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotTrusted', installDuration: watch.elapsed(), signUpErrorCode: undefined });
713
+ return;
629
714
  }
630
715
  const activeElement = getActiveElement();
631
716
  this.setStep(ChatSetupStep.Installing);
632
- await this.install(session, entitlement ?? this.context.state.entitlement);
717
+ await this.install(session, entitlement ?? this.context.state.entitlement, providerId, watch);
633
718
  const currentActiveElement = getActiveElement();
634
719
  focusChatInput = activeElement === currentActiveElement || currentActiveElement === mainWindow.document.body;
635
720
  }
@@ -641,128 +726,183 @@ let ChatSetupController = class ChatSetupController extends Disposable {
641
726
  (await showCopilotView(this.viewsService, this.layoutService))?.focusInput();
642
727
  }
643
728
  }
644
- async signIn() {
729
+ async signIn(providerId) {
645
730
  let session;
646
731
  let entitlement;
647
732
  try {
648
733
  showCopilotView(this.viewsService, this.layoutService);
649
- session = await this.authenticationService.createSession(defaultChat.providerIds[0], defaultChat.providerScopes[0]);
734
+ session = await this.authenticationService.createSession(providerId, defaultChat.providerScopes[0]);
735
+ this.authenticationExtensionsService.updateAccountPreference(defaultChat.extensionId, providerId, session.account);
736
+ this.authenticationExtensionsService.updateAccountPreference(defaultChat.chatExtensionId, providerId, session.account);
650
737
  entitlement = await this.requests.forceResolveEntitlement(session);
651
738
  }
652
- catch (error) {
739
+ catch (e) {
740
+ this.logService.error(`[chat setup] signIn: error ${e}`);
653
741
  }
654
- if (!session) {
655
- this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNotSignedIn', signedIn: false });
742
+ if (!session && !this.willShutdown) {
743
+ const { confirmed } = await this.dialogService.confirm({
744
+ type: Severity.Error,
745
+ message: ( localize(
746
+ 4656,
747
+ "Failed to sign in to {0}. Would you like to try again?",
748
+ ChatSetupRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName
749
+ )),
750
+ detail: ( localize(4657, "You must be signed in to use Copilot.")),
751
+ primaryButton: ( localize(4650, "Retry"))
752
+ });
753
+ if (confirmed) {
754
+ return this.signIn(providerId);
755
+ }
656
756
  }
657
757
  return { session, entitlement };
658
758
  }
659
- async install(session, entitlement) {
660
- const signedIn = !!session;
661
- let installResult = undefined;
759
+ async install(session, entitlement, providerId, watch) {
662
760
  const wasInstalled = this.context.state.installed;
663
- let didSignUp = false;
761
+ let signUpResult = undefined;
664
762
  try {
665
763
  showCopilotView(this.viewsService, this.layoutService);
666
- if (entitlement !== ChatEntitlement.Limited && entitlement !== ChatEntitlement.Pro && entitlement !== ChatEntitlement.Unavailable) {
667
- didSignUp = await this.requests.signUpLimited(session);
668
- if (!didSignUp) {
669
- this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedSignUp', signedIn });
764
+ if (entitlement !== ChatEntitlement.Limited &&
765
+ entitlement !== ChatEntitlement.Pro &&
766
+ entitlement !== ChatEntitlement.Unavailable
767
+ ) {
768
+ if (!session) {
769
+ try {
770
+ session = (await this.authenticationService.getSessions(providerId)).at(0);
771
+ }
772
+ catch (error) {
773
+ }
774
+ if (!session) {
775
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedNoSession', installDuration: watch.elapsed(), signUpErrorCode: undefined });
776
+ return;
777
+ }
778
+ }
779
+ signUpResult = await this.requests.signUpLimited(session);
780
+ if (typeof signUpResult !== 'boolean' ) {
781
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'failedSignUp', installDuration: watch.elapsed(), signUpErrorCode: signUpResult.errorCode });
670
782
  }
671
783
  }
784
+ await this.doInstall();
785
+ }
786
+ catch (error) {
787
+ this.logService.error(`[chat setup] install: error ${error}`);
788
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: isCancellationError(error) ? 'cancelled' : 'failedInstall', installDuration: watch.elapsed(), signUpErrorCode: undefined });
789
+ return;
790
+ }
791
+ this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult: 'installed', installDuration: watch.elapsed(), signUpErrorCode: undefined });
792
+ if (wasInstalled && signUpResult === true) {
793
+ refreshTokens(this.commandService);
794
+ }
795
+ await Promise.race([
796
+ timeout(5000),
797
+ Event.toPromise(this.chatAgentService.onDidChangeAgents)
798
+ ]);
799
+ }
800
+ async doInstall() {
801
+ let error;
802
+ try {
672
803
  await this.extensionsWorkbenchService.install(defaultChat.extensionId, {
673
804
  enable: true,
805
+ isApplicationScoped: true,
674
806
  isMachineScoped: false,
675
807
  installEverywhere: true,
676
808
  installPreReleaseVersion: this.productService.quality !== 'stable'
677
- }, isCopilotEditsViewActive(this.viewsService) ? EditsViewId : ChatViewId);
678
- installResult = 'installed';
809
+ }, preferCopilotEditsView(this.viewsService) ? EditsViewId : ChatViewId);
679
810
  }
680
- catch (error) {
811
+ catch (e) {
681
812
  this.logService.error(`[chat setup] install: error ${error}`);
682
- installResult = isCancellationError(error) ? 'cancelled' : 'failedInstall';
813
+ error = e;
683
814
  }
684
- finally {
685
- if (wasInstalled && didSignUp) {
686
- this.commandService.executeCommand('github.copilot.refreshToken');
687
- }
688
- if (installResult === 'installed') {
689
- await Promise.race([
690
- timeout(5000),
691
- Event.toPromise(this.chatAgentService.onDidChangeAgents)
692
- ]);
815
+ if (error) {
816
+ if (!this.willShutdown) {
817
+ const { confirmed } = await this.dialogService.confirm({
818
+ type: Severity.Error,
819
+ message: ( localize(
820
+ 4658,
821
+ "An error occurred while setting up Copilot. Would you like to try again?"
822
+ )),
823
+ detail: error && !isCancellationError(error) ? toErrorMessage(error) : undefined,
824
+ primaryButton: ( localize(4650, "Retry"))
825
+ });
826
+ if (confirmed) {
827
+ return this.doInstall();
828
+ }
693
829
  }
830
+ throw error;
694
831
  }
695
- this.telemetryService.publicLog2('commandCenter.chatInstall', { installResult, signedIn });
696
832
  }
697
833
  };
698
834
  ChatSetupController = ( __decorate([
699
835
  ( __param(2, ITelemetryService)),
700
836
  ( __param(3, IAuthenticationService)),
701
- ( __param(4, IViewsService)),
702
- ( __param(5, IExtensionsWorkbenchService)),
703
- ( __param(6, IProductService)),
704
- ( __param(7, ILogService)),
705
- ( __param(8, IProgressService)),
706
- ( __param(9, IChatAgentService)),
707
- ( __param(10, IActivityService)),
708
- ( __param(11, ICommandService)),
709
- ( __param(12, IWorkbenchLayoutService))
837
+ ( __param(4, IAuthenticationExtensionsService)),
838
+ ( __param(5, IViewsService)),
839
+ ( __param(6, IExtensionsWorkbenchService)),
840
+ ( __param(7, IProductService)),
841
+ ( __param(8, ILogService)),
842
+ ( __param(9, IProgressService)),
843
+ ( __param(10, IChatAgentService)),
844
+ ( __param(11, IActivityService)),
845
+ ( __param(12, ICommandService)),
846
+ ( __param(13, IWorkbenchLayoutService)),
847
+ ( __param(14, IWorkspaceTrustRequestService)),
848
+ ( __param(15, IDialogService)),
849
+ ( __param(16, IConfigurationService)),
850
+ ( __param(17, ILifecycleService))
710
851
  ], ChatSetupController));
711
852
  let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
712
- constructor(controller, context, instantiationService, contextMenuService, commandService, telemetryService) {
853
+ constructor(controller, context, instantiationService, contextMenuService, configurationService, telemetryService, quickInputService, dialogService) {
713
854
  super();
714
855
  this.controller = controller;
715
856
  this.context = context;
716
857
  this.instantiationService = instantiationService;
717
858
  this.contextMenuService = contextMenuService;
718
- this.commandService = commandService;
859
+ this.configurationService = configurationService;
719
860
  this.telemetryService = telemetryService;
861
+ this.quickInputService = quickInputService;
862
+ this.dialogService = dialogService;
720
863
  this.element = $('.chat-setup-view');
721
864
  this.create();
722
865
  }
723
866
  create() {
724
- const markdown = this._register(this.instantiationService.createInstance(MarkdownRenderer, {}));
867
+ const markdown = this.instantiationService.createInstance(MarkdownRenderer, {});
725
868
  {
726
869
  const header = ( localize(
727
- 4552,
870
+ 4659,
728
871
  "[Copilot]({0}) is your AI pair programmer.",
729
872
  this.context.state.installed ? 'command:github.copilot.open.walkthrough' : defaultChat.documentationUrl
730
873
  ));
731
874
  this.element.appendChild($('p')).appendChild(this._register(markdown.render(( new MarkdownString(header, { isTrusted: true })))).element);
732
- const features = this.element.appendChild($('div.chat-features-container'));
733
- this.element.appendChild(features);
734
- const featureChatContainer = features.appendChild($('div.chat-feature-container'));
875
+ const featuresParent = this.element.appendChild($('div.chat-features-container'));
876
+ this.element.appendChild(featuresParent);
877
+ const featuresContainer = this.element.appendChild($('div'));
878
+ featuresParent.appendChild(featuresContainer);
879
+ const featureChatContainer = featuresContainer.appendChild($('div.chat-feature-container'));
735
880
  featureChatContainer.appendChild(renderIcon(Codicon.code));
736
881
  const featureChatLabel = featureChatContainer.appendChild($('span'));
737
- featureChatLabel.textContent = ( localize(4553, "Code faster with completions and Inline Chat"));
738
- const featureEditsContainer = features.appendChild($('div.chat-feature-container'));
882
+ featureChatLabel.textContent = ( localize(4660, "Code faster with Completions"));
883
+ const featureEditsContainer = featuresContainer.appendChild($('div.chat-feature-container'));
739
884
  featureEditsContainer.appendChild(renderIcon(Codicon.editSession));
740
885
  const featureEditsLabel = featureEditsContainer.appendChild($('span'));
741
- featureEditsLabel.textContent = ( localize(4554, "Build features and resolve bugs with Copilot Edits"));
742
- const featureExploreContainer = features.appendChild($('div.chat-feature-container'));
886
+ featureEditsLabel.textContent = ( localize(4661, "Build features with Copilot Edits"));
887
+ const featureExploreContainer = featuresContainer.appendChild($('div.chat-feature-container'));
743
888
  featureExploreContainer.appendChild(renderIcon(Codicon.commentDiscussion));
744
889
  const featureExploreLabel = featureExploreContainer.appendChild($('span'));
745
- featureExploreLabel.textContent = ( localize(4555, "Explore your codebase with chat"));
890
+ featureExploreLabel.textContent = ( localize(4662, "Explore your codebase with Chat"));
746
891
  }
747
892
  const free = ( localize(
748
- 4556,
893
+ 4663,
749
894
  "$(sparkle-filled) We now offer [Copilot for free]({0}).",
750
895
  defaultChat.skusDocumentationUrl
751
896
  ));
752
897
  const freeContainer = this.element.appendChild($('p'));
753
898
  freeContainer.appendChild(this._register(markdown.render(( new MarkdownString(free, { isTrusted: true, supportThemeIcons: true })))).element);
754
- const actions = [];
755
- if (this.context.state.installed) {
756
- actions.push(toAction({ id: 'chatSetup.signInGh', label: ( localize(4557, "Sign in with a GitHub.com Account")), run: () => this.commandService.executeCommand('github.copilotChat.signIn') }));
757
- actions.push(toAction({ id: 'chatSetup.signInGhe', label: ( localize(4558, "Sign in with a GHE.com Account")), run: () => this.commandService.executeCommand('github.copilotChat.signInGHE') }));
758
- }
759
899
  const buttonContainer = this.element.appendChild($('p'));
760
900
  buttonContainer.classList.add('button-container');
761
- const button = this._register(actions.length === 0 ? ( new Button(buttonContainer, {
762
- supportIcons: true,
763
- ...defaultButtonStyles
764
- })) : ( new ButtonWithDropdown(buttonContainer, {
765
- actions,
901
+ const button = this._register(( new ButtonWithDropdown(buttonContainer, {
902
+ actions: [
903
+ toAction({ id: 'chatSetup.setupWithProvider', label: ( localize(4664, "Sign in with a {0} Account", defaultChat.providerName)), run: () => this.setupWithProvider(false) }),
904
+ toAction({ id: 'chatSetup.setupWithEnterpriseProvider', label: ( localize(4665, "Sign in with a {0} Account", defaultChat.enterpriseProviderName)), run: () => this.setupWithProvider(true) })
905
+ ],
766
906
  addPrimaryActionToDropdown: false,
767
907
  contextMenuProvider: this.contextMenuService,
768
908
  supportIcons: true,
@@ -770,14 +910,14 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
770
910
  })));
771
911
  this._register(button.onDidClick(() => this.controller.setup()));
772
912
  const terms = ( localize(
773
- 4559,
913
+ 4666,
774
914
  "By continuing, you agree to the [Terms]({0}) and [Privacy Policy]({1}).",
775
915
  defaultChat.termsStatementUrl,
776
916
  defaultChat.privacyStatementUrl
777
917
  ));
778
918
  this.element.appendChild($('p')).appendChild(this._register(markdown.render(( new MarkdownString(terms, { isTrusted: true })))).element);
779
919
  const settings = ( localize(
780
- 4560,
920
+ 4667,
781
921
  "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.",
782
922
  defaultChat.publicCodeMatchesUrl,
783
923
  defaultChat.manageSettingsUrl
@@ -793,29 +933,33 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
793
933
  switch (this.context.state.entitlement) {
794
934
  case ChatEntitlement.Unknown:
795
935
  showFree = true;
796
- buttonLabel = this.context.state.registered ? ( localize(4561, "Sign in to Use Copilot")) : ( localize(4562, "Sign in to Use Copilot for Free"));
936
+ buttonLabel = this.context.state.registered ? ( localize(4668, "Sign in to Use Copilot")) : ( localize(4669, "Sign in to Use Copilot for Free"));
797
937
  break;
798
938
  case ChatEntitlement.Unresolved:
799
939
  showFree = true;
800
- buttonLabel = this.context.state.registered ? ( localize(4563, "Use Copilot")) : ( localize(4564, "Use Copilot for Free"));
940
+ buttonLabel = this.context.state.registered ? ( localize(4670, "Use Copilot")) : ( localize(4671, "Use Copilot for Free"));
801
941
  break;
802
942
  case ChatEntitlement.Available:
803
943
  case ChatEntitlement.Limited:
804
944
  showFree = true;
805
- buttonLabel = ( localize(4564, "Use Copilot for Free"));
945
+ buttonLabel = ( localize(4671, "Use Copilot for Free"));
806
946
  break;
807
947
  case ChatEntitlement.Pro:
808
948
  case ChatEntitlement.Unavailable:
809
949
  showFree = false;
810
- buttonLabel = ( localize(4563, "Use Copilot"));
950
+ buttonLabel = ( localize(4670, "Use Copilot"));
811
951
  break;
812
952
  }
813
953
  switch (this.controller.step) {
814
954
  case ChatSetupStep.SigningIn:
815
- buttonLabel = ( localize(4565, "$(loading~spin) Signing in to {0}...", defaultChat.providerName));
955
+ buttonLabel = ( localize(
956
+ 4672,
957
+ "$(loading~spin) Signing in to {0}...",
958
+ ChatSetupRequests.providerId(this.configurationService) === defaultChat.enterpriseProviderId ? defaultChat.enterpriseProviderName : defaultChat.providerName
959
+ ));
816
960
  break;
817
961
  case ChatSetupStep.Installing:
818
- buttonLabel = ( localize(4566, "$(loading~spin) Getting Copilot Ready..."));
962
+ buttonLabel = ( localize(4673, "$(loading~spin) Getting Copilot Ready..."));
819
963
  break;
820
964
  }
821
965
  setVisibility(showFree, freeContainer);
@@ -823,12 +967,107 @@ let ChatSetupWelcomeContent = class ChatSetupWelcomeContent extends Disposable {
823
967
  button.label = buttonLabel;
824
968
  button.enabled = this.controller.step === ChatSetupStep.Initial;
825
969
  }
970
+ async setupWithProvider(useEnterpriseProvider) {
971
+ const registry = ( Registry.as(Extensions.Configuration));
972
+ registry.registerConfiguration({
973
+ 'id': 'copilot.setup',
974
+ 'type': 'object',
975
+ 'properties': {
976
+ [defaultChat.providerSetting]: {
977
+ 'type': 'string'
978
+ },
979
+ [defaultChat.providerUriSetting]: {
980
+ 'type': 'string'
981
+ }
982
+ }
983
+ });
984
+ if (useEnterpriseProvider) {
985
+ await this.configurationService.updateValue(defaultChat.providerSetting, defaultChat.enterpriseProviderId, ConfigurationTarget.USER);
986
+ const success = await this.handleEnterpriseInstance();
987
+ if (!success) {
988
+ return;
989
+ }
990
+ }
991
+ else {
992
+ await this.configurationService.updateValue(defaultChat.providerSetting, undefined, ConfigurationTarget.USER);
993
+ await this.configurationService.updateValue(defaultChat.providerUriSetting, undefined, ConfigurationTarget.USER);
994
+ }
995
+ return this.controller.setup({ forceSignIn: true });
996
+ }
997
+ async handleEnterpriseInstance() {
998
+ const uri = this.configurationService.getValue(defaultChat.providerUriSetting);
999
+ if (uri) {
1000
+ return true;
1001
+ }
1002
+ let isSingleWord = false;
1003
+ const result = await this.quickInputService.input({
1004
+ prompt: ( localize(4674, "What is your {0} instance?", defaultChat.enterpriseProviderName)),
1005
+ placeHolder: ( localize(4675, 'i.e. "octocat" or "https://octocat.ghe.com"...')),
1006
+ validateInput: async (value) => {
1007
+ isSingleWord = false;
1008
+ if (!value) {
1009
+ return undefined;
1010
+ }
1011
+ if (/^[a-zA-Z\-_]+$/.test(value)) {
1012
+ isSingleWord = true;
1013
+ return {
1014
+ content: ( localize(4676, "Will resolve to {0}", `https://${value}.ghe.com`)),
1015
+ severity: Severity.Info
1016
+ };
1017
+ }
1018
+ else {
1019
+ const regex = /^(https:\/\/)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.ghe\.com\/?$/;
1020
+ if (!regex.test(value)) {
1021
+ return {
1022
+ content: ( localize(
1023
+ 4677,
1024
+ 'Please enter a valid {0} instance (i.e. "octocat" or "https://octocat.ghe.com")',
1025
+ defaultChat.enterpriseProviderName
1026
+ )),
1027
+ severity: Severity.Error
1028
+ };
1029
+ }
1030
+ }
1031
+ return undefined;
1032
+ }
1033
+ });
1034
+ if (!result) {
1035
+ const { confirmed } = await this.dialogService.confirm({
1036
+ type: Severity.Error,
1037
+ message: ( localize(
1038
+ 4678,
1039
+ "The provided {0} instance is invalid. Would you like to enter it again?",
1040
+ defaultChat.enterpriseProviderName
1041
+ )),
1042
+ primaryButton: ( localize(4650, "Retry"))
1043
+ });
1044
+ if (confirmed) {
1045
+ return this.handleEnterpriseInstance();
1046
+ }
1047
+ return false;
1048
+ }
1049
+ let resolvedUri = result;
1050
+ if (isSingleWord) {
1051
+ resolvedUri = `https://${resolvedUri}.ghe.com`;
1052
+ }
1053
+ else {
1054
+ const normalizedUri = result.toLowerCase();
1055
+ const hasHttps = normalizedUri.startsWith('https://');
1056
+ if (!hasHttps) {
1057
+ resolvedUri = `https://${result}`;
1058
+ }
1059
+ }
1060
+ await this.configurationService.updateValue(defaultChat.providerUriSetting, resolvedUri, ConfigurationTarget.USER);
1061
+ return true;
1062
+ }
826
1063
  };
827
1064
  ChatSetupWelcomeContent = ( __decorate([
828
1065
  ( __param(2, IInstantiationService)),
829
1066
  ( __param(3, IContextMenuService)),
830
- ( __param(4, ICommandService)),
831
- ( __param(5, ITelemetryService))
1067
+ ( __param(4, IConfigurationService)),
1068
+ ( __param(5, ITelemetryService)),
1069
+ ( __param(6, IQuickInputService)),
1070
+ ( __param(7, IDialogService))
832
1071
  ], ChatSetupWelcomeContent));
833
1072
  let ChatSetupContext = class ChatSetupContext extends Disposable {
834
1073
  static { ChatSetupContext_1 = this; }
@@ -836,19 +1075,19 @@ let ChatSetupContext = class ChatSetupContext extends Disposable {
836
1075
  get state() {
837
1076
  return this.suspendedState ?? this._state;
838
1077
  }
839
- constructor(contextKeyService, storageService, workspaceContextService, extensionService, extensionEnablementService, logService, extensionsWorkbenchService) {
1078
+ constructor(contextKeyService, storageService, workspaceContextService, extensionEnablementService, logService, extensionsWorkbenchService) {
840
1079
  super();
841
1080
  this.contextKeyService = contextKeyService;
842
1081
  this.storageService = storageService;
843
1082
  this.workspaceContextService = workspaceContextService;
844
- this.extensionService = extensionService;
845
1083
  this.extensionEnablementService = extensionEnablementService;
846
1084
  this.logService = logService;
847
1085
  this.extensionsWorkbenchService = extensionsWorkbenchService;
848
1086
  this.canSignUpContextKey = ChatContextKeys.Setup.canSignUp.bindTo(this.contextKeyService);
849
1087
  this.signedOutContextKey = ChatContextKeys.Setup.signedOut.bindTo(this.contextKeyService);
850
1088
  this.limitedContextKey = ChatContextKeys.Setup.limited.bindTo(this.contextKeyService);
851
- this.triggeredContext = ChatContextKeys.Setup.triggered.bindTo(this.contextKeyService);
1089
+ this.proContextKey = ChatContextKeys.Setup.pro.bindTo(this.contextKeyService);
1090
+ this.hiddenContext = ChatContextKeys.Setup.hidden.bindTo(this.contextKeyService);
852
1091
  this.installedContext = ChatContextKeys.Setup.installed.bindTo(this.contextKeyService);
853
1092
  this._state = this.storageService.getObject(ChatSetupContext_1.CHAT_SETUP_CONTEXT_STORAGE_KEY, StorageScope.PROFILE) ?? { entitlement: ChatEntitlement.Unknown };
854
1093
  this.suspendedState = undefined;
@@ -859,34 +1098,25 @@ let ChatSetupContext = class ChatSetupContext extends Disposable {
859
1098
  this.updateContextSync();
860
1099
  }
861
1100
  async checkExtensionInstallation() {
862
- this._register(this.extensionService.onDidChangeExtensions(result => {
863
- for (const extension of result.removed) {
864
- if (ExtensionIdentifier.equals(defaultChat.extensionId, extension.identifier)) {
865
- this.update({ installed: false });
866
- break;
867
- }
868
- }
869
- for (const extension of result.added) {
870
- if (ExtensionIdentifier.equals(defaultChat.extensionId, extension.identifier)) {
871
- this.update({ installed: true });
872
- break;
873
- }
1101
+ await this.extensionsWorkbenchService.queryLocal();
1102
+ this._register(Event.runAndSubscribe(this.extensionsWorkbenchService.onChange, e => {
1103
+ if (e && !ExtensionIdentifier.equals(e.identifier.id, defaultChat.extensionId)) {
1104
+ return;
874
1105
  }
1106
+ const defaultChatExtension = this.extensionsWorkbenchService.local.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId));
1107
+ this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) });
875
1108
  }));
876
- const extensions = await this.extensionsWorkbenchService.queryLocal();
877
- const defaultChatExtension = extensions.find(value => ExtensionIdentifier.equals(value.identifier.id, defaultChat.extensionId));
878
- this.update({ installed: !!defaultChatExtension?.local && this.extensionEnablementService.isEnabled(defaultChatExtension.local) });
879
1109
  }
880
1110
  update(context) {
881
1111
  this.logService.trace(`[chat setup] update(): ${JSON.stringify(context)}`);
882
1112
  if (typeof context.installed === 'boolean') {
883
1113
  this._state.installed = context.installed;
884
1114
  if (context.installed) {
885
- context.triggered = true;
1115
+ context.hidden = false;
886
1116
  }
887
1117
  }
888
- if (typeof context.triggered === 'boolean') {
889
- this._state.triggered = context.triggered;
1118
+ if (typeof context.hidden === 'boolean') {
1119
+ this._state.hidden = context.hidden;
890
1120
  }
891
1121
  if (typeof context.entitlement === 'number') {
892
1122
  this._state.entitlement = context.entitlement;
@@ -906,14 +1136,15 @@ let ChatSetupContext = class ChatSetupContext extends Disposable {
906
1136
  }
907
1137
  updateContextSync() {
908
1138
  this.logService.trace(`[chat setup] updateContext(): ${JSON.stringify(this._state)}`);
909
- if (this._state.triggered && !this._state.installed) {
1139
+ if (!this._state.hidden && !this._state.installed) {
910
1140
  this.storageService.remove('chat.welcomeMessageContent.panel', StorageScope.APPLICATION);
911
1141
  this.storageService.remove('interactive.sessions', this.workspaceContextService.getWorkspace().folders.length ? StorageScope.WORKSPACE : StorageScope.APPLICATION);
912
1142
  }
913
1143
  this.signedOutContextKey.set(this._state.entitlement === ChatEntitlement.Unknown);
914
1144
  this.canSignUpContextKey.set(this._state.entitlement === ChatEntitlement.Available);
915
1145
  this.limitedContextKey.set(this._state.entitlement === ChatEntitlement.Limited);
916
- this.triggeredContext.set(!!this._state.triggered);
1146
+ this.proContextKey.set(this._state.entitlement === ChatEntitlement.Pro);
1147
+ this.hiddenContext.set(!!this._state.hidden);
917
1148
  this.installedContext.set(!!this._state.installed);
918
1149
  this._onDidChange.fire();
919
1150
  }
@@ -931,24 +1162,13 @@ ChatSetupContext = ChatSetupContext_1 = ( __decorate([
931
1162
  ( __param(0, IContextKeyService)),
932
1163
  ( __param(1, IStorageService)),
933
1164
  ( __param(2, IWorkspaceContextService)),
934
- ( __param(3, IExtensionService)),
935
- ( __param(4, IWorkbenchExtensionEnablementService)),
936
- ( __param(5, ILogService)),
937
- ( __param(6, IExtensionsWorkbenchService))
1165
+ ( __param(3, IWorkbenchExtensionEnablementService)),
1166
+ ( __param(4, ILogService)),
1167
+ ( __param(5, IExtensionsWorkbenchService))
938
1168
  ], ChatSetupContext));
939
- function isCopilotEditsViewActive(viewsService) {
940
- return viewsService.getFocusedView()?.id === EditsViewId;
941
- }
942
- function showCopilotView(viewsService, layoutService) {
943
- if (layoutService.activeContainer !== layoutService.mainContainer) {
944
- layoutService.mainContainer.focus();
945
- }
946
- if (isCopilotEditsViewActive(viewsService)) {
947
- return showEditsView(viewsService);
948
- }
949
- else {
950
- return showChatView(viewsService);
951
- }
1169
+ function refreshTokens(commandService) {
1170
+ commandService.executeCommand('github.copilot.signIn');
1171
+ commandService.executeCommand('github.copilot.refreshToken');
952
1172
  }
953
1173
 
954
- export { SetupWelcomeViewCondition, SetupWelcomeViewKeys };
1174
+ export { ChatSetupContribution };