src/vs/workbench/contrib/chat/common/constants.ts

507 LOC · 478 covered · 29 uncovered · 68 ranges · 1733 concepts · 38 introducers · 961 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- constants.ts ×18
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 }
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) { constants.ts ×1
176 > case ChatDefaultPermissionLevel.Default:
177 > return ChatPermissionLevel.Default;
178 > case ChatDefaultPermissionLevel.Assisted:
179 > return ChatPermissionLevel.Assisted;
180 > case ChatDefaultPermissionLevel.AllowAll:
181 > case ChatPermissionLevel.AutoApprove:
182 > return ChatPermissionLevel.AutoApprove;
183 > default:
184 > return undefined;
185 > }
186 > }
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 }
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 }
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;
244 case 'terminal': return ChatAgentLocation.Terminal;
245 case 'notebook': return ChatAgentLocation.Notebook;
246 case 'editor': return ChatAgentLocation.EditorInline;
247 }
248 return ChatAgentLocation.Chat;
249 }
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
270 // Exclude schemes we always know are bad
271 if (chatAlwaysUnsupportedFileSchemes.has(scheme)) {
272 return false;
273 }
274
275 // Plus any schemes used by content providers
276 if (chatService.getContentProviderSchemes().includes(scheme)) {
277 return false;
278 }
279
280 // Everything else is supported
281 return true;
282 }
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, constants.ts ×3
295 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
296 > workspace: IWorkspace,
297 > agentHostEnabled: boolean
298 > ): string {
299 > if (isVirtualWorkspace(workspace)) {
300 > return localChatSessionType; constants.ts ×1
301 > }
303 > if (agentHostEnabled && configurationService.getValue<boolean>(ChatConfiguration.DefaultToCopilotHarness)) { constants.ts ×3
304 > return SessionType.AgentHostCopilot; constants.ts ×1
305 > }
307 > if (isEditorLocalAgentEnabled(configurationService, workspace)) {
308 > return localChatSessionType; constants.ts ×1
309 > }
311 > return getVisibleNonLocalEditorChatSessionTypes(configurationService, chatSessionsService, workspace)[0] ?? localChatSessionType;
314 > export function getComputedDefaultSessionResource(
315 > configurationService: IConfigurationService, constants.ts ×2
316 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
317 > workspace: IWorkspace,
318 > agentHostEnabled: boolean
319 > ): URI {
320 > const defaultType = getComputedDefaultSessionType(configurationService, chatSessionsService, workspace, agentHostEnabled);
321 > return defaultType === localChatSessionType
322 > ? LocalChatSessionUri.getNewSessionUri()
323 > : URI.from({ scheme: defaultType, path: `/untitled-${generateUuid()}` });
324 > }
326 > export function isRememberedSessionTypeUsable(
327 > sessionType: string, constants.ts ×1
328 > configurationService: IConfigurationService,
329 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
330 > workspace: IWorkspace
331 > ): boolean {
332 > if (sessionType === localChatSessionType) {
333 > return isEditorLocalAgentEnabled(configurationService, workspace); constants.ts ×1
334 > }
335 > if (isAgentHostTarget(sessionType)) { constants.ts ×1
336 > return true;
337 > }
338 > return !!chatSessionsService.getChatSessionContribution(sessionType); constants.ts ×1
339 > }
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, constants.ts ×2
360 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
361 > storageService: IStorageService,
362 > workspace: IWorkspace,
363 > agentHostEnabled: boolean,
364 > options?: IDefaultNewChatSessionTypeOptions
365 > ): string {
366 > if (options?.explicitOverride) {
367 > return options.explicitOverride; constants.ts ×1
368 > }
370 > const remembered = getUsableRememberedSessionType(storageService, configurationService, chatSessionsService, workspace);
371 > if (remembered) {
372 > return remembered; constants.ts ×1
373 > }
375 > if (options?.currentSessionType) { constants.ts ×2
376 > return options.currentSessionType; constants.ts ×1
377 > }
379 > return getComputedDefaultSessionType(configurationService, chatSessionsService, workspace, agentHostEnabled);
380 > }
382 > export function resolveDefaultNewChatSessionType(
383 > configurationService: IConfigurationService, constants.ts ×4
384 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
385 > storageService: IStorageService,
386 > workspace: IWorkspace,
387 > agentHostEnabled: boolean,
388 > options?: IDefaultNewChatSessionTypeOptions
389 > ): IResolvedNewChatSessionType {
390 > if (options?.explicitOverride) {
391 > return { sessionType: options.explicitOverride, isPreferCopilotHarnessSwap: false }; constants.ts ×1
392 > }
394 > const remembered = getUsableRememberedSessionType(storageService, configurationService, chatSessionsService, workspace);
395 > if (remembered && remembered !== localChatSessionType) { constants.ts ×4
396 > return { sessionType: remembered, isPreferCopilotHarnessSwap: false }; constants.ts ×1
397 > }
399 > // One-time migration: when the agent host is enabled and the user has opted
400 > // in via `chat.editor.preferCopilotHarness`, swap an existing local editor
401 > // session to Copilot exactly once (guarded by the persisted marker). Never
402 > // swap when the agent host is disabled, since the Copilot harness would be
403 > // unavailable. This function does not persist the marker itself; the caller
404 > // marks it only after applying the swap, so a caller that discards the
405 > // result does not consume the one-time migration.
406 > if (options?.currentSessionType === localChatSessionType constants.ts ×4
407 > && agentHostEnabled constants.ts ×2
408 > && configurationService.getValue<boolean>(ChatConfiguration.EditorPreferCopilotHarness) constants.ts ×1
409 > && !hasPreferredCopilotHarness(storageService)) { constants.ts ×4
410 > return { sessionType: SessionType.AgentHostCopilot, isPreferCopilotHarnessSwap: true }; constants.ts ×1
411 > }
413 > return { sessionType: getDefaultNewChatSessionType(configurationService, chatSessionsService, storageService, workspace, agentHostEnabled, options), isPreferCopilotHarnessSwap: false };
414 > }
416 > function getUsableRememberedSessionType( constants.ts ×1
417 > storageService: IStorageService,
418 > configurationService: IConfigurationService,
419 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
420 > workspace: IWorkspace
421 > ): string | undefined {
422 > const remembered = getRememberedSessionType(storageService);
423 > return remembered && isRememberedSessionTypeUsable(remembered, configurationService, chatSessionsService, workspace) ? remembered : undefined;
424 > }
426 > export function getDefaultNewChatSessionResource(
427 > configurationService: IConfigurationService, constants.ts ×2
428 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
429 > storageService: IStorageService,
430 > workspace: IWorkspace,
431 > agentHostEnabled: boolean,
432 > options?: IDefaultNewChatSessionTypeOptions
433 > ): URI {
434 > const defaultType = getDefaultNewChatSessionType(configurationService, chatSessionsService, storageService, workspace, agentHostEnabled, options);
435 > return defaultType === localChatSessionType
436 > ? LocalChatSessionUri.getNewSessionUri()
437 > : URI.from({ scheme: defaultType, path: `/untitled-${generateUuid()}` });
438 > }
440 > export function recordUserSelectedSessionType(
441 > storageService: IStorageService, constants.ts ×2
442 > configurationService: IConfigurationService,
443 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
444 > workspace: IWorkspace,
445 > sessionType: string,
446 > agentHostEnabled: boolean
447 > ): void {
448 > if (sessionType === getComputedDefaultSessionType(configurationService, chatSessionsService, workspace, agentHostEnabled)) {
449 > clearUserSelectedSessionType(storageService); chatSessionTypePreference.ts ×1
450 > } else { constants.ts ×2
451 > storeUserSelectedSessionType(storageService, sessionType);
452 > }
453 > }
455 > export function isEditorLocalAgentEnabled(configurationService: IConfigurationService, workspace: IWorkspace): boolean {
456 > return isVirtualWorkspace(workspace) || (configurationService.getValue<boolean>(ChatConfiguration.EditorLocalAgentEnabled) ?? true); constants.ts ×1
457 > }
459 > export function isVisibleEditorChatSessionType(
460 > sessionType: string, constants.ts ×2
461 > configurationService: IConfigurationService,
462 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
463 > workspace: IWorkspace
464 > ): boolean {
465 > if (sessionType === localChatSessionType) {
466 > return isEditorLocalAgentEnabled(configurationService, workspace) || getVisibleNonLocalEditorChatSessionTypes(configurationService, chatSessionsService, workspace).length === 0; constants.ts ×1
467 > }
469 > if (sessionType === SessionType.CopilotCLI && configurationService.getValue<boolean>(ChatConfiguration.CopilotCliHideExtensionHostEditor)) { constants.ts ×2
470 > return false; constants.ts ×1
471 > }
473 > return !!chatSessionsService.getChatSessionContribution(sessionType);
474 > }
476 > function getVisibleNonLocalEditorChatSessionTypes( constants.ts ×2
477 > configurationService: IConfigurationService,
478 > chatSessionsService: Pick<IChatSessionsService, 'getChatSessionContribution' | 'getAllChatSessionContributions'>,
479 > workspace: IWorkspace
480 > ): string[] {
481 > const sessionTypes = new Set<string>();
482 > for (const contribution of chatSessionsService.getAllChatSessionContributions()) {
483 > if (contribution.type !== localChatSessionType && isVisibleEditorChatSessionType(contribution.type, configurationService, chatSessionsService, workspace)) { constants.ts ×3
484 > sessionTypes.add(contribution.type);
485 > }
486 > }
487 > return Array.from(sessionTypes); constants.ts ×2
488 > }
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);