Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep review comments inside the pull request's hunks #12583

Mergedagomesp(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/12583/headmerged by juliusmarminge View on GitHub

Expanding a pull request diff exposes context outside the host's hunks. Comments anchored there can cause GitHub to reject the entire submitted review. The resolver now refuses those context positions using the same hunk-membership check already used to place review threads. Explicit selections also retain their side and coordinate, preventing the original partial patch from falling back to a same-numbered line on the opposite side. Valid context, added, and deleted anchors retain their coordinates.

Continued @agomesp's #12583, preserved the author's commits, and merged main. The merge conflict only concerned a redundant function comment removed on main. Part of #12549.

Verification on headless Linux:

  • vp test run apps/web/src/reviewCommentContext.test.ts: 5 before takeover → 5 after, all pass. The single hydrated-patch regression now covers gaps before/between/after hunks on both sides, shifted context mapping, and valid added/deleted lines.
  • Removing the guard produces 1 failure / 4 passes; restoring it produces 5 passes.
  • The partial-patch fallback regression also fails before the explicit-side fix. Three focused suites (reviewCommentContext, pullRequestDiff.logic, and diffRendering) pass: 42 tests total.
  • Web typecheck and targeted lint/format pass.
  • This uses the actual diff hydration/resolution path. Live review submission is unverified. Chromium was initially missing and was installed later; the isolated app starts, but its PR lookup reports that it cannot reach GitHub. This specific flow has not been driven with host PR data, and there are no current browser captures.

The restriction applies across hosts, consistent with existing thread placement. Existing saved drafts outside hunks are not migrated and must be moved or removed. The gutter may remain visible on expanded rows even when no valid anchor can be created.

Not merge-ready until the client flow and host submission are verified.

Not verified: live GitHub/GitLab review submission, macOS, Windows, iOS, Android, Electron desktop. Web and desktop share this resolver; the native mobile diff viewer is separate. No server, contract, provider adapter, or connection-mode change.

Tests: GPT-6-Astra. Implementation: GPT-6.1-Sol. Adversarial review: Claude Opus 5.5 and GPT-6-Sol. Harness: Codex/T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: a0144b2b-2875-49ac-9a06-18eb39ea446d

      📥 Commits

      Reviewing files that changed from the base of the PR and between dfbb11bdd7c3f1a5575cb55d3e3abb12be025727 and b64c6fee29697a161f3b3be3d6e71dfa72f6a618.

      📒 Files selected for processing (2)
      • apps/web/src/reviewCommentContext.test.ts
      • apps/web/src/reviewCommentContext.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

      📝 Walkthrough

      The resolver now returns no review position for context lines outside the file diff. Tests cover separated diff hunks, out-of-hunk selections, and in-hunk position resolution.

      Changes: Diff Position Validation

      Layer / File(s)Summary
      Validate context-line positions
      apps/web/src/reviewCommentContext.ts
      resolveDiffReviewPosition checks whether the selected new-side line is inside the file diff and documents when it returns null.
      Test separated diff hunks
      apps/web/src/reviewCommentContext.test.ts
      Tests hydrate a partial diff, reject selections outside its hunks, and resolve an in-hunk context line.

      Priority: ⬇️ Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: chrisdeeming

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Title checkPassedThe title clearly and concisely describes the main fix: keeping review comments within pull request hunks.
      Description checkPassedThe description explains the problem, implementation, scope, verification results, and known limitations. It includes issue and pull request references and detailed focused test results. The required …
      Full details: Description check

      Explanation

      The description explains the problem, implementation, scope, verification results, and known limitations. It includes issue and pull request references and detailed focused test results. The required headings are not used, and explicit maintainer approval evidence is not provided, but the content is mostly complete for this focused fix.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      Comment `@coderabbitai help` to get the list of available commands.
    3. juliusmarminge added labelsmacroscope-review

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 12fa82e

      Macroscope's review found this PR approvable — This is a small, self-contained web bug fix that prevents invalid review anchors outside pull-request hunks while preserving valid anchors. Targeted regression tests cover partial, expanded, and side-specific selections.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one appears to have been created with an older model (opus 5). If this change is really important, we recommend rebuilding the PR with a newer model if possible.

    6. maria-rcks closed this

    7. Note

      Written by claude-opus-5-5 on behalf of Maria

      Reopening, this was closed by mistake. Sorry for the noise!

    8. maria-rcks reopened this

    9. juliusmarminge assignedjuliusmarminge

    10. Taking over this one as maintainer for batch pull-request-04. Preserving your commits and this PR, merged main, and strengthened the existing hydration regression. The implementation also closes a partial-patch fallback that could resolve a gap to the opposite side. Full-diff reviews underway; no merge planned.

    11. juliusmarminge merged this38d50e3

    12. juliusmarminge closed this

Sign in to join this conversation.