Skip to content

fix(review): land a Checks-pane comment in the diff that carries its hunks - #199

Merged
nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/bug-following-a-pr-comment-from-the-checks-pane
Oct 28, 2026
Merged

nplez1 merged 4 commits into
nplez1/mainfrom
nplez1/bug-following-a-pr-comment-from-the-checks-pane

Conversation

@nplez1

@nplez1 nplez1 commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Closes #192.

The bug

Clicking a review comment in the Checks pane forced mode: 'edit', so the jump landed in a plain
Monaco tab: no inline hunks, no add-note overlay, and the thread drawn against file text instead of
the lines it reviews. The plain tab draws review threads (MonacoEditor mounts
usePRCommentInlineDecorator) but passes an empty commentableLineNumbers and mounts no local-note
decorator, so the "+" affordance could not exist there at all.

The fix

pr-comment-code-navigation.ts now lands on the surface that can actually show the comment, ranked
by how many of the lines it was written about that surface holds:

  1. The file's branch diff — merge base → head, which is the review's own diff. Both decorators
    are mounted there, so the thread, its reply/resolve affordances, and the add-note "+" all exist.
    Accepted only when the stored compare is against the review's own base branch (exact ref or the
    same branch name), because hunks against another base are not the review's.
  2. Changes view mode — the diff against HEAD, when the working tree is what changed. Also a diff
    surface, and its own "No uncommitted changes." banner is the explanation when the review's diff is
    not known to be empty for the file.
  3. A plain tab — only once a compare against the review's base proves the file is in neither the
    review nor the working tree, i.e. when this checkout holds no hunks for it anywhere.

The reveal is unchanged in kind: a diff surface scrolls to the thread by id, a Monaco tab by line —
but the line reveal is now written only for a tab that can consume it, and it is keyed by the opened
file's id rather than its path (which is not the id for a remote owner).

Why the second half is here

The branch compare was loaded only by the Source Control tab, which the Checks tab replaces, and git
status invalidates it on every HEAD move — so in the reported flow the jump would rarely have had a
compare to work with. useChecksPanelBranchCompareWarmup asks for it once per (worktree, base, head)
while the pane is visible, through the existing store actions, resolving its base exactly as
use-source-control-base-refs.ts does so the two tabs can never replace each other's result. It
skips when a compare already answers for that base and head, does not memoize a failed ask (a
reconnecting host is asked again), and keeps a result that lands after the pane hides.

DiffViewer also now defers its first-change auto-scroll to a review-thread reveal; without that, a
freshly opened diff tab scrolled away from the thread it had just revealed.

Verification

  • pnpm test src/renderer/src/components/pr-comment-inline src/renderer/src/components/right-sidebar —
    367 test files / 3,133 tests green (includes the checks panel, source-control and diff-comment
    suites).
  • New: pr-comment-code-navigation.hook.test.tsx pins all four routes (branch diff, Changes mode,
    plain tab with a line reveal, outdated-comment refusal); pr-comment-code-navigation.test.ts pins
    the ranking, the foreign-base and slash-base cases;
    use-checks-panel-branch-compare-warmup.test.tsx pins load-once, reuse, skip-when-hidden and
    retry-after-failure.
  • pnpm tc clean; orca-queue node local/gate-lint.mjs → lint gate @94eeb30977: PASS — 39 green, 0 failing; pnpm run check:code-quality:changed clean; pre-commit oxlint/ast-grep/oxfmt green.
  • Not run: the full unit suite (nightly fork-main-tests.yml + the release gate) — this diff touches
    no global input. Not validated in a running app: that needs a live PR with review comments.

Reviewed by Opus 5.5, high: R1 (3 SHOULD-FIX and 5 MINOR fixed in R2), delta clean on R2..R3, plus
two more MINOR notes from that delta taken in R3; a third round would need to be asked for. Findings
left as notes rather than fixed:

  • MINOR — collapseUnchangedRegions may put a commented line inside a collapsed region on the
    Changes/branch-diff route; not verified whether the decorator's reveal expands it.
  • MINOR (by design) — the branch diff's modified side is the HEAD snapshot, so uncommitted edits to
    the commented lines are invisible there. The review's own hunks win over the live buffer, because
    the thread's line comes from the PR head.
  • MINOR (by design) — with no worktree/repo base pin and the upstream-compare setting off, the
    warm-up has no base to ask for, so the branch-diff route needs the Source Control tab to have loaded
    the compare first and otherwise falls back to Changes mode.
  • NIT (pre-existing) — LEFT-side (deleted-line) comments are still placed by comment.line on the
    modified editor.

…hunks (#192)

Following a review comment forced `mode: 'edit'`, so the jump landed in a plain
Monaco tab: no inline hunks, no add-note overlay, and the thread drawn against
file text instead of the lines it reviews.

- Route the jump to the file's branch diff (merge base -> head, the review's own
  diff) when the worktree has a ready compare, to Changes mode when only the
  working tree changed, and to a plain tab only when no surface holds a hunk for
  the file at all.
- Key Changes mode by the opened file's id rather than its path, which is not the
  id for a remote owner.
- Warm the branch compare from the Checks pane: it replaces the Source Control
  tab, which was the only loader of the diff basis the jump depends on.
- Defer the diff viewer's first-change auto-scroll to a review-thread reveal, which
  it otherwise undid in a diff tab with no stored view state.
- Only claim the review's diff when the stored compare is against the review's own
  base branch, and keep landing in Changes mode — which explains itself — whenever
  that compare is unknown rather than falling back to a silent plain tab.
- Resolve the warm-up's base the way the Source Control tab does, so the two
  writers cannot replace each other's compare on every tab switch; stop re-asking
  for a compare that already answered or failed for the same base and head, and
  keep a result that lands after the panel hides.
- Write a line reveal only for a tab that can consume one.
- Pin the routing with a hook test, and export the compare-base branch helper the
  guard needs.
- Accept an exact base-ref match as well as the branch-name match, so a review
  whose base branch is named `release/2.0` still gets its own diff.
- Memoize the warm-up's ask only once a result arrives, so a host that was not
  connected is asked again instead of being frozen out until the head moves.
- Poll for the reveal in the routing test rather than waiting a fixed 40ms.
The flaky-test ratchet rejects a real-time wait in a test, and it is right: the
reveal lands two animation frames after the open, so advance them instead.
@nplez1
nplez1 merged commit 0a278d5 into nplez1/main Oct 28, 2026
@nplez1
nplez1 deleted the nplez1/bug-following-a-pr-comment-from-the-checks-pane branch October 28, 2026 03:42
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.

[Bug]: Following a PR comment from the Checks pane lands in a plain editor with no diff hunks and no add-note

1 participant