Skip to content

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Nov 12, 2025

To avoid issues with format/fix calls through the AI interfering with unsaved files in the editor, this swaps the MCP-server commands with versions that call the in-editor commands instead.

Fixes #5785

To avoid issues with format/fix calls through the AI interfering with unsaved files in the editor, this swaps the MCP-server commands with versions that call the in-editor commands instead.

Fixes #5785
@DanTup DanTup added this to the v3.124.0 milestone Nov 12, 2025
@DanTup DanTup added is enhancement in ai Relates to AI, such as use of the MCP APIs labels Nov 12, 2025
@DanTup DanTup requested a review from Copilot November 12, 2025 18:10
@DanTup
Copy link
Member Author

DanTup commented Nov 12, 2025

@codex review
/gemini review

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the MCP server's dart_format and dart_fix tools with IDE-friendly versions that operate on in-editor documents rather than directly on disk files. This prevents conflicts with unsaved changes in the editor when AI assistants invoke format/fix operations through the MCP server.

Key changes:

  • Introduced new custom MCP tools (dart_format and dart_fix) that open files in the editor and use VS Code commands
  • Added these tools to the default exclusion list for the Dart MCP server to avoid duplication
  • Added comprehensive test coverage for the new tool implementations

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/shared/vscode/mcp.ts New file implementing McpTools class with custom dart_format and dart_fix tools that use editor commands
src/extension/extension.ts Refactored to instantiate McpTools class instead of inline tool registration
package.json Added tool definitions for dart_format and dart_fix, and included them in default exclusion list for MCP server
src/test/dart/mcp_server.test.ts Updated test expectations and added new tests for dart_format and dart_fix tool implementations
src/test/helpers.ts Added guard to prevent errors when closing files with no open editors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request replaces the MCP server commands for formatting and fixing with IDE-friendly versions that call in-editor commands. This is a solid improvement to avoid issues with unsaved files. The changes are well-implemented, including adding a new McpTools class to encapsulate the logic and updating tests accordingly. I have one minor suggestion to improve code readability in the new McpTools class.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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".

- Remove redundant if block
- Ensure opened editor gets focus so commands always apply to it and not another editor
@DanTup DanTup merged commit 56cd1d2 into master Nov 12, 2025
16 checks passed
@DanTup DanTup deleted the add-better-format-and-fix-all branch November 12, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in ai Relates to AI, such as use of the MCP APIs is enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dart MCP server commands that modify files on disk can conflict with unsaved files

2 participants