gabriel / muse public
fix diff main #71 / 100

fix(diff): semantic symbols in working-tree diff + correct A/D/M prefix (#184)

Before this fix, `muse diff` on the working tree always fell back to a plain file-level `A README.md` for new/modified files because their blobs had never been written to the object store (that only happens on `muse commit`). Semantic symbol diffing worked fine between two *committed* snapshots, but not for the common case of comparing HEAD to the live tree.

Fix 1 — plugin.py: _read_blob + _semantic_ops workdir fallback Added `_read_blob(repo_root, content_id, disk_fallback)` which first tries the object store, then reads the file from disk and verifies its SHA-256 matches the expected content_id before accepting it. `_semantic_ops` now accepts an optional `workdir` parameter; when set, target blobs not in the object store are fetched via `_read_blob` with the on-disk path as fallback. `CodePlugin.diff` passes `workdir=repo_root` unconditionally — the hash check ensures commit-to-commit diffs are never contaminated by stale on-disk content.

Fix 2 — diff.py: correct prefix + inline child ops `_print_structured_delta` now correctly labels PatchOps: - All child ops are inserts → `A file` (newly added file) - All child ops are deletes → `D file` (fully removed file) - Mixed → `M file` (modification) Added `_print_child_ops` which renders up to 12 symbol changes inline with tree connectors (├─ / └─), summarising any overflow on one line. Previously, only the file path and a one-line summary were shown.

Before: A README.md

1 added file

After: A README.md ├─ added section h1: Overview ├─ added section h2: Installation └─ added section h2: Usage

1 added file

Tests: 4 new regression tests in TestDiffWorkingTreeSymbols. 2549 tests total — all green.

Co-authored-by: Gabriel Cardona <gabriel@tellurstori.com>

G Gabriel Cardona <cgcardona@gmail.com> · 3d ago Mar 21, 2026 · 82d83229 · parent 66dc5269
3
files changed
343
files in snapshot
Files Changed 343 in snapshot
~3

0 comments

No comments yet. Be the first to start the discussion.