fix(apple): align merged routing guards

This commit is contained in:
Colin
2026-08-20 06:40:12 -04:00
committed by GitHub
parent ead65c222d
commit 55d305e697
4 changed files with 31 additions and 21 deletions
@@ -636,7 +636,7 @@ extension RootTabsSourceGuardTests {
#expect(activitySource.contains("struct IPadActivityScreen: View"))
#expect(activitySource.contains("self.appModel.makeChatTransport()"))
#expect(appModelSource.contains("return IOSGatewayChatTransport("))
#expect(appModelSource.contains("globalAgentId: self.chatDeliveryAgentId"))
#expect(appModelSource.contains("globalAgentId: chatDeliveryAgentId"))
#expect(!appModelSource.contains("defaultAgentId: self.gatewayDefaultAgentId"))
#expect(activitySource.contains("IPadSidebarScreenChrome("))
#expect(!taskSource.contains("struct IPadActivityScreen"))
@@ -1196,9 +1196,10 @@ extension RootTabsSourceGuardTests {
"self.appModel.makeChatTransport(outboxGatewayID: offlineStore?.gatewayID)"))
#expect(chatSource.contains("activeAgentId: self.appModel.chatDeliveryAgentId"))
#expect(chatSource.contains("Self.requiresViewModelRebuild("))
#expect(chatSource.contains("viewModel.syncSessionRoutingContract"))
#expect(chatSource.contains("viewModel.syncDeliveryIdentity"))
#expect(chatSource.contains("sessionRoutingContract: self.appModel.chatSessionRoutingContract"))
#expect(appModelSource.contains("return IOSGatewayChatTransport("))
#expect(appModelSource.contains("globalAgentId: self.chatDeliveryAgentId"))
#expect(appModelSource.contains("globalAgentId: chatDeliveryAgentId"))
#expect(appModelSource.contains("ifCurrentRoute: operatorRoute"))
#expect(transportSource.matches(of: /ifCurrentRoute: expectedRoute/).count == 4)
#expect(channelsSource.contains("\"clickclack\": SettingsChannelFallbackMetadata"))
@@ -1229,7 +1230,7 @@ extension RootTabsSourceGuardTests {
#expect(pendingActions.contains("pendingForegroundActionDrainInFlight = false"))
#expect(pendingActions.contains("completedPendingForegroundActionIDsByGateway"))
#expect(pendingActions.contains("presentIn: decoded.actions"))
#expect(pendingActions.contains("let currentRoute = await self.nodeGateway.currentRoute()"))
#expect(pendingActions.contains("let currentRoute = await nodeGateway.currentRoute()"))
#expect(pendingActions.contains("ifCurrentRoute: expectedRoute"))
#expect(resolvedState.matches(of: /canApplyExecApprovalResolvedState/).count >= 4)
#expect(resolvedState.contains("routeContext: routeContext"))
@@ -1286,7 +1287,7 @@ extension RootTabsSourceGuardTests {
to: "} catch is CancellationError")
let legacySuccess = try Self.extract(
legacy,
from: "let response = try await self.operatorGateway.request(",
from: "let response = try await operatorGateway.request(",
to: "} catch is CancellationError")
let unifiedCatch = try #require(unified.range(of: "} catch {"))
let legacyCatch = try #require(legacy.range(of: "} catch {"))
@@ -1324,11 +1325,11 @@ extension RootTabsSourceGuardTests {
to: "private func reconcileUnknownExecApprovalResolution(")
let unifiedSuccess = try Self.extract(
unified,
from: "let response = try await self.operatorGateway.request(",
from: "let response = try await operatorGateway.request(",
to: "} catch {")
let legacySuccess = try Self.extract(
legacy,
from: "let response = try await self.operatorGateway.request(",
from: "let response = try await operatorGateway.request(",
to: "} catch {")
let unifiedCatch = try #require(unified.range(of: "} catch {"))
let legacyCatch = try #require(legacy.range(of: "} catch {"))
@@ -634,13 +634,6 @@ public final class OpenClawChatViewModel {
?? self.agentSelectionRequired)
}
public func syncSessionRoutingContract(_ contract: String?) {
self.syncDeliveryIdentity(
activeAgentId: self.deferredDeliveryIdentity?.activeAgentID ?? self.activeAgentId,
sessionRoutingContract: contract,
agentSelectionRequired: nil)
}
/// Updates the alias owner and its gateway routing contract as one
/// identity change so an intermediate bootstrap cannot win either value.
public func syncDeliveryIdentity(
@@ -435,7 +435,9 @@ final class ChatViewModelAttachmentTests: XCTestCase {
preview: nil)
contractViewModel.attachments = [contractAttachment]
contractViewModel.syncSessionRoutingContract(newContract)
contractViewModel.syncDeliveryIdentity(
activeAgentId: "main",
sessionRoutingContract: newContract)
contractViewModel.syncActiveAgentId("main")
contractViewModel.removeAttachment(contractAttachment.id)
@@ -453,7 +455,9 @@ final class ChatViewModelAttachmentTests: XCTestCase {
agentViewModel.attachments = [agentAttachment]
agentViewModel.syncActiveAgentId("work")
agentViewModel.syncSessionRoutingContract(oldContract)
agentViewModel.syncDeliveryIdentity(
activeAgentId: "work",
sessionRoutingContract: oldContract)
agentViewModel.removeAttachment(agentAttachment.id)
return (
@@ -3276,7 +3276,9 @@ struct ChatViewModelTests {
let (_, vm) = await makeViewModel(historyResponses: [historyPayload()])
await MainActor.run {
vm.syncSessionRoutingContract("per-sender|main|unowned")
vm.syncDeliveryIdentity(
activeAgentId: nil,
sessionRoutingContract: "per-sender|main|unowned")
#expect(vm.requiresExplicitAgentSelection)
}
}
@@ -3288,7 +3290,9 @@ struct ChatViewModelTests {
agentSelectionRequired: true)
await MainActor.run {
vm.syncSessionRoutingContract("opaque-routing-contract-v2")
vm.syncDeliveryIdentity(
activeAgentId: nil,
sessionRoutingContract: "opaque-routing-contract-v2")
#expect(vm.requiresExplicitAgentSelection)
vm.syncDeliveryIdentity(
@@ -3801,7 +3805,9 @@ struct ChatViewModelTests {
}
await MainActor.run {
vm.syncSessionRoutingContract("per-sender|work|ops")
vm.syncDeliveryIdentity(
activeAgentId: "ops",
sessionRoutingContract: "per-sender|work|ops")
}
try await waitUntil("replacement custom main history") {
@@ -9390,7 +9396,9 @@ struct ChatViewModelTests {
}
await MainActor.run {
vm.syncSessionRoutingContract("per-sender|work|alpha")
vm.syncDeliveryIdentity(
activeAgentId: "alpha",
sessionRoutingContract: "per-sender|work|alpha")
vm.selectModel("openai/model-b")
}
try await Task.sleep(for: .milliseconds(50))
@@ -9437,7 +9445,11 @@ struct ChatViewModelTests {
await transport.patchedModels() == ["openai/model-a"]
}
await MainActor.run { vm.syncSessionRoutingContract(newContract) }
await MainActor.run {
vm.syncDeliveryIdentity(
activeAgentId: "alpha",
sessionRoutingContract: newContract)
}
try await waitUntil("replacement route bootstraps") {
await MainActor.run { vm.sessionId == "sess-new" }
}