Skip to content

Added simple 3 way merge for unknown files instead of override.#798

Open
JEdward7777 wants to merge 1 commit intogenesis-ai-dev:mainfrom
JEdward7777:JEL_improve_default_merge
Open

Added simple 3 way merge for unknown files instead of override.#798
JEdward7777 wants to merge 1 commit intogenesis-ai-dev:mainfrom
JEdward7777:JEL_improve_default_merge

Conversation

@JEdward7777
Copy link
Copy Markdown

@JEdward7777 JEdward7777 commented Mar 24, 2026

Fix: Remote-only changes to unrecognized file types silently discarded during sync

The Problem

When syncing, if the local user has any modified file (e.g., metadata.json), the branches diverge and Frontier reports all differing files as conflicts — including files that only changed on the remote side. The OVERRIDE strategy, which was the default for all unrecognized file types (.yaml, .py, .txt, etc.), unconditionally kept the local version, silently discarding the remote changes.

The behavior was inconsistent and confusing:

  • ✅ Remote changes to unrecognized files were accepted when there were no local changes (clean fast-forward)
  • ❌ Remote changes to the exact same files were silently thrown away when any unrelated local file had been modified

Whether remote changes survived depended entirely on whether you happened to have an unsaved edit somewhere — a race condition that's hard to debug.

The Fix

Introduces a new SIMPLE_3WAY merge strategy that becomes the default fallback for unrecognized file types. It compares both sides against the common ancestor (base) to determine which side actually changed:

Scenario Before (OVERRIDE) After (SIMPLE_3WAY)
Only remote changed the file ❌ Discarded remote, kept stale local ✅ Accepts remote version
Only local changed the file ✅ Kept local ✅ Kept local
Both sides changed the file ✅ Kept local ✅ Kept local (local wins)
Neither side changed ✅ Kept local ✅ Kept local

Why This Is Safe

  1. No change to existing explicit strategies — Files mapped to OVERRIDE (chat-threads.json, dictionary.sqlite, etc.), CODEX_CUSTOM_MERGE, SPECIAL, ARRAY, JSONL, JSON_MERGE_3WAY, and IGNORE are completely unaffected.

  2. Makes behavior consistent, not new — Remote changes to unrecognized files were already being accepted when no local changes existed (fast-forward path). This PR simply makes the diverged-merge path behave the same way. If accepting remote changes was safe in the fast-forward case, it's equally safe in the diverged case when the local copy hasn't changed.

  3. Local always wins on true conflicts — When both sides modify the same file, local still wins. The only change is that we stop overwriting remote changes when the local file is identical to the base.

Files Changed

  • src/projectManager/utils/merge/types.ts — Added SIMPLE_3WAY enum value
  • src/projectManager/utils/merge/strategies.ts — Added pattern list, changed default fallback
  • src/projectManager/utils/merge/resolvers.ts — Added SIMPLE_3WAY case handler
  • src/test/suite/mergeStrategies.test.ts — Updated test expectation
  • docs/merge-strategy.md — Documented the new strategy

Note

Medium Risk
Changes the default conflict resolution for previously unrecognized file types, which can alter which side’s content is kept during sync/merge and could surface new merge outcomes for users’ projects.

Overview
Updates merge conflict handling so previously unrecognized file types default to a new SIMPLE_3WAY strategy rather than OVERRIDE, preventing remote-only changes from being silently discarded during diverged merges.

Implements SIMPLE_3WAY in resolvers.ts (base/ours/theirs comparison with local wins on true conflicts), wires it into types.ts and strategies.ts as the fallback strategy, updates the merge-strategy docs, and adjusts the mergeStrategies test to expect the new default.

Written by Cursor Bugbot for commit f0b74f9. This will update automatically on new commits. Configure here.

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