fix(pr-review-canvas): number diffs from raw hunks, never silently drop import lines - #482
Open
zichen0116 wants to merge 1 commit into
Open
zichen0116 wants to merge 1 commit into
zichen0116 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #472
Problem
renderDiffincursor-team-kit/skills/pr-review-canvas/renderer.jsdroppedimport lines and rewrote whitespace-only del/add pairs before line numbers
were computed from the
@@hunk headers, so the rendered review was neitherthe diff nor correctly numbered:
matching
isImport— including side-effect imports likeimport './polyfill'— was deleted up front. CountersoL/nLare onlyreset by hunk headers, so every line after a dropped import within the same
hunk was numbered too low. Issue repro:
const x = 1displayed as line 1/1instead of 3/3.
isWhitespaceOnlycomparedboth sides with all whitespace stripped (
replace(/\s/g, '')), so- return "a b"/+ return "ab"was rewritten into an unchanged contextline — likewise for string-literal spacing and Python/YAML/Make
indentation changes.
Fix
hiddeninstead of deleted, so line numbers always follow the originalhunk headers.
"N import lines hidden" row (
toggleHidden) — collapsed by default butnever silent, and they keep their correct line numbers when expanded.
isWhitespaceOnlynow compares after trimming leading/trailingwhitespace only, so internal whitespace differences are preserved as real
del/add rows.
SKILL.mdandstyles.cssupdated to document/style the new behavior.Moved-code detection and the rest of the render pipeline are unchanged.
Verification
node --check renderer.js— syntax clean.renderDiffon the issue's exactrepro diffs): all 8 assertions pass —
const x = 1renders as 3/3, changed import lines presentunder the "3 import lines hidden" row;
"a b"→"ab"renders as del+add, not context;context row, with following lines correctly numbered;
import './polyfill') preserved, line numbers afterit correct;
singular/plural hidden-row labels all verified.
Note
Low Risk
Localized changes to the PR review canvas skill’s client-side diff renderer and docs; no auth, data, or production service impact.
Overview
Fixes incorrect diff line numbers and over-aggressive collapsing in the pr-review-canvas
renderDiffpipeline (#472).renderDiffnow parses and numbers the full raw patch first, then applies display transforms. Import lines are markedhiddeninstead of stripped before counting, so old/new line numbers always match the@@hunk headers. Consecutive hidden imports render as a clickable "N import lines hidden" summary (toggleHidden); expanding shows the real import rows with correct line numbers.Whitespace-only collapsing is tightened:
isWhitespaceOnlycompares lines after trimming leading/trailing whitespace only, so internal spacing changes (e.g."a b"→"ab") stay visible as del/add instead of fake context rows.SKILL.mddocuments the new behavior;styles.cssadds styling for the hidden-import summary and detail rows. Moved-code detection is unchanged aside from indexing cleanup.Reviewed by Cursor Bugbot for commit c4520aa. Bugbot is set up for automated code reviews on this repo. Configure here.