Files
openclaw/apps/macos/Sources/OpenClaw/AppNavigationActions.swift
Peter Steinberger 6903ab3d4f feat(mac): thread agent id through WebChat routes for global-scope sessions (#110118)
- WebChatRoute (sessionKey + normalized agentID) replaces string tracking in
  WebChatManager; window/panel reuse compares the full route; session-key
  callbacks retain the explicit agent and guard against stale controllers
- WebChatSwiftUIWindowController gains agentID; explicit selection feeds the
  existing MacGatewayChatTransport(defaultGlobalAgentID:)/initialActiveAgentID
  seams and is pinned against gateway-default refreshes
- AppNavigationActions.openChat(sessionKey:agentID:) route-aware; Quick Chat's
  Command-Return opens the accepted route's agent conversation (global scope
  included), retiring the v2 tradeoff comment
- tests: route reuse identity, explicit-vs-default precedence, navigation seam
2026-07-17 23:58:12 +01:00

54 lines
1.7 KiB
Swift

import AppKit
@MainActor
enum AppNavigationActions {
static func openDashboard() {
NSApp.activate(ignoringOtherApps: true)
if DashboardManager.shared.showConfiguredWindowIfPossible() {
return
}
Task { @MainActor in
if DashboardManager.shared.showConfiguredWindowIfPossible() {
return
}
do {
try await DashboardManager.shared.show()
} catch {
DashboardManager.shared.showFailure(error)
}
}
}
static func openChat(sessionKey: String? = nil, agentID: String? = nil) {
NSApp.activate(ignoringOtherApps: true)
Task { @MainActor in
let resolvedSessionKey = if let sessionKey {
sessionKey
} else {
await WebChatManager.shared.preferredSessionKey()
}
WebChatManager.shared.show(sessionKey: resolvedSessionKey, agentID: agentID)
}
}
static func toggleCanvas() {
NSApp.activate(ignoringOtherApps: true)
Task { @MainActor in
if AppStateStore.shared.canvasPanelVisible {
CanvasManager.shared.hideAll()
} else {
let sessionKey = await GatewayConnection.shared.mainSessionKey()
_ = try? CanvasManager.shared.show(sessionKey: sessionKey, path: nil)
}
}
}
static func openSettings(tab: SettingsTab = .general) {
SettingsTabRouter.request(tab)
SettingsWindowOpener.shared.open()
DispatchQueue.main.async {
NotificationCenter.default.post(name: .openclawSelectSettingsTab, object: tab)
}
}
}