feat: Linux menubar companion (GTK3 + WebKitGTK)#35
Open
Conversation
Extract platform-agnostic companion logic from darwin-only build tags into shared unix files, then implement a native Linux popover using CGO + GTK3 + WebKitGTK - mirroring the macOS Cocoa/WebKit pattern. Phase 1 - Shared code extraction: - Move menubarPopover interface/constants to popover.go (no build tag) - Rename companion_darwin.go -> companion_unix.go (darwin || linux) - Extend runtime_state.go build tag to include linux - Create menubar_linux.go with Init/Stop/IsSupported/IsRunning - Update menubar_stub.go to exclude linux from no-op builds - Remove hardcoded runtime.GOOS check in menubar_runtime.go Phase 2 - Linux native popover: - popover_linux.c: GTK3 popup window + WebKitGTK WebView - webview_linux.go: CGO bridge (same API as webview_darwin.go) - webview_stub_linux.go: browser fallback when CGO disabled - Focus-out dismissal, top-right workarea positioning - External URL interception with browser redirect Phase 3 - Build & release infrastructure: - app.sh: auto-detect GTK/WebKit and build with menubar tags - release.yml: add build-linux-desktop job on ubuntu-latest - Two Linux variants: headless (no CGO) and desktop (with menubar) Phase 4 - Tests: - Rename runtime_state_darwin_test.go -> runtime_state_unix_test.go - Add webview_linux_test.go for popover lifecycle testing
Critical fixes: - Remove //go:build ignore from popover_linux.c that prevented CGO compilation (C symbols would be undefined at link time) - Extract shared TestMain/runOnMainThread to webview_cgo_test.go with //go:build menubar && (darwin || linux) && cgo to eliminate duplicate symbol risk between platform test files - Add gtk_widget_grab_focus after gtk_window_present in do_show and do_toggle to ensure focus-out dismissal works on GNOME/KDE - Fix potential deadlock in onwatch_run_on_main_sync by using g_cond_wait_until with g_main_context_iteration fallback when GTK main loop is not yet processing idle sources Other fixes: - Update stale comment in menubar_darwin.go referencing deleted companion_darwin.go (now companion_unix.go) - Add GTK/WebKit dev lib installation to app.sh --deps for Debian/Ubuntu and Fedora/RHEL Test coverage for new/changed code: - popover_test.go: dimension constants, error sentinel - companion_unix_test.go: normalizeRefreshSeconds boundaries, trayTooltip nil/zero/normal cases, tray controller URL construction with nil/custom config, stopCompanion idempotency - runtime_state_unix_test.go: PID path construction, readPID with valid/empty/malformed/whitespace content, companionPIDEnvValue, companionProcessRunning smoke, TriggerRefresh with missing/dead PID
- Fix TrayTitle comment: "macOS tray icon" -> "system tray icon" - Remove dead Windows branch in defaultCompanionPIDDir (unreachable under darwin || linux build tag) and unused runtime import - Remove unused showMenubar method from companion_unix.go - Replace no-op TestRefreshStatusNilController with honest t.Skip - Align menubar_linux.go Init comment with menubar_darwin.go - Add doc comments to webview stub files explaining browser fallback
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Starting the review now, gonna send updates soon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the macOS-only menubar companion to Linux using CGO + GTK3 + WebKitGTK. The existing architecture already uses
fyne.io/systray(which supports Linux vialibayatana-appindicator3), so the main work is implementing the native popover window and extracting shared code from darwin-only build tags.companion_unix.go(wascompanion_darwin.go)Testing on Linux
Prerequisites
Ubuntu 22.04+ or Debian Bookworm+ (for
webkit2gtk-4.1).On Fedora 38+:
Build
Or use the build script (auto-detects GTK/WebKit):
Run
Run tests
Test plan
./app.sh --build && ./app.sh --test- no regressionsxvfb-run go test -tags menubar -race ./internal/menubar/...passes on ubuntu-latestReporting issues
If something doesn't work on your Linux setup, please open an issue with:
cat /etc/os-release)./onwatch --debug 2>&1 | head -100Important: Mask any API keys before sharing logs or config files. Replace key values with
***in.envfiles and log output.Runtime dependencies (Linux desktop variant)
libayatana-appindicator3-1(system tray)libwebkit2gtk-4.1-0(WebView rendering)libgtk-3-0(windowing)