Skip to main content

Diff view

When AI suggests code changes, the Diff View displays them for you to review rather than applying them automatically. This gives you full control, allowing you to understand every modification before you apply it. This article explains how to review, manage, and apply these changes at the change block or file level.

Diff preview format

The Diff View uses color-coding to distinguish between new, deleted, and unchanged lines of code:
  • Added content: New lines of code are highlighted in green.
  • Deleted content: Removed lines of code are highlighted in red.
  • Contextual code: Unchanged lines are displayed in a neutral color to provide context and help you locate the changes within the codebase.
This inline diff format allows you to:
  • See exactly what will change
  • Understand why the change was made
  • Evaluate how the change fits into your existing codebase
You can then accept, edit, or reject each change.

Diff view in a single file

You can then review the changes and apply them per change block or to the entire file.

Block-level operations

To control individual changes, use the options in the upper-right corner of each change block:
  • Accept: Apply the changes in the current change block.
  • Reject: Discard the changes in the current change block.

File-level operations

To manage all suggested changes in the current file at once, use the controls at the bottom of the file:
  • Accept All: Apply all suggested changes in the current file.
  • Reject All: Discard all suggested changes in the current file.
  • File navigation: Switch to other files with pending changes.

Diff view in multiple files

When a task modifies multiple files, a list of all affected files appears above the AI Chat panel. You can use the following operations to manage these cross-file changes:
  • Global operations: Perform bulk actions across all files.
    • Accept: Apply all changes in all listed files.
    • Reject: Discard all changes in all listed files.
  • File-level operations
    • Click a file name to open that file in the Diff View.
      package com.macro.mall.demo.config;
      import org.mybatis.spring.annotation.MapperScan;
      import org.springframework.context.annotation.Configuration;
      /**
       * MyBatis configuration.
       *
       * This configuration class is mainly used for:
       * 1. Configuring the scan path for MyBatis mappers.
       * 2. Enabling MyBatis auto-configuration features.
       * 3. Integrating with Spring Boot to provide data access layer support.
       *
       * Created by macro on 2018/4/26.
       */
      // Spring configuration class for MyBatis settings.
      @Configuration
      // Scans for MyBatis mapper interfaces in the specified package and registers them as Spring beans.
      // This allows you to directly inject Mapper interfaces in the service layer for database operations.
      @MapperScan("com.macro.mall.mapper")
      public class MyBatisConfig {
          // This configuration currently only requires the @MapperScan annotation for basic setup.
          // Spring Boot's auto-configuration handles other MyBatis-related settings.
          // To customize SqlSessionFactory or TransactionManager, you can add corresponding @Bean methods in this class.
      }
      
    • Hovering over a file name displays the Reject or Accept options for that file.
This multi-file navigation simplifies managing complex cross-file refactoring.