Skip to content

[FIX] Incoming cells now overwrite instead of dropping - #81

Merged
Avni2000 merged 4 commits into
mainfrom
incoming-only-changes
Feb 12, 2026
Merged

Avni2000 merged 4 commits into
mainfrom
incoming-only-changes

Conversation

@Avni2000

@Avni2000 Avni2000 commented Feb 12, 2026 •

Copy link
Copy Markdown
Owner

Incoming cells were silently dropping when they should've been overwriting

  • If base == current, we short circuited and chose current automatically and called it a unified row.
  • A handful of other small fixes to execution count, metadata handling, etc.

Summary by CodeRabbit

  • New Features

    • Improved notebook merge behavior: enhanced 3-way merge preserves one-sided incoming edits and uses deterministic metadata checks to pick the best cell when safe.
  • Bug Fixes

    • Deterministic renumbering of execution counts in merged notebooks to ensure consistent, predictable numbering.
  • Tests

    • Added regression tests and demo notebooks to validate incoming-only preservation and execution-count renumbering.

@coderabbitai

coderabbitai Bot commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a deterministic 3-way cell selection function and integrates it into resolver and UI paths to choose non-conflicting merged cells; includes regression tests and notebook fixtures to validate one-sided incoming edits and execution_count renumbering.

Changes

Cohort / File(s) Summary
3-way merge helper
src/notebookUtils.ts
New exported selectNonConflictMergedCell(baseCell?, currentCell?, incomingCell?) and internal stableStringify() to deterministically compare sources/metadata and pick the appropriate non-conflict cell.
Resolver integration
src/resolver.ts
Now imports and uses selectNonConflictMergedCell(...) when assembling non-conflict/identical rows instead of the previous simple fallback; removed an empty-string guard in non-conflict handling.
UI integration
src/web/client/MergeRow.tsx
Replaced direct identical-row fallback with selectNonConflictMergedCell(row.baseCell, row.currentCell, row.incomingCell) to preserve one-sided edits in the UI flow.
Tests: regression & logic
src/tests/incomingNonConflictRegression.test.ts, src/tests/logicRegression.test.ts
Added an end-to-end Playwright regression test to ensure incoming-only edits are preserved and a unit-style logic regression asserting metadata merge and execution_count renumbering. Both export run(): Promise<void>.
Test registry update
src/tests/registry.ts
Added a regression TEST_GROUP with regression_incoming_nonconflict and regression_logic_metadata_renumber test entries referencing the new test modules.
Notebook fixtures
test/demo_base.ipynb, test/demo_current.ipynb, test/demo_incoming.ipynb
Added three fixture notebooks demonstrating divergent edits (code/metadata/content) used by the new regression tests.
Execution count renumbering
src/notebookParser.ts
Adjusted renumberExecutionCounts to compute a nextCount and use it consistently for cell and execute_result execution_count assignments.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(200,200,255,0.5)
    participant UI as MergeRow (UI)
    end
    rect rgba(200,255,200,0.5)
    participant Resolver as Resolver
    end
    rect rgba(255,200,200,0.5)
    participant Utils as notebookUtils
    end

    UI->>Resolver: request assemble row (base,current,incoming)
    Resolver->>Utils: selectNonConflictMergedCell(base,current,incoming)
    Utils-->>Resolver: chosenCell (incoming | current | base | undefined)
    Resolver-->>UI: assembled row with chosenCell
    UI->>UI: render merged row / preserve incoming edits
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through three paths, small and bright—
Base, current, incoming in soft moonlight.
When one side changed and the rest stayed true,
I nudged the incoming so its voice came through.
A tiny hop for code, a blossom in view. 🌸

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title '[FIX] Incoming cells now overwrite instead of dropping' directly captures the main fix: preventing incoming cells from being dropped and ensuring they overwrite existing data when appropriate.
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 incoming-only-changes

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.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test/demo_incoming.ipynb`:
- Around line 34-51: The function grad_descent has a parameter named
learning_size but callers use learning_rate; rename the parameter in
grad_descent from learning_size to learning_rate and update all internal uses
(the multiplier where you subtract learning_size * d) so the signature and body
match the call sites (and thus the stored output). Ensure you only change the
parameter name in grad_descent and its internal references so calls that pass
learning_rate work without error.
🧹 Nitpick comments (1)
src/tests/incomingNonConflictRegression.test.ts (1)

26-36: getStep1GradientDescentSource searches markdown cells only by content substring — consider tightening the match.

The function finds any cell whose full source includes "## Step 1: Gradient Descent". If a code cell ever contained that string in a comment, it would match unexpectedly. This is unlikely given the fixtures, so just a minor observation.

Comment thread test/demo_incoming.ipynb
Comment on lines +34 to +51
"source": [
"def grad_descent(iterations: int, learning_size: float, init: int) -> float:\n",
" \"\"\"This is a summary\n",
"\n",
" Args:\n",
" iterations (int): _description_\n",
" learning_size (float): _description_\n",
" init (int): _description_\n",
"\n",
" Returns:\n",
" float: _description_\n",
" \"\"\"\n",
" minimizer = init\n",
" # Start from initial point and move towards minimum\n",
" for _ in range(iterations):\n",
" d = 2*minimizer\n",
" minimizer = minimizer - learning_size * d\n",
" return round(minimizer, 5)"

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.

⚠️ Potential issue | 🟡 Minor

Parameter name mismatch between function definition and call site.

The function is defined with learning_size (Line 35) but invoked with learning_rate (Line 78). This would raise a TypeError at runtime in Python. The base notebook (demo_base.ipynb) correctly uses learning_rate in both places.

While this fixture is only used for source-text comparison in the regression test (not executed), the stored output 0.0 on Line 72 is inconsistent with this broken code — the cell couldn't have produced that output.

Suggested fix
-    "def grad_descent(iterations: int, learning_size: float, init: int) -> float:\n",
+    "def grad_descent(iterations: int, learning_rate: float, init: int) -> float:\n",

Also applies to: 76-78

🤖 Prompt for AI Agents
In `@test/demo_incoming.ipynb` around lines 34 - 51, The function grad_descent has
a parameter named learning_size but callers use learning_rate; rename the
parameter in grad_descent from learning_size to learning_rate and update all
internal uses (the multiplier where you subtract learning_size * d) so the
signature and body match the call sites (and thus the stored output). Ensure you
only change the parameter name in grad_descent and its internal references so
calls that pass learning_rate work without error.

@Avni2000 Avni2000 changed the title Incoming-only-changes [FIX] Incoming cells now overwrite instead of dropping Feb 12, 2026
@Avni2000
Avni2000 merged commit 7afc62f into main Feb 12, 2026
4 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Feb 12, 2026
@Avni2000
Avni2000 deleted the incoming-only-changes branch March 1, 2026 01:38
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