constants.ts ×18

Frontier kind: Code frontier

unlabeled · c_21b2815ce1ff

961 tests · 21892 LOC · 118 files · introduces 0 tests · 577 LOC · 4 files

Introduces — evidence that enters the hierarchy at this concept

Code
34 ranges577 lines · 4 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2435 ranges21892 lines · 118 files · Browse complete extent
All tests (intent)
961 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

4 files ranked by introduced lines: 577 introduced LOC across 34 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/constants.ts 306 introduced LOC · 18 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- constants.ts
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 { Schemas } from '../../../../base/common/network.js';
7 > import { IChatSessionsService, isAgentHostTarget, localChatSessionType, SessionType } from './chatSessionsService.js';
8 > import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
9 > import { IStorageService } from '../../../../platform/storage/common/storage.js';
10 > import { IWorkspace } from '../../../../platform/workspace/common/workspace.js';
11 > import { isVirtualWorkspace } from '../../../../platform/workspace/common/virtualWorkspace.js';
12 > import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
13 > import { ContextKeyExpr, RawContextKey } from '../../../../platform/contextkey/common/contextkey.js';
14 > import { ChatEntitlementContextKeys } from '../../../services/chat/common/chatEntitlementService.js';
15 > import { IsAuxiliaryWindowContext, IsSessionsWindowContext } from '../../../common/contextkeys.js';
16 > import { URI } from '../../../../base/common/uri.js';
17 > import { generateUuid } from '../../../../base/common/uuid.js';
18 > import { LocalChatSessionUri } from './model/chatUri.js';
19 > import { clearUserSelectedSessionType, getRememberedSessionType, hasPreferredCopilotHarness, storeUserSelectedSessionType } from './chatSessionTypePreference.js';
20 >
21 > export const enum BYOKUtilityModelDefault {
22 > None = 'none',
23 > MainAgent = 'mainAgent',
24 > Copilot = 'copilot',
25 > }
26 >
27 > export enum ChatConfiguration {
28 > AIDisabled = 'chat.disableAIFeatures',
29 > PluginsEnabled = 'chat.plugins.enabled',
30 > PluginLocations = 'chat.pluginLocations',
31 > PluginMarketplaces = 'chat.plugins.marketplaces',
32 > ExtraMarketplaces = 'chat.plugins.extraMarketplaces',
33 > StrictMarketplaces = 'chat.plugins.strictMarketplaces',
34 > EnabledPlugins = 'chat.plugins.enabledPlugins',
35 > AgentEnabled = 'chat.agent.enabled',
36 > PlanAgentDefaultModel = 'chat.planAgent.defaultModel',
37 > ExploreAgentDefaultModel = 'chat.exploreAgent.defaultModel',
38 > UtilityModel = 'chat.utilityModel',
39 > UtilitySmallModel = 'chat.utilitySmallModel',
40 > BYOKUtilityModelDefault = 'chat.byokUtilityModelDefault',
41 > RequestQueueingDefaultAction = 'chat.requestQueuing.defaultAction',
42 > AgentStatusEnabled = 'chat.agentsControl.enabled',
43 > EditorAssociations = 'chat.editorAssociations',
44 > UnifiedAgentsBar = 'chat.unifiedAgentsBar.enabled',
45 > AgentSessionProjectionEnabled = 'chat.agentSessionProjection.enabled',
46 > ExtensionToolsEnabled = 'chat.extensionTools.enabled',
47 > RepoInfoEnabled = 'chat.repoInfo.enabled',
48 > EditRequests = 'chat.editRequests',
49 > InlineReferencesStyle = 'chat.inlineReferences.style',
50 > AutoReply = 'chat.autoReply',
51 > GlobalAutoApprove = 'chat.tools.global.autoApprove',
52 > AutoApproveEdits = 'chat.tools.edits.autoApprove',
53 > AutoApprovedUrls = 'chat.tools.urls.autoApprove',
54 > EligibleForAutoApproval = 'chat.tools.eligibleForAutoApproval',
55 > EnableMath = 'chat.math.enabled',
56 > CheckpointsEnabled = 'chat.checkpoints.enabled',
57 > ThinkingStyle = 'chat.agent.thinkingStyle',
58 > ThinkingGenerateTitles = 'chat.agent.thinking.generateTitles',
59 > TerminalToolsInThinking = 'chat.agent.thinking.terminalTools',
60 > SimpleTerminalCollapsible = 'chat.tools.terminal.simpleCollapsible',
61 > CompressOutputEnabled = 'chat.tools.compressOutput.enabled',
62 > ThinkingPhrases = 'chat.agent.thinking.phrases',
63 > AutoExpandToolFailures = 'chat.tools.autoExpandFailures',
64 > TodosShowWidget = 'chat.tools.todos.showWidget',
65 > NotifyWindowOnConfirmation = 'chat.notifyWindowOnConfirmation',
66 > NotifyWindowOnResponseReceived = 'chat.notifyWindowOnResponseReceived',
67 > ChatViewSessionsEnabled = 'chat.viewSessions.enabled',
68 > SessionSyncEnabled = 'chat.sessionSync.enabled',
69 > SessionSyncExcludeRepositories = 'chat.sessionSync.excludeRepositories',
70 > ChatViewSessionsGrouping = 'chat.viewSessions.grouping',
71 > ChatViewSessionsOrientation = 'chat.viewSessions.orientation',
72 > ChatViewProgressBadgeEnabled = 'chat.viewProgressBadge.enabled',
73 > ChatContextUsageEnabled = 'chat.contextUsage.enabled',
74 > Verbose = 'chat.verbose',
75 > ProgressBorder = 'chat.progressBorder.enabled',
76 > SubagentToolCustomAgents = 'chat.customAgentInSubagent.enabled',
77 > SubagentsAllowInvocationsFromSubagents = 'chat.subagents.allowInvocationsFromSubagents',
78 > ShowCodeBlockProgressAnimation = 'chat.agent.codeBlockProgress',
79 > RestoreLastPanelSession = 'chat.restoreLastPanelSession',
80 > ExitAfterDelegation = 'chat.exitAfterDelegation',
81 > ExplainChangesEnabled = 'chat.editing.explainChanges.enabled',
82 > RevealNextChangeOnResolve = 'chat.editing.revealNextChangeOnResolve',
83 > OpenChangedFileInDiffEditor = 'chat.editing.openChangedFileInDiffEditor',
84 > GrowthNotificationEnabled = 'chat.growthNotification.enabled',
85 > TitleBarSignInEnabled = 'chat.titleBar.signIn.enabled',
86 > TitleBarOpenInAgentsWindowEnabled = 'chat.titleBar.openInAgentsWindow.enabled',
87 >
88 > ChatCustomizationsStructuredPreviewEnabled = 'chat.customizations.structuredPreview.enabled',
89 > ChatCustomizationsPromptMigrationEnabled = 'chat.customizations.promptMigration.enabled',
90 > AutopilotAdvancedEnabled = 'chat.autopilot.advanced.enabled',
91 > PlanReviewInlineEditorEnabled = 'chat.planReview.inlineEditor.enabled',
92 > DefaultPermissionLevel = 'chat.permissions.default',
93 > AssistedPermissionsEnabled = 'chat.assistedPermissions.enabled',
94 > PermissionsSandboxToggleEnabled = 'chat.experimental.permissionsSandboxToggle.enabled',
95 > DefaultConfiguration = 'chat.defaultConfiguration',
96 > DefaultModel = 'chat.defaultModel',
97 > ImageCarouselEnabled = 'imageCarousel.chat.enabled',
98 > ArtifactsEnabled = 'chat.artifacts.enabled',
99 > ArtifactsRulesByMimeType = 'chat.artifacts.rules.byMimeType',
100 > ArtifactsRulesByFilePath = 'chat.artifacts.rules.byFilePath',
101 > ArtifactsRulesByMemoryFilePath = 'chat.artifacts.rules.byMemoryFilePath',
102 > ToolConfirmationCarousel = 'chat.tools.confirmationCarousel.enabled',
103 > ToolRiskAssessmentEnabled = 'chat.tools.riskAssessment.enabled',
104 > ToolRiskAssessmentModel = 'chat.tools.riskAssessment.model',
105 > DefaultNewSessionMode = 'chat.newSession.defaultMode',
106 > CopilotCliHideExtensionHostAgents = 'chat.agents.copilotCli.hideExtensionHost',
107 > EditorPreferCopilotHarness = 'chat.editor.preferCopilotHarness',
108 > DefaultToCopilotHarness = 'chat.defaultToCopilotHarness',
109 > EditorLocalAgentEnabled = 'chat.editor.localAgent.enabled',
110 > CopilotCliHideExtensionHostEditor = 'chat.editor.copilotCli.hideExtensionHost',
111 > AgentsHandoffTipMode = 'chat.agentsHandoffTip.mode',
112 > TurnStatusPills = 'chat.turnStatusPills',
113 >
114 > IncrementalRendering = 'chat.experimental.incrementalRendering.enabled',
115 > IncrementalRenderingStyle = 'chat.experimental.incrementalRendering.animationStyle',
116 > IncrementalRenderingBuffering = 'chat.experimental.incrementalRendering.buffering',
117 >
118 > CollectInstructionsInExtension = 'chat.experimental.collectInstructionsInExtension',
119 > ImplicitContextActiveEditor = 'chat.implicitContext.includeActiveEditor',
120 > }
121 >
122 > /**
123 > * The "kind" of agents for custom agents.
124 > */
125 > export enum ChatModeKind {
126 > Ask = 'ask',
127 > Edit = 'edit',
128 > Agent = 'agent'
129 > }
130 >
131 > /**
132 > * The permission level controlling tool auto-approval behavior.
133 > */
134 > export enum ChatPermissionLevel {
135 > /** Use existing auto-approve settings */
136 > Default = 'default',
137 > /** Delegate approval decisions to a model */
138 > Assisted = 'assisted',
139 > /** Auto-approve all tool calls, auto-retry on error */
140 > AutoApprove = 'autoApprove',
141 > /** Everything AutoApprove does plus an internal stop hook that continues until the task is done */
142 > Autopilot = 'autopilot'
143 > }
144 >
145 > const chatPermissionLevels = new Set<string>(Object.values(ChatPermissionLevel));
146 >
147 > export function isChatPermissionLevel(level: unknown | undefined): level is ChatPermissionLevel {
148 return chatPermissionLevels.has(level as string);
149 }
150 > constants.ts
151 > /**
152 > * Shape of the {@link ChatConfiguration.DefaultConfiguration}
153 > * object setting. Controls the starting `mode` and `approvals` for new agent-host
154 > * sessions (such as Copilot CLI). All properties are optional — a missing property
155 > * falls back to the per-axis default.
156 > */
157 > export type AgentSessionMode = 'interactive' | 'plan' | 'autopilot';
158 >
159 > /** Approval values exposed by the `chat.defaultConfiguration` setting. */
160 > export enum ChatDefaultPermissionLevel {
161 > Default = 'default',
162 > Assisted = 'assisted',
163 > AllowAll = 'allowAll',
164 > }
165 >
166 > export interface IChatDefaultConfiguration {
167 > /** Starting agent mode: `interactive` / `plan` / `autopilot`. */
168 > readonly mode?: AgentSessionMode;
169 > /** Starting approval level: `default` / `assisted` / `allowAll`. */
170 > readonly approvals?: ChatDefaultPermissionLevel;
171 > }
172 >
173 > /** Maps a default-configuration value to the internal Agent Host permission level. */
174 > export function getChatPermissionLevelFromDefaultConfiguration(value: unknown): ChatPermissionLevel | undefined {
175 switch (value) {
176 case ChatDefaultPermissionLevel.Default:
185 }
186 }
187 > constants.ts
188 > /**
189 > * Returns true if the permission level enables auto-approval of all tool calls.
190 > * Both {@link ChatPermissionLevel.AutoApprove} and {@link ChatPermissionLevel.Autopilot} enable auto-approval.
191 > */
192 > export function isAutoApproveLevel(level: ChatPermissionLevel | undefined): boolean {
193 return level === ChatPermissionLevel.AutoApprove || level === ChatPermissionLevel.Autopilot;
194 }
195 > constants.ts
196 > /**
197 > * True for {@link ChatPermissionLevel.Autopilot} only. Unlike {@link isAutoApproveLevel}, this
198 > * excludes {@link ChatPermissionLevel.AutoApprove}, so it can gate Autopilot-only behavior such as
199 > * risk-based skipping of tool calls.
200 > */
201 > export function isAutopilotLevel(level: ChatPermissionLevel | undefined): boolean {
202 return level === ChatPermissionLevel.Autopilot;
203 }
204 > constants.ts
205 > // Thinking display modes for pinned content
206 > export enum ThinkingDisplayMode {
207 > Collapsed = 'collapsed',
208 > CollapsedPreview = 'collapsedPreview',
209 > FixedScrolling = 'fixedScrolling',
210 > }
211 >
212 > export enum CollapsedToolsDisplayMode {
213 > Off = 'off',
214 > WithThinking = 'withThinking',
215 > Always = 'always',
216 > }
217 >
218 > export enum ChatNotificationMode {
219 > Off = 'off',
220 > WindowNotFocused = 'windowNotFocused',
221 > Always = 'always',
222 > }
223 >
224 > export type RawChatParticipantLocation = 'panel' | 'terminal' | 'notebook' | 'editing-session';
225 >
226 > export enum ChatAgentLocation {
227 > /**
228 > * This is chat, whether it's in the sidebar, a chat editor, or quick chat.
229 > * Leaving the values alone as they are in stored data so we don't have to normalize them.
230 > */
231 > Chat = 'panel',
232 > Terminal = 'terminal',
233 > Notebook = 'notebook',
234 > /**
235 > * EditorInline means inline chat in a text editor.
236 > */
237 > EditorInline = 'editor',
238 > }
239 >
240 > export namespace ChatAgentLocation {
241 > export function fromRaw(value: RawChatParticipantLocation | string): ChatAgentLocation {
242 switch (value) {
243 case 'panel': return ChatAgentLocation.Chat;
248 return ChatAgentLocation.Chat;
249 }
250 > } constants.ts
251 >
252 > /**
253 > * List of file schemes that are always unsupported for use in chat
254 > */
255 > const chatAlwaysUnsupportedFileSchemes = new Set([
256 > Schemas.vscodeChatEditor,
257 > Schemas.walkThrough,
258 > Schemas.vscodeLocalChatSession,
259 > Schemas.vscodeSettings,
260 > Schemas.webviewPanel,
261 > Schemas.vscodeUserData,
262 > Schemas.extension,
263 > 'ccreq',
264 > 'openai-codex', // Codex session custom editor scheme
265 > ]);
266 >
267 > export function isSupportedChatFileScheme(accessor: ServicesAccessor, scheme: string): boolean {
268 const chatService = accessor.get(IChatSessionsService);
269
281 return true;
282 }
283 > constants.ts
284 > /**
285 > * Returns the effective default session type for a new chat in the VS Code
286 > * editor window.
287 > *
288 > * Virtual workspaces always default to {@link localChatSessionType}. Otherwise,
289 > * when the agent host is enabled and `chat.defaultToCopilotHarness` is opted in,
290 > * Agent Host Copilot CLI is the default. It falls back to the local harness
291 > * when enabled, or to the first visible non-local provider.
292 > */
293 > export function getComputedDefaultSessionType(
294 configurationService: IConfigurationService,
295 chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
311 return getVisibleNonLocalEditorChatSessionTypes(configurationService, chatSessionsService, workspace)[0] ?? localChatSessionType;
312 }
313 > constants.ts
314 > export function getComputedDefaultSessionResource(
315 configurationService: IConfigurationService,
316 chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
323 : URI.from({ scheme: defaultType, path: `/untitled-${generateUuid()}` });
324 }
325 > constants.ts
326 > export function isRememberedSessionTypeUsable(
327 sessionType: string,
328 configurationService: IConfigurationService,
338 return !!chatSessionsService.getChatSessionContribution(sessionType);
339 }
340 > constants.ts
341 > export interface IDefaultNewChatSessionTypeOptions {
342 > readonly explicitOverride?: string;
343 > readonly currentSessionType?: string;
344 > }
345 >
346 > export interface IResolvedNewChatSessionType {
347 > /** The session type to open for the new chat. */
348 > readonly sessionType: string;
349 > /**
350 > * True when {@link sessionType} is the one-time `chat.editor.preferCopilotHarness`
351 > * swap. The caller must persist the marker (via `markPreferredCopilotHarness`)
352 > * only once it has actually applied this session type, so the migration is not
353 > * consumed by a caller that discards the result.
354 > */
355 > readonly isPreferCopilotHarnessSwap: boolean;
356 > }
357 >
358 > export function getDefaultNewChatSessionType(
359 configurationService: IConfigurationService,
360 chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
379 return getComputedDefaultSessionType(configurationService, chatSessionsService, workspace, agentHostEnabled);
380 }
381 > constants.ts
382 > export function resolveDefaultNewChatSessionType(
383 configurationService: IConfigurationService,
384 chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
413 return { sessionType: getDefaultNewChatSessionType(configurationService, chatSessionsService, storageService, workspace, agentHostEnabled, options), isPreferCopilotHarnessSwap: false };
414 }
415 > constants.ts
416 function getUsableRememberedSessionType(
417 storageService: IStorageService,
423 return remembered && isRememberedSessionTypeUsable(remembered, configurationService, chatSessionsService, workspace) ? remembered : undefined;
424 }
425 > constants.ts
426 > export function getDefaultNewChatSessionResource(
427 configurationService: IConfigurationService,
428 chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
437 : URI.from({ scheme: defaultType, path: `/untitled-${generateUuid()}` });
438 }
439 > constants.ts
440 > export function recordUserSelectedSessionType(
441 storageService: IStorageService,
442 configurationService: IConfigurationService,
452 }
453 }
454 > constants.ts
455 > export function isEditorLocalAgentEnabled(configurationService: IConfigurationService, workspace: IWorkspace): boolean {
456 return isVirtualWorkspace(workspace) || (configurationService.getValue<boolean>(ChatConfiguration.EditorLocalAgentEnabled) ?? true);
457 }
458 > constants.ts
459 > export function isVisibleEditorChatSessionType(
460 sessionType: string,
461 configurationService: IConfigurationService,
473 return !!chatSessionsService.getChatSessionContribution(sessionType);
474 }
475 > constants.ts
476 function getVisibleNonLocalEditorChatSessionTypes(
477 configurationService: IConfigurationService,
487 return Array.from(sessionTypes);
488 }
489 > constants.ts
490 > export const MANAGE_CHAT_COMMAND_ID = 'workbench.action.chat.manage';
491 > export const CHAT_OPEN_AGENT_HOST_CHAT_COMMAND_ID = 'workbench.action.chat.openAgentHostChat';
492 >
493 > export const OPEN_WORKSPACE_IN_AGENTS_WINDOW_COMMAND_ID = 'workbench.action.openWorkspaceInAgentsWindow';
494 > export const OPEN_AGENTS_WINDOW_COMMAND_ID = 'workbench.action.openAgentsWindow';
495 > export const OPEN_AGENTS_WINDOW_PRECONDITION = ContextKeyExpr.and(
496 > ChatEntitlementContextKeys.Setup.hidden.negate(),
497 > ChatEntitlementContextKeys.Setup.disabledInWorkspace.negate(),
498 > IsSessionsWindowContext.negate(),
499 > ContextKeyExpr.has(`config.${ChatConfiguration.AgentEnabled}`),
500 > IsAuxiliaryWindowContext.negate()
501 > );
502 >
503 > export const ChatEditorTitleMaxLength = 30;
504 >
505 > export const CHAT_TERMINAL_OUTPUT_MAX_PREVIEW_LINES = 1000;
506 > export const CONTEXT_MODELS_EDITOR = new RawContextKey<boolean>('inModelsEditor', false);
507 > export const CONTEXT_MODELS_SEARCH_FOCUS = new RawContextKey<boolean>('inModelsSearch', false);
src/vs/workbench/common/contextkeys.ts 250 introduced LOC · 10 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- contextkeys.ts
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 { DisposableStore } from '../../base/common/lifecycle.js';
7 > import { URI } from '../../base/common/uri.js';
8 > import { localize } from '../../nls.js';
9 > import { IContextKeyService, IContextKey, RawContextKey } from '../../platform/contextkey/common/contextkey.js';
10 > import { basename, dirname, extname, isEqual } from '../../base/common/resources.js';
11 > import { ILanguageService } from '../../editor/common/languages/language.js';
12 > import { IFileService } from '../../platform/files/common/files.js';
13 > import { IModelService } from '../../editor/common/services/model.js';
14 > import { Schemas } from '../../base/common/network.js';
15 > import { EditorInput } from './editor/editorInput.js';
16 > import { IEditorResolverService } from '../services/editor/common/editorResolverService.js';
17 > import { DEFAULT_EDITOR_ASSOCIATION, isDiffEditorInput } from './editor.js';
18 >
19 > //#region < --- Workbench --- >
20 >
21 > export const WorkbenchStateContext = new RawContextKey<string>('workbenchState', undefined, { type: 'string', description: localize('workbenchState', "The kind of workspace opened in the window, either 'empty' (no workspace), 'folder' (single folder) or 'workspace' (multi-root workspace)") });
22 > export const WorkspaceFolderCountContext = new RawContextKey<number>('workspaceFolderCount', 0, localize('workspaceFolderCount', "The number of root folders in the workspace"));
23 >
24 > export const OpenFolderWorkspaceSupportContext = new RawContextKey<boolean>('openFolderWorkspaceSupport', true, true);
25 > export const EnterMultiRootWorkspaceSupportContext = new RawContextKey<boolean>('enterMultiRootWorkspaceSupport', true, true);
26 > export const EmptyWorkspaceSupportContext = new RawContextKey<boolean>('emptyWorkspaceSupport', true, true);
27 >
28 > export const DirtyWorkingCopiesContext = new RawContextKey<boolean>('dirtyWorkingCopies', false, localize('dirtyWorkingCopies', "Whether there are any working copies with unsaved changes"));
29 >
30 > export const RemoteNameContext = new RawContextKey<string>('remoteName', '', localize('remoteName', "The name of the remote the window is connected to or an empty string if not connected to any remote"));
31 >
32 > export const VirtualWorkspaceContext = new RawContextKey<string>('virtualWorkspace', '', localize('virtualWorkspace', "The scheme of the current workspace is from a virtual file system or an empty string."));
33 > export const TemporaryWorkspaceContext = new RawContextKey<boolean>('temporaryWorkspace', false, localize('temporaryWorkspace', "The scheme of the current workspace is from a temporary file system."));
34 >
35 > export const IsSessionsWindowContext = new RawContextKey<boolean>('isSessionsWindow', false, localize('isSessionsWindow', "Whether the current window is a agent sessions window."));
36 >
37 > export const HasWebFileSystemAccess = new RawContextKey<boolean>('hasWebFileSystemAccess', false, true); // Support for FileSystemAccess web APIs (https://wicg.github.io/file-system-access)
38 >
39 > export const EmbedderIdentifierContext = new RawContextKey<string | undefined>('embedderIdentifier', undefined, localize('embedderIdentifier', 'The identifier of the embedder according to the product service, if one is defined'));
40 >
41 > export const InAutomationContext = new RawContextKey<boolean>('inAutomation', false, localize('inAutomation', "Whether VS Code is running under automation/smoke test"));
42 >
43 > //#endregion
44 >
45 > //#region < --- Window --- >
46 >
47 > export const IsMainWindowFullscreenContext = new RawContextKey<boolean>('isFullscreen', false, localize('isFullscreen', "Whether the main window is in fullscreen mode"));
48 > export const IsAuxiliaryWindowFocusedContext = new RawContextKey<boolean>('isAuxiliaryWindowFocusedContext', false, localize('isAuxiliaryWindowFocusedContext', "Whether an auxiliary window is focused"));
49 >
50 > export const IsWindowAlwaysOnTopContext = new RawContextKey<boolean>('isWindowAlwaysOnTop', false, localize('isWindowAlwaysOnTop', "Whether the window is always on top"));
51 >
52 > export const IsAuxiliaryWindowContext = new RawContextKey<boolean>('isAuxiliaryWindow', false, localize('isAuxiliaryWindow', "Window is an auxiliary window"));
53 >
54 >
55 > //#endregion
56 >
57 >
58 > //#region < --- Editor --- >
59 >
60 > // Editor State Context Keys
61 > export const ActiveEditorDirtyContext = new RawContextKey<boolean>('activeEditorIsDirty', false, localize('activeEditorIsDirty', "Whether the active editor has unsaved changes"));
62 > export const ActiveEditorPinnedContext = new RawContextKey<boolean>('activeEditorIsNotPreview', false, localize('activeEditorIsNotPreview', "Whether the active editor is not in preview mode"));
63 > export const ActiveEditorFirstInGroupContext = new RawContextKey<boolean>('activeEditorIsFirstInGroup', false, localize('activeEditorIsFirstInGroup', "Whether the active editor is the first one in its group"));
64 > export const ActiveEditorLastInGroupContext = new RawContextKey<boolean>('activeEditorIsLastInGroup', false, localize('activeEditorIsLastInGroup', "Whether the active editor is the last one in its group"));
65 > export const ActiveEditorStickyContext = new RawContextKey<boolean>('activeEditorIsPinned', false, localize('activeEditorIsPinned', "Whether the active editor is pinned"));
66 > export const ActiveEditorReadonlyContext = new RawContextKey<boolean>('activeEditorIsReadonly', false, localize('activeEditorIsReadonly', "Whether the active editor is read-only"));
67 > export const ActiveCompareEditorCanSwapContext = new RawContextKey<boolean>('activeCompareEditorCanSwap', false, localize('activeCompareEditorCanSwap', "Whether the active compare editor can swap sides"));
68 > export const ActiveEditorCanToggleReadonlyContext = new RawContextKey<boolean>('activeEditorCanToggleReadonly', true, localize('activeEditorCanToggleReadonly', "Whether the active editor can toggle between being read-only or writeable"));
69 > export const ActiveEditorCanRevertContext = new RawContextKey<boolean>('activeEditorCanRevert', false, localize('activeEditorCanRevert', "Whether the active editor can revert"));
70 > export const ActiveEditorCanSplitInGroupContext = new RawContextKey<boolean>('activeEditorCanSplitInGroup', true);
71 >
72 > // Editor Kind Context Keys
73 > export const ActiveEditorContext = new RawContextKey<string | null>('activeEditor', null, { type: 'string', description: localize('activeEditor', "The identifier of the active editor") });
74 > export const ActiveEditorAvailableEditorIdsContext = new RawContextKey<string>('activeEditorAvailableEditorIds', '', localize('activeEditorAvailableEditorIds', "The available editor identifiers that are usable for the active editor"));
75 > export const TextCompareEditorVisibleContext = new RawContextKey<boolean>('textCompareEditorVisible', false, localize('textCompareEditorVisible', "Whether a text compare editor is visible"));
76 > export const TextCompareEditorActiveContext = new RawContextKey<boolean>('textCompareEditorActive', false, localize('textCompareEditorActive', "Whether a text compare editor is active"));
77 > export const SideBySideEditorActiveContext = new RawContextKey<boolean>('sideBySideEditorActive', false, localize('sideBySideEditorActive', "Whether a side by side editor is active"));
78 > export const ActiveCustomEditorDiffCanToggleLayoutContext = new RawContextKey<boolean>('activeCustomEditorDiffCanToggleLayout', false, localize('activeCustomEditorDiffCanToggleLayout', "Whether the active custom editor diff can toggle between inline and side by side layout"));
79 > export const ActiveCustomEditorTextDiffContext = new RawContextKey<boolean>('activeCustomEditorTextDiff', false, localize('activeCustomEditorTextDiff', "Whether the active custom editor diff is backed by text documents"));
80 >
81 > // Editor Group Context Keys
82 > export const EditorGroupEditorsCountContext = new RawContextKey<number>('groupEditorsCount', 0, localize('groupEditorsCount', "The number of opened editor groups"));
83 > export const IsTopRightEditorGroupContext = new RawContextKey<boolean>('isTopRightEditorGroup', false, localize('isTopRightEditorGroup', "Whether the editor group is the top right editor group in the editor part"));
84 > export const ActiveEditorGroupEmptyContext = new RawContextKey<boolean>('activeEditorGroupEmpty', false, localize('activeEditorGroupEmpty', "Whether the active editor group is empty"));
85 > export const ActiveEditorGroupIndexContext = new RawContextKey<number>('activeEditorGroupIndex', 0, localize('activeEditorGroupIndex', "The index of the active editor group"));
86 > export const ActiveEditorGroupLastContext = new RawContextKey<boolean>('activeEditorGroupLast', false, localize('activeEditorGroupLast', "Whether the active editor group is the last group"));
87 > export const ActiveEditorGroupLockedContext = new RawContextKey<boolean>('activeEditorGroupLocked', false, localize('activeEditorGroupLocked', "Whether the active editor group is locked"));
88 > export const MultipleEditorGroupsContext = new RawContextKey<boolean>('multipleEditorGroups', false, localize('multipleEditorGroups', "Whether there are multiple editor groups opened"));
89 > export const SingleEditorGroupsContext = MultipleEditorGroupsContext.toNegated();
90 > export const MultipleEditorsSelectedInGroupContext = new RawContextKey<boolean>('multipleEditorsSelectedInGroup', false, localize('multipleEditorsSelectedInGroup', "Whether multiple editors have been selected in an editor group"));
91 > export const TwoEditorsSelectedInGroupContext = new RawContextKey<boolean>('twoEditorsSelectedInGroup', false, localize('twoEditorsSelectedInGroup', "Whether exactly two editors have been selected in an editor group"));
92 > export const SelectedEditorsInGroupFileOrUntitledResourceContextKey = new RawContextKey<boolean>('SelectedEditorsInGroupFileOrUntitledResourceContextKey', true, localize('SelectedEditorsInGroupFileOrUntitledResourceContextKey', "Whether all selected editors in a group have a file or untitled resource associated"));
93 >
94 > // Editor Part Context Keys
95 > export const EditorPartMultipleEditorGroupsContext = new RawContextKey<boolean>('editorPartMultipleEditorGroups', false, localize('editorPartMultipleEditorGroups', "Whether there are multiple editor groups opened in an editor part"));
96 > export const EditorPartSingleEditorGroupsContext = EditorPartMultipleEditorGroupsContext.toNegated();
97 > export const EditorPartMaximizedEditorGroupContext = new RawContextKey<boolean>('editorPartMaximizedEditorGroup', false, localize('editorPartEditorGroupMaximized', "Editor Part has a maximized group"));
98 >
99 > export const EditorPartModalContext = new RawContextKey<boolean>('editorPartModal', false, localize('editorPartModal', "Whether focus is in a modal editor part"));
100 > export const EditorPartModalVisibleContext = new RawContextKey<boolean>('editorPartModalVisible', false, localize('editorPartModalVisible', "Whether a modal editor part is visible"));
101 > export const EditorPartModalMaximizedContext = new RawContextKey<boolean>('editorPartModalMaximized', false, localize('editorPartModalMaximized', "Whether the modal editor part is maximized"));
102 > export const EditorPartModalNavigationContext = new RawContextKey<boolean>('editorPartModalNavigation', false, localize('editorPartModalNavigation', "Whether the modal editor part has navigation context"));
103 > export const EditorPartModalSidebarContext = new RawContextKey<boolean>('editorPartModalSidebar', false, localize('editorPartModalSidebar', "Whether the modal editor part has a sidebar"));
104 > export const EditorPartModalSidebarVisibleContext = new RawContextKey<boolean>('editorPartModalSidebarVisible', false, localize('editorPartModalSidebarVisible', "Whether the modal editor part sidebar is visible"));
105 >
106 > // Editor Layout Context Keys
107 > export const EditorsVisibleContext = new RawContextKey<boolean>('editorIsOpen', false, localize('editorIsOpen', "Whether an editor is open"));
108 > export const EditorAreaFocusContext = new RawContextKey<boolean>('editorAreaFocus', false, localize('editorAreaFocus', "Whether the editor area (any editor part) has keyboard focus"));
109 > export const InEditorZenModeContext = new RawContextKey<boolean>('inZenMode', false, localize('inZenMode', "Whether Zen mode is enabled"));
110 > export const IsMainEditorCenteredLayoutContext = new RawContextKey<boolean>('isCenteredLayout', false, localize('isMainEditorCenteredLayout', "Whether centered layout is enabled for the main editor"));
111 > export const SplitEditorsVertically = new RawContextKey<boolean>('splitEditorsVertically', false, localize('splitEditorsVertically', "Whether editors split vertically"));
112 > export const MainEditorAreaVisibleContext = new RawContextKey<boolean>('mainEditorAreaVisible', true, localize('mainEditorAreaVisible', "Whether the editor area in the main window is visible"));
113 > export const EditorTabsVisibleContext = new RawContextKey<boolean>('editorTabsVisible', true, localize('editorTabsVisible', "Whether editor tabs are visible"));
114 >
115 > //#endregion
116 >
117 >
118 > //#region < --- Side Bar --- >
119 >
120 > export const SideBarVisibleContext = new RawContextKey<boolean>('sideBarVisible', false, localize('sideBarVisible', "Whether the sidebar is visible"));
121 > export const SidebarFocusContext = new RawContextKey<boolean>('sideBarFocus', false, localize('sideBarFocus', "Whether the sidebar has keyboard focus"));
122 > export const ActiveViewletContext = new RawContextKey<string>('activeViewlet', '', localize('activeViewlet', "The identifier of the active viewlet"));
123 >
124 > //#endregion
125 >
126 >
127 > //#region < --- Status Bar --- >
128 >
129 > export const StatusBarFocused = new RawContextKey<boolean>('statusBarFocused', false, localize('statusBarFocused', "Whether the status bar has keyboard focus"));
130 >
131 > //#endregion
132 >
133 > //#region < --- Title Bar --- >
134 >
135 > export const TitleBarStyleContext = new RawContextKey<string>('titleBarStyle', 'custom', localize('titleBarStyle', "Style of the window title bar"));
136 > export const TitleBarVisibleContext = new RawContextKey<boolean>('titleBarVisible', false, localize('titleBarVisible', "Whether the title bar is visible"));
137 > export const IsCompactTitleBarContext = new RawContextKey<boolean>('isCompactTitleBar', false, localize('isCompactTitleBar', "Title bar is in compact mode"));
138 >
139 > //#endregion
140 >
141 >
142 > //#region < --- Banner --- >
143 >
144 > export const BannerFocused = new RawContextKey<boolean>('bannerFocused', false, localize('bannerFocused', "Whether the banner has keyboard focus"));
145 >
146 > //#endregion
147 >
148 >
149 > //#region < --- Notifications --- >
150 >
151 > export const NotificationFocusedContext = new RawContextKey<boolean>('notificationFocus', true, localize('notificationFocus', "Whether a notification has keyboard focus"));
152 > export const NotificationsCenterVisibleContext = new RawContextKey<boolean>('notificationCenterVisible', false, localize('notificationCenterVisible', "Whether the notifications center is visible"));
153 > export const NotificationsToastsVisibleContext = new RawContextKey<boolean>('notificationToastsVisible', false, localize('notificationToastsVisible', "Whether a notification toast is visible"));
154 >
155 > //#endregion
156 >
157 >
158 > //#region < --- Auxiliary Bar --- >
159 >
160 > export const ActiveAuxiliaryContext = new RawContextKey<string>('activeAuxiliary', '', localize('activeAuxiliary', "The identifier of the active auxiliary panel"));
161 > export const AuxiliaryBarFocusContext = new RawContextKey<boolean>('auxiliaryBarFocus', false, localize('auxiliaryBarFocus', "Whether the auxiliary bar has keyboard focus"));
162 > export const AuxiliaryBarVisibleContext = new RawContextKey<boolean>('auxiliaryBarVisible', false, localize('auxiliaryBarVisible', "Whether the auxiliary bar is visible"));
163 > export const SecondarySideBarVisibleContext = new RawContextKey<boolean>('secondarySideBarVisible', false, localize('secondarySideBarVisible', "Whether the layout surface representing the secondary side bar is visible"));
164 > export const AuxiliaryBarMaximizedContext = new RawContextKey<boolean>('auxiliaryBarMaximized', false, localize('auxiliaryBarMaximized', "Whether the auxiliary bar is maximized"));
165 >
166 > //#endregion
167 >
168 >
169 > //#region < --- Panel --- >
170 >
171 > export const ActivePanelContext = new RawContextKey<string>('activePanel', '', localize('activePanel', "The identifier of the active panel"));
172 > export const PanelFocusContext = new RawContextKey<boolean>('panelFocus', false, localize('panelFocus', "Whether the panel has keyboard focus"));
173 > export const PanelPositionContext = new RawContextKey<string>('panelPosition', 'bottom', localize('panelPosition', "The position of the panel, always 'bottom'"));
174 > export const PanelAlignmentContext = new RawContextKey<string>('panelAlignment', 'center', localize('panelAlignment', "The alignment of the panel, either 'center', 'left', 'right' or 'justify'"));
175 > export const PanelVisibleContext = new RawContextKey<boolean>('panelVisible', false, localize('panelVisible', "Whether the panel is visible"));
176 > export const PanelMaximizedContext = new RawContextKey<boolean>('panelMaximized', false, localize('panelMaximized', "Whether the panel is maximized"));
177 >
178 > //#endregion
179 >
180 >
181 > //#region < --- Views --- >
182 >
183 > export const FocusedViewContext = new RawContextKey<string>('focusedView', '', localize('focusedView', "The identifier of the view that has keyboard focus"));
184 > export function getVisbileViewContextKey(viewId: string): string { return `view.${viewId}.visible`; }
185 >
186 > //#endregion
187 >
188 >
189 > //#region < --- Resources --- >
190 >
191 > abstract class AbstractResourceContextKey {
192 >
193 > // NOTE: DO NOT CHANGE THE DEFAULT VALUE TO ANYTHING BUT
194 > // UNDEFINED! IT IS IMPORTANT THAT DEFAULTS ARE INHERITED
195 > // FROM THE PARENT CONTEXT AND ONLY UNDEFINED DOES THIS
196 >
197 > static readonly Scheme = new RawContextKey<string>('resourceScheme', undefined, { type: 'string', description: localize('resourceScheme', "The scheme of the resource") });
198 > static readonly Filename = new RawContextKey<string>('resourceFilename', undefined, { type: 'string', description: localize('resourceFilename', "The file name of the resource") });
199 > static readonly Dirname = new RawContextKey<string>('resourceDirname', undefined, { type: 'string', description: localize('resourceDirname', "The folder name the resource is contained in") });
200 > static readonly Path = new RawContextKey<string>('resourcePath', undefined, { type: 'string', description: localize('resourcePath', "The full path of the resource") });
201 > static readonly LangId = new RawContextKey<string>('resourceLangId', undefined, { type: 'string', description: localize('resourceLangId', "The language identifier of the resource") });
202 > static readonly Resource = new RawContextKey<string>('resource', undefined, { type: 'URI', description: localize('resource', "The full value of the resource including scheme and path") });
203 > static readonly Extension = new RawContextKey<string>('resourceExtname', undefined, { type: 'string', description: localize('resourceExtname', "The extension name of the resource") });
204 > static readonly HasResource = new RawContextKey<boolean>('resourceSet', undefined, { type: 'boolean', description: localize('resourceSet', "Whether a resource is present or not") });
205 > static readonly IsFileSystemResource = new RawContextKey<boolean>('isFileSystemResource', undefined, { type: 'boolean', description: localize('isFileSystemResource', "Whether the resource is backed by a file system provider") });
206 >
207 > protected _value: URI | undefined;
208 > protected readonly _resourceKey: IContextKey<string | null>;
209 > protected readonly _schemeKey: IContextKey<string | null>;
210 > protected readonly _filenameKey: IContextKey<string | null>;
211 > protected readonly _dirnameKey: IContextKey<string | null>;
212 > protected readonly _pathKey: IContextKey<string | null>;
213 > protected readonly _langIdKey: IContextKey<string | null>;
214 > protected readonly _extensionKey: IContextKey<string | null>;
215 > protected readonly _hasResource: IContextKey<boolean>;
216 > protected readonly _isFileSystemResource: IContextKey<boolean>;
217 >
218 > constructor(
219 @IContextKeyService protected readonly _contextKeyService: IContextKeyService,
220 @IFileService protected readonly _fileService: IFileService,
232 this._isFileSystemResource = AbstractResourceContextKey.IsFileSystemResource.bindTo(this._contextKeyService);
233 }
235 > protected _setLangId(): void {
236 const value = this.get();
237 if (!value) {
242 this._langIdKey.set(langId);
243 }
245 > set(value: URI | null | undefined) {
246 value = value ?? undefined;
247 if (isEqual(this._value, value)) {
261 });
262 }
264 > protected uriToPath(uri: URI): string {
265 if (uri.scheme === Schemas.file) {
266 return uri.fsPath;
268 return uri.path;
269 }
271 > reset(): void {
272 this._value = undefined;
273 this._contextKeyService.bufferChangeEvents(() => {
283 });
284 }
286 > get(): URI | undefined {
287 return this._value;
288 }
289 > } contextkeys.ts
290 >
291 > export class ResourceContextKey extends AbstractResourceContextKey {
292 >
293 > private readonly _disposables = new DisposableStore();
294 >
295 > constructor(
296 @IContextKeyService contextKeyService: IContextKeyService,
297 @IFileService fileService: IFileService,
315 }));
316 }
318 > dispose(): void {
319 this._disposables.dispose();
320 }
321 > } contextkeys.ts
322 >
323 > /**
324 > * This is a version of ResourceContextKey that is not disposable and has no listeners for model change events.
325 > * It will configure itself for the state/presence of a model only when created and not update.
326 > */
327 > export class StaticResourceContextKey extends AbstractResourceContextKey { }
328 >
329 >
330 > //#endregion
331 >
332 > export function applyAvailableEditorIds(contextKey: IContextKey<string>, editor: EditorInput | undefined | null, editorResolverService: IEditorResolverService): void {
333 if (!editor) {
334 contextKey.set('');
339 contextKey.set(editors.join(','));
340 }
342 function getAvailableEditorIds(editor: EditorInput, editorResolverService: IEditorResolverService): string[] {
343 // Non text editor untitled files cannot be easily serialized between
src/vs/workbench/contrib/chat/common/chatSessionTypePreference.ts 19 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatSessionTypePreference.ts
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 { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
7 >
8 > export const CHAT_USER_SELECTED_SESSION_TYPE_STORAGE_KEY = 'chat.userSelectedSessionType';
9 > const CHAT_PREFERRED_COPILOT_HARNESS_STORAGE_KEY = 'chat.preferredCopilotHarness';
10 >
11 > export function getRememberedSessionType(storageService: IStorageService): string | undefined {
12 return storageService.get(CHAT_USER_SELECTED_SESSION_TYPE_STORAGE_KEY, StorageScope.PROFILE);
13 }
15 > export function storeUserSelectedSessionType(storageService: IStorageService, sessionType: string): void {
16 storageService.store(CHAT_USER_SELECTED_SESSION_TYPE_STORAGE_KEY, sessionType, StorageScope.PROFILE, StorageTarget.MACHINE);
17 }
19 > export function clearUserSelectedSessionType(storageService: IStorageService): void {
20 storageService.remove(CHAT_USER_SELECTED_SESSION_TYPE_STORAGE_KEY, StorageScope.PROFILE);
21 }
23 > export function hasPreferredCopilotHarness(storageService: IStorageService): boolean {
24 return storageService.getBoolean(CHAT_PREFERRED_COPILOT_HARNESS_STORAGE_KEY, StorageScope.PROFILE, false);
25 }
27 > export function markPreferredCopilotHarness(storageService: IStorageService): void {
28 storageService.store(CHAT_PREFERRED_COPILOT_HARNESS_STORAGE_KEY, true, StorageScope.PROFILE, StorageTarget.MACHINE);
29 }
src/vs/platform/contextkey/common/contextkey.ts 2 introduced LOC · 1 range

Open complete file

2015
2016 public toNegated(): ContextKeyExpression {
2017 > return this.negate(); contextkey.ts
2018 > }
2019
2020 public isEqualTo(value: any): ContextKeyExpression {