Files
vscode/src/vs/platform/agentHost/test/node/agentHostManagedSettingsService.test.ts
T
joshspicerandCopilot 4d0ab006bd agentHost: bridge legacy settings to managed permissions (#330349)
* agentHost: bridge legacy settings to managed permissions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: apply managed settings with extension methods disabled

Treat the typed managed-settings notification independently from generic extension requests, and cover the local host configuration. Initialize the Copilot managed-settings snapshot in the constructor to satisfy class-field ordering checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: isolate managed settings bridge plumbing

Send managed permissions before fresh-connect restoration and assert that wire order. Inject the dedicated managed-settings service into the protocol handler so the provider-neutral agent service no longer exposes Copilot SDK types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: keep managed permission types host-owned

Use a restrictive host DTO across common and browser layers so Copilot SDK Node globals do not pollute Monaco compilation. Cover the exact local apply and clear notifications, and correct the AHP notification terminology.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: clean managed settings on handler disposal

Remove every handler-owned client's managed permission contribution before disposing active connections or disconnect-grace timers, preventing stale restrictions when an endpoint handler is replaced.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: scope managed settings by protocol handler

Namespace managed permission contributions per ProtocolServerHandler so handler-local client IDs cannot collide in the shared aggregate. Preserve same-handler reconnect identity and cover cross-handler cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-12 00:13:36 +00:00

55 lines
2.0 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import assert from 'assert';
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';
import { AgentHostManagedSettingsService } from '../../node/agentHostManagedSettingsService.js';
suite('AgentHostManagedSettingsService', () => {
const store = ensureNoDisposablesAreLeakedInTestSuite();
test('aggregates restrictive client contributions and removes them by owner', () => {
const service = store.add(new AgentHostManagedSettingsService());
service.setClientPermissions('client-1', { disableBypassPermissionsMode: 'disable' });
service.setClientPermissions('client-2', { ask: ['Shell'], deny: ['Write(**)'] });
const combined = service.permissions;
service.removeClientPermissions('client-1');
const afterFirstRemoval = service.permissions;
service.removeClientPermissions('client-2');
assert.deepStrictEqual({
combined,
afterFirstRemoval,
afterAllRemoved: service.permissions,
}, {
combined: {
disableBypassPermissionsMode: 'disable',
ask: ['Shell'],
deny: ['Write(**)'],
},
afterFirstRemoval: {
ask: ['Shell'],
deny: ['Write(**)'],
},
afterAllRemoved: {},
});
});
test('only fires when the effective aggregate changes', () => {
const service = store.add(new AgentHostManagedSettingsService());
let changes = 0;
store.add(service.onDidChange(() => changes++));
service.setClientPermissions('client-1', { ask: ['Shell'] });
service.setClientPermissions('client-2', { ask: ['Shell'] });
service.removeClientPermissions('client-1');
service.removeClientPermissions('client-2');
assert.strictEqual(changes, 2);
});
});