include argus workflow
This commit is contained in:
@@ -2,8 +2,24 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - AppDelegate (subprocess cleanup on quit)
|
||||
|
||||
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
/// Called for normal quits (Cmd+Q), window close, and SIGTERM.
|
||||
/// Ensures the argus subprocess is killed before the process exits.
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
// applicationWillTerminate runs on the main thread, so we can safely
|
||||
// call @MainActor methods synchronously via assumeIsolated.
|
||||
MainActor.assumeIsolated {
|
||||
SessionManager.shared.stopMonitoring()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
struct LockInBroApp: App {
|
||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||
|
||||
@State private var auth = AuthManager.shared
|
||||
@State private var session = SessionManager.shared
|
||||
|
||||
@@ -13,9 +29,11 @@ struct LockInBroApp: App {
|
||||
ContentView()
|
||||
.environment(auth)
|
||||
.environment(session)
|
||||
.onChange(of: session.isSessionActive) { _, isActive in
|
||||
if isActive {
|
||||
.onChange(of: auth.isLoggedIn, initial: true) { _, loggedIn in
|
||||
if loggedIn {
|
||||
// Show HUD and start always-on monitoring as soon as user logs in
|
||||
FloatingPanelController.shared.show(session: session)
|
||||
Task { await session.startMonitoring() }
|
||||
} else {
|
||||
FloatingPanelController.shared.close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user