From 91e87476f5b5706482dfc84058829c255717f7d8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Apr 2026 20:17:00 +0000 Subject: [PATCH] fix(menubar): open dashboard on configured port, not hardcoded 9211 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:/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 --- internal/menubar/popover_darwin.m | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/menubar/popover_darwin.m b/internal/menubar/popover_darwin.m index 968c5c4..8531071 100644 --- a/internal/menubar/popover_darwin.m +++ b/internal/menubar/popover_darwin.m @@ -426,9 +426,20 @@ - (void)userContentController:(WKUserContentController *)userContentController } if ([action isEqualToString:@"open_dashboard"]) { - NSURL *url = [NSURL URLWithString:@"http://localhost:9211"]; - if (url) { - [[NSWorkspace sharedWorkspace] openURL:url]; + // Derive the dashboard origin from the webview's own URL so we honor the + // runtime port (ONWATCH_PORT / --port) without threading it through CGO. + NSURL *current = self.webView.URL; + if (!current || ![self isLocalURL:current]) { + return; + } + NSURLComponents *components = + [NSURLComponents componentsWithURL:current resolvingAgainstBaseURL:NO]; + components.path = @""; + components.query = nil; + components.fragment = nil; + NSURL *dashboardURL = components.URL; + if (dashboardURL) { + [[NSWorkspace sharedWorkspace] openURL:dashboardURL]; [self close]; } }