From 63c538616db9f30221a9f2631e77a436b2c666ff Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 17 Oct 2025 22:06:21 -0700 Subject: [PATCH] Fix bd delete panic when daemon is running Closes bd-155 When daemon is running, store is nil because PersistentPreRun returns early after connecting to daemon. The delete command (both single and batch) now falls back to direct storage access when store is nil, following the pattern used by other commands like ready and blocked. Amp-Thread-ID: https://ampcode.com/threads/T-4e1ac6f1-7465-442a-a385-adaa98b539ad Co-authored-by: Amp --- cmd/bd/delete.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cmd/bd/delete.go b/cmd/bd/delete.go index 6b8567d7..05456798 100644 --- a/cmd/bd/delete.go +++ b/cmd/bd/delete.go @@ -86,6 +86,17 @@ Force: Delete and orphan dependents // Single issue deletion (legacy behavior) issueID := issueIDs[0] + // If daemon is running but doesn't support this command, use direct storage + if daemonClient != nil && store == nil { + var err error + store, err = sqlite.New(dbPath) + if err != nil { + fmt.Fprintf(os.Stderr, "Error: failed to open database: %v\n", err) + os.Exit(1) + } + defer store.Close() + } + ctx := context.Background() // Get the issue to be deleted @@ -358,6 +369,17 @@ func removeIssueFromJSONL(issueID string) error { // deleteBatch handles deletion of multiple issues func deleteBatch(cmd *cobra.Command, issueIDs []string, force bool, dryRun bool, cascade bool) { + // If daemon is running but doesn't support this command, use direct storage + if daemonClient != nil && store == nil { + var err error + store, err = sqlite.New(dbPath) + if err != nil { + fmt.Fprintf(os.Stderr, "Error: failed to open database: %v\n", err) + os.Exit(1) + } + defer store.Close() + } + ctx := context.Background() // Type assert to SQLite storage