Skip to content

reconcile: the per-item diff labels "--- source / +++ dest" but its -/+ sides are the destination and the source #256

Description

@spxrogers

What

reconcile's per-item value display (renderItemValues in internal/cli/reconcile.go) prints the header

  --- source
  +++ dest

and then renders dmp.DiffMain(dst, src, false). In diffmatchpatch, deletions come from the first text and insertions from the second, so the [-…-] fragments are destination bytes and the {+…+} fragments are source bytes: the opposite of what the header promises.

Repro

Source mcp/github.toml has command = "npx"; the rendered ~/.claude.json is edited to "npm". agentsync reconcile shows:

  --- source
  +++ dest
  {
    "command": "np[-m-]{+x+}",
    "type": "stdio"
  }

m (the destination's edit) is shown as removed and x (the source's value) as added. Read with the header, that says the destination reverted to the source, when the user did the reverse. [w]rite-back and [o]verride decide which side wins, so the diff's direction is exactly the thing the user is reading it for.

Fix

Either swap the arguments (DiffMain(src, dst, false)) so the markers match the header, or swap the header lines. Swapping the arguments is the smaller change and keeps the conventional "old = source, new = destination" reading. A test that drifts one value and asserts the marker sides ([-x-]{+m+} for the repro above) would pin it; TestReconcile_DroppedServer_WriteBackRemovesSource and the FinishRunsExactlyOnce fixtures already produce this transcript.

Scope note

Pre-existing at 309fde0 (identical in the pre-#232 binary's transcript); surfaced by the round-4 test-rigor review of #253, whose new dropped-server test made the transcript visible in-repo. Out of #253's behaviour-preserving scope. Both value-display sites (the prompt and [d]iff) call the same function, so one fix covers both.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions