fix(pr-review-toolkit): translate merge-result line numbers to PR HEAD before posting#71
Conversation
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds documentation and prompt updates for translating finding line numbers from the merge-result checkout to PR HEAD line numbers before posting review comments, and bumps the plugin manifest version from 1.8.1 to 1.9.0. ChangesLine-number translation for PR review comments
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a real failure mode in the pr-review-toolkit review-pr skill: when the PR's base branch has diverged, line numbers derived from the local merge-result checkout (HEAD^1..HEAD) no longer match the PR branch HEAD (HEAD^2), causing add_comment_to_pending_review to fail with "line doesn't exist in PR diff". It adds a documented procedure to translate merge-result line numbers back to PR HEAD before posting, updates the analysis prompts to signal that translation happens, and bumps the plugin version.
The translation algorithm itself is sound: it correctly interprets git diff HEAD^2 HEAD hunk headers (- side = PR HEAD, + side = merge result), correctly moves merge-only (+) lines to the review body, correctly counts context/- lines within a hunk, and correctly accumulates (b - d) offsets between hunks.
Changes:
- Add a "Translate Line Numbers for Posting" section to
SKILL.mddescribing how to map merge-result lines to PR HEAD and move unmappable findings to the review body. - Update
patchInstructions()inreview-pr.jsto tell local-git-mode agents their line numbers will be translated before posting. - Bump plugin version 1.8.1 → 1.9.0.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pr-review-toolkit/skills/review-pr/SKILL.md | Adds the line-number translation procedure between preview/approval and posting. |
| pr-review-toolkit/skills/review-pr/review-pr.js | Adds a "will be translated" note to the two local-git diff-context prompts. |
| pr-review-toolkit/.claude-plugin/plugin.json | Version bump to 1.9.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…D before posting Review agents analyze the merge-result checkout for quality, but GitHub's add_comment_to_pending_review API expects line numbers from the PR branch HEAD (HEAD^2). When the base branch has diverged, lines shift between the two, causing API rejections for valid findings. Add a translation step in SKILL.md before posting that diffs HEAD^2 vs HEAD to compute the offset, and moves unmappable findings to the review body. Update workflow prompt strings to note that agent line numbers correspond to the merge result. Assisted-by: Claude:claude-opus-4-6
2f811cb to
dd8db72
Compare
Summary
HEAD^2vsHEADto translate merge-result line numbers to PR HEAD before posting comments, and moves unmappable findings (merge-only lines or lines outside PR diff hunks) to the review bodypatchInstructions()prompt strings inreview-pr.jsto inform agents that their line numbers correspond to the merge-result checkout and will be translated before postingFixes the issue where
add_comment_to_pending_reviewcalls fail with "line doesn't exist in PR diff" when the base branch has diverged and lines have shifted between the merge result and PR branch HEAD.Test plan
mainhas diverged, touching files the PR also modifiesSummary by CodeRabbit
New Features
Bug Fixes
Chores