Skip to content

Conversation

@Avni2000
Copy link
Owner

@Avni2000 Avni2000 commented Feb 10, 2026

  • Add and implement setting to hide base by default
  • Red highlighting defines divergence between current and incoming
  • Don't render markdown for conflicted cells
  • Base is never highlighted
  • Automatic whitespace-only conflict resolution (configurable)
    closes [FIX] Diffing on 3 way merge conflicts #11

Summary by CodeRabbit

  • New Features
    • Automatic whitespace-only conflict resolution (configurable)
    • Optional base/ancestor column in the merge conflict view (configurable)
    • Enhanced cell diff rendering with branch-based color highlighting for clearer conflicts

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds whitespace-only auto-resolution, a toggleable "Base" column in the 3-way merge UI, and an undo/redo hotkey flag. Settings and package.json expose new config keys; conflict detection, resolver, and web UI are updated to propagate and act on these flags with whitespace-aware diff rendering.

Changes

Cohort / File(s) Summary
Configuration & Settings
package.json, src/settings.ts
Added public config keys mergeNB.autoResolve.whitespace, mergeNB.ui.showBaseColumn, and mergeNB.ui.enableUndoRedoHotkeys. Settings interface and defaults extended; getSettings() now reads these keys.
Whitespace Auto-Resolution
src/conflictDetector.ts
Added stripAllWhitespace() and isWhitespaceOnlyDifference() helpers and integrated whitespace-only auto-resolution for modified/added cell conflicts when enabled. Updates autoResolved counts and descriptions.
Conflict Pipeline & Payload
src/resolver.ts, src/web/WebConflictPanel.ts, src/web/webTypes.ts, src/web/client/types.ts
Plumbed optional showBaseColumn through UnifiedConflict/UnifiedConflictData and into the browser payload; adjusted semantic-resolution messaging paths and minor flow/formatting tweaks.
Web UI — Diff Rendering
src/web/client/CellContent.tsx, src/web/client/styles.ts
CellContent gains baseCell and diffMode; DiffContent and helpers become whitespace-aware. Introduced branch-based diff classes and CSS vars (--current-rgb, --incoming-rgb) for current/incoming/conflict highlighting.
Web UI — Base Column Toggle
src/web/client/ConflictResolver.tsx, src/web/client/MergeRow.tsx
Added showBaseColumn prop and conditional rendering/layout for an optional Base column; hides "Use Base" when disabled and propagates diffMode='conflict' to children.
Tests / Setup
src/tests/repoSetup.ts
Test repo setup now writes .vscode/settings.json with mergeNB.ui.showBaseColumn: true.

Sequence Diagram

sequenceDiagram
    participant Config as Extension Config
    participant Settings as Settings Module
    participant Detector as Conflict Detector
    participant Resolver as Conflict Resolver
    participant Panel as WebConflictPanel
    participant UI as Web UI (React)

    Config->>Settings: Load flags (autoResolveWhitespace, showBaseColumn, enableUndoRedoHotkeys)
    Settings->>Detector: Provide autoResolveWhitespace
    Detector->>Detector: Detect whitespace-only diffs
    alt Whitespace-only
        Detector->>Detector: Auto-resolve conflict (update counters/descriptions)
        Detector->>Resolver: Return auto-resolved results
    else Non-whitespace / remaining
        Detector->>Resolver: Return remaining conflicts
    end
    Resolver->>Panel: Build UnifiedConflict (include showBaseColumn)
    Panel->>UI: Send conflict payload to browser
    UI->>UI: Conditionally render Base column and apply branch-aware diff styling
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I nibble at whitespace seams,

where quiet lines mend merge-time dreams.
Base column peeks when I decree,
Ctrl+Z dances for you and me.
Hops and patches—conflicts flee.

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "[FIX] Improve-diffs" is vague and generic; it doesn't clearly convey what the PR improves or what specific fix is being applied. Provide a more descriptive title that specifies the key improvements, such as "[FIX] Improve diff highlighting and add base column toggle for 3-way merge conflicts" or similar.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements all requirements from issue #11: improved diff highlighting using branch-based colors (current/incoming/conflict), conditional base column display, and disables Markdown rendering for conflicted cells to clarify 3-way merge semantics.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #11 objectives: configuration properties for base column visibility and undo/redo hotkeys, whitespace conflict detection, diff rendering enhancements, and test setup for the new settings.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-diffs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/web/webTypes.ts (1)

84-102: ⚠️ Potential issue | 🟡 Minor

showBaseColumn is missing from WebConflictData.

UnifiedConflict (Line 34) and the client-side UnifiedConflictData (in src/web/client/types.ts:58) both include showBaseColumn, but WebConflictData — described as the "web-compatible version of UnifiedConflict" — does not. The payload constructed in WebConflictPanel._sendConflictData() includes showBaseColumn, so the browser receives it, but the type definition here is out of sync.

📝 Add the missing field
     // Display options
     hideNonConflictOutputs?: boolean;
     showCellHeaders?: boolean;
+    showBaseColumn?: boolean;
 
     // Branch information
     currentBranch?: string;
🤖 Fix all issues with AI agents
In `@src/conflictDetector.ts`:
- Around line 22-29: The current whitespace-normalization is too aggressive:
update the logic so it no longer strips newlines/indentation or auto-resolves
indentation-sensitive languages. Either (A) change stripAllWhitespace to only
normalize line endings and trim trailing spaces (preserve internal newlines and
indentation) and keep using isWhitespaceOnlyDifference, or (B) add a language
check before invoking isWhitespaceOnlyDifference (in the conflict resolution
paths referenced around conflictDetector usage at the sites noted, e.g., where
calls occur near the lines mentioned) to skip auto-resolution for
indentation-sensitive languages like Python (detect via notebook
kernelspec/language_info). Ensure you reference and update the functions
stripAllWhitespace and isWhitespaceOnlyDifference and the conflict resolution
callers so indentation differences in Python are not auto-resolved.

In `@src/web/client/styles.ts`:
- Around line 996-1018: Update the inline comments so the color labels match the
CSS variables: change the comment "Current branch highlights (green)" to reflect
blue (or mention --current-rgb / --current-border) and change "Incoming branch
highlights (blue)" to reflect green/teal (or mention --incoming-rgb /
--incoming-border); align the parenthetical color names with the variables used
by .diff-line-current, .diff-inline-current, .diff-line-incoming, and
.diff-inline-incoming.
🧹 Nitpick comments (4)
src/conflictDetector.ts (1)

62-68: Consider removing or gating these debug logs.

These console.log calls fire for every semantic conflict detection and log raw content lengths and equality comparisons. In a VS Code extension, these will appear in the Extension Host output and add noise. Consider removing them or wrapping them behind a verbose/debug setting.

src/web/client/MergeRow.tsx (1)

49-49: Default for showBaseColumn is inconsistent with the parent component.

MergeRow defaults showBaseColumn to true, while ConflictResolver resolves it to false from the conflict payload. Since ConflictResolver always passes the prop explicitly, this isn't a runtime bug, but the default here is misleading — it suggests base is shown by default, which contradicts the PR intent.

Suggested fix
-    showBaseColumn = true,
+    showBaseColumn = false,

Also applies to: 75-75

src/web/client/CellContent.tsx (2)

93-101: side prop is not forwarded from CellContent to DiffContent.

CellContent receives side as a prop but doesn't pass it through to DiffContent (lines 97–101). DiffContent falls back to 'current' (line 149). This is currently harmless because diffMode='conflict' makes side irrelevant in getDiffLineClass, but it will silently produce wrong branch-based coloring if diffMode='base' is ever used.

Suggested fix
                 <DiffContent
                     source={source}
                     compareSource={normalizeCellSource((compareCell ?? baseCell)!.source)}
                     diffMode={diffMode}
+                    side={side}
                 />

Also applies to: 129-136


184-188: side='base' falls through to incoming styling in base diffMode.

When side is 'base' and diffMode is 'base', line 188 routes to 'diff-line-incoming' because the ternary only checks for 'current'. While currently unreachable (MergeRow always uses diffMode='conflict'), this would produce incorrect coloring if a base-mode diff view is added later.

Consider an explicit check:

Suggested fix
-            return side === 'current' ? 'diff-line diff-line-current' : 'diff-line diff-line-incoming';
+            if (side === 'base') return 'diff-line diff-line-conflict';
+            return side === 'current' ? 'diff-line diff-line-current' : 'diff-line diff-line-incoming';

Comment on lines 996 to 1018
/* Current branch highlights (green) */
.diff-line-current {
background: rgba(var(--current-rgb), 0.18);
border-left: 3px solid rgba(var(--current-rgb), 0.7);
}

.diff-inline-current {
background: rgba(var(--current-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
}

/* Incoming branch highlights (blue) */
.diff-line-incoming {
background: rgba(var(--incoming-rgb), 0.18);
border-left: 3px solid rgba(var(--incoming-rgb), 0.7);
}

.diff-inline-incoming {
background: rgba(var(--incoming-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
text-decoration: line-through;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Swapped color labels in comments.

The comment on Line 996 says "Current branch highlights (green)" but --current-rgb is 64, 164, 223 (blue, matching --current-border: #40a4df). Similarly, Line 1008 says "Incoming branch highlights (blue)" but `--incoming-rgb` is `78, 201, 176` (teal/green, matching `--incoming-border: `#4ec9b0). The CSS is correct; only the parenthetical color names are swapped.

📝 Fix comments
-/* Current branch highlights (green) */
+/* Current branch highlights (blue) */
 .diff-line-current {
     background: rgba(var(--current-rgb), 0.18);
     border-left: 3px solid rgba(var(--current-rgb), 0.7);
 }
...
-/* Incoming branch highlights (blue) */
+/* Incoming branch highlights (teal) */
 .diff-line-incoming {
     background: rgba(var(--incoming-rgb), 0.18);
     border-left: 3px solid rgba(var(--incoming-rgb), 0.7);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/* Current branch highlights (green) */
.diff-line-current {
background: rgba(var(--current-rgb), 0.18);
border-left: 3px solid rgba(var(--current-rgb), 0.7);
}
.diff-inline-current {
background: rgba(var(--current-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
}
/* Incoming branch highlights (blue) */
.diff-line-incoming {
background: rgba(var(--incoming-rgb), 0.18);
border-left: 3px solid rgba(var(--incoming-rgb), 0.7);
}
.diff-inline-incoming {
background: rgba(var(--incoming-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
text-decoration: line-through;
}
/* Current branch highlights (blue) */
.diff-line-current {
background: rgba(var(--current-rgb), 0.18);
border-left: 3px solid rgba(var(--current-rgb), 0.7);
}
.diff-inline-current {
background: rgba(var(--current-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
}
/* Incoming branch highlights (teal) */
.diff-line-incoming {
background: rgba(var(--incoming-rgb), 0.18);
border-left: 3px solid rgba(var(--incoming-rgb), 0.7);
}
.diff-inline-incoming {
background: rgba(var(--incoming-rgb), 0.35);
padding: 0 2px;
border-radius: 2px;
}
🤖 Prompt for AI Agents
In `@src/web/client/styles.ts` around lines 996 - 1018, Update the inline comments
so the color labels match the CSS variables: change the comment "Current branch
highlights (green)" to reflect blue (or mention --current-rgb /
--current-border) and change "Incoming branch highlights (blue)" to reflect
green/teal (or mention --incoming-rgb / --incoming-border); align the
parenthetical color names with the variables used by .diff-line-current,
.diff-inline-current, .diff-line-incoming, and .diff-inline-incoming.

Avni2000 and others added 3 commits February 10, 2026 13:12
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Avni2000 Avni2000 merged commit 58bf469 into main Feb 10, 2026
2 checks passed
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.

[FIX] Diffing on 3 way merge conflicts

1 participant