From 02d53ff3b50995c51a9db276cecffc32e54755a3 Mon Sep 17 00:00:00 2001 From: Daan van Etten Date: Sat, 18 Oct 2025 00:17:17 +0200 Subject: [PATCH] Add fallback for 'bd blocked' command when daemon is running (#71) The 'blocked' command doesn't have RPC support in the daemon yet. When the daemon is running, store is nil, causing a panic. This fix detects when daemon is running but store is nil, and opens a direct database connection as a fallback. This allows the command to work even when the daemon is active, until proper RPC support is added. --- cmd/bd/ready.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/bd/ready.go b/cmd/bd/ready.go index 36f3efc2..c6c649a1 100644 --- a/cmd/bd/ready.go +++ b/cmd/bd/ready.go @@ -9,6 +9,7 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" "github.com/steveyegge/beads/internal/rpc" + "github.com/steveyegge/beads/internal/storage/sqlite" "github.com/steveyegge/beads/internal/types" ) @@ -130,6 +131,17 @@ var blockedCmd = &cobra.Command{ Use: "blocked", Short: "Show blocked issues", Run: func(cmd *cobra.Command, args []string) { + // 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() blocked, err := store.GetBlockedIssues(ctx) if err != nil {