Skip to content

Commit 9ff87ae

Browse files
authored
Merge branch 'main' into agent/fix-codex-rollout-jsonl-streaming
2 parents 348b42c + 97d374b commit 9ff87ae

26 files changed

Lines changed: 648 additions & 398 deletions

‎apps/.i18n/native-source.json‎

Lines changed: 156 additions & 92 deletions
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ final class AppState {
8888
}
8989
}
9090

91+
var nativeSettingsPanesEnabled: Bool {
92+
didSet {
93+
self.ifNotPreview {
94+
UserDefaults.standard.set(self.nativeSettingsPanesEnabled, forKey: nativeSettingsPanesEnabledKey)
95+
}
96+
}
97+
}
98+
9199
var swabbleEnabled: Bool {
92100
didSet {
93101
self.ifNotPreview {
@@ -344,6 +352,7 @@ final class AppState {
344352
self.launchAtLogin = false
345353
self.onboardingSeen = onboardingSeen
346354
self.debugPaneEnabled = UserDefaults.standard.bool(forKey: debugPaneEnabledKey)
355+
self.nativeSettingsPanesEnabled = UserDefaults.standard.bool(forKey: nativeSettingsPanesEnabledKey)
347356
let savedVoiceWake = UserDefaults.standard.bool(forKey: swabbleEnabledKey)
348357
self.swabbleEnabled = voiceWakeSupported ? savedVoiceWake : false
349358
self.swabbleTriggerWords = UserDefaults.standard
@@ -1190,6 +1199,7 @@ extension AppState {
11901199
state.launchAtLogin = true
11911200
state.onboardingSeen = true
11921201
state.debugPaneEnabled = true
1202+
state.nativeSettingsPanesEnabled = true
11931203
state.swabbleEnabled = true
11941204
state.swabbleTriggerWords = ["Claude", "Computer", "Jarvis"]
11951205
state.voiceWakeTriggerChime = .system(name: "Glass")

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ let cliValidatedVersionKey = "openclaw.cliValidatedVersion"
6161
let macNodeIdentityProfileKey = "openclaw.macNodeIdentityProfile"
6262
let heartbeatsEnabledKey = "openclaw.heartbeatsEnabled"
6363
let debugPaneEnabledKey = "openclaw.debugPaneEnabled"
64+
let nativeSettingsPanesEnabledKey = "openclaw.nativeSettingsPanesEnabled"
6465
let debugFileLogEnabledKey = "openclaw.debug.fileLogEnabled"
6566
let appLogLevelKey = "openclaw.debug.appLogLevel"
6667
let voiceWakeSupported: Bool = ProcessInfo.processInfo.operatingSystemVersion.majorVersion >= 26
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import SwiftUI
2+
3+
struct DashboardHandoffSettingsView: View {
4+
let tab: SettingsTab
5+
let dashboardRoute: String
6+
7+
var body: some View {
8+
VStack(spacing: 18) {
9+
Spacer()
10+
11+
Image(systemName: self.tab.systemImage)
12+
.font(.system(size: 42, weight: .medium))
13+
.foregroundStyle(.secondary)
14+
15+
VStack(spacing: 7) {
16+
Text(self.tab.title)
17+
.font(.title2.weight(.semibold))
18+
Text("This configuration lives on your gateway and is managed in the Dashboard.")
19+
.font(.callout)
20+
.foregroundStyle(.secondary)
21+
.multilineTextAlignment(.center)
22+
}
23+
24+
Button("Open in Dashboard") {
25+
Task { await DashboardManager.shared.show(atPath: self.dashboardRoute) }
26+
}
27+
.buttonStyle(.borderedProminent)
28+
.controlSize(.large)
29+
30+
Text("The legacy native pane can be re-enabled in Settings > Debug.")
31+
.font(.caption)
32+
.foregroundStyle(.tertiary)
33+
34+
Spacer()
35+
}
36+
.frame(maxWidth: .infinity, maxHeight: .infinity)
37+
.padding(32)
38+
}
39+
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class DashboardManager {
3131
@ObservationIgnored private var endpointTask: Task<Void, Never>?
3232
@ObservationIgnored private var pendingOpenCommands: [DashboardNativeCommand] = []
3333
@ObservationIgnored private var openForCommandTask: Task<Void, Never>?
34+
@ObservationIgnored private var navigationGeneration: UInt64 = 0
3435
@ObservationIgnored private var updater: UpdaterProviding?
3536
@ObservationIgnored private var displayedRouteRevision: UInt64?
3637
@ObservationIgnored private var switchGenerations: [ObjectIdentifier: UInt64] = [:]
@@ -346,6 +347,24 @@ final class DashboardManager {
346347
Task { _ = try? await ControlChannel.shared.health(timeout: 3) }
347348
}
348349

350+
func show(atPath path: String) async {
351+
self.navigationGeneration &+= 1
352+
let generation = self.navigationGeneration
353+
do {
354+
try await self.show()
355+
guard generation == self.navigationGeneration else { return }
356+
guard let controller,
357+
let fallbackURL = DashboardRouteMap.dashboardURL(
358+
byAppendingSameAppPath: path,
359+
to: controller.dashboardBaseURL)
360+
else { return }
361+
controller.dispatchNativeNavigation(DashboardNativeNavigation(path: path, fallbackURL: fallbackURL))
362+
} catch {
363+
guard generation == self.navigationGeneration else { return }
364+
self.showFailure(error)
365+
}
366+
}
367+
349368
func showFailure(_ error: Error) {
350369
let message = (error as NSError).localizedDescription
351370
dashboardManagerLogger.error("dashboard setup failed error=\(message, privacy: .public)")
@@ -405,6 +424,10 @@ final class DashboardManager {
405424
}
406425

407426
func dispatchNativeCommand(_ command: DashboardNativeCommand) {
427+
if command.supersedesPendingNavigation {
428+
// This also invalidates a handoff still suspended in show(atPath:).
429+
self.navigationGeneration &+= 1
430+
}
408431
NSApp.activate(ignoringOtherApps: true)
409432
if let controller, controller.isWindowOpen, controller.canDeliverNativeCommands {
410433
controller.show()

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ enum DashboardNativeCommand: String {
5555
case .commandPalette: "openclaw:native-open-search"
5656
}
5757
}
58+
59+
var supersedesPendingNavigation: Bool {
60+
self == .newSession
61+
}
62+
}
63+
64+
struct DashboardNativeNavigation: Equatable {
65+
let path: String
66+
let fallbackURL: URL
5867
}
5968

6069
enum DashboardLinkTarget: String, Equatable {

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

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
112112
private var browserProfileImportOfferRetryPending = false
113113
private var hasLiveContent = false
114114
private var isShowingFailurePage = false
115+
private var navigationGeneration: UInt64 = 0
115116
private var pendingNativeCommands: [DashboardNativeCommand] = []
117+
private var pendingNativeNavigation: DashboardNativeNavigation?
116118
var onClosed: (() -> Void)?
117119

118120
init(
@@ -404,14 +406,6 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
404406
return window.isVisible || window.isMiniaturized
405407
}
406408

407-
/// Commands are deliverable when a document is live or a load is in flight
408-
/// (the queue flushes at `didFinish`). A failure page, or a terminally
409-
/// cancelled load with no successor, needs a reload before dispatch —
410-
/// otherwise queued ⌘N/⌘K would wait on a `didFinish` that never comes.
411-
var canDeliverNativeCommands: Bool {
412-
!self.isShowingFailurePage && (self.hasLiveContent || self.webView.isLoading)
413-
}
414-
415409
func show() {
416410
if let window {
417411
let frame = window.frame
@@ -442,9 +436,11 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
442436
func showFailure(title: String, message: String, detail: String? = nil) {
443437
self.hasLiveContent = false
444438
self.isShowingFailurePage = true
439+
self.advanceNavigationGeneration()
445440
// Queued commands are moment-bound user intent; replaying them after a
446441
// later recovery reload would toggle or navigate unexpectedly.
447442
self.pendingNativeCommands = []
443+
self.pendingNativeNavigation = nil
448444
self.currentURL = URL(string: "about:blank")!
449445
self.auth = DashboardWindowAuth(gatewayUrl: nil, token: nil, password: nil)
450446
self.setUpdateBridgeEnabled(false)
@@ -1017,9 +1013,11 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
10171013
}
10181014
self.hasLiveContent = false
10191015
self.isShowingFailurePage = true
1016+
self.advanceNavigationGeneration()
10201017
// Same moment-bound rule as showFailure: a terminal load failure
10211018
// invalidates commands queued for the document that never arrived.
10221019
self.pendingNativeCommands = []
1020+
self.pendingNativeNavigation = nil
10231021
dashboardWindowLogger.error(
10241022
"""
10251023
dashboard load failed url=\(dashboardLogString(for: self.currentURL), privacy: .public) \
@@ -1035,6 +1033,20 @@ final class DashboardWindowController: NSWindowController, WKNavigationDelegate,
10351033
}
10361034

10371035
extension DashboardWindowController {
1036+
/// Commands are deliverable when a document is live or a load is in flight
1037+
/// (the queue flushes at `didFinish`). A failure page, or a terminally
1038+
/// cancelled load with no successor, needs a reload before dispatch —
1039+
/// otherwise queued ⌘N/⌘K would wait on a `didFinish` that never comes.
1040+
var canDeliverNativeCommands: Bool {
1041+
!self.isShowingFailurePage && (self.hasLiveContent || self.webView.isLoading)
1042+
}
1043+
1044+
/// The canonical Dashboard mount URL supplied by the manager. WebKit route
1045+
/// loads and SPA history do not mutate it, so native fallbacks stay rooted.
1046+
var dashboardBaseURL: URL {
1047+
self.currentURL
1048+
}
1049+
10381050
func windowWillClose(_: Notification) {
10391051
self.webView.stopLoading()
10401052
self.closeLinkBrowser(focusDashboard: false)
@@ -1119,16 +1131,25 @@ extension DashboardWindowController {
11191131
}
11201132

11211133
func dispatchNativeCommand(_ command: DashboardNativeCommand) {
1134+
if command.supersedesPendingNavigation {
1135+
self.advanceNavigationGeneration()
1136+
}
11221137
guard self.hasLiveContent else {
11231138
// Ordered queue, duplicates included: two ⌘K presses while loading
11241139
// must toggle twice, and ⌘N followed by ⌘K must deliver both.
1140+
if command.supersedesPendingNavigation {
1141+
self.pendingNativeNavigation = nil
1142+
}
11251143
self.pendingNativeCommands.append(command)
11261144
return
11271145
}
11281146
self.evaluateNativeCommand(command)
11291147
}
11301148

11311149
private func evaluateNativeCommand(_ command: DashboardNativeCommand) {
1150+
if command.supersedesPendingNavigation {
1151+
self.advanceNavigationGeneration()
1152+
}
11321153
guard let fallback = command.legacyFallbackEventName else {
11331154
self.webView.evaluateJavaScript(
11341155
"window.dispatchEvent(new CustomEvent(\(Self.jsStringLiteral(command.rawValue))))")
@@ -1157,6 +1178,53 @@ extension DashboardWindowController {
11571178
self.evaluateNativeCommand(command)
11581179
}
11591180
}
1181+
1182+
func dispatchNativeNavigation(_ navigation: DashboardNativeNavigation) {
1183+
self.advanceNavigationGeneration()
1184+
guard self.hasLiveContent else {
1185+
// Navigation is state selection, so only the newest destination matters while loading.
1186+
self.pendingNativeNavigation = navigation
1187+
return
1188+
}
1189+
self.evaluateNativeNavigation(navigation)
1190+
}
1191+
1192+
private func evaluateNativeNavigation(_ navigation: DashboardNativeNavigation) {
1193+
let generation = self.navigationGeneration
1194+
let sourceURL = self.currentURL
1195+
let script =
1196+
"""
1197+
(() => !window.dispatchEvent(new CustomEvent('openclaw:native-navigate', {
1198+
cancelable: true,
1199+
detail: {path: \(Self.jsStringLiteral(navigation.path))}
1200+
})))()
1201+
"""
1202+
Task { @MainActor [weak self] in
1203+
guard let self else { return }
1204+
let result = try? await self.webView.evaluateJavaScript(script)
1205+
let handled = result as? Bool
1206+
// Async completions may return after another route or New Session intent.
1207+
// Only the newest navigation intent may load its fallback URL.
1208+
guard handled != true,
1209+
self.navigationFallbackIsCurrent(generation: generation, sourceURL: sourceURL)
1210+
else { return }
1211+
self.load(navigation.fallbackURL)
1212+
}
1213+
}
1214+
1215+
private func advanceNavigationGeneration() {
1216+
self.navigationGeneration &+= 1
1217+
}
1218+
1219+
private func navigationFallbackIsCurrent(generation: UInt64, sourceURL: URL) -> Bool {
1220+
self.navigationGeneration == generation && self.currentURL == sourceURL
1221+
}
1222+
1223+
private func flushPendingNativeNavigation() {
1224+
guard let navigation = self.pendingNativeNavigation else { return }
1225+
self.pendingNativeNavigation = nil
1226+
self.evaluateNativeNavigation(navigation)
1227+
}
11601228
}
11611229

11621230
/// WKNavigationDelegate policy lives in an extension to keep the class
@@ -1285,6 +1353,7 @@ extension DashboardWindowController {
12851353
self.publishNativeHistoryState()
12861354
// History state must reach the shell before a queued command can navigate it.
12871355
self.flushPendingNativeCommands()
1356+
self.flushPendingNativeNavigation()
12881357
}
12891358
}
12901359

@@ -1488,6 +1557,18 @@ extension DashboardWindowController {
14881557
self.pendingNativeCommands
14891558
}
14901559

1560+
var _testPendingNativeNavigation: DashboardNativeNavigation? {
1561+
self.pendingNativeNavigation
1562+
}
1563+
1564+
var _testNavigationGeneration: UInt64 {
1565+
self.navigationGeneration
1566+
}
1567+
1568+
func _testNavigationFallbackIsCurrent(generation: UInt64, sourceURL: URL) -> Bool {
1569+
self.navigationFallbackIsCurrent(generation: generation, sourceURL: sourceURL)
1570+
}
1571+
14911572
var _testNavigationWebViewIdentity: ObjectIdentifier {
14921573
ObjectIdentifier(self.activeNavigationWebView)
14931574
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ struct DebugSettings: View {
166166
self.gridLabel("PID")
167167
Text("\(ProcessInfo.processInfo.processIdentifier)")
168168
}
169+
GridRow {
170+
self.gridLabel("Settings")
171+
VStack(alignment: .leading, spacing: 4) {
172+
Toggle("Show native settings panes", isOn: self.$state.nativeSettingsPanesEnabled)
173+
Text("These panes are being retired in favor of the Dashboard.")
174+
.font(.caption)
175+
.foregroundStyle(.secondary)
176+
}
177+
}
169178
GridRow {
170179
self.gridLabel("Binary path")
171180
Text(Bundle.main.bundlePath)

0 commit comments

Comments
 (0)