mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-01 09:43:43 +00:00
Summary: - Replace the legacy iOS shell with Pro Command, Chat, Agents, and Settings tabs. - Wire iOS chat/session/settings/diagnostics and realtime Talk flows through gateway-backed APIs. - Add gateway/session and shared chat coverage for the new iOS flow. Verification: - git diff --check - node scripts/run-vitest.mjs src/gateway/server.sessions.create.test.ts src/gateway/talk-realtime-relay.test.ts - swift test --filter ChatViewModelTests (apps/shared/OpenClawKit) - xcodebuild build for Nimrod's iPhone succeeded; install succeeded; launch was blocked because the phone was locked Known follow-up: - Preserve traceLevel in sessions.create parent runtime inheritance and keep the changelog credit in the follow-up patch.
72 lines
2.6 KiB
Swift
72 lines
2.6 KiB
Swift
import Foundation
|
|
|
|
enum OnboardingConnectionMode: String, CaseIterable {
|
|
case homeNetwork = "home_network"
|
|
case remoteDomain = "remote_domain"
|
|
case developerLocal = "developer_local"
|
|
|
|
var title: String {
|
|
switch self {
|
|
case .homeNetwork:
|
|
"Home Network"
|
|
case .remoteDomain:
|
|
"Remote Domain"
|
|
case .developerLocal:
|
|
"Same Machine (Dev)"
|
|
}
|
|
}
|
|
}
|
|
|
|
enum OnboardingStateStore {
|
|
private static let completedDefaultsKey = "onboarding.completed"
|
|
private static let firstRunIntroSeenDefaultsKey = "onboarding.first_run_intro_seen"
|
|
private static let lastModeDefaultsKey = "onboarding.last_mode"
|
|
private static let lastSuccessTimeDefaultsKey = "onboarding.last_success_time"
|
|
|
|
@MainActor
|
|
static func shouldPresentOnLaunch(
|
|
appModel: NodeAppModel,
|
|
defaults: UserDefaults = .standard,
|
|
hasSavedGatewayConnection: Bool? = nil)
|
|
-> Bool
|
|
{
|
|
if defaults.bool(forKey: self.completedDefaultsKey) { return false }
|
|
let hasSavedGatewayConnection =
|
|
hasSavedGatewayConnection ?? (GatewaySettingsStore.loadLastGatewayConnection() != nil)
|
|
if hasSavedGatewayConnection { return false }
|
|
return appModel.gatewayServerName == nil
|
|
}
|
|
|
|
static func markCompleted(mode: OnboardingConnectionMode? = nil, defaults: UserDefaults = .standard) {
|
|
defaults.set(true, forKey: self.completedDefaultsKey)
|
|
if let mode {
|
|
defaults.set(mode.rawValue, forKey: self.lastModeDefaultsKey)
|
|
}
|
|
defaults.set(Int(Date().timeIntervalSince1970), forKey: Self.lastSuccessTimeDefaultsKey)
|
|
}
|
|
|
|
static func shouldPresentFirstRunIntro(defaults: UserDefaults = .standard) -> Bool {
|
|
!defaults.bool(forKey: self.firstRunIntroSeenDefaultsKey)
|
|
}
|
|
|
|
static func markFirstRunIntroSeen(defaults: UserDefaults = .standard) {
|
|
defaults.set(true, forKey: self.firstRunIntroSeenDefaultsKey)
|
|
}
|
|
|
|
static func markIncomplete(defaults: UserDefaults = .standard) {
|
|
defaults.set(false, forKey: self.completedDefaultsKey)
|
|
}
|
|
|
|
static func reset(defaults: UserDefaults = .standard) {
|
|
defaults.set(false, forKey: self.completedDefaultsKey)
|
|
defaults.set(false, forKey: self.firstRunIntroSeenDefaultsKey)
|
|
}
|
|
|
|
static func lastMode(defaults: UserDefaults = .standard) -> OnboardingConnectionMode? {
|
|
let raw = defaults.string(forKey: Self.lastModeDefaultsKey)?
|
|
.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
|
|
guard !raw.isEmpty else { return nil }
|
|
return OnboardingConnectionMode(rawValue: raw)
|
|
}
|
|
}
|