From 3108000f72bf84bf7cb04ebdbfa32dc2ffb4dedc Mon Sep 17 00:00:00 2001 From: beads/crew/emma Date: Wed, 31 Dec 2025 12:24:17 -0800 Subject: [PATCH] fix: add text reference updates to deleteBatchFallback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code review found that deleteBatchFallback was missing the text reference update step (replacing "issue-id" with "[deleted:issue-id]" in connected issues). This aligns the fallback path with the SQLite batch delete behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cmd/bd/delete.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cmd/bd/delete.go b/cmd/bd/delete.go index 86507714..ffc943d2 100644 --- a/cmd/bd/delete.go +++ b/cmd/bd/delete.go @@ -618,6 +618,31 @@ func deleteBatchFallback(issueIDs []string, force bool, dryRun bool, cascade boo return } + // Pre-collect connected issues before deletion (for text reference updates) + connectedIssues := make(map[string]*types.Issue) + idSet := make(map[string]bool) + for _, id := range issueIDs { + idSet[id] = true + } + for _, id := range issueIDs { + deps, err := store.GetDependencies(ctx, id) + if err == nil { + for _, dep := range deps { + if !idSet[dep.ID] { + connectedIssues[dep.ID] = dep + } + } + } + dependents, err := store.GetDependents(ctx, id) + if err == nil { + for _, dep := range dependents { + if !idSet[dep.ID] { + connectedIssues[dep.ID] = dep + } + } + } + } + // Delete each issue deleteActor := getActorWithGit() deletedCount := 0 @@ -652,6 +677,9 @@ func deleteBatchFallback(issueIDs []string, force bool, dryRun bool, cascade boo deletedCount++ } + // Update text references in connected issues + updatedCount := updateTextReferencesInIssues(ctx, issueIDs, connectedIssues) + // Hard delete: remove from JSONL immediately if hardDelete { for _, id := range issueIDs { @@ -668,10 +696,12 @@ func deleteBatchFallback(issueIDs []string, force bool, dryRun bool, cascade boo "deleted": issueIDs, "deleted_count": deletedCount, "dependencies_removed": depsRemoved, + "references_updated": updatedCount, }) } else { fmt.Printf("%s Deleted %d issue(s)\n", ui.RenderPass("✓"), deletedCount) fmt.Printf(" Removed %d dependency link(s)\n", depsRemoved) + fmt.Printf(" Updated text references in %d issue(s)\n", updatedCount) } }