fileManagedSettingsIpc.ts ×7

Frontier kind: Code frontier

unlabeled · c_b52a4b2c6207

16 tests · 12423 LOC · 63 files · introduces 0 tests · 95 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges95 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1733 ranges12423 lines · 63 files · Browse complete extent
All tests (intent)
16 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: 95 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/policy/common/fileManagedSettingsIpc.ts 49 introduced LOC · 7 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- fileManagedSettingsIpc.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 { Emitter, Event } from '../../../base/common/event.js';
7 > import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js';
8 > import { equals } from '../../../base/common/objects.js';
9 > import { ManagedSettingsData } from '../../../base/common/policy.js';
10 > import { IChannel, IServerChannel } from '../../../base/parts/ipc/common/ipc.js';
11 > import { IFileManagedSettingsService, RawManagedSettingsData } from './copilotManagedSettings.js';
12 >
13 > export class FileManagedSettingsChannel implements IServerChannel {
14 >
15 > private readonly disposables = new DisposableStore();
16 >
17 > constructor(private readonly service: IFileManagedSettingsService) { }
18 >
19 > listen<T>(_: unknown, event: string): Event<T> {
20 switch (event) {
21 case 'onDidChangeRawManagedSettings': return this.service.onDidChangeRawManagedSettings as Event<T>;
25 throw new Error(`Event not found: ${event}`);
26 }
28 > call<T>(_: unknown, command: string): Promise<T> {
29 switch (command) {
30 case 'getRawManagedSettings': return Promise.resolve(this.service.rawManagedSettings as T);
34 throw new Error(`Call not found: ${command}`);
35 }
37 > dispose(): void {
38 this.disposables.dispose();
39 }
41 >
42 > export class FileManagedSettingsChannelClient extends Disposable implements IFileManagedSettingsService {
43 >
44 > readonly _serviceBrand: undefined;
45 >
46 > private _rawManagedSettings: RawManagedSettingsData = {};
47 > get rawManagedSettings(): RawManagedSettingsData { return this._rawManagedSettings; }
48 > private hasReceivedRawManagedSettings = false;
49 >
50 > private _managedSettings: ManagedSettingsData = {};
51 > get managedSettings(): ManagedSettingsData { return this._managedSettings; }
52 > private hasReceivedManagedSettings = false;
53 >
54 > private readonly _onDidChangeRawManagedSettings = this._register(new Emitter<RawManagedSettingsData>());
55 > readonly onDidChangeRawManagedSettings = this._onDidChangeRawManagedSettings.event;
56 >
57 > private readonly _onDidChangeManagedSettings = this._register(new Emitter<ManagedSettingsData>());
58 > readonly onDidChangeManagedSettings = this._onDidChangeManagedSettings.event;
59 >
60 > constructor(channel: IChannel) {
61 super();
62 this._register(channel.listen<RawManagedSettingsData>('onDidChangeRawManagedSettings')(managedSettings => this.updateRawManagedSettings(managedSettings, true)));
73 });
74 }
76 > private updateRawManagedSettings(managedSettings: RawManagedSettingsData, fireEvent: boolean): void {
77 this.hasReceivedRawManagedSettings = true;
78 if (equals(this._rawManagedSettings, managedSettings)) {
85 }
86 }
88 > private updateManagedSettings(managedSettings: ManagedSettingsData, fireEvent: boolean): void {
89 this.hasReceivedManagedSettings = true;
90 if (equals(this._managedSettings, managedSettings)) {
src/vs/platform/policy/common/fileManagedSettingsService.ts 46 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- fileManagedSettingsService.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 { ThrottledDelayer } from '../../../base/common/async.js';
7 > import { Emitter, Event } from '../../../base/common/event.js';
8 > import { Disposable } from '../../../base/common/lifecycle.js';
9 > import { equals } from '../../../base/common/objects.js';
10 > import { ManagedSettingsData } from '../../../base/common/policy.js';
11 > import { isObject } from '../../../base/common/types.js';
12 > import { URI } from '../../../base/common/uri.js';
13 > import { FileOperationError, FileOperationResult, IFileService } from '../../files/common/files.js';
14 > import { ILogService } from '../../log/common/log.js';
15 > import { IFileManagedSettingsService, normalizeManagedSettings, RawManagedSettingsData } from './copilotManagedSettings.js';
16 >
17 > /**
18 > * Upper bound on the size of `managed-settings.json` we will read into the main process. A
19 > * legitimate settings file is a few KB; capping the read keeps a malformed or hostile file on the
20 > * (externally writable, privileged) well-known path from OOM-ing the main process. `readFile`
21 > * throws `FILE_TOO_LARGE` past this, which `refresh()` treats like any other read failure.
22 > */
23 > const MANAGED_SETTINGS_MAX_FILE_SIZE = 1024 * 1024; // 1 MB
24 >
25 > export class FileManagedSettingsService extends Disposable implements IFileManagedSettingsService {
26 >
27 > readonly _serviceBrand: undefined;
28 >
29 > private _rawManagedSettings: RawManagedSettingsData = {};
30 > get rawManagedSettings(): RawManagedSettingsData { return this._rawManagedSettings; }
31 >
32 > private _managedSettings: ManagedSettingsData = {};
33 > get managedSettings(): ManagedSettingsData { return this._managedSettings; }
34 >
35 > private readonly _onDidChangeRawManagedSettings = this._register(new Emitter<RawManagedSettingsData>());
36 > readonly onDidChangeRawManagedSettings = this._onDidChangeRawManagedSettings.event;
37 >
38 > private readonly _onDidChangeManagedSettings = this._register(new Emitter<ManagedSettingsData>());
39 > readonly onDidChangeManagedSettings = this._onDidChangeManagedSettings.event;
40 >
41 > private readonly throttledDelayer = this._register(new ThrottledDelayer(500));
42 >
43 > constructor(
44 private readonly file: URI,
45 @IFileService private readonly fileService: IFileService,
57 this.throttledDelayer.trigger(() => this.refresh(), 0);
58 }
60 > private async refresh(): Promise<void> {
61 const previousRaw = this._rawManagedSettings;
62 const previous = this._managedSettings;