Skip to content

Treat touching edits as a merge conflict - #349

Closed
ThePumpingLemma wants to merge 1 commit into
block:mainfrom
ThePumpingLemma:dgrochowski/merge-touching-edits
Closed

ThePumpingLemma wants to merge 1 commit into
block:mainfrom
ThePumpingLemma:dgrochowski/merge-touching-edits

Conversation

@ThePumpingLemma

Copy link
Copy Markdown
Contributor

What changed and why

When a web save is stale, Coplan merges the draft with the current version three ways, on the server (Plans::MergeText) and in the editor (merge_text.js). Both treated edits that touch as separate, and combined them:

Base One person The other Merged on main
Run the backfill daily. Run the backfill twice daily. Run the backfill weekly. Run the backfill twice weekly.
Ship in Q4. Ship in Q4 2027. Ship in Q3. Ship in Q3 2027.

Neither person wrote the result. It's saved as a human version, so it also blocks agent writes until someone reads it, and nothing tells either person their text was combined.

Now both merges treat edits that touch as a conflict, as diff3 does: an insert at the edge of a replacement, and two replacements that abut. Edits still combine when unchanged text separates them, even one character. A conflict shows the existing review step, as overlapping edits already did.

Found in the Coplan STPA review (finding content-edits-6): https://coplan.sqprod.co/dgrochowski/reliability-analyses/coplan-stamp-stpa-analysis-service-review

Evidence

The editor's mergeText, run with Bun on main and on this branch:

Base / one / other main this PR
daily / twice daily / weekly Run the backfill twice weekly. conflict
Q4 / Q4 2027 / Q3 Ship in Q3 2027. conflict
abc / aBc / abC aBC conflict
abcd / aBcd / abcD aBcD aBcD
Café ☀️, alpha and beta (ALPHA / BETA) Café ☀️, ALPHA and BETA. Café ☀️, ALPHA and BETA.

spec/services/plans/merge_text_spec.rb covers the same cases on the server, in both orders.

How to try it

bin/rails runner 'p Coplan::Plans::MergeText.call(base: "Run the backfill daily.", local: "Run the backfill twice daily.", remote: "Run the backfill weekly.")'

This raises Coplan::Plans::MergeText::Conflict. On main it prints "Run the backfill twice weekly.".

In the browser:

  1. Open one plan in two tabs as hampton@example.com.
  2. In tab A, change "daily" to "weekly" and save.
  3. In tab B, which still has the old version, add "twice " before "daily" and save.

Tab B should ask you to review the conflict instead of saving "twice weekly".

Testing

  • No new UI. The conflict review already exists; this PR only changes when it appears. CI runs the existing system specs that cover it.
  • Updated merge_text_spec.rb. The old "combines adjacent replacements and boundary insertions" example pinned the behaviour this PR removes, so it now expects a conflict.
  • Ran bundle exec rspec --exclude-pattern "spec/system/**/*_spec.rb": 2,929 examples, 0 failures. System specs can't start Chrome locally, so CI covers them.
  • Light and dark mode don't apply.
  • Evidence is the table above.

- MergeText and the editor's mergeText combined an insert at a replacement's edge, and abutting replacements, splicing text neither author wrote ('twice daily' + 'weekly' -> 'twice weekly').
- Edits must now be separated by unchanged text to combine, as in diff3.

@HamptonMakes HamptonMakes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, this is going to be a 'no' for me.

In the current implementation, if you were a human editor, you would SEE the result of the merge... both of the editors would. It would visibly be wrong.

In this proposal, one of them silently is ignored and... neither author can address the actual meaning conflict they had on that content.

Further, we don't even have multi-author editing right now... though it is coming and will be a feature, so the overall intention is right.

But yeah- we have live updating on both reader and editor human views and this is just NOT a bug.

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.

2 participants