fix(sync): cleanup snapshots after sync regardless of --no-pull (bd-0io)

Moved snapshot cleanup call to the end of successful sync, outside the
!noPull block. This ensures snapshot files (beads.base.jsonl, beads.left.jsonl)
are removed even when --no-pull is used.

Previously, captureLeftSnapshot was called before the pull block, but
cleanup was only inside the pull block, leaving orphaned files when
--no-pull was used.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-28 21:50:47 -08:00
parent efff0c9851
commit 40b86a15a7
2 changed files with 77 additions and 78 deletions

View File

@@ -428,20 +428,19 @@ Use --merge to merge the sync branch back to main branch.`,
if dryRun {
fmt.Println("\n✓ Dry run complete (no changes made)")
} else {
// Clean up temporary snapshot files after successful sync (bd-0io)
// This runs regardless of whether pull was performed
sm := NewSnapshotManager(jsonlPath)
if err := sm.Cleanup(); err != nil {
fmt.Fprintf(os.Stderr, "Warning: failed to clean up snapshots: %v\n", err)
}
// Auto-compact deletions manifest if enabled and threshold exceeded
if err := maybeAutoCompactDeletions(ctx, jsonlPath); err != nil {
// Non-fatal - just log warning
fmt.Fprintf(os.Stderr, "Warning: auto-compact deletions failed: %v\n", err)
}
// Clean up snapshot files after successful sync (bd-0io fix)
// This ensures snapshots are removed even when --no-pull is used,
// since captureLeftSnapshot is called before the pull block.
sm := NewSnapshotManager(jsonlPath)
if err := sm.Cleanup(); err != nil {
fmt.Fprintf(os.Stderr, "Warning: failed to clean up snapshots: %v\n", err)
}
fmt.Println("\n✓ Sync complete")
}
},