Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions internal/tray/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ type Callbacks struct {
OnQuit func() // called when user clicks Quit
}

// Run starts the systray on the main thread. It blocks until quit.
// Must be called from the main goroutine on macOS.
func Run(cb Callbacks) {
systray.Run(func() {
// Register sets up the systray without starting its own event loop.
// This must be used when another framework (like Wails) already owns
// the main thread and NSApplication run loop on macOS.
func Register(cb Callbacks) {
systray.Register(func() {
systray.SetTemplateIcon(iconData, iconData)
systray.SetTitle("")
systray.SetTooltip("Egressor — egress monitor")
Expand Down
4 changes: 2 additions & 2 deletions internal/tray/tray_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type Callbacks struct {
OnQuit func()
}

// Run is a no-op on unsupported platforms.
func Run(_ Callbacks) {}
// Register is a no-op on unsupported platforms.
func Register(_ Callbacks) {}

// Available returns false when the systray is not compiled in.
func Available() bool {
Expand Down
6 changes: 4 additions & 2 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ func (a *App) Startup(ctx context.Context) {
slog.Error("failed to start proxy", "err", err)
}

// Start system tray icon (macOS menu bar)
// Set up system tray icon (macOS menu bar).
// Uses Register instead of Run to avoid starting a second NSApplication
// run loop — Wails already owns the main thread.
if tray.Available() {
go tray.Run(tray.Callbacks{
tray.Register(tray.Callbacks{
OnPauseToggle: func(paused bool) {
a.engine.SetBypassed(paused)
if paused {
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function App() {
)}
</>
) : (
<div className="w-full max-w-2xl overflow-auto">
<div className="w-full overflow-auto">
<PolicyEditor
patterns={policy.patterns}
onAdd={policy.addPattern}
Expand Down
Loading