Aligns the iOS app with the Clawnet refactor by implementing proper role separation for gateway connections. Uses separate operator and node sessions to match the gateway's authorization requirements. Changes: - New GatewayOperatorSession: Wraps GatewayChannelActor for operator-role RPC requests (chat.*, health, sessions.list) without invoke handling - Dual-connection architecture: Operator session for requests, node session for node.event calls (e.g., chat.subscribe) - Separate websocket sessions: Each connection gets its own URLSession to prevent response cross-talk - Updated chat transport: IOSGatewayChatTransport uses operator session for requests, node session for subscriptions ClawdbotKit (shared): - Deadlock fix in GatewayChannel.swift: Moved connection finalization (listen(), connected=true, isConnecting=false, waiter resumption) to occur before calling pushHandler. This fixes a latent bug where requests made from onConnected callbacks would deadlock. Does not affect macOS (its callback doesn't make requests). - Package.swift: Fixed argument order for Swift 6.2 compatibility iOS chat is now working. This is the base PR to unlock further work on the iOS app.
84 lines
2.7 KiB
Swift
84 lines
2.7 KiB
Swift
import MoltbotKit
|
|
import SwiftUI
|
|
import Testing
|
|
import UIKit
|
|
@testable import Moltbot
|
|
|
|
@Suite struct SwiftUIRenderSmokeTests {
|
|
@MainActor private static func host(_ view: some View) -> UIWindow {
|
|
let window = UIWindow(frame: UIScreen.main.bounds)
|
|
window.rootViewController = UIHostingController(rootView: view)
|
|
window.makeKeyAndVisible()
|
|
window.rootViewController?.view.setNeedsLayout()
|
|
window.rootViewController?.view.layoutIfNeeded()
|
|
return window
|
|
}
|
|
|
|
@Test @MainActor func statusPillConnectingBuildsAViewHierarchy() {
|
|
let root = StatusPill(gateway: .connecting, voiceWakeEnabled: true, brighten: true) {}
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func statusPillDisconnectedBuildsAViewHierarchy() {
|
|
let root = StatusPill(gateway: .disconnected, voiceWakeEnabled: false) {}
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func settingsTabBuildsAViewHierarchy() {
|
|
let appModel = NodeAppModel()
|
|
let gatewayController = GatewayConnectionController(appModel: appModel, startDiscovery: false)
|
|
|
|
let root = SettingsTab()
|
|
.environment(appModel)
|
|
.environment(appModel.voiceWake)
|
|
.environment(gatewayController)
|
|
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func rootTabsBuildAViewHierarchy() {
|
|
let appModel = NodeAppModel()
|
|
let gatewayController = GatewayConnectionController(appModel: appModel, startDiscovery: false)
|
|
|
|
let root = RootTabs()
|
|
.environment(appModel)
|
|
.environment(appModel.voiceWake)
|
|
.environment(gatewayController)
|
|
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func voiceTabBuildsAViewHierarchy() {
|
|
let appModel = NodeAppModel()
|
|
|
|
let root = VoiceTab()
|
|
.environment(appModel)
|
|
.environment(appModel.voiceWake)
|
|
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func voiceWakeWordsViewBuildsAViewHierarchy() {
|
|
let appModel = NodeAppModel()
|
|
let root = NavigationStack { VoiceWakeWordsSettingsView() }
|
|
.environment(appModel)
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func chatSheetBuildsAViewHierarchy() {
|
|
let appModel = NodeAppModel()
|
|
let root = ChatSheet(
|
|
gateway: appModel.gatewaySession,
|
|
nodeSession: appModel.gatewayNodeSession,
|
|
sessionKey: "test")
|
|
.environment(appModel)
|
|
.environment(appModel.voiceWake)
|
|
_ = Self.host(root)
|
|
}
|
|
|
|
@Test @MainActor func voiceWakeToastBuildsAViewHierarchy() {
|
|
let root = VoiceWakeToast(command: "moltbot: do something")
|
|
_ = Self.host(root)
|
|
}
|
|
}
|