From 8347e5bcd7e2d1c1f094d245594b478ec42be219 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 16 Oct 2025 20:50:40 -0700 Subject: [PATCH] Fix: Add auto-flush to renumber, rename-prefix, and compact commands These commands modify issues in bulk but weren't triggering auto-export to JSONL. This caused database and JSONL to get out of sync. Added markDirtyAndScheduleFlush() calls to: - bd renumber (after renumbering completes) - bd rename-prefix (after prefix rename completes) - bd compact (after single/batch compaction) - bd delete (already had it) Fixes the issue where massive cleanups weren't exported to JSONL. Amp-Thread-ID: https://ampcode.com/threads/T-a43dc9fa-e9bc-43c7-9055-33acc08bc642 Co-authored-by: Amp --- cmd/bd/compact.go | 8 ++++++++ cmd/bd/rename_prefix.go | 3 +++ cmd/bd/renumber.go | 3 +++ 3 files changed, 14 insertions(+) diff --git a/cmd/bd/compact.go b/cmd/bd/compact.go index 100a4497..cbbf07fc 100644 --- a/cmd/bd/compact.go +++ b/cmd/bd/compact.go @@ -183,6 +183,9 @@ func runCompactSingle(ctx context.Context, compactor *compact.Compactor, store * originalSize, compactedSize, savingBytes, float64(savingBytes)/float64(originalSize)*100) fmt.Printf(" Time: %v\n", elapsed) + + // Schedule auto-flush to export changes + markDirtyAndScheduleFlush() } func runCompactAll(ctx context.Context, compactor *compact.Compactor, store *sqlite.SQLiteStorage) { @@ -304,6 +307,11 @@ func runCompactAll(ctx context.Context, compactor *compact.Compactor, store *sql if totalOriginal > 0 { fmt.Printf(" Saved: %d bytes (%.1f%%)\n", totalSaved, float64(totalSaved)/float64(totalOriginal)*100) } + + // Schedule auto-flush to export changes + if successCount > 0 { + markDirtyAndScheduleFlush() + } } func runCompactStats(ctx context.Context, store *sqlite.SQLiteStorage) { diff --git a/cmd/bd/rename_prefix.go b/cmd/bd/rename_prefix.go index c7466042..6fdb9621 100644 --- a/cmd/bd/rename_prefix.go +++ b/cmd/bd/rename_prefix.go @@ -96,6 +96,9 @@ Example: os.Exit(1) } + // Schedule auto-flush to export changes + markDirtyAndScheduleFlush() + fmt.Printf("%s Successfully renamed prefix from %s to %s\n", green("✓"), cyan(oldPrefix), cyan(newPrefix)) if jsonOutput { diff --git a/cmd/bd/renumber.go b/cmd/bd/renumber.go index 08773ffa..b6ef49d3 100644 --- a/cmd/bd/renumber.go +++ b/cmd/bd/renumber.go @@ -127,6 +127,9 @@ Risks: os.Exit(1) } + // Schedule auto-flush to export changes + markDirtyAndScheduleFlush() + fmt.Printf("%s Successfully renumbered %d issues\n", green("✓"), len(issues)) // Count actual changes