@codingame/monaco-vscode-welcome-service-override 37.1.0 → 37.3.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 (40) hide show
  1. package/common.d.ts +2 -0
  2. package/common.js +15 -0
  3. package/index.js +3 -7
  4. package/package.json +11 -3
  5. package/session.d.ts +2 -0
  6. package/session.js +10 -0
  7. package/vscode/src/vs/workbench/contrib/onboarding/browser/onboarding.contribution.js +8 -8
  8. package/vscode/src/vs/workbench/contrib/onboarding/browser/onboardingService.d.ts +1 -1
  9. package/vscode/src/vs/workbench/contrib/onboarding/browser/onboardingService.js +5 -5
  10. package/vscode/src/vs/workbench/contrib/onboarding/browser/sequence/sequencePresentation.d.ts +1 -1
  11. package/vscode/src/vs/workbench/contrib/onboarding/browser/sequence/sequencePresentation.js +2 -2
  12. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightOverlay.d.ts +2 -2
  13. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightOverlay.js +9 -9
  14. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightPresentation.d.ts +2 -2
  15. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightPresentation.js +7 -4
  16. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingPresentation.d.ts +1 -1
  17. package/vscode/src/vs/workbench/contrib/welcomeAgentSessions/browser/agentSessionsWelcome.contribution.js +5 -5
  18. package/vscode/src/vs/workbench/contrib/welcomeAgentSessions/browser/agentSessionsWelcome.d.ts +105 -0
  19. package/vscode/src/vs/workbench/contrib/welcomeAgentSessions/browser/agentSessionsWelcome.js +765 -0
  20. package/vscode/src/vs/workbench/contrib/welcomeAgentSessions/browser/media/agentSessionsWelcome.css +564 -0
  21. package/vscode/src/vs/workbench/contrib/welcomeOnboarding/browser/onboardingVariationA.js +55 -55
  22. package/vscode/src/vs/workbench/contrib/welcomeOnboarding/browser/welcomeOnboarding.contribution.js +2 -2
  23. package/vscode/src/vs/workbench/contrib/welcomeViews/common/newFile.contribution.js +10 -10
  24. package/vscode/src/vs/workbench/contrib/welcomeViews/common/viewsWelcomeContribution.js +1 -1
  25. package/vscode/src/vs/workbench/contrib/welcomeViews/common/viewsWelcomeExtensionPoint.js +8 -8
  26. package/vscode/src/vs/workbench/contrib/onboarding/browser/media/onboardingTarget.css +0 -28
  27. package/vscode/src/vs/workbench/contrib/onboarding/browser/sequence/runOnboardingStep.d.ts +0 -17
  28. package/vscode/src/vs/workbench/contrib/onboarding/browser/sequence/runOnboardingStep.js +0 -32
  29. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/onboardingTarget.d.ts +0 -37
  30. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/onboardingTarget.js +0 -29
  31. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightTypes.d.ts +0 -67
  32. package/vscode/src/vs/workbench/contrib/onboarding/browser/spotlight/spotlightTypes.js +0 -5
  33. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingRegistry.d.ts +0 -21
  34. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingRegistry.js +0 -35
  35. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingScenario.d.ts +0 -172
  36. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingScenario.js +0 -20
  37. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingScenarioService.d.ts +0 -48
  38. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingScenarioService.js +0 -11
  39. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingSequence.d.ts +0 -45
  40. package/vscode/src/vs/workbench/contrib/onboarding/common/onboardingSequence.js +0 -29
@@ -0,0 +1,765 @@
1
+
2
+ import { registerCss } from '@codingame/monaco-vscode-api/css';
3
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
+ import * as agentSessionsWelcome from './media/agentSessionsWelcome.css';
5
+ import { $, clearNode, append, createTextNode, getWindow, scheduleAtNextAnimationFrame, addDisposableListener } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
6
+ import { renderIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/iconLabel/iconLabels';
7
+ import { DomScrollableElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
8
+ import { Toggle } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/toggle/toggle';
9
+ import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
10
+ import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
11
+ import { DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
12
+ import { MarshalledId } from '@codingame/monaco-vscode-api/vscode/vs/base/common/marshallingIds';
13
+ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
14
+ import { ScrollbarVisibility } from '@codingame/monaco-vscode-api/vscode/vs/base/common/scrollable';
15
+ import { basename } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
16
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
17
+ import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
18
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
19
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
20
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
21
+ import { ServiceCollection } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/serviceCollection';
22
+ import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
23
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
24
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
25
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
26
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colorUtils';
27
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/baseColors';
28
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/chartsColors';
29
+ import { editorBackground } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/editorColors';
30
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/inputColors';
31
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/listColors';
32
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/menuColors';
33
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/minimapColors';
34
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/miscColors';
35
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quickpickColors';
36
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
37
+ import { getListStyles, getToggleStyles } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/browser/defaultStyles';
38
+ import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
39
+ import { EditorPane } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/parts/editor/editorPane';
40
+ import { SIDE_BAR_FOREGROUND } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/theme';
41
+ import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
42
+ import { IWorkbenchLayoutService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/layout/browser/layoutService.service';
43
+ import { ChatAgentLocation, ChatModeKind, ChatConfiguration } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
44
+ import { ChatContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/actions/chatContextKeys';
45
+ import { ChatWidget } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/widget/chatWidget';
46
+ import { ACTION_ID_NEW_CHAT } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/actions/chatActions';
47
+ import { IAgentSessionsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsService.service';
48
+ import { AgentSessionProviders } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessions';
49
+ import { agentSessionsWelcomeCommandId, AgentSessionsWelcomeInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/welcomeAgentSessions/browser/agentSessionsWelcomeInput';
50
+ import { IChatService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/chatService/chatService.service';
51
+ import { ChatViewId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat';
52
+ import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
53
+ import { getResourceForNewChatSession, ChatSessionPosition } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution';
54
+ import { IChatEntitlementService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service';
55
+ import { AgentSessionsControl } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsControl';
56
+ import { AgentSessionsFilter } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsFilter';
57
+ import { AgentSessionsListDelegate } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsViewer';
58
+ import { HoverPosition } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hoverWidget';
59
+ import { IWalkthroughsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.service';
60
+ import { GettingStartedInput } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedInput';
61
+ import { IMarkdownRendererService } from '@codingame/monaco-vscode-api/vscode/vs/platform/markdown/browser/markdownRenderer.service';
62
+ import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
63
+ import { WorkbenchState } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace';
64
+ import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
65
+ import { isRecentFolder, isRecentWorkspace } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspaces/common/workspaces';
66
+ import { IWorkspacesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspaces/common/workspaces.service';
67
+ import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
68
+ import { IWorkspaceTrustManagementService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspaceTrust.service';
69
+ import { ViewContainerLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views';
70
+ import { IViewDescriptorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/views.service';
71
+ import { toErrorMessage } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errorMessage';
72
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
73
+ import { canShowAgentsBanner, createAgentsBanner } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/agentSessions/agentSessionsBanner';
74
+
75
+ var AgentSessionsWelcomePage_1;
76
+ registerCss(agentSessionsWelcome, 1);
77
+ const configurationKey = "workbench.startupEditor";
78
+ const MAX_SESSIONS = 6;
79
+ const MAX_REPO_PICKS = 10;
80
+ const MAX_WALKTHROUGHS = 10;
81
+ const WELCOME_CHAT_INPUT_LAYOUT_HEIGHT = 150;
82
+ const WELCOME_CHAT_INPUT_RESERVED_LIST_HEIGHT = 50;
83
+ const WELCOME_CHAT_INPUT_RESERVED_CHROME_HEIGHT = 72;
84
+ const WELCOME_COMPACT_HEIGHT = 800;
85
+ const WELCOME_CHAT_INPUT_MAX_HEIGHT_OVERRIDE = WELCOME_CHAT_INPUT_LAYOUT_HEIGHT + WELCOME_CHAT_INPUT_RESERVED_LIST_HEIGHT + WELCOME_CHAT_INPUT_RESERVED_CHROME_HEIGHT;
86
+ let AgentSessionsWelcomePage = class AgentSessionsWelcomePage extends EditorPane {
87
+ static {
88
+ AgentSessionsWelcomePage_1 = this;
89
+ }
90
+ static {
91
+ this.ID = "agentSessionsWelcomePage";
92
+ }
93
+ static {
94
+ this.COMMAND_ID = agentSessionsWelcomeCommandId;
95
+ }
96
+ constructor(
97
+ group,
98
+ telemetryService,
99
+ themeService,
100
+ storageService,
101
+ instantiationService,
102
+ contextKeyService,
103
+ layoutService,
104
+ commandService,
105
+ editorService,
106
+ agentSessionsService,
107
+ configurationService,
108
+ productService,
109
+ walkthroughsService,
110
+ chatService,
111
+ chatEntitlementService,
112
+ markdownRendererService,
113
+ workspaceContextService,
114
+ workspacesService,
115
+ hostService,
116
+ workspaceTrustManagementService,
117
+ viewDescriptorService,
118
+ chatWidgetService,
119
+ logService
120
+ ) {
121
+ super(
122
+ AgentSessionsWelcomePage_1.ID,
123
+ group,
124
+ telemetryService,
125
+ themeService,
126
+ storageService
127
+ );
128
+ this.storageService = storageService;
129
+ this.instantiationService = instantiationService;
130
+ this.layoutService = layoutService;
131
+ this.commandService = commandService;
132
+ this.editorService = editorService;
133
+ this.agentSessionsService = agentSessionsService;
134
+ this.configurationService = configurationService;
135
+ this.productService = productService;
136
+ this.walkthroughsService = walkthroughsService;
137
+ this.chatService = chatService;
138
+ this.chatEntitlementService = chatEntitlementService;
139
+ this.markdownRendererService = markdownRendererService;
140
+ this.workspaceContextService = workspaceContextService;
141
+ this.workspacesService = workspacesService;
142
+ this.hostService = hostService;
143
+ this.workspaceTrustManagementService = workspaceTrustManagementService;
144
+ this.viewDescriptorService = viewDescriptorService;
145
+ this.chatWidgetService = chatWidgetService;
146
+ this.logService = logService;
147
+ this.sessionsControlDisposables = this._register(( new DisposableStore()));
148
+ this.contentDisposables = this._register(( new DisposableStore()));
149
+ this.walkthroughs = [];
150
+ this._selectedSessionProvider = AgentSessionProviders.Local;
151
+ this._recentTrustedWorkspaces = [];
152
+ this._isEmptyWorkspace = false;
153
+ this._workspaceKind = "empty";
154
+ this._openedAt = 0;
155
+ this.container = $(".agentSessionsWelcome", {
156
+ role: "document",
157
+ tabindex: 0,
158
+ "aria-label": ( localize(20898, "Overview of agent sessions and how to get started."))
159
+ });
160
+ this.contextService = this._register(contextKeyService.createScoped(this.container));
161
+ ChatContextKeys.inAgentSessionsWelcome.bindTo(this.contextService).set(true);
162
+ this._register(this.chatEntitlementService.onDidChangeSentiment(() => {
163
+ const input = this.input || this._storedInput;
164
+ if (this.chatEntitlementService.sentiment.hidden && input) {
165
+ this._closedBy = "chatHidden";
166
+ this.group.closeEditor(input);
167
+ }
168
+ }));
169
+ }
170
+ createEditor(parent) {
171
+ parent.appendChild(this.container);
172
+ this.contentContainer = $(".agentSessionsWelcome-content");
173
+ this.scrollableElement = this._register(( new DomScrollableElement(this.contentContainer, {
174
+ className: "agentSessionsWelcome-scrollable",
175
+ vertical: ScrollbarVisibility.Auto
176
+ })));
177
+ this.container.appendChild(this.scrollableElement.getDomNode());
178
+ }
179
+ async setInput(input, options, context, token) {
180
+ this._storedInput = input;
181
+ this._openedAt = Date.now();
182
+ await super.setInput(input, options, context, token);
183
+ this._workspaceKind = input.workspaceKind ?? "empty";
184
+ await this.buildContent();
185
+ }
186
+ clearInput() {
187
+ if (this._openedAt > 0) {
188
+ const visibleDurationMs = Date.now() - this._openedAt;
189
+ this.telemetryService.publicLog2("agentSessionsWelcome.closed", {
190
+ visibleDurationMs,
191
+ closedBy: this._closedBy ?? "disposed"
192
+ });
193
+ this._openedAt = 0;
194
+ this._closedBy = undefined;
195
+ }
196
+ super.clearInput();
197
+ }
198
+ async buildContent() {
199
+ this.contentDisposables.clear();
200
+ this.sessionsControlDisposables.clear();
201
+ this.sessionsControl = undefined;
202
+ clearNode(this.contentContainer);
203
+ this._isEmptyWorkspace = this.workspaceContextService.getWorkbenchState() === WorkbenchState.EMPTY;
204
+ if (this._isEmptyWorkspace) {
205
+ const recentlyOpened = await this.getRecentlyOpenedWorkspaces(true);
206
+ this._recentTrustedWorkspaces = recentlyOpened.slice(0, MAX_REPO_PICKS);
207
+ }
208
+ this.walkthroughs = this.walkthroughsService.getWalkthroughs();
209
+ const header = append(this.contentContainer, $(".agentSessionsWelcome-header"));
210
+ append(header, $("h1.product-name", {}, this.productService.nameLong));
211
+ const startEntries = append(header, $(".agentSessionsWelcome-startEntries"));
212
+ await this.buildStartEntries(startEntries);
213
+ const chatSection = append(this.contentContainer, $(".agentSessionsWelcome-chatSection"));
214
+ this.buildChatWidget(chatSection);
215
+ const sessionsSection = append(this.contentContainer, $(".agentSessionsWelcome-sessionsSection"));
216
+ this.buildSessionsOrPrompts(sessionsSection);
217
+ const footer = append(this.contentContainer, $(".agentSessionsWelcome-footer"));
218
+ this.buildFooter(footer);
219
+ let originalSessions = this.agentSessionsService.model.sessions.length > 0;
220
+ this.contentDisposables.add(this.agentSessionsService.model.onDidChangeSessions(() => {
221
+ const hasSessions = this.agentSessionsService.model.sessions.length > 0;
222
+ if (hasSessions !== originalSessions) {
223
+ originalSessions = hasSessions;
224
+ clearNode(sessionsSection);
225
+ this.buildSessionsOrPrompts(sessionsSection);
226
+ }
227
+ this.layoutSessionsControl();
228
+ }));
229
+ this.scrollableElement?.scanDomNode();
230
+ }
231
+ async buildStartEntries(container) {
232
+ const workspaces = await this.getRecentlyOpenedWorkspaces(false);
233
+ const openEntry = workspaces.length > 0 ? {
234
+ icon: Codicon.folderOpened,
235
+ label: ( localize(20899, "Open Recent...")),
236
+ command: "workbench.action.openRecent"
237
+ } : {
238
+ icon: Codicon.folderOpened,
239
+ label: ( localize(20900, "Open Folder...")),
240
+ command: "workbench.action.files.openFolder"
241
+ };
242
+ const entries = [openEntry, {
243
+ icon: Codicon.newFile,
244
+ label: ( localize(20901, "New file...")),
245
+ command: "welcome.showNewFileEntries"
246
+ }, {
247
+ icon: Codicon.repoClone,
248
+ label: ( localize(20902, "Clone Git Repository...")),
249
+ command: "git.clone"
250
+ }];
251
+ for (const entry of entries) {
252
+ const button = append(container, $("button.agentSessionsWelcome-startEntry"));
253
+ button.appendChild(renderIcon(entry.icon));
254
+ button.appendChild(createTextNode(entry.label));
255
+ button.onclick = () => {
256
+ this.telemetryService.publicLog2("agentSessionsWelcome.ActionExecuted", {
257
+ welcomeKind: "agentSessionsWelcomePage",
258
+ action: "executeCommand",
259
+ actionId: entry.command
260
+ });
261
+ this.commandService.executeCommand(entry.command);
262
+ };
263
+ }
264
+ }
265
+ buildChatWidget(container) {
266
+ const chatWidgetContainer = append(container, $(".agentSessionsWelcome-chatWidget"));
267
+ const editorOverflowWidgetsDomNode = this.layoutService.getContainer(getWindow(chatWidgetContainer)).appendChild($(".chat-editor-overflow.monaco-editor"));
268
+ this.contentDisposables.add(toDisposable(() => editorOverflowWidgetsDomNode.remove()));
269
+ const scopedContextKeyService = this.contentDisposables.add(this.contextService.createScoped(chatWidgetContainer));
270
+ const scopedInstantiationService = this.contentDisposables.add(this.instantiationService.createChild(( new ServiceCollection([IContextKeyService, scopedContextKeyService]))));
271
+ const onDidChangeActiveSessionProvider = this.contentDisposables.add(( new Emitter()));
272
+ const recreateSessionForProvider = async provider => {
273
+ if (this.chatWidget && this.chatModelRef) {
274
+ this.chatWidget.setModel(undefined);
275
+ this.chatModelRef.dispose();
276
+ const newResource = getResourceForNewChatSession({
277
+ type: provider,
278
+ position: ChatSessionPosition.Sidebar});
279
+ const ref = await this.chatService.acquireOrLoadSession(newResource, ChatAgentLocation.Chat, CancellationToken.None);
280
+ this.chatModelRef = ref ?? this.chatService.startNewLocalSession(ChatAgentLocation.Chat);
281
+ this.contentDisposables.add(this.chatModelRef);
282
+ if (this.chatModelRef.object) {
283
+ this.chatWidget.setModel(this.chatModelRef.object);
284
+ }
285
+ }
286
+ };
287
+ const sessionTypePickerDelegate = {
288
+ getActiveSessionProvider: () => this._selectedSessionProvider,
289
+ setActiveSessionProvider: provider => {
290
+ this._selectedSessionProvider = provider;
291
+ onDidChangeActiveSessionProvider.fire(provider);
292
+ try {
293
+ recreateSessionForProvider(provider);
294
+ } catch {}
295
+ },
296
+ onDidChangeActiveSessionProvider: onDidChangeActiveSessionProvider.event
297
+ };
298
+ const onDidChangeSelectedWorkspace = this.contentDisposables.add(( new Emitter()));
299
+ const onDidChangeWorkspaces = this.contentDisposables.add(( new Emitter()));
300
+ const workspacePickerDelegate = this._isEmptyWorkspace ? {
301
+ getWorkspaces: () => this._recentTrustedWorkspaces.map(w => ({
302
+ uri: this.getWorkspaceUri(w),
303
+ label: this.getWorkspaceLabel(w),
304
+ isFolder: isRecentFolder(w)
305
+ })),
306
+ getSelectedWorkspace: () => this._selectedWorkspace,
307
+ setSelectedWorkspace: workspace => {
308
+ this._selectedWorkspace = workspace;
309
+ onDidChangeSelectedWorkspace.fire(workspace);
310
+ },
311
+ onDidChangeSelectedWorkspace: onDidChangeSelectedWorkspace.event,
312
+ onDidChangeWorkspaces: onDidChangeWorkspaces.event,
313
+ openFolderCommand: "workbench.action.files.openFolder"
314
+ } : undefined;
315
+ this.chatWidget = this.contentDisposables.add(scopedInstantiationService.createInstance(
316
+ ChatWidget,
317
+ ChatAgentLocation.Chat,
318
+ {},
319
+ {
320
+ autoScroll: mode => mode !== ChatModeKind.Ask,
321
+ renderFollowups: false,
322
+ supportsFileReferences: true,
323
+ renderInputOnTop: true,
324
+ rendererOptions: {
325
+ renderTextEditsAsSummary: () => true,
326
+ referencesExpandedWhenEmptyResponse: false,
327
+ progressMessageAtBottomOfResponse: mode => mode !== ChatModeKind.Ask
328
+ },
329
+ editorOverflowWidgetsDomNode,
330
+ enableImplicitContext: true,
331
+ enableWorkingSet: "explicit",
332
+ supportsChangingModes: true,
333
+ sessionTypePickerDelegate,
334
+ workspacePickerDelegate,
335
+ submitHandler: this._isEmptyWorkspace ? (query, mode) => this.handleWorkspaceSubmission(query, mode) : undefined
336
+ },
337
+ {
338
+ listForeground: SIDE_BAR_FOREGROUND,
339
+ listBackground: editorBackground,
340
+ overlayBackground: editorBackground,
341
+ inputEditorBackground: editorBackground,
342
+ resultEditorBackground: editorBackground
343
+ }
344
+ ));
345
+ this.chatWidget.render(chatWidgetContainer);
346
+ this.chatWidget.setVisible(true);
347
+ this.contentDisposables.add(scheduleAtNextAnimationFrame(getWindow(chatWidgetContainer), () => {
348
+ this.layoutChatWidget();
349
+ }));
350
+ this.chatModelRef = this.chatService.startNewLocalSession(ChatAgentLocation.Chat);
351
+ this.contentDisposables.add(this.chatModelRef);
352
+ if (this.chatModelRef.object) {
353
+ this.chatWidget.setModel(this.chatModelRef.object);
354
+ }
355
+ this.contentDisposables.add(addDisposableListener(chatWidgetContainer, "mousedown", () => {
356
+ this.chatWidget?.focusInput();
357
+ }));
358
+ this.contentDisposables.add(this.chatService.onDidSubmitRequest((
359
+ {
360
+ chatSessionResource
361
+ }
362
+ ) => {
363
+ if (this.chatModelRef?.object?.sessionResource.toString() === ( chatSessionResource.toString())) {
364
+ const mode = this.chatWidget?.input.currentModeObs.get().name.get() || "unknown";
365
+ this.telemetryService.publicLog2("agentSessionsWelcome.chatSubmitted", {
366
+ mode,
367
+ provider: this._selectedSessionProvider,
368
+ workspaceKind: this._workspaceKind,
369
+ selectedRecentWorkspace: this._selectedWorkspace !== undefined
370
+ });
371
+ this._closedBy = "chatSubmission";
372
+ this.openSessionInChat(chatSessionResource);
373
+ }
374
+ }));
375
+ this.applyPrefillData();
376
+ }
377
+ getWorkspaceLabel(workspace) {
378
+ if (isRecentFolder(workspace)) {
379
+ return workspace.label || basename(workspace.folderUri);
380
+ } else if (isRecentWorkspace(workspace)) {
381
+ return workspace.label || basename(workspace.workspace.configPath);
382
+ }
383
+ return "";
384
+ }
385
+ getWorkspaceUri(workspace) {
386
+ if (isRecentFolder(workspace)) {
387
+ return workspace.folderUri;
388
+ } else if (isRecentWorkspace(workspace)) {
389
+ return workspace.workspace.configPath;
390
+ }
391
+ throw ( new Error("Invalid workspace type"));
392
+ }
393
+ async handleWorkspaceSubmission(query, mode) {
394
+ if (!this._selectedWorkspace) {
395
+ return false;
396
+ }
397
+ if (!query.trim()) {
398
+ return false;
399
+ }
400
+ const prefillData = {
401
+ query,
402
+ mode,
403
+ timestamp: Date.now()
404
+ };
405
+ this.storageService.store(
406
+ "chat.welcomeViewPrefill",
407
+ JSON.stringify(prefillData),
408
+ StorageScope.APPLICATION,
409
+ StorageTarget.MACHINE
410
+ );
411
+ const workspace = this._recentTrustedWorkspaces.find(w => ( this.getWorkspaceUri(w).toString()) === this._selectedWorkspace?.uri.toString());
412
+ if (workspace) {
413
+ try {
414
+ if (isRecentFolder(workspace)) {
415
+ await this.hostService.openWindow([{
416
+ folderUri: workspace.folderUri
417
+ }]);
418
+ } else if (isRecentWorkspace(workspace)) {
419
+ await this.hostService.openWindow([{
420
+ workspaceUri: workspace.workspace.configPath
421
+ }]);
422
+ }
423
+ return true;
424
+ } catch (e) {}
425
+ }
426
+ this.storageService.remove("chat.welcomeViewPrefill", StorageScope.APPLICATION);
427
+ return false;
428
+ }
429
+ applyPrefillData() {
430
+ const prefillData = this.storageService.get("chat.welcomeViewPrefill", StorageScope.APPLICATION);
431
+ if (prefillData) {
432
+ this.storageService.remove("chat.welcomeViewPrefill", StorageScope.APPLICATION);
433
+ try {
434
+ const {
435
+ query,
436
+ mode,
437
+ timestamp
438
+ } = JSON.parse(prefillData);
439
+ if (timestamp && Date.now() - timestamp > 60 * 1000) {
440
+ return;
441
+ }
442
+ if (query && this.chatWidget) {
443
+ this.chatWidget.setInput(query);
444
+ }
445
+ if (mode !== undefined && this.chatWidget) {
446
+ this.chatWidget.input.setChatMode(mode, false);
447
+ }
448
+ this.chatWidget?.focusInput();
449
+ } catch {}
450
+ }
451
+ }
452
+ buildSessionsOrPrompts(container) {
453
+ this.sessionsControlDisposables.clear();
454
+ this.sessionsControl = undefined;
455
+ const sessions = this.agentSessionsService.model.sessions.filter(s => !s.isArchived());
456
+ if (sessions.length > 0) {
457
+ this.buildSessionsGrid(container, sessions);
458
+ } else {
459
+ this.buildWalkthroughs(container);
460
+ }
461
+ }
462
+ buildSessionsGrid(container, _sessions) {
463
+ this.sessionsControlContainer = append(container, $(".agentSessionsWelcome-sessionsGrid"));
464
+ const options = {
465
+ overrideStyles: getListStyles({
466
+ listBackground: editorBackground
467
+ }),
468
+ filter: this.sessionsControlDisposables.add(this.instantiationService.createInstance(AgentSessionsFilter, {
469
+ limitResults: () => MAX_SESSIONS,
470
+ overrideExclude: session => session.isArchived() ? true : undefined
471
+ })),
472
+ createNewChat: () => this.commandService.executeCommand(ACTION_ID_NEW_CHAT, this.chatWidget?.viewModel ? {
473
+ $mid: MarshalledId.ChatViewContext,
474
+ sessionResource: this.chatWidget.viewModel.sessionResource
475
+ } : undefined),
476
+ getHoverPosition: () => HoverPosition.BELOW,
477
+ trackActiveEditorSession: () => false,
478
+ source: "welcomeView",
479
+ itemHeight: AgentSessionsListDelegate.ITEM_HEIGHT,
480
+ sectionHeight: AgentSessionsListDelegate.SECTION_HEIGHT,
481
+ notifySessionOpened: () => {
482
+ const isProjectionEnabled = this.configurationService.getValue(ChatConfiguration.AgentSessionProjectionEnabled);
483
+ if (!isProjectionEnabled) {
484
+ this._closedBy = "sessionClicked";
485
+ this.revealMaximizedChat();
486
+ }
487
+ }
488
+ };
489
+ this.sessionsControl = this.sessionsControlDisposables.add(
490
+ this.instantiationService.createInstance(AgentSessionsControl, this.sessionsControlContainer, options)
491
+ );
492
+ this.sessionsControlDisposables.add(this.agentSessionsService.model.onDidResolve(() => {
493
+ this.layoutSessionsControl();
494
+ }));
495
+ if (this.agentSessionsService.model.resolved) {
496
+ this.layoutSessionsControl();
497
+ }
498
+ this.sessionsControlDisposables.add(
499
+ scheduleAtNextAnimationFrame(getWindow(this.sessionsControlContainer), () => {
500
+ this.layoutSessionsControl();
501
+ })
502
+ );
503
+ if (canShowAgentsBanner(this.chatEntitlementService)) {
504
+ const agentsBanner = createAgentsBanner({
505
+ cssClass: "agentSessionsWelcome-agentsBanner",
506
+ source: "agentSessionsWelcome",
507
+ label: ( localize(20903, "View All Sessions")),
508
+ onButtonClick: () => {
509
+ this._closedBy = "viewAllSessions";
510
+ }
511
+ }, this.commandService, this.telemetryService);
512
+ this.sessionsControlDisposables.add(agentsBanner.disposables);
513
+ append(container, agentsBanner.element);
514
+ }
515
+ }
516
+ buildWalkthroughs(container) {
517
+ const activeWalkthroughs = this.walkthroughs.filter(w => !w.when || this.contextService.contextMatchesRules(w.when)).slice(0, MAX_WALKTHROUGHS);
518
+ if (activeWalkthroughs.length === 0) {
519
+ return;
520
+ }
521
+ let currentIndex = 0;
522
+ const card = append(container, $(".agentSessionsWelcome-walkthroughCard"));
523
+ const iconContainer = append(card, $(".agentSessionsWelcome-walkthroughCard-icon"));
524
+ const content = append(card, $(".agentSessionsWelcome-walkthroughCard-content"));
525
+ const title = append(content, $(".agentSessionsWelcome-walkthroughCard-title"));
526
+ const desc = append(content, $(".agentSessionsWelcome-walkthroughCard-description"));
527
+ const navContainer = append(card, $(".agentSessionsWelcome-walkthroughCard-nav"));
528
+ const prevButton = append(navContainer, $("button.nav-button"));
529
+ prevButton.appendChild(renderIcon(Codicon.chevronLeft));
530
+ prevButton.title = ( localize(20904, "Previous"));
531
+ const nextButton = append(navContainer, $("button.nav-button"));
532
+ nextButton.appendChild(renderIcon(Codicon.chevronRight));
533
+ nextButton.title = ( localize(20905, "Next"));
534
+ const updateContent = () => {
535
+ const walkthrough = activeWalkthroughs[currentIndex];
536
+ clearNode(iconContainer);
537
+ if (walkthrough.icon.type === "icon") {
538
+ iconContainer.appendChild(renderIcon(walkthrough.icon.icon));
539
+ }
540
+ title.textContent = walkthrough.title;
541
+ desc.textContent = walkthrough.description || "";
542
+ prevButton.disabled = currentIndex === 0;
543
+ nextButton.disabled = currentIndex === activeWalkthroughs.length - 1;
544
+ };
545
+ updateContent();
546
+ card.onclick = () => {
547
+ const walkthrough = activeWalkthroughs[currentIndex];
548
+ this.telemetryService.publicLog2("agentSessionsWelcome.ActionExecuted", {
549
+ welcomeKind: "agentSessionsWelcomePage",
550
+ action: "openWalkthrough",
551
+ actionId: walkthrough.id
552
+ });
553
+ const options = {
554
+ selectedCategory: walkthrough.id,
555
+ returnToCommand: AgentSessionsWelcomePage_1.COMMAND_ID
556
+ };
557
+ this.editorService.openEditor({
558
+ resource: GettingStartedInput.RESOURCE,
559
+ options
560
+ });
561
+ };
562
+ prevButton.onclick = e => {
563
+ e.stopPropagation();
564
+ if (currentIndex > 0) {
565
+ currentIndex--;
566
+ updateContent();
567
+ }
568
+ };
569
+ nextButton.onclick = e => {
570
+ e.stopPropagation();
571
+ if (currentIndex < activeWalkthroughs.length - 1) {
572
+ currentIndex++;
573
+ updateContent();
574
+ }
575
+ };
576
+ }
577
+ static {
578
+ this.PRIVACY_NOTICE_DISMISSED_KEY = "agentSessionsWelcome.privacyNoticeDismissed";
579
+ }
580
+ buildPrivacyNotice(container) {
581
+ if (!this.chatEntitlementService.anonymous) {
582
+ return;
583
+ }
584
+ if (this.storageService.getBoolean(
585
+ AgentSessionsWelcomePage_1.PRIVACY_NOTICE_DISMISSED_KEY,
586
+ StorageScope.APPLICATION,
587
+ false
588
+ )) {
589
+ return;
590
+ }
591
+ const providers = this.productService.defaultChatAgent?.provider;
592
+ if (!providers || !providers.default || !this.productService.defaultChatAgent?.termsStatementUrl || !this.productService.defaultChatAgent?.privacyStatementUrl) {
593
+ return;
594
+ }
595
+ const tosCard = append(
596
+ container,
597
+ $(".agentSessionsWelcome-walkthroughCard.agentSessionsWelcome-tosCard")
598
+ );
599
+ const dismissNotice = () => {
600
+ this.storageService.store(
601
+ AgentSessionsWelcomePage_1.PRIVACY_NOTICE_DISMISSED_KEY,
602
+ true,
603
+ StorageScope.APPLICATION,
604
+ StorageTarget.USER
605
+ );
606
+ tosCard.remove();
607
+ };
608
+ this.contentDisposables.add(this.chatService.onDidSubmitRequest(() => dismissNotice()));
609
+ const iconContainer = append(tosCard, $(".agentSessionsWelcome-walkthroughCard-icon"));
610
+ iconContainer.appendChild(renderIcon(Codicon.chatSparkle));
611
+ const content = append(tosCard, $(".agentSessionsWelcome-walkthroughCard-content"));
612
+ const title = append(content, $(".agentSessionsWelcome-walkthroughCard-title"));
613
+ title.textContent = ( localize(20906, "Try GitHub Copilot for free, no sign-in required!"));
614
+ const desc = append(content, $(".agentSessionsWelcome-walkthroughCard-description"));
615
+ const descriptionMarkdown = ( new MarkdownString(( localize(
616
+ 20907,
617
+ "By continuing, you agree to {0}'s [Terms]({1}) and [Privacy Statement]({2}).",
618
+ providers.default.name,
619
+ this.productService.defaultChatAgent.termsStatementUrl,
620
+ this.productService.defaultChatAgent.privacyStatementUrl
621
+ )), {
622
+ isTrusted: true
623
+ }));
624
+ const renderedMarkdown = this.markdownRendererService.render(descriptionMarkdown);
625
+ desc.appendChild(renderedMarkdown.element);
626
+ const dismissButton = append(tosCard, $("button.agentSessionsWelcome-tosCard-dismiss"));
627
+ dismissButton.appendChild(renderIcon(Codicon.close));
628
+ dismissButton.title = ( localize(20908, "Dismiss"));
629
+ dismissButton.onclick = e => {
630
+ e.stopPropagation();
631
+ dismissNotice();
632
+ };
633
+ }
634
+ buildFooter(container) {
635
+ this.buildPrivacyNotice(container);
636
+ const showOnStartupContainer = append(container, $(".agentSessionsWelcome-showOnStartup"));
637
+ const showOnStartupCheckbox = this.contentDisposables.add(( new Toggle({
638
+ icon: Codicon.check,
639
+ actionClassName: "agentSessionsWelcome-checkbox",
640
+ isChecked: this.configurationService.getValue(configurationKey) === "agentSessionsWelcomePage",
641
+ title: ( localize(20909, "When checked, this page will be shown on startup.")),
642
+ ...getToggleStyles({
643
+ inputActiveOptionBackground: "var(--vscode-descriptionForeground)",
644
+ inputActiveOptionForeground: "var(--vscode-editor-background)",
645
+ inputActiveOptionBorder: "var(--vscode-descriptionForeground)"
646
+ })
647
+ })));
648
+ showOnStartupCheckbox.domNode.id = "showOnStartup";
649
+ const showOnStartupLabel = $("label.caption", {
650
+ for: "showOnStartup"
651
+ }, ( localize(20910, "Show welcome page on startup")));
652
+ const onShowOnStartupChanged = () => {
653
+ if (showOnStartupCheckbox.checked) {
654
+ this.configurationService.updateValue(configurationKey, "agentSessionsWelcomePage");
655
+ } else {
656
+ this.configurationService.updateValue(configurationKey, "none");
657
+ }
658
+ };
659
+ this.contentDisposables.add(showOnStartupCheckbox.onChange(() => onShowOnStartupChanged()));
660
+ this.contentDisposables.add(addDisposableListener(showOnStartupLabel, "click", () => {
661
+ showOnStartupCheckbox.checked = !showOnStartupCheckbox.checked;
662
+ onShowOnStartupChanged();
663
+ }));
664
+ showOnStartupContainer.appendChild(showOnStartupCheckbox.domNode);
665
+ showOnStartupContainer.appendChild(showOnStartupLabel);
666
+ }
667
+ layout(dimension) {
668
+ this.lastDimension = dimension;
669
+ this.container.style.height = `${dimension.height}px`;
670
+ this.container.style.width = `${dimension.width}px`;
671
+ this.container.classList.toggle("height-constrained", dimension.height <= WELCOME_COMPACT_HEIGHT);
672
+ this.layoutChatWidget();
673
+ this.layoutSessionsControl();
674
+ this.scrollableElement?.scanDomNode();
675
+ }
676
+ layoutChatWidget() {
677
+ if (!this.chatWidget || !this.lastDimension) {
678
+ return;
679
+ }
680
+ const chatWidth = Math.min(800, this.lastDimension.width - 80);
681
+ this.chatWidget.setInputPartMaxHeightOverride(WELCOME_CHAT_INPUT_MAX_HEIGHT_OVERRIDE);
682
+ this.chatWidget.layout(WELCOME_CHAT_INPUT_LAYOUT_HEIGHT, chatWidth);
683
+ }
684
+ layoutSessionsControl() {
685
+ if (!this.sessionsControl || !this.sessionsControlContainer || !this.lastDimension) {
686
+ return;
687
+ }
688
+ const sessionsWidth = Math.min(800, this.lastDimension.width - 80);
689
+ const visibleSessions = Math.min(
690
+ this.agentSessionsService.model.sessions.filter(s => !s.isArchived()).length,
691
+ MAX_SESSIONS
692
+ );
693
+ const sessionsHeight = visibleSessions * AgentSessionsListDelegate.ITEM_HEIGHT;
694
+ this.sessionsControl.layout(sessionsHeight, sessionsWidth);
695
+ const marginOffset = Math.floor(visibleSessions / 2) * AgentSessionsListDelegate.ITEM_HEIGHT;
696
+ this.sessionsControl.element.style.marginBottom = `-${marginOffset}px`;
697
+ }
698
+ focus() {
699
+ super.focus();
700
+ this.chatWidget?.focusInput();
701
+ }
702
+ async revealMaximizedChat() {
703
+ try {
704
+ await this.closeEditorAndMaximizeAuxiliaryBar();
705
+ } catch (error) {
706
+ this.logService.error("Failed to open maximized chat: {0}", toErrorMessage(error));
707
+ }
708
+ }
709
+ async openSessionInChat(sessionResource) {
710
+ try {
711
+ await this.closeEditorAndMaximizeAuxiliaryBar(sessionResource);
712
+ } catch (error) {
713
+ this.logService.error("Failed to open agent session: {0}", toErrorMessage(error));
714
+ }
715
+ }
716
+ async closeEditorAndMaximizeAuxiliaryBar(sessionResource) {
717
+ const editorToClose = this.input || this._storedInput;
718
+ if (editorToClose && this.group.contains(editorToClose)) {
719
+ await ( new Promise(resolve => {
720
+ const disposable = this.group.onDidActiveEditorChange(e => {
721
+ disposable.dispose();
722
+ resolve();
723
+ });
724
+ this.group.closeEditor(editorToClose);
725
+ }));
726
+ }
727
+ if (sessionResource) {
728
+ await this.chatWidgetService.openSession(sessionResource);
729
+ } else {
730
+ await this.commandService.executeCommand("workbench.action.chat.open");
731
+ }
732
+ const chatViewLocation = this.viewDescriptorService.getViewLocationById(ChatViewId);
733
+ if (chatViewLocation === ViewContainerLocation.AuxiliaryBar) {
734
+ this.layoutService.setAuxiliaryBarMaximized(true);
735
+ }
736
+ }
737
+ async getRecentlyOpenedWorkspaces(onlyTrusted = false) {
738
+ const workspaces = await this.workspacesService.getRecentlyOpened();
739
+ const trustInfoPromises = workspaces.workspaces.map(async ws => {
740
+ const uri = isRecentWorkspace(ws) ? ws.workspace.configPath : ws.folderUri;
741
+ const trustInfo = await this.workspaceTrustManagementService.getUriTrustInfo(uri);
742
+ return {
743
+ workspace: ws,
744
+ trusted: trustInfo.trusted
745
+ };
746
+ });
747
+ const trustInfoResults = await Promise.all(trustInfoPromises);
748
+ const filteredWorkspaces = trustInfoResults.filter(result => onlyTrusted ? result.trusted : true).map(result => result.workspace);
749
+ return filteredWorkspaces;
750
+ }
751
+ };
752
+ AgentSessionsWelcomePage = AgentSessionsWelcomePage_1 = ( __decorate([( __param(1, ITelemetryService)), ( __param(2, IThemeService)), ( __param(3, IStorageService)), ( __param(4, IInstantiationService)), ( __param(5, IContextKeyService)), ( __param(6, IWorkbenchLayoutService)), ( __param(7, ICommandService)), ( __param(8, IEditorService)), ( __param(9, IAgentSessionsService)), ( __param(10, IConfigurationService)), ( __param(11, IProductService)), ( __param(12, IWalkthroughsService)), ( __param(13, IChatService)), ( __param(14, IChatEntitlementService)), ( __param(15, IMarkdownRendererService)), ( __param(16, IWorkspaceContextService)), ( __param(17, IWorkspacesService)), ( __param(18, IHostService)), ( __param(19, IWorkspaceTrustManagementService)), ( __param(20, IViewDescriptorService)), ( __param(21, IChatWidgetService)), ( __param(22, ILogService))], AgentSessionsWelcomePage));
753
+ class AgentSessionsWelcomeInputSerializer {
754
+ canSerialize(editorInput) {
755
+ return true;
756
+ }
757
+ serialize(editorInput) {
758
+ return JSON.stringify({});
759
+ }
760
+ deserialize(instantiationService, serializedEditorInput) {
761
+ return ( new AgentSessionsWelcomeInput({}));
762
+ }
763
+ }
764
+
765
+ export { AgentSessionsWelcomeInputSerializer, AgentSessionsWelcomePage };