mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-04 13:51:35 +00:00
- 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
30 lines
1.2 KiB
Swift
30 lines
1.2 KiB
Swift
import Testing
|
|
@testable import OpenClaw
|
|
|
|
@Suite(.serialized)
|
|
@MainActor
|
|
struct WebChatManagerTests {
|
|
@Test func `controller reuse requires the full normalized route`() {
|
|
let work = WebChatRoute(sessionKey: "global", agentID: " Work ")
|
|
let sameWork = WebChatRoute(sessionKey: "global", agentID: "work")
|
|
let main = WebChatRoute(sessionKey: "global", agentID: "main")
|
|
|
|
#expect(work == sameWork)
|
|
#expect(WebChatManager.shouldReuseController(currentRoute: work, requestedRoute: sameWork))
|
|
#expect(!WebChatManager.shouldReuseController(currentRoute: work, requestedRoute: main))
|
|
#expect(!WebChatManager.shouldReuseController(
|
|
currentRoute: work,
|
|
requestedRoute: WebChatRoute(sessionKey: "main", agentID: "work")))
|
|
}
|
|
|
|
@Test func `blank agent route normalizes to nil`() {
|
|
#expect(WebChatRoute(sessionKey: "global", agentID: " ") ==
|
|
WebChatRoute(sessionKey: "global", agentID: nil))
|
|
}
|
|
|
|
@Test func `preferred session key is non empty`() async {
|
|
let key = await WebChatManager.shared.preferredSessionKey()
|
|
#expect(!key.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
|
}
|
|
}
|