From d1497369463b43f95c9a7fd5622f1e7597ae6e68 Mon Sep 17 00:00:00 2001 From: Felix Martin Date: Tue, 2 Jun 2026 12:33:23 -0400 Subject: [PATCH] Share unavailable() so the Windows sensor logs unavailable transitions --- internal/evidence/unavailable.go | 10 ++++++++++ internal/evidence/windows.go | 2 +- internal/evidence/x11.go | 5 ----- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 internal/evidence/unavailable.go diff --git a/internal/evidence/unavailable.go b/internal/evidence/unavailable.go new file mode 100644 index 0000000..927804e --- /dev/null +++ b/internal/evidence/unavailable.go @@ -0,0 +1,10 @@ +package evidence + +import "log" + +// unavailable builds an Unavailable snapshot and logs the reason. It is shared +// by every platform sensor so an unobservable window is recorded consistently. +func unavailable(reason string) WindowSnapshot { + log.Printf("evidence: %s", reason) + return WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: reason}} +} diff --git a/internal/evidence/windows.go b/internal/evidence/windows.go index 79aae4f..8f597b1 100644 --- a/internal/evidence/windows.go +++ b/internal/evidence/windows.go @@ -31,7 +31,7 @@ func (windowsSource) Watch(ctx context.Context, onChange func(WindowSnapshot)) { return } if !ok { - onChange(WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: "no foreground window"}}) + onChange(unavailable("no foreground window")) return } onChange(WindowSnapshot{Title: title, Class: class, Health: EvidenceHealth{Available: true}}) diff --git a/internal/evidence/x11.go b/internal/evidence/x11.go index 7c972e0..cbf1ace 100644 --- a/internal/evidence/x11.go +++ b/internal/evidence/x11.go @@ -4,7 +4,6 @@ package evidence import ( "context" - "log" "github.com/jezek/xgb/xproto" "github.com/jezek/xgbutil" @@ -88,7 +87,3 @@ func snapshot(X *xgbutil.XUtil) WindowSnapshot { } } -func unavailable(reason string) WindowSnapshot { - log.Printf("evidence: %s", reason) - return WindowSnapshot{Health: EvidenceHealth{Available: false, Reason: reason}} -}