mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 11:30:41 +00:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 8165ec5bae
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
49 lines
1.7 KiB
Swift
49 lines
1.7 KiB
Swift
import SwiftUI
|
|
import Foundation
|
|
|
|
@main
|
|
struct OpenClawApp: App {
|
|
@State private var appModel: NodeAppModel
|
|
@State private var gatewayController: GatewayConnectionController
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
init() {
|
|
Self.installUncaughtExceptionLogger()
|
|
GatewaySettingsStore.bootstrapPersistence()
|
|
let appModel = NodeAppModel()
|
|
_appModel = State(initialValue: appModel)
|
|
_gatewayController = State(initialValue: GatewayConnectionController(appModel: appModel))
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootCanvas()
|
|
.environment(self.appModel)
|
|
.environment(self.appModel.voiceWake)
|
|
.environment(self.gatewayController)
|
|
.onOpenURL { url in
|
|
Task { await self.appModel.handleDeepLink(url: url) }
|
|
}
|
|
.onChange(of: self.scenePhase) { _, newValue in
|
|
self.appModel.setScenePhase(newValue)
|
|
self.gatewayController.setScenePhase(newValue)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension OpenClawApp {
|
|
private static func installUncaughtExceptionLogger() {
|
|
NSLog("OpenClaw: installing uncaught exception handler")
|
|
NSSetUncaughtExceptionHandler { exception in
|
|
// Useful when the app hits NSExceptions from SwiftUI/WebKit internals; these do not
|
|
// produce a normal Swift error backtrace.
|
|
let reason = exception.reason ?? "(no reason)"
|
|
NSLog("UNCAUGHT EXCEPTION: %@ %@", exception.name.rawValue, reason)
|
|
for line in exception.callStackSymbols {
|
|
NSLog(" %@", line)
|
|
}
|
|
}
|
|
}
|
|
}
|