From 3e33d1053c222dcb0400c39657aba776cadf086b Mon Sep 17 00:00:00 2001 From: wenjie Date: Tue, 17 Mar 2026 20:13:11 +0800 Subject: [PATCH] fix(backend): add no-cgo tray fallback for darwin and freebsd (#1691) * refactor(backend): add darwin no-cgo tray fallback * fix(release): stub tray for freebsd builds without cgo --- web/backend/systray.go | 2 +- web/backend/tray_stub_nocgo.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 web/backend/tray_stub_nocgo.go diff --git a/web/backend/systray.go b/web/backend/systray.go index 902cc65e0..2ae4434bb 100644 --- a/web/backend/systray.go +++ b/web/backend/systray.go @@ -1,4 +1,4 @@ -//go:build !darwin || cgo +//go:build (!darwin && !freebsd) || cgo package main diff --git a/web/backend/tray_stub_nocgo.go b/web/backend/tray_stub_nocgo.go new file mode 100644 index 000000000..13ecfd2cb --- /dev/null +++ b/web/backend/tray_stub_nocgo.go @@ -0,0 +1,33 @@ +//go:build (darwin || freebsd) && !cgo + +package main + +import ( + "context" + "os" + "os/signal" + "runtime" + "syscall" + "time" + + "github.com/sipeed/picoclaw/pkg/logger" +) + +func runTray() { + logger.Infof("System tray is unavailable in %s builds without cgo; running without tray", runtime.GOOS) + + if !*noBrowser { + go func() { + time.Sleep(browserDelay) + if err := openBrowser(); err != nil { + logger.Errorf("Warning: Failed to auto-open browser: %v", err) + } + }() + } + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + <-ctx.Done() + shutdownApp() +}