Skip to content

Conversation

@code-crusher
Copy link
Member

No description provided.

Fixes 90% miss rate by converting .ext to *.ext patterns

- Automatically converts file patterns like .ts to *.ts for ripgrep's --glob
- Preserves existing glob patterns like *.ts or **/*.ts
- Defaults to * when no pattern provided

Resolves issue where ripgrep's --glob parameter expects proper glob patterns
but users were passing just file extensions
@matter-code-review
Copy link
Contributor

Context

Summary By MatterAI MatterAI logo

🔄 What Changed

Introduced a comprehensive AI Code Review feature that allows users to analyze uncommitted git changes directly within the IDE. This includes a new CodeReviewService for handling asynchronous API polling, backend handlers for git diff extraction using the Git CLI, and a suite of React components (SourceControlPanel, CodeReviewPanel) to visualize and apply suggested fixes.

🔍 Impact of the Change

Users can now receive proactive feedback on their code before committing. The integration of an automated fix application mechanism (applyCodeReviewFix) significantly reduces the friction between identifying an issue and resolving it, enhancing developer productivity and code quality.

📁 Total Files Changed

Click to Expand
File ChangeLog
Async Service codeReviewService.ts Implemented async polling and retry logic for the Code Review API.
Message Handler webviewMessageHandler.ts Added git metadata/diff extraction and review request orchestration.
UI Orchestration ChatView.tsx Integrated source control state and periodic git change polling.
Review UI CodeReviewPanel.tsx Created component to display review summaries and individual comments.
Git UI SourceControlPanel.tsx Built a panel to show pending changes and trigger AI reviews.
Config Update package.json Bumped version to 4.210.0 and added vscode.git dependency.
Search Fix ripgrep/index.ts Normalized file patterns for more reliable regex searches.
Type Definitions WebviewMessage.ts Defined new payloads for code review results and fix applications.

🧪 Test Added/Recommended

Recommended

  • Unit Tests: Mock axios in CodeReviewService to verify exponential backoff and polling timeout logic.
  • Integration Tests: Validate getGitChanges helper against various git states (staged, unstaged, untracked).
  • UI Tests: Ensure SourceControlPanel correctly reflects file additions/deletions from the git status.

🔒 Security Vulnerabilities

  • Command Injection: getGitChanges uses child_process.exec. While parameters are currently internal, ensure no user-controlled input is ever passed to these commands.
  • Token Exposure: Ensure kilocodeToken is handled securely and not logged in the provider.log calls.

Implementation

The feature follows an asynchronous request-poll pattern. The backend uses the Git CLI to generate a unified diff of uncommitted changes (including untracked files via a manual diff generator). The CodeReviewService manages the lifecycle of the review request, including retries for network flakiness and polling the Matter AI API until completion. The UI is updated via VS Code's message-passing architecture, allowing for real-time status updates in the webview.

Screenshots

before after
N/A AI Review Panel integrated into Chat View

How to Test

  1. Open a git repository in the extension.
  2. Make several changes to files (staged and unstaged).
  3. Click the "Run AI Code Review" button in the chat area.
  4. Observe the "Analyzing..." state and subsequent review results.
  5. Click "Fix" on a suggestion and verify a new task is created to apply the change.

Get in Touch

Axon Code Discord: @engineering_team

Copy link
Contributor

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

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

🧪 PR Review is completed: The implementation of the AI Code Review service is solid, but there are some performance and code quality issues. The polling mechanism in the UI is too aggressive, and there is redundant logic in the Git change detection.

Skipped files
  • CHANGELOG.md: Skipped file pattern
  • README.md: Skipped file pattern
⬇️ Low Priority Suggestions (1)
src/core/kilocode/api/codeReviewService.ts (1 suggestion)

Location: src/core/kilocode/api/codeReviewService.ts (Lines 90-93)

🔵 Code Quality

Issue: The attempt variable is incremented but never used in the polling logic.

Fix: Remove the unused variable.

Impact: Cleans up unused code.

-  		let attempt = 0
-  
-  		while (Date.now() - startTime < this.MAX_POLLING_DURATION) {
-  			attempt++
+  		const startTime = Date.now()
+  
+  		while (Date.now() - startTime < this.MAX_POLLING_DURATION) {

Comment on lines +1018 to +1021
// Set up periodic checking for changes (every 5 seconds)
const interval = setInterval(() => {
vscode.postMessage({ type: "getGitChangesForReview" })
}, 5000)
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 Performance

Issue: Polling for git changes every 5 seconds using setInterval can be resource-intensive, especially for large repositories where git diff is slow. This runs unconditionally even if the user is not interacting with the review panel.

Fix: Increase the polling interval to a less aggressive value (e.g., 15 seconds) to reduce system load.

Impact: Improves performance and reduces background CPU usage.

Suggested change
// Set up periodic checking for changes (every 5 seconds)
const interval = setInterval(() => {
vscode.postMessage({ type: "getGitChangesForReview" })
}, 5000)
// Set up periodic checking for changes (every 15 seconds)
const interval = setInterval(() => {
vscode.postMessage({ type: "getGitChangesForReview" })
}, 15000)

Comment on lines +230 to +232
for (const file of untrackedFilter) {
try {
const content = await fs.readFile(file.absolutePath, "utf8")
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Stability

Issue: The code reads the entire content of untracked files into memory to generate diffs. If an untracked file is very large (e.g., a large log file or binary), this could cause high memory usage or crash the extension.

Fix: Add a file size check before reading the content and skip files that are too large (e.g., > 1MB).

Impact: Prevents potential Out-Of-Memory errors and improves stability.

Suggested change
for (const file of untrackedFilter) {
try {
const content = await fs.readFile(file.absolutePath, "utf8")
for (const file of untrackedFilter) {
try {
const stats = await fs.stat(file.absolutePath)
if (stats.size > 1024 * 1024) continue // Skip large files > 1MB
const content = await fs.readFile(file.absolutePath, "utf8")

@code-crusher
Copy link
Member Author

/matterai fix

@matter-code-review
Copy link
Contributor

❌ I couldn't generate code fixes for this PR. This might be because the review comments don't require code changes, or the AI couldn't determine the appropriate fixes.

@matter-code-review
Copy link
Contributor

Note

PR Review Skipped

PR review skipped as no relevant changes found due to large diff hunk OR part of a non-reviewable file.

📄Files skipped in review
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link
Contributor

Note

PR Review Skipped

PR review skipped as no relevant changes found due to large diff hunk OR part of a non-reviewable file.

📄Files skipped in review
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
  • undefined: undefined
💡Tips to use MatterAI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with MatterAI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@code-crusher code-crusher merged commit 42865ad into main Jan 2, 2026
6 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants