Skip to content

fix: count repeated lines in the content diff preview - #31

Open
Abhishek-B-R wants to merge 1 commit into
context-dot-dev:mainfrom
Abhishek-B-R:fix/diff-preview-duplicate-lines
Open

Abhishek-B-R wants to merge 1 commit into
context-dot-dev:mainfrom
Abhishek-B-R:fix/diff-preview-duplicate-lines

Conversation

@Abhishek-B-R

Copy link
Copy Markdown

diffPreview compared snapshots as sets of lines. The change check is a hash of the whole page, so when a page only gains a second copy of an existing line (or loses one of two identical lines) the alert still fires, but its preview is empty with 0 added / 0 removed, and triage and the AI summary get "no line-level diff available".

This counts occurrences instead of using a Set. Output is the same for everything that worked before.

Added src/lib/diff-preview.test.ts. The two duplicate cases fail on main and pass here. npm test, typecheck and lint are clean.

diffPreview compared the two snapshots as sets of lines, so adding a second
copy of a line that already existed, or removing one of two identical lines,
changed the page hash and raised a PAGE_CONTENT alert whose preview was empty
with 0 added and 0 removed. The AI triage and summary saw no diff at all for
the same reason. Compare the lines as a multiset instead.
@Abhishek-B-R

Copy link
Copy Markdown
Author

@YahiaBakour friendly bump: this makes diffPreview count line occurrences instead of comparing sets, so an alert caused by a duplicated or removed repeated line shows that line in the preview rather than an empty 0 added / 0 removed diff. It's only waiting on a review, and the new diff-preview.test.ts cases cover both directions. Happy to adjust anything if the approach doesn't fit.

@Abhishek-B-R

Copy link
Copy Markdown
Author

@YahiaBakour following up once: the branch has no conflicts with main and the only thing outstanding is a review. The change is limited to diffPreview (occurrence counts instead of a Set), with tests for both the added-duplicate and removed-duplicate cases. Happy to adjust if you'd prefer a different approach.

This branch has not been deployed

No deployments
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.

1 participant