Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationWelcomePage.ts
13406 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as DOM from '../../../../../base/browser/dom.js';
7
import { Disposable, IDisposable } from '../../../../../base/common/lifecycle.js';
8
import { ICommandService } from '../../../../../platform/commands/common/commands.js';
9
import { AICustomizationManagementSection } from './aiCustomizationManagement.js';
10
import { IAICustomizationWorkspaceService, IWelcomePageFeatures } from '../../common/aiCustomizationWorkspaceService.js';
11
import { PromptLaunchersAICustomizationWelcomePage } from './aiCustomizationWelcomePagePromptLaunchers.js';
12
import { IHoverService } from '../../../../../platform/hover/browser/hover.js';
13
14
const $ = DOM.$;
15
16
export interface IWelcomePageCallbacks {
17
selectSection(section: AICustomizationManagementSection): void;
18
selectSectionWithMarketplace(section: AICustomizationManagementSection): void;
19
closeEditor(): void;
20
/**
21
* Prefill the chat input with a query. In the sessions window this
22
* uses the sessions chat widget; in core VS Code it opens the chat view.
23
*
24
* @param options.newChat When true, always opens a new chat instead of
25
* reusing the active one.
26
*/
27
prefillChat(query: string, options?: { isPartialQuery?: boolean; newChat?: boolean }): void;
28
}
29
30
export interface IAICustomizationWelcomePageImplementation extends IDisposable {
31
readonly container: HTMLElement;
32
rebuildCards(visibleSectionIds: ReadonlySet<AICustomizationManagementSection>): void;
33
focus(): void;
34
/** Called when the welcome page becomes visible after navigation — clears any transient state. */
35
reset?(): void;
36
}
37
38
/**
39
* Renders the welcome page for the AI Customization Management Editor.
40
*/
41
export class AICustomizationWelcomePage extends Disposable {
42
43
private readonly implementation: IAICustomizationWelcomePageImplementation;
44
45
readonly container: HTMLElement;
46
47
constructor(
48
parent: HTMLElement,
49
welcomePageFeatures: IWelcomePageFeatures | undefined,
50
callbacks: IWelcomePageCallbacks,
51
commandService: ICommandService,
52
workspaceService: IAICustomizationWorkspaceService,
53
hoverService: IHoverService,
54
) {
55
super();
56
57
this.container = DOM.append(parent, $('.welcome-page-host'));
58
this.container.style.height = '100%';
59
this.container.style.overflow = 'hidden';
60
this.implementation = this._register(new PromptLaunchersAICustomizationWelcomePage(this.container, welcomePageFeatures, callbacks, commandService, workspaceService, hoverService));
61
}
62
63
rebuildCards(visibleSectionIds: ReadonlySet<AICustomizationManagementSection>): void {
64
this.implementation.rebuildCards(visibleSectionIds);
65
}
66
67
focus(): void {
68
this.implementation.focus();
69
}
70
71
reset(): void {
72
this.implementation.reset?.();
73
}
74
}
75
76