forked from ishaan1013/sandbox
-
Notifications
You must be signed in to change notification settings - Fork 17
Add Granular Diff Controls with Algorithmic Diff Detection #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BurhanCantCode
wants to merge
12
commits into
main
Choose a base branch
from
enchancing_codediffs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
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
…ith granular diff detection and using a diff algorithm instead of gpt4o for code merging
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Nice!
|
done! |
Applying the first change removes all the red/green highlighting: Untitled.mov |
… set changes as pending
…g logic in CodeEditor
looks great so far @BurhanCantCode , couple of more bugs:
To recreate this bug:
|
thanks for the feedback @jamesmurdza and @akhileshrangani4, ill get to it the earliest i can |
…ment and improve file handling - Fix AI chat showing accept/reject buttons for all files instead of per-file - Add per-file diff state tracking with fileDiffStates map - Prevent memory leaks by adding event listener cleanup to block widgets - Add file versioning to prevent race conditions during rapid file switching - Fix file redirect logic with proper intended file scoping - Add async delay for file switching to ensure content loads before code application
… - Successfully resolved merge conflicts between enhancing_codediffs and main branch. Preserved core enhancements: per-file diff state tracking, memory leak prevention, race condition protection, proper file scoping. Fixed integration issues: removed non-existent imports, replaced apiClient with socket calls, fixed saveFile parameters (content to body), added projectId from main. Result: all enhanced functionality intact, compatible with main branch, no TypeScript errors, consistent socket API usage.
…ackage-lock.json - Added new dependencies: @clerk/backend, @hono/zod-validator, @scalar/hono-api-reference, @t3-oss/env-nextjs, @types/pg, drizzle-orm, drizzle-zod, hono, hono-openapi, pg, zod-openapi. - Updated existing dependencies: @clerk/shared, @clerk/types, zod to newer versions. - Removed outdated dependencies and ensured compatibility with the latest versions.
…g to the right file
c1d9d0b
to
b2c2ce6
Compare
f5acb81
to
df7abea
Compare
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.
Add Granular Diff Controls with Algorithmic Diff Detection
Overview
Replace naive line-by-line diff comparison with proper Myers algorithm and add granular block-level accept/reject controls for better code review workflow.
Problem
<p>Hi Burhan!</p>
created 20+ line diffs showing entire sections as removed/addedSolution
Proper Diff Algorithm
Replaced naive diff with industry-standard Myers algorithm:
Granular Block Controls
Technical Implementation
Core Diff Processing
diffLines
from 'diff' npm library (Myers algorithm)DiffBlock
objects for each change chunkLineChange
objects within each blockGranularDiffState
for editor modelVisual Controls
addContentWidget
API for floating buttonsState Management
rebuildEditorFromBlockState
Files Changed
components/editor/index.tsx
- Main diff algorithm and granular controlsimport { diffLines } from 'diff'
handleApplyCode
function with proper diff detectionhandleBlockAction
,addBlockControlWidgets
,rebuildEditorFromBlockState
Result