aiCustomization: make plugin/extension/builtin files read-only (#302592)

* aiCustomization: make plugin/extension/builtin files read-only

- Open plugin, extension, and built-in customization files as read-only
  in the editor, with a message explaining they cannot be edited.
- Extract isReadonlyStorage() helper to DRY the repeated storage type
  check used in both the open and delete actions.

Fixes https://github.com/microsoft/vscode/issues/301292

(Commit message generated by Copilot)

* pr comments
This commit is contained in:
Connor Peet
2026-03-18 08:32:20 -07:00
committed by GitHub
parent 055de422e4
commit e32215ecaf

View File

@@ -44,6 +44,8 @@ import { Schemas } from '../../../../../base/common/network.js';
import { isWindows, isMacintosh } from '../../../../../base/common/platform.js';
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js';
import { IClipboardService } from '../../../../../platform/clipboard/common/clipboardService.js';
import { getCodeEditor } from '../../../../../editor/browser/editorBrowser.js';
import { MarkdownString } from '../../../../../base/common/htmlContent.js';
import { IAgentPluginService } from '../../common/plugins/agentPluginService.js';
//#region Telemetry
@@ -164,9 +166,19 @@ registerAction2(class extends Action2 {
}
async run(accessor: ServicesAccessor, context: AICustomizationContext): Promise<void> {
const editorService = accessor.get(IEditorService);
await editorService.openEditor({
const storage = extractStorage(context);
const editorPane = await editorService.openEditor({
resource: extractURI(context)
});
const codeEditor = getCodeEditor(editorPane?.getControl());
if (codeEditor && (storage === PromptsStorage.extension || storage === PromptsStorage.plugin)) {
codeEditor.updateOptions({
readOnly: true,
readOnlyMessage: new MarkdownString(localize('readonlyPluginFile', "This file is provided by a plugin or extension and cannot be edited.")),
});
}
}
});