fix(menubar): open dashboard on configured port, not hardcoded 9211#66
Merged
fix(menubar): open dashboard on configured port, not hardcoded 9211#66
Conversation
The macOS menubar popover's "Open Dashboard" button used a hardcoded http://localhost:9211 URL, ignoring ONWATCH_PORT / --port. If the user ran onWatch on any other port (e.g. 7777), clicking Open Dashboard in the popover opened a dead URL. Fix by deriving the dashboard origin from the WKWebView's own current URL (which was loaded from http://localhost:<cfg.Port>/menubar by the Go side) and stripping path/query/fragment. No new CGO symbol, no JS contract change, no second copy of the port to keep in sync - the webview's loaded origin is already the authoritative value. Fixes #65
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Fixes #65. On macOS, clicking "Open Dashboard" inside the menubar popover opened
http://localhost:9211regardless of the configured port, so users running withONWATCH_PORT=7777(or--port) got a dead URL.The bug was a single hardcoded literal in
internal/menubar/popover_darwin.m:429:The Go-side tray menu item ("Open Dashboard" via right-click) was already correct - it goes through
c.dashboardURL()which honorscfg.Port. Only the popover's in-page button was broken.Approach
Derive the dashboard origin from the
WKWebView's own loaded URL rather than threading the port through CGO or accepting one from JS:Why this over alternatives:
ONWATCH_PORTenv in Obj-C: env is a config input; the webview's origin reflects the resolved port (after flag override, auto-fallback, etc.). Env-reading would also duplicate Go's resolution rules in C.cfg.Portinto Obj-C state: no new C symbols, no second copy of the port to keep in sync, no ordering rule ("call setter before show"). TheWKWebViewalready holds the authoritative URL.isLocalURL:(already present in this file) still guards against a non-local origin.Test plan
go vet ./...clean.go test -race -count=1 ./internal/menubar/... ./internal/web/...passes (the web package asserts the JS still firessendNativeAction("open_dashboard")- unchanged).9211andopen_dashboardreferences - only the legitDefaultConfig()default, CLI banner tests, marketing copy, and the action-name string itself remain.//go:build menubar && darwin && cgo, so Linux can't compile or exercise the Obj-C path. Manual check needed: runONWATCH_PORT=7777 onwatch, open the menubar popover, click "Open Dashboard", confirm the browser openshttp://localhost:7777(not:9211).Fixes #65
Generated by Claude Code