feat: implement vertically aligned split view for diff viewer#26
Merged
ionfwsrijan merged 1 commit intoJun 3, 2026
Merged
Conversation
Contributor
Author
|
hi @ionfwsrijan kindly review it and let me know if any changes required. thanks! attatched the screenshot of the split view in diff checker also. |
|
@ionfwsrijan seems fine, go ahead |
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.
Linked issue
Closes #24
What this PR does
This PR updates the
DiffViewercomponent to support a true side-by-side split layout that maintains perfect vertical alignment. It dynamically processes the diff data to inject blank "spacer" blocks where code additions and removals are asymmetrical, ensuring that unchanged code lines remain perfectly synced horizontally across both the "Before" and "After" columns.Type of change
ML tier (if applicable)
Changes
Frontend
src/app/components/ui/diff-viewer.tsxto include a custom alignment algorithm withinrenderSplitView.flush()mechanism to group consecutiveaddedandremovedlines and pad them with{ type: "empty" }spacer lines before rendering.Testing
How did you test this?
Ran the frontend locally via Vite and navigated to the
/fixroute to test against the mock vulnerability diffs. Toggled between "Unified" and "Split" views, visually verifying that both single-line and multi-line changes injected the correct number of empty spacers to keep the surrounding context lines horizontally aligned. Also verified that the "Copy" functionality remains unaffected.Checklist
console.erroror unhandled Python exceptions introducedrequirements.txt/package.jsonupdated if new dependencies added.pkl,.pt, etc.) are gitignored, not committedAnything reviewers should focus on
Reviewers can focus on the
flush()logic insiderenderSplitViewindiff-viewer.tsx. It handles the synchronization of the left and right arrays to ensure the Tailwind flex containers maintain equal heights. No external diffing libraries were needed since the parent component already provides parsed diff objects.Screenshots (if UI changed)