Path: blob/main/extensions/copilot/src/extension/prompts/node/panel/preferences.tsx
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { BasePromptElementProps, PromptElement, PromptReference, PromptSizing } from '@vscode/prompt-tsx';6import { ConfigKey, IConfigurationService } from '../../../../platform/configuration/common/configurationService';7import { IVSCodeExtensionContext } from '../../../../platform/extContext/common/extensionContext';8import { IFileSystemService } from '../../../../platform/filesystem/common/fileSystemService';9import { URI } from '../../../../util/vs/base/common/uri';10import { Tag } from '../base/tag';1112export interface UserPreferencesProps extends BasePromptElementProps { }1314export class UserPreferences extends PromptElement<UserPreferencesProps> {15constructor(16props: UserPreferencesProps,17@IFileSystemService private readonly fileSystemService: IFileSystemService,18@IConfigurationService private readonly configurationService: IConfigurationService,19@IVSCodeExtensionContext private readonly extensionContext: IVSCodeExtensionContext20) {21super(props);22}23override async render(state: void, sizing: PromptSizing) {24if (!this.configurationService.getConfig(ConfigKey.Advanced.EnableUserPreferences)) {25return undefined;26}2728try {29const uri = URI.joinPath(this.extensionContext.globalStorageUri, 'copilotUserPreferences.md');30const fileContents = await this.fileSystemService.readFile(uri);31return (<>32<Tag name='instructions'>33<references value={[new PromptReference(uri)]} />34{new TextDecoder().decode(fileContents)}35</Tag>3637</>);38} catch (ex) {39return undefined;40}4142}43}444546