Skip to content

[FEATURE] Implement code diff/merge view when multiple users edit the same line simultaneously in a room #712

@Abhushan187

Description

@Abhushan187

Problem

When two users edit the same line or nearby lines in a collaborative room, the last-write-wins behavior in Firestore causes silent data loss. The user whose change arrives second overwrites the first user's work without any warning or merge opportunity.


Proposed Improvement

Add an inline diff/merge conflict resolution UI that detects when concurrent edits collide and presents both versions side-by-side for manual resolution. The feature should:

  • Detect line-level edit conflicts using operational transform or last-modified timestamps
  • Display a split-pane diff view inline within the editor when conflicts are detected
  • Show both versions with author labels and timestamps
  • Provide "Accept Mine", "Accept Theirs", and "Merge Both" actions
  • Store conflict metadata temporarily until resolved
  • Fall back to last-write-wins if user ignores the conflict for >60 seconds

Expected Impact

  • Better user experience by preventing silent data loss
  • Improved collaboration trust — users know their edits won't disappear
  • Higher usability for competitive programming and hackathon scenarios
  • Better long-term scalability with robust conflict resolution

Possible Implementation

  • Add ConflictDetector utility in src/utils/ comparing local vs remote document versions using diff-match-patch
  • Extend useRoom.js to track lastModifiedBy and lastModifiedAt per line range
  • Create MergeConflictPanel component with split Monaco instances showing both versions
  • Add conflict state to Firestore rooms/{roomId}/conflicts/{conflictId}
  • Integrate with existing useEditor hook to pause auto-sync during active conflict
  • Write unit tests for conflict detection edge cases (same line, adjacent lines, multi-line blocks)

I'm GSSoC'26 contributor, Please assign this task to me!

Metadata

Metadata

Assignees

Labels

gssocOfficial GSSoC '26 issue tagtype:bugVulnerability or logical bug fixestype:designTactile visual design and UI alignmentstype:docsDocumentation and guide upgradestype:featureNew functional feature additionstype:securitySecurity patches and threat fixestype:testingIntegration and unit test coverage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions