From 5c158dafdbab3d22985f9f989eeaa4b3ad1c1bf7 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Fri, 23 Oct 2026 23:46:10 -0700 Subject: [PATCH] fix: log macOS notification status and failures On the maintainer's Mac, macOS reports Driga as not allowed to notify, yet Driga never appears in System Settings and nothing explains why. The collector now logs the permission status at startup, a refused permission request, and any delivery error, with macOS's own message. Claude-Session: https://claude.ai/code/session_01T2vtcW6ihn1ywy9vxUq9a4 --- internal/attention/notifications.go | 10 +++++++++- internal/cli/collect.go | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/attention/notifications.go b/internal/attention/notifications.go index 23a2dd36..4f08e9a4 100644 --- a/internal/attention/notifications.go +++ b/internal/attention/notifications.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "errors" "fmt" + "log/slog" "path/filepath" "sync" "time" @@ -54,6 +55,9 @@ func (m *MacNotifier) Notify(ctx context.Context, n Notification) error { m.mu.Unlock() if start { // outside the lock: the callback may run synchronously m.Center.Authorize(func(err error) { + if err != nil { + slog.Warn("macOS notification permission refused", "event", "notifications_refused", "err", err.Error()) + } m.mu.Lock() m.authErr = err if err != nil { @@ -109,7 +113,11 @@ func (m *MacNotifier) post(ctx context.Context, n Notification) error { } ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() - return m.Center.Add(ctx, nativeNotificationRequest(n)) + if err := m.Center.Add(ctx, nativeNotificationRequest(n)); err != nil { + slog.Warn("macOS notification not delivered", "event", "notification_failed", "err", err.Error()) + return err + } + return nil } func nativeNotificationRequest(n Notification) NativeNotificationRequest { diff --git a/internal/cli/collect.go b/internal/cli/collect.go index 54ac2e14..28920b39 100644 --- a/internal/cli/collect.go +++ b/internal/cli/collect.go @@ -3,6 +3,7 @@ package cli import ( "context" "fmt" + "github.com/labstack/driga/internal/attention" "io" "log/slog" "os" @@ -70,6 +71,14 @@ func (c CollectCmd) Run(g *Globals) error { if err != nil { return err } + if runtime.GOOS == "darwin" { + // Record what macOS reports, so a silent notification problem shows in the log. + if status, err := attention.MacNotificationStatus(); err != nil { + slog.Warn("macOS notifications unavailable", "event", "notifications_unavailable", "err", err.Error()) + } else { + slog.Info("macOS notifications", "event", "notifications_status", "status", status) + } + } ctx, stop := notifyContext(context.Background()) defer stop() if c.CPUProfile != "" {