From 1c9ce267d5ce1cbf72780c98edc157e20d805739 Mon Sep 17 00:00:00 2001 From: ace Date: Mon, 26 Jan 2026 12:30:37 -0800 Subject: [PATCH] perf(mail): add daemon bypass for mail queries Add --no-daemon --allow-stale flags to runBdCommand in mail/bd.go, matching the pattern used in beads/beads.go. This avoids daemon IPC overhead for mail operations and prevents stale sync errors. Recovered from lost commit 2f960462. Co-Authored-By: Claude Opus 4.5 --- internal/mail/bd.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/mail/bd.go b/internal/mail/bd.go index eefb8520..89c9f038 100644 --- a/internal/mail/bd.go +++ b/internal/mail/bd.go @@ -39,8 +39,14 @@ func (e *bdError) ContainsError(substr string) bool { // beadsDir is the BEADS_DIR environment variable value. // extraEnv contains additional environment variables to set (e.g., "BD_IDENTITY=..."). // Returns stdout bytes on success, or a *bdError on failure. +// +// Uses --no-daemon for faster read operations (avoids daemon IPC overhead). +// Uses --allow-stale to prevent failures when db is out of sync with JSONL +// (e.g., after daemon is killed during shutdown before syncing). func runBdCommand(args []string, workDir, beadsDir string, extraEnv ...string) ([]byte, error) { - cmd := exec.Command("bd", args...) //nolint:gosec // G204: bd is a trusted internal tool + // Prepend daemon bypass flags for performance + fullArgs := append([]string{"--no-daemon", "--allow-stale"}, args...) + cmd := exec.Command("bd", fullArgs...) //nolint:gosec // G204: bd is a trusted internal tool cmd.Dir = workDir env := append(cmd.Environ(), "BEADS_DIR="+beadsDir)