chatPermissionWarnings.ts ×4

Frontier kind: Code frontier

unlabeled · c_49ffc53bb18b

6 tests · 23880 LOC · 129 files · introduces 0 tests · 92 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges92 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2627 ranges23880 lines · 129 files · Browse complete extent
All tests (intent)
6 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.

2 files ranked by introduced lines: 92 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/chatPermissionWarnings.ts 82 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatPermissionWarnings.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 { Codicon } from '../../../../base/common/codicons.js';
7 > import { MarkdownString } from '../../../../base/common/htmlContent.js';
8 > import Severity from '../../../../base/common/severity.js';
9 > import { ThemeIcon } from '../../../../base/common/themables.js';
10 > import { localize } from '../../../../nls.js';
11 > import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
12 > import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
13 > import { ASSISTED_APPROVAL_DONT_SHOW_AGAIN_KEY, AUTO_APPROVE_DONT_SHOW_AGAIN_KEY, AUTOPILOT_DONT_SHOW_AGAIN_KEY } from './chatPermissionStorageKeys.js';
14 > import { ChatConfiguration, ChatPermissionLevel } from './constants.js';
15 >
16 > /**
17 > * In-memory record of warnings already accepted in this VS Code session.
18 > * Checked alongside the persisted "Don't show again" storage value so that the
19 > * warning isn't repeated within a session even when the user didn't tick the
20 > * checkbox.
21 > *
22 > * Per-renderer; the `StorageScope.PROFILE` storage entry is what synchronizes
23 > * the dismissed state across windows (workbench and Agents).
24 > */
25 > const shownWarnings = new Set<ChatPermissionLevel>();
26 >
27 function dontShowAgainKey(level: ChatPermissionLevel): string | undefined {
28 if (level === ChatPermissionLevel.Autopilot) {
37 return undefined;
38 }
40 > /**
41 > * Clears the in-process suppression set so that previously accepted (but not
42 > * persistently dismissed) warnings will be shown again within this session.
43 > * Call this alongside removing the persisted storage keys when implementing a
44 > * "reset" developer action.
45 > */
46 > export function resetShownWarnings(): void {
47 > shownWarnings.clear();
48 > }
49 >
50 > /**
51 > * Relative "auto-approval reach" of each elevated level, used to suppress
52 > * lower-level warnings once a stronger one has been accepted. Bypass Approvals
53 > * and Autopilot both auto-approve *every* tool call, so confirming either in
54 > * this session (or persistently) implies acceptance of the other — the user is
55 > * not warned again when stepping between them (e.g. Autopilot → Bypass).
56 > */
57 > const ELEVATION_RANK: ReadonlyMap<ChatPermissionLevel, number> = new Map([
58 > [ChatPermissionLevel.Assisted, 1],
59 > [ChatPermissionLevel.AutoApprove, 2],
60 > [ChatPermissionLevel.Autopilot, 2],
61 > ]);
62 >
63 > export function hasShownElevatedWarning(level: ChatPermissionLevel, storageService: IStorageService): boolean {
64 > const rank = ELEVATION_RANK.get(level);
65 > if (rank === undefined) {
66 return false;
67 }
82 return false;
83 }
85 > interface IElevatedWarningCopy {
86 > readonly title: string;
87 > readonly confirm: string;
88 > readonly icon: ThemeIcon;
89 > readonly detail: string;
90 > }
91 >
92 function getElevatedWarningCopy(level: ChatPermissionLevel, defaultSettingKey: string, levelLabel?: string): IElevatedWarningCopy | undefined {
93 switch (level) {
119 }
120 }
122 > /**
123 > * If `level` is an elevated permission level (Bypass Approvals or Autopilot)
124 > * that hasn't already been confirmed in this session or persistently
125 > * dismissed, show the corresponding warning dialog. Returns:
126 > *
127 > * - `true` if the level is not elevated, has already been confirmed, or the
128 > * user accepts the dialog. In these cases the caller should proceed to apply
129 > * the level.
130 > * - `false` if the user cancels the dialog. The caller should abort the
131 > * permission change.
132 > *
133 > * When the user ticks "Don't show again", the choice is persisted in
134 > * `StorageScope.PROFILE`, which is shared across the workbench and Agents
135 > * windows so a dismissal in one applies to the other.
136 > *
137 > * `options.defaultSettingKey` controls which "make this the default" setting
138 > * the dialog links to — local chat uses `chat.permissions.default` (the
139 > * default), while agent-host sessions pass
140 > * `chat.defaultConfiguration`.
141 > */
142 export async function maybeConfirmElevatedPermissionLevel(
143 level: ChatPermissionLevel,
src/vs/workbench/contrib/chat/common/chatPermissionStorageKeys.ts 10 introduced LOC · 1 range

Open complete file

1 > /*--------------------------------------------------------------------------------------------- chatPermissionStorageKeys.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 > // Storage keys for persisting the user's choice to skip the warning dialog
7 > // across sessions when "Don't show again" is checked.
8 > export const AUTOPILOT_DONT_SHOW_AGAIN_KEY = 'chat.permissions.autopilot.dontShowWarningAgain';
9 > export const AUTO_APPROVE_DONT_SHOW_AGAIN_KEY = 'chat.permissions.autoApprove.dontShowWarningAgain';
10 > export const ASSISTED_APPROVAL_DONT_SHOW_AGAIN_KEY = 'chat.permissions.assisted.dontShowWarningAgain';