From 7473e95635113b6e0c38a3ee9cca314e383e5f53 Mon Sep 17 00:00:00 2001 From: Gronod Date: Thu, 1 Oct 2026 12:53:17 +0100 Subject: [PATCH] fix: Isolate views to @MainActor and use @ObservedObject for Swift 5.7 compatibility --- Sources/UI/Alerts/AlertsView.swift | 3 ++- Sources/UI/ContentView.swift | 2 ++ Sources/UI/MenuBar/QuickGlancePopoverView.swift | 3 ++- Sources/UI/Settings/AlertsSettingsView.swift | 1 + Tests/MMMenuBarTests.swift | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/UI/Alerts/AlertsView.swift b/Sources/UI/Alerts/AlertsView.swift index 7dd65fe..c27e522 100644 --- a/Sources/UI/Alerts/AlertsView.swift +++ b/Sources/UI/Alerts/AlertsView.swift @@ -4,8 +4,9 @@ import SwiftUI /// Sidebar tab showing currently breached thresholds and the in-app /// alert history log maintained by `AlertEngine`. +@MainActor public struct AlertsView: View { - @State private var engine = AlertEngine.shared + @ObservedObject private var engine = AlertEngine.shared public init() {} diff --git a/Sources/UI/ContentView.swift b/Sources/UI/ContentView.swift index 0b4f8a5..e52bba5 100644 --- a/Sources/UI/ContentView.swift +++ b/Sources/UI/ContentView.swift @@ -1,5 +1,6 @@ import SwiftUI +@MainActor public struct ContentView: View { @StateObject private var store = SystemTelemetryStore.shared @State private var selectedTab: String? = "Dashboard" @@ -1220,6 +1221,7 @@ public struct ContentView: View { } // MARK: - Process Detail Inspector Sheet +@MainActor struct ProcessDetailSheet: View { let inspector: MMProcessDetailInspector let pid: Int32 diff --git a/Sources/UI/MenuBar/QuickGlancePopoverView.swift b/Sources/UI/MenuBar/QuickGlancePopoverView.swift index 07e0ab5..44fbd12 100644 --- a/Sources/UI/MenuBar/QuickGlancePopoverView.swift +++ b/Sources/UI/MenuBar/QuickGlancePopoverView.swift @@ -1,7 +1,8 @@ import SwiftUI +@MainActor public struct QuickGlancePopoverView: View { - var store: SystemTelemetryStore + @ObservedObject var store: SystemTelemetryStore public init(store: SystemTelemetryStore) { self.store = store diff --git a/Sources/UI/Settings/AlertsSettingsView.swift b/Sources/UI/Settings/AlertsSettingsView.swift index 29584a0..41a77d5 100644 --- a/Sources/UI/Settings/AlertsSettingsView.swift +++ b/Sources/UI/Settings/AlertsSettingsView.swift @@ -5,6 +5,7 @@ import UserNotifications /// Preferences UI for threshold alert rules. Bound directly to /// `AlertEngine.shared.configuration`, which auto-persists to `UserDefaults`. +@MainActor public struct AlertsSettingsView: View { @ObservedObject private var engine = AlertEngine.shared @State private var authorizationStatus: UNAuthorizationStatus = .notDetermined diff --git a/Tests/MMMenuBarTests.swift b/Tests/MMMenuBarTests.swift index 2ff00e3..3fdd308 100644 --- a/Tests/MMMenuBarTests.swift +++ b/Tests/MMMenuBarTests.swift @@ -2,6 +2,7 @@ import XCTest import SwiftUI @testable import MacMonitor +@MainActor final class MMMenuBarTests: XCTestCase { func testMenuBarStatusViewInitialization() { -- 2.39.5