feat: File operation auto-approve with glob pattern rules (Auto-approve Part 3)#216
Open
xinyi-gong wants to merge 3 commits into
Open
feat: File operation auto-approve with glob pattern rules (Auto-approve Part 3)#216xinyi-gong wants to merge 3 commits into
xinyi-gong wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds configurable auto-approve support for Agent Mode file operations (read/write/edit) using glob-pattern allow/deny rules, with CLS-synced defaults and preference UI integration—extending the existing confirmation/auto-approve framework beyond terminal commands.
Changes:
- Introduces file-operation auto-approve rule model + CLS protocol/API for fetching default file safety rules.
- Implements file-operation confirmation handling (attached-files/session cache/outside-workspace/rules/unmatched fallback) and wires it into
ConfirmationService. - Adds preferences UI to manage file-operation rules and sync them to CLS; updates chat to stage/flush attached files by conversation.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/messages.properties | Adds NLS strings for file-operation auto-approve preference UI. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/Messages.java | Exposes new preference NLS keys as public static String fields. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/LanguageServerSettingManager.java | Syncs file-operation auto-approve rules + unmatched toggle into CLS settings. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/FileOperationAutoApproveSection.java | New preference section for viewing/editing file-operation glob rules and CLS defaults. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/CopilotPreferenceInitializer.java | Seeds default file-operation rule JSON and unmatched default. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AutoApprovePreferencePage.java | Hosts both terminal and file-operation auto-approve sections and persists them. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AddFileOperationRuleDialog.java | New dialog for adding file-operation rules (pattern/description/allow-deny). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/AgentToolService.java | Adds AttachedFileRegistry and passes it into ConfirmationService. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/messages.properties | Adds file-operation confirmation dialog titles/messages and session actions. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/Messages.java | Exposes new chat confirmation NLS keys. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/FileOperationConfirmationHandler.java | New handler implementing rule evaluation + session/global decisions for file ops. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/ConfirmationService.java | Registers file-operation handler for FILE_READ/FILE_WRITE/FILE_OPERATION categories. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/AttachedFileRegistry.java | New registry to track user-attached files (pending + per-conversation). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java | Stages pending attached files before send and flushes them once conversationId is known. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/preferences/LanguageServerSettingManagerTests.java | Updates expected settings initialization for tools edit/terminal auto-approve maps. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/TerminalConfirmationHandlerTests.java | Adjusts Mockito strictness configuration for tests. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/FileOperationConfirmationHandlerTests.java | Adds unit tests covering file-operation confirmation evaluation paths. |
| com.microsoft.copilot.eclipse.swtbot.test/test-plans/file-operation-auto-approve/file-operation-auto-approve.md | Adds E2E manual test plan for file-operation auto-approve feature. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/GetDefaultFileSafetyRulesResult.java | New protocol type for CLS default file safety rules response. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/FileSafetyRuleInfo.java | New protocol type representing a CLS file safety rule. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotAgentSettings.java | Extends agent settings with unmatched file-op flag and tools.edit auto-approve rules. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServerConnection.java | Adds getDefaultFileSafetyRules() wrapper method. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServer.java | Adds JSON-RPC request getDefaultFileSafetyRules. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/Constants.java | Adds preference keys for file-operation rule JSON + unmatched toggle. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/FileOperationAutoApproveRule.java | Adds rule model for pattern/description/allow-deny, including default-rule marker. |
Comments suppressed due to low confidence (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AddFileOperationRuleDialog.java:72
- The description placeholder text is hardcoded ("Optional description"). For consistency/localization, externalize this string into
messages.properties/Messages(similar toAddTerminalRuleDialog).
Label descLabel = new Label(container, SWT.NONE);
descLabel.setText(
Messages.preferences_page_file_op_auto_approve_add_dialog_description);
descriptionText = new Text(container, SWT.BORDER);
descriptionText.setMessage("Optional description");
descriptionText.setLayoutData(
new GridData(SWT.FILL, SWT.CENTER, true, false));
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds file-operation (read/write) auto-approve support to the confirmation framework, allowing users to configure glob-pattern rules that automatically approve or deny file access requests from Agent Mode.
This is Auto-approve Part 3, building on the terminal auto-approve shipped in Part 2.
Changes
Core
FileOperationAutoApproveRule— Data model for glob pattern → allow/deny rulesFileSafetyRuleInfo/GetDefaultFileSafetyRulesResult— LSP protocol types for fetching default rules from CLSCopilotLanguageServer/CopilotLanguageServerConnection— AddedgetDefaultFileSafetyRulesJSON-RPC methodCopilotAgentSettings— AddedautoApproveUnmatchedFileOpfield,EditSettingsinner class withequals/hashCode/toString(also added toToolsSettingsandTerminalSettings)Constants— AddedAUTO_APPROVE_FILE_OP_RULESandAUTO_APPROVE_UNMATCHED_FILE_OPConfirmation Handler
FileOperationConfirmationHandler— Evaluates file confirmation requests with this priority:AttachedFileRegistry— Tracks user-attached context files with pending/flush lifecycle for conversation ID timingConfirmationService— Registers handler forFILE_READ,FILE_WRITE,FILE_OPERATIONcategoriesPreferences UI
FileOperationAutoApproveSection— Rule table with add/remove/toggle/reset, fetches CLS defaults asyncAddFileOperationRuleDialog— Dialog for adding glob patterns with allow/deny selectionAutoApprovePreferencePage— Now hosts both terminal and file operation sectionsCopilotPreferenceInitializer— Added file-operation rule defaultsLanguageServerSettingManager— Syncs file-operation rules and unmatched setting to CLSChatView Integration
AttachedFileRegistrybefore sending messagesTests
FileOperationConfirmationHandlerTests— 42 unit tests covering all evaluation pathsLanguageServerSettingManagerTests— Updated expected params to account for tools initializationtest-plans/file-operation-auto-approve/— 9 E2E test casesPreference Page:

Resets to Default:

Add Rule:

Allow dialog for files under workspace:

Allow dialog for outside-of-workspace files:
