Conversation
| for (const editEntry of edit.edits) { | ||
| const beforeLines = (editEntry.originalContent || "").split("\n") | ||
| const afterLines = (editEntry.newContent || "").split("\n") | ||
|
|
||
| // Simple line-based diff calculation for each edit | ||
| if (beforeLines.length === 0 && afterLines.length > 0) { | ||
| // New content added | ||
| totalAdditions += afterLines.length | ||
| } else if (beforeLines.length > 0 && afterLines.length === 0) { | ||
| // Content deleted | ||
| totalDeletions += beforeLines.length | ||
| } else { | ||
| deletions = Math.abs(lineDiff) | ||
| } | ||
| // If same line count, assume at least some lines changed | ||
| if (lineDiff === 0 && beforeLines.some((line, i) => line !== afterLines[i])) { | ||
| additions = 1 | ||
| deletions = 1 | ||
| // Modified content - use simple line count difference | ||
| const lineDiff = afterLines.length - beforeLines.length | ||
| if (lineDiff > 0) { | ||
| totalAdditions += lineDiff | ||
| } else { | ||
| totalDeletions += Math.abs(lineDiff) | ||
| } | ||
| // If same line count, assume at least some lines changed | ||
| if (lineDiff === 0 && beforeLines.some((line, i) => line !== afterLines[i])) { | ||
| totalAdditions += 1 | ||
| totalDeletions += 1 | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🟠 Logic Error
Issue: The diff calculation logic has two flaws:
split(' ')on an empty string returns[''](length 1), causing new or empty files to be counted as modifications (+1/-1) instead of pure additions/deletions.- For modified files with line count changes (
lineDiff > 0), the current logic ignores content changes in the overlapping lines, leading to under-reported stats.
Fix: Handle empty content explicitly to return empty arrays, and use a heuristic that counts changes in the overlapping region in addition to the length difference.
Impact: Ensures accurate diff statistics in the review UI.
| for (const editEntry of edit.edits) { | |
| const beforeLines = (editEntry.originalContent || "").split("\n") | |
| const afterLines = (editEntry.newContent || "").split("\n") | |
| // Simple line-based diff calculation for each edit | |
| if (beforeLines.length === 0 && afterLines.length > 0) { | |
| // New content added | |
| totalAdditions += afterLines.length | |
| } else if (beforeLines.length > 0 && afterLines.length === 0) { | |
| // Content deleted | |
| totalDeletions += beforeLines.length | |
| } else { | |
| deletions = Math.abs(lineDiff) | |
| } | |
| // If same line count, assume at least some lines changed | |
| if (lineDiff === 0 && beforeLines.some((line, i) => line !== afterLines[i])) { | |
| additions = 1 | |
| deletions = 1 | |
| // Modified content - use simple line count difference | |
| const lineDiff = afterLines.length - beforeLines.length | |
| if (lineDiff > 0) { | |
| totalAdditions += lineDiff | |
| } else { | |
| totalDeletions += Math.abs(lineDiff) | |
| } | |
| // If same line count, assume at least some lines changed | |
| if (lineDiff === 0 && beforeLines.some((line, i) => line !== afterLines[i])) { | |
| totalAdditions += 1 | |
| totalDeletions += 1 | |
| } | |
| } | |
| } | |
| for (const editEntry of edit.edits) { | |
| const beforeLines = editEntry.originalContent ? editEntry.originalContent.split("\n") : [] | |
| const afterLines = editEntry.newContent ? editEntry.newContent.split("\n") : [] | |
| // Calculate additions/deletions based on length difference | |
| const lineDiff = afterLines.length - beforeLines.length | |
| if (lineDiff > 0) { | |
| totalAdditions += lineDiff | |
| } else { | |
| totalDeletions += Math.abs(lineDiff) | |
| } | |
| // Check for modified lines in the overlapping region | |
| const commonLength = Math.min(beforeLines.length, afterLines.length) | |
| for (let i = 0; i < commonLength; i++) { | |
| if (beforeLines[i] !== afterLines[i]) { | |
| totalAdditions++ | |
| totalDeletions++ | |
| } | |
| } | |
| } |
| <VSCodeButtonLink | ||
| variant="secondary" | ||
| href="https://app.matterai.so/get-started" | ||
| style={{ | ||
| background: "var(--color-matterai-chip-blue)", | ||
| border: "1px solid var(--color-matterai-blue)", | ||
| borderRadius: "6px", | ||
| }}> | ||
| Get Started for free | ||
| </VSCodeButtonLink> | ||
| </div> | ||
| <div className="self-start mt-1"> | ||
| <VSCodeButtonLink | ||
| variant="secondary" | ||
| href="https://docs.matterai.so/quickstart-ai-code-review-agent" | ||
| style={{ borderRadius: "6px" }}> | ||
| Read Docs | ||
| </VSCodeButtonLink> |
There was a problem hiding this comment.
🔵 UX Improvement
Issue: External links in the webview might open inside the editor or fail to open if target="_blank" is missing.
Fix: Add target="_blank" to the VSCodeButtonLink components to ensure they open in the user's default browser.
Impact: Improves user experience by handling external navigation correctly.
| <VSCodeButtonLink | |
| variant="secondary" | |
| href="https://app.matterai.so/get-started" | |
| style={{ | |
| background: "var(--color-matterai-chip-blue)", | |
| border: "1px solid var(--color-matterai-blue)", | |
| borderRadius: "6px", | |
| }}> | |
| Get Started for free | |
| </VSCodeButtonLink> | |
| </div> | |
| <div className="self-start mt-1"> | |
| <VSCodeButtonLink | |
| variant="secondary" | |
| href="https://docs.matterai.so/quickstart-ai-code-review-agent" | |
| style={{ borderRadius: "6px" }}> | |
| Read Docs | |
| </VSCodeButtonLink> | |
| <VSCodeButtonLink | |
| variant="secondary" | |
| href="https://app.matterai.so/get-started" | |
| target="_blank" | |
| style={{ | |
| background: "var(--color-matterai-chip-blue)", | |
| border: "1px solid var(--color-matterai-blue)", | |
| borderRadius: "6px", | |
| }}> | |
| Get Started for free | |
| </VSCodeButtonLink> | |
| </div> | |
| <div className="self-start mt-1"> | |
| <VSCodeButtonLink | |
| variant="secondary" | |
| href="https://docs.matterai.so/quickstart-ai-code-review-agent" | |
| target="_blank" | |
| style={{ borderRadius: "6px" }}> | |
| Read Docs | |
| </VSCodeButtonLink> |
|
/matterai fix |
|
❌ 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. |
No description provided.