diff --git a/.github/workflows/continue-detailed-review.yaml b/.github/workflows/continue-detailed-review.yaml index 26e2530ae..bbad06f21 100644 --- a/.github/workflows/continue-detailed-review.yaml +++ b/.github/workflows/continue-detailed-review.yaml @@ -61,6 +61,11 @@ jobs: # Annotate diff with GitHub API positions node ${{ github.workspace }}/pr-review-action/scripts/annotate-diff.js pr_diff.txt > pr_diff_annotated.txt + + # Debug: Show sample of annotated diff + echo "=== SAMPLE OF ANNOTATED DIFF ===" + head -100 pr_diff_annotated.txt | grep -E "^\[POS:|^@@|^diff --git" || head -50 pr_diff_annotated.txt + echo "=== END SAMPLE ===" # Create review prompt for inline comments cat > inline_review_prompt.txt << 'EOF' @@ -225,6 +230,12 @@ jobs: body: comment.body })); + // Debug: Log the positions we're trying to use + console.log('Attempting to post comments with positions:'); + comments.forEach(c => { + console.log(` ${c.path}: position ${c.position}`); + }); + // Create the review if (comments.length > 0) { try { diff --git a/pr-review-action/scripts/annotate-diff.js b/pr-review-action/scripts/annotate-diff.js index 0c3d5f969..16f434d09 100644 --- a/pr-review-action/scripts/annotate-diff.js +++ b/pr-review-action/scripts/annotate-diff.js @@ -16,9 +16,16 @@ function annotateDiff(diffContent) { let inHunk = false; for (const line of lines) { - // Pass through git headers unchanged - if (line.startsWith('diff --git') || - line.startsWith('index ') || + // Handle new file - reset position counter + if (line.startsWith('diff --git')) { + githubPos = 0; + inHunk = false; + output.push(line); + continue; + } + + // Pass through other git headers unchanged + if (line.startsWith('index ') || line.startsWith('---') || line.startsWith('+++') || line.startsWith('rename ') ||