Skip to content

Commit bef3356

Browse files
committed
fix(macos): keep dashboard failures in window
1 parent 086d3d0 commit bef3356

7 files changed

Lines changed: 130 additions & 29 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Docs: https://docs.openclaw.ai
2828

2929
### Fixes
3030

31+
- Mac app: keep app-level menu commands and Dashboard failure states reachable when the remote Gateway is disconnected, and keep the Settings sidebar toggle in the leading titlebar area.
3132
- Mac app: align the Sessions settings pane with the standard Settings page gutter and row spacing.
3233
- Codex app-server: preserve streamed native command output in mirrored transcripts and trajectory exports when final snapshots omit aggregated output. (#83200) Thanks @rozmiarD.
3334
- Codex app-server: fail closed when chat or sender policy denies tools, disabling native code, app, environment, and user MCP surfaces for restricted turns. (#82374) Thanks @VACInc.

‎apps/macos/Sources/OpenClaw/DashboardManager.swift‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ final class DashboardManager {
1010
static let shared = DashboardManager()
1111

1212
private var controller: DashboardWindowController?
13+
private static let failureURL = URL(string: "about:blank")!
1314

1415
private init() {}
1516

@@ -69,6 +70,19 @@ final class DashboardManager {
6970
Task { _ = try? await ControlChannel.shared.health(timeout: 3) }
7071
}
7172

73+
func showFailure(_ error: Error) {
74+
let message = (error as NSError).localizedDescription
75+
dashboardManagerLogger.error("dashboard setup failed error=\(message, privacy: .public)")
76+
let controller = self.controller ?? DashboardWindowController(
77+
url: Self.failureURL,
78+
auth: DashboardWindowAuth(gatewayUrl: nil, token: nil, password: nil))
79+
self.controller = controller
80+
controller.showFailure(
81+
title: "Dashboard unavailable",
82+
message: message,
83+
detail: "Check Settings → Connection or use Debug → Reset Remote Tunnel, then try again.")
84+
}
85+
7286
func close() {
7387
self.controller?.closeDashboard()
7488
}

‎apps/macos/Sources/OpenClaw/DashboardWindowController.swift‎

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
8080
self.window?.performClose(nil)
8181
}
8282

83+
func showFailure(title: String, message: String, detail: String? = nil) {
84+
self.currentURL = URL(string: "about:blank")!
85+
self.auth = DashboardWindowAuth(gatewayUrl: nil, token: nil, password: nil)
86+
self.refreshNativeAuthScript(url: self.currentURL, auth: self.auth)
87+
self.webView.stopLoading()
88+
self.webView.loadHTMLString(
89+
Self.failureHTML(title: title, message: message, detail: detail, url: nil),
90+
baseURL: nil)
91+
self.show()
92+
}
93+
8394
private func load(_ url: URL) {
8495
dashboardWindowLogger.debug("dashboard load \(url.absoluteString, privacy: .public)")
8596
self.webView.load(URLRequest(url: url))
@@ -282,54 +293,107 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
282293
if nsError.domain == NSURLErrorDomain, nsError.code == NSURLErrorCancelled { return }
283294
dashboardWindowLogger.error(
284295
"dashboard load failed url=\(self.currentURL.absoluteString, privacy: .public) error=\(error.localizedDescription, privacy: .public)")
285-
let html = Self.failureHTML(url: self.currentURL, message: error.localizedDescription)
296+
let html = Self.failureHTML(
297+
title: "Dashboard unavailable",
298+
message: error.localizedDescription,
299+
detail: "The dashboard window is open, but the web UI could not load from this endpoint.",
300+
url: self.currentURL)
286301
self.webView.loadHTMLString(html, baseURL: nil)
287302
}
288303

289-
private static func failureHTML(url: URL, message: String) -> String {
290-
"""
304+
private static func failureHTML(title: String, message: String, detail: String?, url: URL?) -> String {
305+
let detailHTML = detail.map { "<p class=\"detail\">\(self.htmlEscape($0))</p>" } ?? ""
306+
let urlHTML = url.map { "<code>\(self.htmlEscape($0.absoluteString))</code>" } ?? ""
307+
return """
291308
<!doctype html>
292309
<html>
293310
<head>
294311
<meta charset="utf-8">
295312
<style>
296313
:root { color-scheme: light dark; }
314+
* { box-sizing: border-box; }
297315
body {
298316
margin: 0;
299317
min-height: 100vh;
300318
display: grid;
301319
place-items: center;
302-
background: Canvas;
303-
color: CanvasText;
304-
font: -apple-system-body;
320+
background: #101114;
321+
color: rgba(255,255,255,.92);
322+
font: 15px -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
305323
}
306324
main {
307-
width: min(520px, calc(100vw - 64px));
308-
line-height: 1.4;
325+
width: min(540px, calc(100vw - 72px));
326+
padding: 34px;
327+
border: 1px solid rgba(255,255,255,.12);
328+
border-radius: 22px;
329+
background: rgba(255,255,255,.035);
330+
box-shadow: 0 28px 90px rgba(0,0,0,.36);
331+
line-height: 1.45;
332+
}
333+
.badge {
334+
width: 44px;
335+
height: 44px;
336+
display: grid;
337+
place-items: center;
338+
margin-bottom: 20px;
339+
border-radius: 14px;
340+
background: rgba(255,255,255,.07);
341+
color: #ff746b;
342+
font-size: 24px;
309343
}
310344
h1 {
311-
margin: 0 0 10px;
312-
font: -apple-system-title2;
313-
font-weight: 650;
345+
margin: 0 0 12px;
346+
font-size: 24px;
347+
line-height: 1.16;
348+
font-weight: 700;
349+
letter-spacing: 0;
350+
}
351+
p {
352+
margin: 0;
353+
color: rgba(255,255,255,.76);
354+
font-size: 16px;
355+
}
356+
.detail {
357+
margin-top: 14px;
358+
color: rgba(255,255,255,.56);
359+
font-size: 13px;
314360
}
315-
p { margin: 8px 0; color: color-mix(in srgb, CanvasText 72%, transparent); }
316361
code {
317362
display: block;
318-
margin-top: 14px;
363+
margin-top: 18px;
319364
padding: 12px;
320-
border-radius: 8px;
321-
background: color-mix(in srgb, CanvasText 8%, transparent);
322-
color: CanvasText;
365+
border: 1px solid rgba(255,255,255,.08);
366+
border-radius: 10px;
367+
background: rgba(0,0,0,.26);
368+
color: rgba(255,255,255,.76);
323369
overflow-wrap: anywhere;
324370
font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
325371
}
372+
@media (prefers-color-scheme: light) {
373+
body { background: #f5f6f8; color: rgba(0,0,0,.86); }
374+
main {
375+
background: rgba(255,255,255,.84);
376+
border-color: rgba(0,0,0,.1);
377+
box-shadow: 0 28px 90px rgba(0,0,0,.12);
378+
}
379+
.badge { background: rgba(0,0,0,.06); }
380+
p { color: rgba(0,0,0,.68); }
381+
.detail { color: rgba(0,0,0,.54); }
382+
code {
383+
background: rgba(0,0,0,.05);
384+
border-color: rgba(0,0,0,.08);
385+
color: rgba(0,0,0,.68);
386+
}
387+
}
326388
</style>
327389
</head>
328390
<body>
329391
<main>
330-
<h1>Dashboard unavailable</h1>
392+
<div class="badge">!</div>
393+
<h1>\(self.htmlEscape(title))</h1>
331394
<p>\(self.htmlEscape(message))</p>
332-
<code>\(self.htmlEscape(url.absoluteString))</code>
395+
\(detailHTML)
396+
\(urlHTML)
333397
</main>
334398
</body>
335399
</html>

‎apps/macos/Sources/OpenClaw/DeepLinks.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ final class DeepLinkHandler {
184184
do {
185185
try await DashboardManager.shared.show()
186186
} catch {
187-
self.presentAlert(title: "Dashboard unavailable", message: error.localizedDescription)
187+
DashboardManager.shared.showFailure(error)
188188
}
189189
}
190190

‎apps/macos/Sources/OpenClaw/MenuBar.swift‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ struct OpenClawApp: App {
9191
}
9292
}
9393

94-
private func applyStatusItemAppearance(paused: Bool, sleeping: Bool) {
95-
self.statusItem?.button?.appearsDisabled = paused || sleeping
94+
private func applyStatusItemAppearance(paused _: Bool, sleeping _: Bool) {
95+
// Keep the status item actionable even when the Gateway is paused or disconnected.
96+
// The SwiftUI label already renders those states; AppKit's disabled appearance can
97+
// leak into menu item validation and grey out app-level commands like Settings.
98+
self.statusItem?.button?.appearsDisabled = false
9699
}
97100

98101
private static func applyAttachOnlyOverrideIfNeeded() {
@@ -180,10 +183,7 @@ struct OpenClawApp: App {
180183
do {
181184
try await DashboardManager.shared.show()
182185
} catch {
183-
let alert = NSAlert()
184-
alert.messageText = "Dashboard unavailable"
185-
alert.informativeText = error.localizedDescription
186-
alert.runModal()
186+
DashboardManager.shared.showFailure(error)
187187
}
188188
}
189189
}
@@ -302,10 +302,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
302302
do {
303303
try await DashboardManager.shared.show()
304304
} catch {
305-
let alert = NSAlert()
306-
alert.messageText = "Dashboard unavailable"
307-
alert.informativeText = error.localizedDescription
308-
alert.runModal()
305+
DashboardManager.shared.showFailure(error)
309306
}
310307
}
311308
}

‎apps/macos/Sources/OpenClaw/SettingsRootView.swift‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ struct SettingsRootView: View {
4848
}
4949
.frame(width: SettingsTab.windowWidth, height: SettingsTab.windowHeight, alignment: .topLeading)
5050
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
51+
.toolbar(removing: .sidebarToggle)
52+
.toolbar {
53+
ToolbarItem(placement: .navigation) {
54+
Button {
55+
NSApp.sendAction(#selector(NSSplitViewController.toggleSidebar(_:)), to: nil, from: nil)
56+
} label: {
57+
Image(systemName: "sidebar.left")
58+
}
59+
.help("Show or hide sidebar")
60+
}
61+
}
5162
.background(SettingsWindowChromeConfigurator())
5263
.onReceive(NotificationCenter.default.publisher(for: .openclawSelectSettingsTab)) { note in
5364
if let tab = note.object as? SettingsTab {

‎apps/macos/Tests/OpenClawIPCTests/DashboardWindowSmokeTests.swift‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,18 @@ struct DashboardWindowSmokeTests {
3737
let url = try #require(URL(string: "http://[fd12:3456:789a::1]:18789/control/"))
3838
#expect(DashboardWindowController.originString(for: url) == "http://[fd12:3456:789a::1]:18789")
3939
}
40+
41+
@Test func `dashboard failure state opens in dashboard window`() throws {
42+
let url = try #require(URL(string: "http://127.0.0.1:18789/control/"))
43+
let controller = DashboardWindowController(
44+
url: url,
45+
auth: DashboardWindowAuth(gatewayUrl: nil, token: nil, password: nil))
46+
controller.showFailure(
47+
title: "Dashboard unavailable",
48+
message: "Remote control tunnel failed",
49+
detail: "Reset the remote tunnel and try again.")
50+
#expect(controller.window?.isVisible == true)
51+
#expect(controller.window?.styleMask.contains(.closable) == true)
52+
controller.closeDashboard()
53+
}
4054
}

0 commit comments

Comments
 (0)