From 2f9604620f2310930f3110f33c3eba02d4e13273 Mon Sep 17 00:00:00 2001 From: kirk Date: Wed, 21 Jan 2026 16:23:45 -0800 Subject: [PATCH] Fix gt mail inbox performance: bypass daemon for mail queries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mail operations were taking 30+ seconds due to beads daemon auto-import cycles. Each bd query would wait up to 5 seconds for auto-import to complete, and with 3+ queries per inbox check, this added up. The fix bypasses the daemon by passing --no-daemon to all bd commands in the mail package. This is appropriate because: - Mail queries are read-heavy and don't benefit from daemon caching - Direct SQLite access is faster for one-off queries - Avoids daemon auto-import/export cycle delays Performance improvement: 31+ seconds → 1.2 seconds Fixes: hq-b1o08 Co-Authored-By: Claude Opus 4.5 --- internal/mail/bd.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/mail/bd.go b/internal/mail/bd.go index eefb8520..3665d74d 100644 --- a/internal/mail/bd.go +++ b/internal/mail/bd.go @@ -39,7 +39,13 @@ 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 to bypass the beads daemon for direct database access. +// This avoids 5+ second delays caused by daemon auto-import cycles (bd-xxxx). +// Mail operations are read-heavy and don't benefit from daemon caching. func runBdCommand(args []string, workDir, beadsDir string, extraEnv ...string) ([]byte, error) { + // Prepend --no-daemon to avoid daemon auto-import delays + args = append([]string{"--no-daemon"}, args...) cmd := exec.Command("bd", args...) //nolint:gosec // G204: bd is a trusted internal tool cmd.Dir = workDir