commit fef4d58901aab7548697ac4d8fe9244ca0d3b172
parent da64b73eb5af90f07efe9cdb028425767c5d07e0
Author: triesap <tyson@radroots.org>
Date: Fri, 12 Jun 2026 00:28:02 -0700
app: support nostr ui-test startup states
- avoid relay configuration before a local identity exists
- add a guarded deterministic startup-failure path for UI acceptance
- keep first launch on the Nostr identity setup surface
Diffstat:
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/Radroots/App/AppState.swift b/Radroots/App/AppState.swift
@@ -2,11 +2,14 @@ import Foundation
enum FieldAppRuntimeError: LocalizedError {
case runtimeNotReady
+ case forcedStartupFailure
var errorDescription: String? {
switch self {
case .runtimeNotReady:
"Runtime not ready. Please retry."
+ case .forcedStartupFailure:
+ "Startup failure requested by field iOS runtime mode."
}
}
}
@@ -78,6 +81,9 @@ public final class AppState: ObservableObject {
guard bootstrapPhase == .idle || isFailed else { return }
bootstrapPhase = .starting
do {
+ if startupFailureWasRequested {
+ throw FieldAppRuntimeError.forcedStartupFailure
+ }
let service = try radroots.start()
let custodyStore = try FieldIdentityCustodyStore.configured()
identityCustodyStore = custodyStore
@@ -88,7 +94,6 @@ public final class AppState: ObservableObject {
} else {
try await restorePersistedIdentity(using: service, custodyStore: custodyStore)
}
- try await configureRelays(using: service)
try await refreshRuntimeState(using: service)
if hasKey && !isLocked {
try await connect(using: service)
@@ -186,6 +191,22 @@ public final class AppState: ObservableObject {
return false
}
+ private var startupFailureWasRequested: Bool {
+ let arguments = ProcessInfo.processInfo.arguments
+ let environment = ProcessInfo.processInfo.environment
+ guard environment["RADROOTS_FIELD_IOS_UI_TEST"] == "true" ||
+ arguments.contains("--radroots-field-ios-ui-test") else {
+ return false
+ }
+ if BuildConfig.string(.runtimeMode) == "ui-test-startup-failure" {
+ return true
+ }
+ if environment["RADROOTS_FIELD_IOS_FORCE_STARTUP_FAILURE"] == "true" {
+ return true
+ }
+ return arguments.contains("--radroots-field-ios-force-startup-failure")
+ }
+
private func configureRelays(using service: FieldRuntimeService) async throws {
try await service.nostrSetDefaultRelays(try RelaySettings.relays())
}