Add Explain Changes feature for code review
Description
Adds the Explain Changes feature - a code review capability that generates inline explanations for code changes directly in VS Code's diff view.
Key capabilities:
- Button in completion messages: After Cline completes a task with file changes, an "Explain Changes" button appears alongside "View Changes"
- Streaming inline comments: Explanations stream in real-time as comments directly in the multi-file diff view
- Interactive comment threads: Users can ask follow-up questions in each comment thread for deeper understanding
- Conversation integration: Click comment thread titles to move discussions into Cline's main chat for further action
-
/explain-changesslash command: Also supports explaining any git diff (commits, branches, PRs) via a new slash command with thegenerate_explanationtool
Implementation highlights:
- New gRPC RPC
explainChangesintask.proto - New
GENERATE_EXPLANATIONsay type for UI state -
CommentReviewControllerfor managing VS Code comment threads with streaming support -
generate_explanationtool added to all system prompt variants - Full documentation added
Test Procedure
- Verified the Explain Changes button appears after task completion with file changes
- Tested streaming comments appear correctly in diff view
- Confirmed follow-up questions work in comment threads
- Tested cancellation properly cleans up comments and diff views
- Verified
/explain-changesslash command works with various git refs
Type of Change
- [x] ✨ New feature (non-breaking change which adds functionality)
Pre-flight Checklist
- [x] Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
- [x] Tests are passing (
npm test) and code is formatted and linted (npm run format && npm run lint) - [x] I have created a changeset using
npm run changeset(required for user-facing changes) - [x] I have reviewed contributor guidelines
Additional Notes
Requires Checkpoints to be enabled for the button-triggered explain changes (tracking workspace state). The slash command works independently by comparing git refs.
[!IMPORTANT] Introduces "Explain Changes" feature in VS Code for AI-generated explanations of code changes, with interactive comments and a slash command for git diffs.
- Behavior:
- Adds "Explain Changes" button in VS Code's diff view for AI-generated explanations of code changes.
- Supports interactive comment threads for follow-up questions.
- Introduces
/explain-changesslash command for explaining git diffs.- Implementation:
- Adds
explainChangesRPC intask.proto.- Implements
CommentReviewControllerfor managing VS Code comment threads.- Adds
generate_explanationtool to system prompts.- UI:
- Updates
ChatRow.tsxto include "Explain Changes" button.- Adds announcement for the new feature in
Announcement.tsx.- Misc:
- Updates
tools.tsto includeGENERATE_EXPLANATIONtool.- Adds documentation for the feature in
docs/features/explain-changes.mdx.This description was created by
for 01b66fe4ff7815082c120125b5a902f9ba94bd0f. You can customize this summary. It will automatically update as commits are pushed.
🦋 Changeset detected
Latest commit: d19a7fd06725c2490f24c2468de72900c14425f2
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Fixed changes in the documentation and added the videos explaining each of the features, so they should be good to go. I would recommend reducing the number of examples to four. I would pick the explain the last commit one, explain uncommitted changes, explain a pull request, and explain branch differences. Currently, we have too many samples that might be a little bit overwhelming for the user that is reading through this documentation.
The generate_explanation tool (used for the "Explain Changes" feature) relies on VS Code's Comments API to display inline code review comments. This feature doesn't work on JetBrains or CLI platforms.
We've already hidden the /explain-changes slash command and the announcement banner for non-VS Code platforms, but the tool itself is still included in the system prompt for all platforms.
I've created an issue for excluding the generate_explanation tool from non-VS Code platforms: https://github.com/cline/cline/issues/7807
JetBrains Plugin tests cancelled 🚫
The JetBrains plugin integration tests were cancelled, likely due to a newer workflow run being triggered.
If you need the tests to complete, please re-trigger the workflow or wait for any currently running tests to finish.
Branch: saoudrizwan/review-mode
Workflow: View run
JetBrains Plugin tests failed ❌
⚠️ Action Required: This PR needs to be updated to ensure compatibility with both cline-core and JetBrains.
The changes in this PR are causing test failures in the JetBrains plugin integration. Please review and fix your changes to ensure they work properly with:
- The cline-core functionality
- JetBrains IDE integration
Please check the workflow logs for specific test failure details and update your PR accordingly.
Branch: saoudrizwan/review-mode
Workflow: View run
JetBrains Plugin tests failed ❌
⚠️ Action Required: This PR needs to be updated to ensure compatibility with both cline-core and JetBrains.
The changes in this PR are causing test failures in the JetBrains plugin integration. Please review and fix your changes to ensure they work properly with:
- The cline-core functionality
- JetBrains IDE integration
Please check the workflow logs for specific test failure details and update your PR accordingly.
Branch: saoudrizwan/review-mode
Workflow: View run