Skip to content

fix logical errors in conflict detection - #194

Merged
Avni2000 merged 4 commits into
mainfrom
nested-md-cell-patch
Mar 22, 2026
Merged

Avni2000 merged 4 commits into
mainfrom
nested-md-cell-patch

Conversation

@Avni2000

@Avni2000 Avni2000 commented Mar 22, 2026 •

Copy link
Copy Markdown
Owner
  • Resolve issues with nested Markdown conflict cells
  • improve the logic for detecting conflicts by ensuring that conflicts are only created when both current and incoming states differ from the base state.

Summary by CodeRabbit

  • Bug Fixes

    • Tightened conflict detection: execution counts, outputs, and kernel/language-version checks now require both sides to differ from the baseline before reporting conflicts, reducing false positives and changing when auto-resolution descriptions/counters apply.
  • Style

    • Markdown cell styling no longer applies to cells marked as having conflicts, preserving visual conflict indicators.
  • Tests

    • Updated test inputs/expectations to reflect the refined conflict-detection behavior.

- only create conflict when current != incoming AND (instead of OR) (cur differs from base AND inc differs from base)
@coderabbitai

coderabbitai Bot commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ea77dba-6e84-4b38-a4f8-9f4fe5ddad21

📥 Commits

Reviewing files that changed from the base of the PR and between 6bc5084 and 2c58497.

📒 Files selected for processing (1)
  • src/conflictDetector.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/conflictDetector.ts

📝 Walkthrough

Walkthrough

Tightens conflict-detection to record execution-count, outputs, and kernel/language_info conflicts only when both current and incoming values differ from base. Narrows markdown cell styling to exclude .has-conflict cells. Updates a test case altering a synthetic cell output from '1' to '2'.

Changes

Cohort / File(s) Summary
Conflict Detection Logic
src/conflictDetector.ts
Tightened conflict conditions: execution-count and outputs conflicts now require current !== incoming AND both current !== base and incoming !== base. Kernel kernelspec / language_info “version differs” checks in applyAutoResolutions and hasKernelVersionConflict use the same both-differ-from-base logic; adjusted null/string handling.
Markdown Cell Styling
src/web/client/styles.ts
Selector narrowed to .markdown-cell:not(.has-conflict) .cell-content, so the padding/background/border-left accent rules no longer apply for conflicted markdown cells.
Tests
src/tests/settingsMatrix.test.ts
Test fixture changed: a cell execute_result output text updated from '1' to '2', modifying the synthetic “outputs-changed” input for the scenario.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • #163: Related edits to execution-count conflict handling and auto-resolution logic in src/conflictDetector.ts.
  • #160: Modifies the same conflict-detection/resolution code paths (execution_count, outputs, kernel/language_info).
  • #110: Adjusts auto-resolution behavior and resolved cell selection used by applyAutoResolutions in src/conflictDetector.ts.

Poem

🐇 I hopped the diff and twitched my nose,
Both sides must differ for the conflict to pose.
I hide my padding when strife is found,
I tweak a test and thump the ground.
Hooray for tidy merges — now I nap, unbound.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix logical errors in conflict detection' directly summarizes the main changes across all modified files, which involve tightening conflict detection logic to require both sides differ from base.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nested-md-cell-patch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

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

595-604: ⚠️ Potential issue | 🟠 Major

Handle deleted kernelspec values in this helper too.

applyAutoResolutions() now treats missing notebook metadata as null, but hasKernelVersionConflict() still exits before the new 3-way predicate when either side deletes metadata.kernelspec. That misses delete-vs-modify conflicts even though the main auto-resolution path will classify them correctly.

💡 Suggested fix
 export function hasKernelVersionConflict(
     current?: Notebook,
     incoming?: Notebook,
     base?: Notebook
 ): boolean {
     if (!current || !incoming) return false;

     const currentKernel = current.metadata?.kernelspec;
     const incomingKernel = incoming.metadata?.kernelspec;
     const baseKernel = base?.metadata?.kernelspec;

-    if (!currentKernel || !incomingKernel) return false;
-
-    const currentStr = stableStringify(currentKernel);
-    const incomingStr = stableStringify(incomingKernel);
-    const baseStr = baseKernel ? stableStringify(baseKernel) : '';
+    const currentStr = stableStringify(currentKernel ?? null);
+    const incomingStr = stableStringify(incomingKernel ?? null);
+    const baseStr = stableStringify(baseKernel ?? null);
     /**
      * Only consider it a conflict if current and incoming kernelspecs differ, and both differ from base
      */
     return currentStr !== incomingStr && 
     (currentStr !== baseStr && incomingStr !== baseStr); // both differ from base
 }
As per coding guidelines, "Always parse raw JSON in .ipynb files; conflicts may be in cells[].source, cells[].outputs, or metadata—never assume they're only in code"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/conflictDetector.ts` around lines 595 - 604, The helper
hasKernelVersionConflict currently returns early if either currentKernel or
incomingKernel is missing, which skips delete-vs-modify cases; update
hasKernelVersionConflict to allow null/missing kernelspecs by removing the early
return and normalizing currentKernel/incomingKernel/baseKernel to explicit null
(or a consistent placeholder) before calling stableStringify, then perform the
same 3-way comparison (using stableStringify on currentKernel, incomingKernel,
baseKernel) so delete (null) vs modify conflicts are detected; refer to the
hasKernelVersionConflict function and the
currentKernel/incomingKernel/baseKernel variables and use stableStringify for
the comparisons.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/conflictDetector.ts`:
- Around line 595-604: The helper hasKernelVersionConflict currently returns
early if either currentKernel or incomingKernel is missing, which skips
delete-vs-modify cases; update hasKernelVersionConflict to allow null/missing
kernelspecs by removing the early return and normalizing
currentKernel/incomingKernel/baseKernel to explicit null (or a consistent
placeholder) before calling stableStringify, then perform the same 3-way
comparison (using stableStringify on currentKernel, incomingKernel, baseKernel)
so delete (null) vs modify conflicts are detected; refer to the
hasKernelVersionConflict function and the
currentKernel/incomingKernel/baseKernel variables and use stableStringify for
the comparisons.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 853c0519-a3f9-466a-bb69-b8091c0935c5

📥 Commits

Reviewing files that changed from the base of the PR and between 364c1ee and f4e067f.

📒 Files selected for processing (2)
  • src/conflictDetector.ts
  • src/web/client/styles.ts

@Avni2000
Avni2000 enabled auto-merge March 22, 2026 21:17
@Avni2000
Avni2000 merged commit 48f8fdf into main Mar 22, 2026
5 checks passed
@Avni2000
Avni2000 deleted the nested-md-cell-patch branch March 22, 2026 21:25
@coderabbitai coderabbitai Bot mentioned this pull request Apr 2, 2026
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