diff --git a/apps/macos/Sources/Clawdis/MenuContentView.swift b/apps/macos/Sources/Clawdis/MenuContentView.swift index 38d0bb1e4..bee233769 100644 --- a/apps/macos/Sources/Clawdis/MenuContentView.swift +++ b/apps/macos/Sources/Clawdis/MenuContentView.swift @@ -44,6 +44,11 @@ struct MenuContent: View { Button("Open Chat") { WebChatManager.shared.show(sessionKey: WebChatManager.shared.preferredSessionKey()) } + Button("Open Dashboard") { + Task { @MainActor in + await self.openDashboard() + } + } Toggle( isOn: Binding( get: { self.browserControlEnabled }, @@ -225,6 +230,40 @@ struct MenuContent: View { NotificationCenter.default.post(name: .clawdisSelectSettingsTab, object: tab) } + @MainActor + private func openDashboard() async { + do { + let config = try await GatewayEndpointStore.shared.requireConfig() + let wsURL = config.url + guard var components = URLComponents(url: wsURL, resolvingAgainstBaseURL: false) else { + throw NSError(domain: "Dashboard", code: 1, userInfo: [ + NSLocalizedDescriptionKey: "Invalid gateway URL", + ]) + } + switch components.scheme?.lowercased() { + case "ws": + components.scheme = "http" + case "wss": + components.scheme = "https" + default: + components.scheme = "http" + } + components.path = "/ui/" + components.query = nil + guard let url = components.url else { + throw NSError(domain: "Dashboard", code: 2, userInfo: [ + NSLocalizedDescriptionKey: "Failed to build dashboard URL", + ]) + } + NSWorkspace.shared.open(url) + } catch { + let alert = NSAlert() + alert.messageText = "Dashboard unavailable" + alert.informativeText = error.localizedDescription + alert.runModal() + } + } + private var healthStatus: (label: String, color: Color) { if let activity = self.activityStore.current { let color: Color = activity.role == .main ? .accentColor : .gray