diff --git a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift index 4a5536e..f4b17c7 100644 --- a/NucleicRemote/NucleicRemote/Models/RemoteStore.swift +++ b/NucleicRemote/NucleicRemote/Models/RemoteStore.swift @@ -326,6 +326,40 @@ final class RemoteStore: ObservableObject { NotificationRouter.shared.updateBadge(0) } + /// Enter the in-app demo (the "Explore a demo" button): drop any live connection, persist the + /// flag so it survives relaunch (a reviewer may relaunch), and seed the mock world. `isPaired` + /// then returns true, so `RootView` shows the full TabView. + func enterDemo() { + teardown() + demoMode = true + UserDefaults.standard.set(true, forKey: Self.demoModeKey) + reconnectAttempts = 0 + seedDemo() + } + + /// Leave the demo (Settings ▸ Leave demo): cancel any simulated runs, clear the mock world, + /// and return to the real state — reconnect if a Mac is actually paired, else the pairing intro. + func exitDemo() { + demoMode = false + UserDefaults.standard.set(false, forKey: Self.demoModeKey) + demoTasks.forEach { $0.cancel() } + demoTasks.removeAll() + openSessionID = nil + openEvents = [] + openApprovals = [] + openDiff = nil + diffLoading = false + sessions = [] + dashboard = .empty + LiveActivityManager.shared.end() + NotificationRouter.shared.updateBadge(0) + if IdentityStore.loadPairedHost() != nil { + reconnect() + } else { + connectivity = .unpaired + } + } + // MARK: - Intents (UX_IOS §9) func open(_ sessionID: SessionID) {