feat - support auto approve (#255)#25
Conversation
* feat - LSP data layer + confirmationService skeleton (Auto-approve Part 1 ) (microsoft#132) * feat: Terminal auto-approve with confirmation dialog enhancement (Auto-approve Part 2) (microsoft#171) * revert splitDropdownButton padding change (microsoft#184) * feat: File operation auto-approve with glob pattern rules (Auto-approve Part 3) (microsoft#216) * add file operation approve logic * resolve comments * change default rules color * resolve comments * update test cases * feat: MCP tool auto-approve and global auto-approve (Auto-approve Part 4) (microsoft#218) * add mcp approve support and global approve support * resolve comments * fix test cases * resolve comments and add token/policy check * fix compile error * Fix auto-approve preference page layout instability * fix copilot comments
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end “Tool Auto Approve” support across the Eclipse UI, introducing a centralized confirmation/auto-approval system (terminal, file operations, MCP tools, and global “YOLO” mode) and syncing relevant rule configuration into CLS agent settings.
Changes:
- Adds a new Tool Auto Approve preference page with sections for terminal rules, file-operation rules, MCP approval, and global auto-approve.
- Introduces a ConfirmationService + per-tool confirmation handlers (Terminal/File/MCP/Fallback) to evaluate auto-approval, render richer confirmation UI actions, and cache/persist decisions.
- Extends CLS protocol/settings plumbing (tool annotations + metadata, default file safety rules request, and agent settings fields) and updates settings sync/tests accordingly.
Reviewed changes
Copilot reviewed 62 out of 62 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/utils/PreferencesUtils.java | Adds AutoApprove preference page ID to the known preference pages list. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/SplitDropdownButton.java | Renames/relocates the split dropdown button and adds configurable separator color. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/TerminalAutoApproveSection.java | New preference UI section for terminal allow/deny rules and unmatched toggle. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/messages.properties | Adds shared auto-approve UI strings and section-specific labels/messages. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/Messages.java | Adds NLS bindings for new auto-approve preference strings. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/McpAutoApproveSection.java | New preference UI section for MCP tool/server approvals and trust annotations toggle. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/LanguageServerSettingManager.java | Syncs auto-approve preferences into CLS agent settings (maps + unmatched toggles). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/GlobalAutoApproveSection.java | New preference UI section for global “YOLO” auto-approve with warning confirmation. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/FileOperationAutoApproveSection.java | New preference UI section for file-operation rules, defaults loading/merge, and unmatched toggle. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/CopilotPreferencesPage.java | Adds a preference link entry to the new Tool Auto Approve page. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/CopilotPreferenceInitializer.java | Adds default preference values for auto-approve rules/toggles. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AutoApprovePreferencePage.java | New preference page composing all auto-approve sections and MCP binding lifecycle. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AddTerminalRuleDialog.java | Dialog for adding a terminal rule (command/regex + allow/deny). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/AddFileOperationRuleDialog.java | Dialog for adding a file-operation rule (glob + description + allow/deny). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/dialogs/mcp/McpServerItem.java | Updates MCP server install UI to use SplitDropdownButton. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/McpConfigService.java | Adds binding support to feed server/tool collections into MCP auto-approve UI. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/AgentToolService.java | Integrates ConfirmationService evaluation + decision caching into tool confirmation flow. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/messages.properties | Adds confirmation dialog action labels and titles/messages for new flows. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/Messages.java | Adds NLS bindings for new chat confirmation strings. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/InvokeToolConfirmationDialog.java | Refactors confirmation dialog rendering to be driven by ConfirmationContent/actions with dropdown. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/TerminalConfirmationHandler.java | New terminal auto-approval evaluator + session/global caching and action construction. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/McpConfirmationHandler.java | New MCP tool/server auto-approval evaluator + trust-annotations support. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/FileOperationConfirmationHandler.java | New file-operation evaluator (workspace/outside-workspace rules, session/global decisions, attached-files). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/FallbackConfirmationHandler.java | New catch-all confirmation handler (Allow Once / Skip). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/ConfirmationService.java | New central dispatcher for tool confirmation classification/evaluation and caching delegation. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/ConfirmationHandler.java | New UI-side handler contract + shared helpers (tool type extraction, session eviction). |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/AttachedFileRegistry.java | New registry to auto-approve operations on user-attached context files across conversation lifecycle. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java | Stages/flushed attached files into registry around conversation creation/continuation. |
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/BaseTurnWidget.java | Updates confirmation request API to accept ConfirmationContent; exposes current dialog reference. |
| com.microsoft.copilot.eclipse.ui/plugin.xml | Registers the new Tool Auto Approve preference page. |
| com.microsoft.copilot.eclipse.ui/plugin.properties | Adds display name for the new preference page; fixes formatting. |
| com.microsoft.copilot.eclipse.ui/META-INF/MANIFEST.MF | Exports the new confirmation package for UI tests (friends). |
| com.microsoft.copilot.eclipse.ui/css/light.css | Updates CSS selector for command panel inside ScrolledComposite. |
| com.microsoft.copilot.eclipse.ui/css/dark.css | Updates CSS selector for command panel inside ScrolledComposite. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/preferences/LanguageServerSettingManagerTests.java | Updates expected settings for new terminal/edit autoApprove maps; relaxes Mockito strictness. |
| com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/confirmation/McpConfirmationHandlerTests.java | Adds unit tests for MCP auto-approve logic and persistence behaviors. |
| com.microsoft.copilot.eclipse.swtbot.test/test-plans/mcp-auto-approve/mcp-auto-approve.md | Adds manual SWTBot-style test plan for MCP auto-approve end-to-end scenarios. |
| com.microsoft.copilot.eclipse.swtbot.test/test-plans/global-auto-approve/global-auto-approve.md | Adds manual test plan for global auto-approve (YOLO) behaviors. |
| com.microsoft.copilot.eclipse.swtbot.test/test-plans/file-operation-auto-approve/file-operation-auto-approve.md | Adds manual test plan for file-operation auto-approve and attached-files behavior. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/ToolMetadata.java | Adds protocol model for tool metadata (terminal command data + sensitive file data). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/ToolAnnotations.java | Adds protocol model for MCP tool annotations (readOnly/openWorld/etc.). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/policy/DidChangePolicyParams.java | Adds policy field for auto-approval enablement and updates equality/hash/toString. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/InvokeClientToolConfirmationParams.java | Extends confirmation params with tool annotations + tool metadata. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/GetDefaultFileSafetyRulesResult.java | Adds protocol result type for fetching default file safety rules from CLS. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/FileSafetyRuleInfo.java | Adds protocol model for a file safety rule entry (pattern/description/requiresConfirmation). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/DidChangeFeatureFlagsParams.java | Adds auto-approval feature flag helper (token-based). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotAgentSettings.java | Extends agent settings with auto-approve maps, unmatched toggles, and tool settings structure. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServerConnection.java | Adds client method to request default file safety rules from CLS. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServer.java | Adds JSON-RPC request definition for getDefaultFileSafetyRules. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageClient.java | Wires token/policy updates into FeatureFlags for auto-approval availability. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/FeatureFlags.java | Adds auto-approval enabled computation from token + org policy. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/Constants.java | Adds preference keys for all auto-approve settings. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/TerminalAutoApproveRule.java | Adds core model for a terminal allow/deny rule (command/regex + decision). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/FileOperationAutoApproveRule.java | Adds core model for a file-operation allow/deny rule (pattern/description + decision). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationResult.java | Adds core representation for auto-approved vs needs-confirmation vs dismissed results. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationHandler.java | Adds a core-side handler interface (currently appears unused). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationContent.java | Adds core model for dialog content (title/message/actions). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationActionScope.java | Adds scope enum for decision persistence (once/session/global). |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/ConfirmationAction.java | Adds action model + helpers for confirmation UI buttons and metadata. |
Comments suppressed due to low confidence (1)
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/SplitDropdownButton.java:318
addSelectionListenerregisters the wrapper as both a SelectionListener and a MouseListener, butremoveSelectionListeneronly removes it as a SelectionListener (and also callsbutton.removeSelectionListener(listener)even though the delegate wasn’t registered directly). This leaves the MouseListener (and wrapper reference) behind and can leak listeners. Consider removing the wrapper fromselectionListenerWrappersand callingbutton.removeMouseListener(wrapper)when detaching.
| case ACCEPT_ALL_SESSION: | ||
| allowAllConversations.add(convId); | ||
| // Cap allowAllConversations the same way | ||
| while (allowAllConversations.size() > MAX_SESSION_CONVERSATIONS) { | ||
| allowAllConversations.iterator().remove(); | ||
| } |
| /** | ||
| * Normalizes a file path for case-insensitive, separator-agnostic comparison. | ||
| * Converts backslashes to forward slashes and lowercases the result. | ||
| * | ||
| * @param path the file path to normalize | ||
| * @return the normalized path | ||
| */ | ||
| static String normalizePath(String path) { | ||
| return path.replace('\\', '/').toLowerCase(Locale.ROOT); | ||
| } |
| // Normalize both path and pattern to forward slashes for consistent matching | ||
| String normalizedPath = filePath.replace('\\', '/'); | ||
| String normalizedPattern = globPattern.replace('\\', '/'); | ||
|
|
||
| // Fast exact-match for absolute file path rules (e.g., from "Always Allow") | ||
| if (normalizedPath.equalsIgnoreCase(normalizedPattern)) { | ||
| return true; | ||
| } |
| // Update existing rule if path matches (case-insensitive for Windows) | ||
| boolean found = false; | ||
| for (FileOperationAutoApproveRule r : rules) { | ||
| if (r.getPattern().equalsIgnoreCase(globalFp)) { | ||
| r.setAutoApprove(true); | ||
| found = true; |
| private void handleServerCheckChanged( | ||
| McpServerToolsCollection server, boolean checked) { | ||
| String serverLower = server.getName() != null | ||
| ? server.getName().toLowerCase(Locale.ROOT) : ""; | ||
| treeViewer.setGrayed(server, false); | ||
|
|
||
| if (checked) { | ||
| checkedServers.add(serverLower); | ||
| } else { | ||
| checkedServers.remove(serverLower); | ||
| } | ||
|
|
||
| // Check/uncheck all children | ||
| List<McpToolInformation> tools = server.getTools(); | ||
| if (tools != null) { | ||
| for (McpToolInformation tool : tools) { | ||
| treeViewer.setChecked(tool, checked); | ||
| String toolKey = serverLower + "::" | ||
| + (tool.getName() != null | ||
| ? tool.getName().toLowerCase(Locale.ROOT) : ""); | ||
| if (checked) { | ||
| checkedTools.add(toolKey); | ||
| } else { | ||
| checkedTools.remove(toolKey); | ||
| } | ||
| } | ||
| } |
| /** | ||
| * Evaluates whether a tool confirmation request can be auto-approved. | ||
| * Each implementation handles a specific category of tool (terminal, file operations, MCP, etc.). | ||
| */ | ||
| public interface ConfirmationHandler { | ||
|
|
||
| /** | ||
| * Evaluates whether the given confirmation request should be auto-approved. | ||
| * | ||
| * @param params the confirmation request parameters from CLS | ||
| * @return ConfirmationResult.AUTO_APPROVED if the tool call can proceed without user | ||
| * confirmation, or ConfirmationResult.NEEDS_CONFIRMATION if the user must approve | ||
| */ | ||
| ConfirmationResult evaluate(InvokeClientToolConfirmationParams params); | ||
| } |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9289af0250
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Unmatched workspace file: auto-approve | ||
| return ConfirmationResult.AUTO_APPROVED; |
There was a problem hiding this comment.
Prompt unmatched file ops when auto-approval is disabled
When evaluate(..., isAutoApprovalEnabled=false) is used (token/policy disabled), this branch still auto-approves unmatched workspace file operations instead of requiring user confirmation. That contradicts the disabled-mode contract used elsewhere in this feature (terminal/MCP fall back to Allow Once/Skip), so a policy-disabled org can still get silent file reads/writes for any path that doesn't hit fallback deny rules.
Useful? React with 👍 / 👎.
feat - LSP data layer + confirmationService skeleton (Auto-approve Part 1 ) (feat - LSP data layer + confirmationService skeleton (Auto-approve Part 1 ) microsoft/copilot-for-eclipse#132)
feat: Terminal auto-approve with confirmation dialog enhancement (Auto-approve Part 2) (feat: Terminal auto-approve with confirmation dialog enhancement (Auto-approve Part 2) microsoft/copilot-for-eclipse#171)
revert splitDropdownButton padding change (fix - revert splitDropdownButton padding change microsoft/copilot-for-eclipse#184)
feat: File operation auto-approve with glob pattern rules (Auto-approve Part 3) (feat: File operation auto-approve with glob pattern rules (Auto-approve Part 3) microsoft/copilot-for-eclipse#216)
add file operation approve logic
resolve comments
change default rules color
resolve comments
update test cases
feat: MCP tool auto-approve and global auto-approve (Auto-approve Part 4) (feat: MCP tool auto-approve and global auto-approve (Auto-approve Part 4) microsoft/copilot-for-eclipse#218)
add mcp approve support and global approve support
resolve comments
fix test cases
resolve comments and add token/policy check
fix compile error
Fix auto-approve preference page layout instability
fix copilot comments