1 Commits
Author SHA1 Message Date
gronod 9f2d0c58d8 Merge pull request 'release: v0.0.2 — M6 bugfix release' (#40) from develop into main
MacMonitor CI/CD Pipeline / Build & Test (Intel x86_64) (push) Successful in 49s
MacMonitor CI/CD Pipeline / Package Release Artifact (push) Successful in 1m4s
2026-09-08 15:19:51 +01:00
15 changed files with 147 additions and 297 deletions
+2 -2
View File
@@ -12,7 +12,7 @@ concurrency:
jobs: jobs:
build-and-test: build-and-test:
name: Build & Test (Intel x86_64) name: Build & Test (Intel x86_64)
runs-on: macos-12 runs-on: macos-14
steps: steps:
- name: Check out repository - name: Check out repository
@@ -78,7 +78,7 @@ jobs:
release-package: release-package:
name: Package Release Artifact name: Package Release Artifact
needs: build-and-test needs: build-and-test
runs-on: macos-12 runs-on: macos-14
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v')
steps: steps:
-4
View File
@@ -25,7 +25,3 @@ xcuserdata/
*.dmg *.dmg
*.zip *.zip
*.app *.app
FIRST-PASS-REFERENCE.md
SECOND-PASS-REFERENCE.md
Docs/AppleSilicon-plan.md
Docs/Monterey-plan.md
+3 -3
View File
@@ -3,7 +3,7 @@
## 1. Project Specifications & Architectural Constraints ## 1. Project Specifications & Architectural Constraints
- **Platform Target:** macOS for Intel (`x86_64`). - **Platform Target:** macOS for Intel (`x86_64`).
- **Minimum OS Version:** macOS 12.0 (Monterey) or higher. - **Minimum OS Version:** macOS 14.0 (Sonoma) or higher.
- **Language Stack:** SwiftUI (Presentation & ViewModels) + Objective-C / C (Low-level Mach, IOKit, SMC, BSD Sysctl APIs). - **Language Stack:** SwiftUI (Presentation & ViewModels) + Objective-C / C (Low-level Mach, IOKit, SMC, BSD Sysctl APIs).
- **Interoperability:** Modular Objective-C bridging layer (`MacMonitor-Bridging-Header.h`) exposing thread-safe C primitives to Swift. - **Interoperability:** Modular Objective-C bridging layer (`MacMonitor-Bridging-Header.h`) exposing thread-safe C primitives to Swift.
- **CI/CD Platform:** Gitea Actions executing on Intel macOS runners (`[macos, intel]`). - **CI/CD Platform:** Gitea Actions executing on Intel macOS runners (`[macos, intel]`).
@@ -144,7 +144,7 @@ graph TD
2. **Phase 1.2 (Parallel Tracks):** 2. **Phase 1.2 (Parallel Tracks):**
- **Track 1.2A:** `#2` AppleSMC Client (`feat/2-smc-client`). Low-level SMC key reader, data parsers (`sp78`, `fpe2`, `flt`). - **Track 1.2A:** `#2` AppleSMC Client (`feat/2-smc-client`). Low-level SMC key reader, data parsers (`sp78`, `fpe2`, `flt`).
- **Track 1.2B:** `#25` Gitea CI/CD Pipeline (`feat/25-gitea-ci`). Create `.gitea/workflows/build.yml` targeting Intel runners. - **Track 1.2B:** `#25` Gitea CI/CD Pipeline (`feat/25-gitea-ci`). Create `.gitea/workflows/build.yml` targeting Intel runners.
- **Quality Gate M1:** Successful build and execution of sample test suite on Gitea Actions runner compiling for `x86_64` macOS 12. - **Quality Gate M1:** Successful build and execution of sample test suite on Gitea Actions runner compiling for `x86_64` macOS 14.
--- ---
@@ -189,7 +189,7 @@ graph TD
### Milestone 4: Presentation, Visuals & Menu Bar Integration ### Milestone 4: Presentation, Visuals & Menu Bar Integration
- **Integration Branch:** `milestone/m4-presentation` - **Integration Branch:** `milestone/m4-presentation`
- **Goal:** User-facing presentation layer: macOS 12 Menu Bar Extra, popover widgets, display brightness management, and Swift Charts rolling graphs. - **Goal:** User-facing presentation layer: macOS 14 Menu Bar Extra, popover widgets, display brightness management, and Swift Charts rolling graphs.
- **Execution Order:** - **Execution Order:**
1. `#13` Screen Brightness & Display Management (`feat/13-display-brightness`) 1. `#13` Screen Brightness & Display Management (`feat/13-display-brightness`)
2. `#22` Status Bar Menu Bar Extra & Popover (`feat/22-menubar-popover`) 2. `#22` Status Bar Menu Bar Extra & Popover (`feat/22-menubar-popover`)
+6 -6
View File
@@ -698,7 +698,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitor; PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitor;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h";
@@ -720,7 +720,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@loader_path/../Frameworks", "@loader_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitorTests; PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitorTests;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h";
@@ -778,7 +778,7 @@
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.2; MARKETING_VERSION = 0.0.2;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
@@ -807,7 +807,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@loader_path/../Frameworks", "@loader_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitorTests; PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitorTests;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h";
@@ -871,7 +871,7 @@
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.2; MARKETING_VERSION = 0.0.2;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
@@ -902,7 +902,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 12.0; MACOSX_DEPLOYMENT_TARGET = 14.0;
PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitor; PRODUCT_BUNDLE_IDENTIFIER = com.i3omb.MacMonitor;
SDKROOT = macosx; SDKROOT = macosx;
SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Sources/Bridging/MacMonitor-Bridging-Header.h";
+13 -108
View File
@@ -1,67 +1,19 @@
import SwiftUI import SwiftUI
import Combine
/// Bridges app-lifecycle events into SwiftUI: requests Notification Center /// Bridges app-lifecycle events into SwiftUI: requests Notification Center
/// authorization once at launch so threshold alerts can post banners. /// authorization once at launch so threshold alerts can post banners.
@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate { final class AppDelegate: NSObject, NSApplicationDelegate {
var statusItem: NSStatusItem?
var popover: NSPopover?
var cancellable: AnyCancellable?
func applicationDidFinishLaunching(_ notification: Notification) { func applicationDidFinishLaunching(_ notification: Notification) {
if AlertEngine.shared.configuration.alertsEnabled { if AlertEngine.shared.configuration.alertsEnabled {
AlertEngine.shared.requestNotificationAuthorization() AlertEngine.shared.requestNotificationAuthorization()
} }
setupMenuBar()
}
private func setupMenuBar() {
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
let popover = NSPopover()
popover.contentSize = NSSize(width: 320, height: 400)
popover.behavior = .transient
popover.contentViewController = NSHostingController(rootView: QuickGlancePopoverView(store: SystemTelemetryStore.shared))
self.popover = popover
if let button = statusItem?.button {
button.action = #selector(togglePopover(_:))
button.target = self
}
cancellable = SystemTelemetryStore.shared.$latestSnapshot.sink { [weak self] _ in
DispatchQueue.main.async {
self?.updateMenuBarLabel()
}
}
updateMenuBarLabel()
}
@objc func togglePopover(_ sender: AnyObject?) {
guard let button = statusItem?.button, let popover = popover else { return }
if popover.isShown {
popover.performClose(sender)
} else {
popover.show(relativeTo: button.bounds, of: button, preferredEdge: .minY)
}
}
private func updateMenuBarLabel() {
guard let button = statusItem?.button else { return }
let cpu = SystemTelemetryStore.shared.cpuLoad.totalLoad
let mem = SystemTelemetryStore.shared.memory.utilizationPercentage
let alerts = AlertEngine.shared.activeAlerts.count
let alertStr = alerts > 0 ? "⚠️ " : ""
button.title = String(format: "%@CPU: %.0f%% • RAM: %.0f%%", alertStr, cpu, mem)
} }
} }
@main @main
struct MacMonitorApp: App { struct MacMonitorApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
@StateObject private var store = SystemTelemetryStore.shared @State private var store = SystemTelemetryStore.shared
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
@@ -69,68 +21,21 @@ struct MacMonitorApp: App {
} }
.windowStyle(.titleBar) .windowStyle(.titleBar)
.windowToolbarStyle(.unified) .windowToolbarStyle(.unified)
.defaultSize(width: 960, height: 640)
MenuBarExtra {
QuickGlancePopoverView(store: store)
} label: {
MenuBarStatusView(
cpuLoad: store.cpuLoad.totalLoad,
memoryPercent: store.memory.utilizationPercentage,
activeAlertCount: store.alertEngine.activeAlerts.count
)
}
.menuBarExtraStyle(.window)
Settings { Settings {
AlertsSettingsView() AlertsSettingsView()
} }
} }
} }
// MARK: - UI Shims (macOS 12 Support)
public struct MMLabeledContent<Label: View, Content: View>: View {
public let label: Label
public let content: Content
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) {
self.label = label()
self.content = content()
}
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) where Label == Text {
self.label = Text(titleKey)
self.content = content()
}
public init<S: StringProtocol>(_ title: S, @ViewBuilder content: () -> Content) where Label == Text {
self.label = Text(title)
self.content = content()
}
public var body: some View {
HStack {
label
Spacer()
content
}
}
}
public extension View {
@ViewBuilder
func mmMonospaced() -> some View {
if #available(macOS 13.0, *) {
self.monospaced()
} else {
self
}
}
@ViewBuilder
func mmMonospacedDigit() -> some View {
if #available(macOS 13.0, *) {
self.monospacedDigit()
} else {
self
}
}
@ViewBuilder
func mmFormStyleGrouped() -> some View {
if #available(macOS 13.0, *) {
self.formStyle(.grouped)
} else {
self
}
}
}
+25 -24
View File
@@ -1,6 +1,6 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
import Combine import Observation
// MARK: - Typed Telemetry Models // MARK: - Typed Telemetry Models
@@ -220,38 +220,39 @@ public struct AudioDeviceItem: Identifiable, Sendable {
// MARK: - SystemTelemetryStore // MARK: - SystemTelemetryStore
@Observable
@MainActor @MainActor
public final class SystemTelemetryStore: ObservableObject { public final class SystemTelemetryStore {
public static let shared = SystemTelemetryStore() public static let shared = SystemTelemetryStore()
@Published public private(set) var isRunning: Bool = false public private(set) var isRunning: Bool = false
@Published public private(set) var lastUpdateTimestamp: Date = .now public private(set) var lastUpdateTimestamp: Date = .now
@Published public private(set) var sampleInterval: TimeInterval = 1.0 public private(set) var sampleInterval: TimeInterval = 1.0
/// Raw snapshots organized by provider identifier /// Raw snapshots organized by provider identifier
@Published public private(set) var latestSnapshot: [String: [String: Any]] = [:] public private(set) var latestSnapshot: [String: [String: Any]] = [:]
/// Milestone 2 Structured Metrics /// Milestone 2 Structured Metrics
@Published public private(set) var cpuLoad = CPULoadMetrics() public private(set) var cpuLoad = CPULoadMetrics()
@Published public private(set) var memory = MemoryMetrics() public private(set) var memory = MemoryMetrics()
@Published public private(set) var storageVolumes: [StorageVolumeItem] = [] public private(set) var storageVolumes: [StorageVolumeItem] = []
@Published public private(set) var cpuThermal = CPUThermalMetrics() public private(set) var cpuThermal = CPUThermalMetrics()
@Published public private(set) var fans: [FanTelemetryItem] = [] public private(set) var fans: [FanTelemetryItem] = []
@Published public private(set) var componentTemps: [ComponentThermalItem] = [] public private(set) var componentTemps: [ComponentThermalItem] = []
@Published public private(set) var power = PowerMetrics() public private(set) var power = PowerMetrics()
/// Milestone 3 Structured Metrics /// Milestone 3 Structured Metrics
@Published public private(set) var kernelCounters = KernelCountersMetrics() public private(set) var kernelCounters = KernelCountersMetrics()
@Published public private(set) var systemLoad = SystemLoadMetrics() public private(set) var systemLoad = SystemLoadMetrics()
@Published public private(set) var diskIO: [DiskIOItem] = [] public private(set) var diskIO: [DiskIOItem] = []
@Published public private(set) var networkBandwidth: [NetworkBandwidthItem] = [] public private(set) var networkBandwidth: [NetworkBandwidthItem] = []
@Published public private(set) var networkSockets: [SocketItem] = [] public private(set) var networkSockets: [SocketItem] = []
@Published public private(set) var processes: [ProcessItem] = [] public private(set) var processes: [ProcessItem] = []
@Published public private(set) var gpus: [GPUCardItem] = [] public private(set) var gpus: [GPUCardItem] = []
@Published public private(set) var batteryHealth = BatteryHealthMetrics() public private(set) var batteryHealth = BatteryHealthMetrics()
@Published public private(set) var peripherals: [PeripheralDeviceItem] = [] public private(set) var peripherals: [PeripheralDeviceItem] = []
@Published public private(set) var audioDevices: [AudioDeviceItem] = [] public private(set) var audioDevices: [AudioDeviceItem] = []
@Published public private(set) var displays: [MMDisplayInfo] = [] public private(set) var displays: [MMDisplayInfo] = []
/// Historical Telemetry Store /// Historical Telemetry Store
public let historyStore = TelemetryHistoryStore.shared public let historyStore = TelemetryHistoryStore.shared
+3 -3
View File
@@ -1,6 +1,5 @@
import Foundation import Foundation
import SwiftUI import SwiftUI
import Combine
public struct TelemetrySnapshotRecord { public struct TelemetrySnapshotRecord {
public let cpuLoad: Double public let cpuLoad: Double
@@ -36,7 +35,8 @@ public struct TelemetrySnapshotRecord {
} }
} }
public final class TelemetryHistoryStore: ObservableObject { @Observable
public final class TelemetryHistoryStore {
public static let shared = TelemetryHistoryStore() public static let shared = TelemetryHistoryStore()
public let cpuHistory = RollingRingBuffer<Double>(capacity: 60) public let cpuHistory = RollingRingBuffer<Double>(capacity: 60)
@@ -48,7 +48,7 @@ public final class TelemetryHistoryStore: ObservableObject {
public let cpuTempHistory = RollingRingBuffer<Double>(capacity: 60) public let cpuTempHistory = RollingRingBuffer<Double>(capacity: 60)
public let powerHistory = RollingRingBuffer<Double>(capacity: 60) public let powerHistory = RollingRingBuffer<Double>(capacity: 60)
@Published public private(set) var sampleCounter: UInt64 = 0 public private(set) var sampleCounter: UInt64 = 0
public init() {} public init() {}
+5 -5
View File
@@ -1,6 +1,5 @@
import Foundation import Foundation
import UserNotifications import UserNotifications
import Combine
// MARK: - Alert Engine // MARK: - Alert Engine
@@ -14,17 +13,18 @@ import Combine
/// persistent -> re-fire only after `cooldownMinutes` elapse /// persistent -> re-fire only after `cooldownMinutes` elapse
/// recovery -> remove from active set, log `.resolved`, clear cooldown so /// recovery -> remove from active set, log `.resolved`, clear cooldown so
/// the next breach alerts immediately /// the next breach alerts immediately
@Observable
@MainActor @MainActor
public final class AlertEngine: ObservableObject { public final class AlertEngine {
public static let shared = AlertEngine() public static let shared = AlertEngine()
/// Currently breached conditions, refreshed every evaluation pass. /// Currently breached conditions, refreshed every evaluation pass.
@Published public private(set) var activeAlerts: [SystemAlert] = [] public private(set) var activeAlerts: [SystemAlert] = []
/// Newest-first audit log of trigger/resolve events (capped). /// Newest-first audit log of trigger/resolve events (capped).
@Published public private(set) var history: [AlertEvent] = [] public private(set) var history: [AlertEvent] = []
/// Threshold settings. Mutations are persisted immediately. /// Threshold settings. Mutations are persisted immediately.
@Published public var configuration: AlertConfiguration { public var configuration: AlertConfiguration {
didSet { configuration.save(to: defaults) } didSet { configuration.save(to: defaults) }
} }
@@ -1,20 +1,20 @@
import Foundation import Foundation
import UserNotifications import UserNotifications
import Combine
// MARK: - Navigation Bus // MARK: - Navigation Bus
/// Lightweight bus letting notification action handlers steer the main window: /// Lightweight bus letting notification action handlers steer the main window:
/// tapping a notification (or its "View Processes" action) activates the app and /// tapping a notification (or its "View Processes" action) activates the app and
/// selects the requested sidebar tab inside `ContentView`. /// selects the requested sidebar tab inside `ContentView`.
public final class AppNavigationBus: ObservableObject { @Observable
public final class AppNavigationBus {
public static let shared = AppNavigationBus() public static let shared = AppNavigationBus()
/// Sidebar tag the main window should switch to (e.g. `"Processes"`). /// Sidebar tag the main window should switch to (e.g. `"Processes"`).
/// `nil` means "just bring the window forward". /// `nil` means "just bring the window forward".
@Published public private(set) var requestedTab: String? public private(set) var requestedTab: String?
/// Monotonic counter so repeated taps on the same tab still trigger `onChange`. /// Monotonic counter so repeated taps on the same tab still trigger `onChange`.
@Published public private(set) var requestCounter: Int = 0 public private(set) var requestCounter: Int = 0
private init() {} private init() {}
@@ -118,12 +118,11 @@ public final class UNAlertNotificationDispatcher: NSObject, AlertNotificationDis
didReceive response: UNNotificationResponse, didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void withCompletionHandler completionHandler: @escaping () -> Void
) { ) {
let targetTab: String? let targetTab: String? = switch response.actionIdentifier {
switch response.actionIdentifier {
case AlertNotificationAction.viewProcessesIdentifier: case AlertNotificationAction.viewProcessesIdentifier:
targetTab = "Processes" "Processes"
default: default:
targetTab = nil nil
} }
Task { @MainActor in Task { @MainActor in
AppNavigationBus.shared.request(tab: targetTab) AppNavigationBus.shared.request(tab: targetTab)
+2 -3
View File
@@ -4,9 +4,8 @@ import SwiftUI
/// Sidebar tab showing currently breached thresholds and the in-app /// Sidebar tab showing currently breached thresholds and the in-app
/// alert history log maintained by `AlertEngine`. /// alert history log maintained by `AlertEngine`.
@MainActor
public struct AlertsView: View { public struct AlertsView: View {
@ObservedObject private var engine = AlertEngine.shared @State private var engine = AlertEngine.shared
public init() {} public init() {}
@@ -110,7 +109,7 @@ public struct AlertsView: View {
Text(event.alertID) Text(event.alertID)
.font(.caption2) .font(.caption2)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
.mmMonospaced() .monospaced()
} }
Spacer() Spacer()
Text(event.timestamp.formatted(date: .abbreviated, time: .standard)) Text(event.timestamp.formatted(date: .abbreviated, time: .standard))
+25 -69
View File
@@ -1,7 +1,5 @@
import SwiftUI import SwiftUI
#if canImport(Charts)
import Charts import Charts
#endif
public struct TelemetryTrendChartView: View { public struct TelemetryTrendChartView: View {
public let title: String public let title: String
@@ -45,7 +43,8 @@ public struct TelemetryTrendChartView: View {
Spacer() Spacer()
HStack(spacing: 12) { HStack(spacing: 12) {
Text(String(format: "Cur: %.1f %@", currentValue, unit)) Text(String(format: "Cur: %.1f %@", currentValue, unit))
.font(.system(size: 11, weight: .semibold)) .font(.caption)
.fontWeight(.semibold)
.foregroundColor(color) .foregroundColor(color)
Text(String(format: "Avg: %.1f %@", averageValue, unit)) Text(String(format: "Avg: %.1f %@", averageValue, unit))
.font(.caption) .font(.caption)
@@ -56,78 +55,35 @@ public struct TelemetryTrendChartView: View {
} }
} }
#if canImport(Charts) Chart {
if #available(macOS 13.0, *) { ForEach(Array(samples.enumerated()), id: \.element.id) { index, sample in
Chart { LineMark(
ForEach(Array(samples.enumerated()), id: \.element.id) { index, sample in x: .value("Sample", index),
LineMark( y: .value("Value", sample.value)
x: .value("Sample", index), )
y: .value("Value", sample.value) .interpolationMethod(.monotone)
.foregroundStyle(color)
AreaMark(
x: .value("Sample", index),
y: .value("Value", sample.value)
)
.interpolationMethod(.monotone)
.foregroundStyle(
LinearGradient(
colors: [color.opacity(0.35), color.opacity(0.05)],
startPoint: .top,
endPoint: .bottom
) )
.interpolationMethod(.monotone) )
.foregroundStyle(color)
AreaMark(
x: .value("Sample", index),
y: .value("Value", sample.value)
)
.interpolationMethod(.monotone)
.foregroundStyle(
LinearGradient(
colors: [color.opacity(0.35), color.opacity(0.05)],
startPoint: .top,
endPoint: .bottom
)
)
}
} }
.chartYScale(domain: 0...(maxY ?? max(1.0, maxValue * 1.15)))
.chartXAxis(.hidden)
.frame(height: 120)
} else {
fallbackChart
} }
#else .chartYScale(domain: 0...(maxY ?? max(1.0, maxValue * 1.15)))
fallbackChart .chartXAxis(.hidden)
#endif .frame(height: 120)
} }
.padding(14) .padding(14)
.background(Color(NSColor.controlBackgroundColor)) .background(Color(NSColor.controlBackgroundColor))
.cornerRadius(10) .cornerRadius(10)
} }
@ViewBuilder
private var fallbackChart: some View {
Canvas { context, size in
guard samples.count > 1 else { return }
let effectiveMaxY = maxY ?? max(1.0, maxValue * 1.15)
let dx = size.width / CGFloat(samples.count - 1)
var path = Path()
var areaPath = Path()
for (index, sample) in samples.enumerated() {
let x = CGFloat(index) * dx
let y = size.height - (CGFloat(sample.value) / CGFloat(effectiveMaxY)) * size.height
if index == 0 {
path.move(to: CGPoint(x: x, y: y))
areaPath.move(to: CGPoint(x: x, y: size.height))
areaPath.addLine(to: CGPoint(x: x, y: y))
} else {
path.addLine(to: CGPoint(x: x, y: y))
areaPath.addLine(to: CGPoint(x: x, y: y))
}
}
if let lastIndex = samples.indices.last {
let lastX = CGFloat(lastIndex) * dx
areaPath.addLine(to: CGPoint(x: lastX, y: size.height))
areaPath.closeSubpath()
}
context.fill(areaPath, with: .linearGradient(Gradient(colors: [color.opacity(0.35), color.opacity(0.05)]), startPoint: .zero, endPoint: CGPoint(x: 0, y: size.height)))
context.stroke(path, with: .color(color), lineWidth: 2)
}
.frame(height: 120)
}
} }
+38 -43
View File
@@ -1,20 +1,20 @@
import SwiftUI import SwiftUI
@MainActor
public struct ContentView: View { public struct ContentView: View {
@StateObject private var store = SystemTelemetryStore.shared @State private var store = SystemTelemetryStore.shared
@State private var selectedTab: String? = "Dashboard" @State private var selectedTab: String = "Dashboard"
@State private var processSearchText: String = "" @State private var processSearchText: String = ""
@State private var socketSearchText: String = "" @State private var socketSearchText: String = ""
@State private var selectedPID: Int32? = nil @State private var selectedPID: Int32? = nil
@State private var showingProcessDetail: Bool = false @State private var showingProcessDetail: Bool = false
@StateObject private var navBus = AppNavigationBus.shared @State private var navBus = AppNavigationBus.shared
public init() {} public init() {}
public var body: some View { public var body: some View {
NavigationView { NavigationSplitView {
sidebarContent sidebarContent
} detail: {
detailContent detailContent
} }
.frame(minWidth: 1000, minHeight: 700) .frame(minWidth: 1000, minHeight: 700)
@@ -26,7 +26,7 @@ public struct ContentView: View {
ProcessDetailSheet(inspector: store.processInspector, pid: pid) ProcessDetailSheet(inspector: store.processInspector, pid: pid)
} }
} }
.onChange(of: navBus.requestCounter) { _ in .onChange(of: navBus.requestCounter) { _, _ in
NSApp.activate(ignoringOtherApps: true) NSApp.activate(ignoringOtherApps: true)
if let window = NSApp.windows.first(where: { $0.canBecomeMain }) { if let window = NSApp.windows.first(where: { $0.canBecomeMain }) {
window.makeKeyAndOrderFront(nil) window.makeKeyAndOrderFront(nil)
@@ -109,7 +109,7 @@ public struct ContentView: View {
} }
} }
.listStyle(.sidebar) .listStyle(.sidebar)
.frame(minWidth: 210, idealWidth: 240, maxWidth: 300) .navigationSplitViewColumnWidth(min: 210, ideal: 240, max: 300)
} }
// MARK: - Detail Content Router // MARK: - Detail Content Router
@@ -120,7 +120,7 @@ public struct ContentView: View {
headerCard headerCard
engineControlCard engineControlCard
switch selectedTab ?? "Dashboard" { switch selectedTab {
case "Dashboard": case "Dashboard":
dashboardView dashboardView
case "Architecture": case "Architecture":
@@ -169,7 +169,7 @@ public struct ContentView: View {
} }
.padding(24) .padding(24)
} }
.navigationTitle("MacMonitor — \(selectedTab ?? "Dashboard")") .navigationTitle("MacMonitor — \(selectedTab)")
} }
// MARK: - Dashboard Composite View // MARK: - Dashboard Composite View
@@ -358,20 +358,20 @@ public struct ContentView: View {
Label("Kernel & VM Telemetry", systemImage: "waveform.path.ecg") Label("Kernel & VM Telemetry", systemImage: "waveform.path.ecg")
.font(.headline) .font(.headline)
VStack(alignment: .leading, spacing: 8) { Grid(alignment: .leading, horizontalSpacing: 20, verticalSpacing: 8) {
HStack { GridRow {
Text("Context Switches:").foregroundStyle(.secondary) Text("Context Switches:").foregroundStyle(.secondary)
Text("\(Int(store.kernelCounters.contextSwitchesPerSec))/s").bold().monospacedDigit() Text("\(Int(store.kernelCounters.contextSwitchesPerSec))/s").bold().monospacedDigit()
Text("Syscalls:").foregroundStyle(.secondary) Text("Syscalls:").foregroundStyle(.secondary)
Text("\(Int(store.kernelCounters.syscallsPerSec))/s").bold().monospacedDigit() Text("\(Int(store.kernelCounters.syscallsPerSec))/s").bold().monospacedDigit()
} }
HStack { GridRow {
Text("Page Faults:").foregroundStyle(.secondary) Text("Page Faults:").foregroundStyle(.secondary)
Text("\(Int(store.kernelCounters.pageFaultsPerSec))/s").bold().monospacedDigit() Text("\(Int(store.kernelCounters.pageFaultsPerSec))/s").bold().monospacedDigit()
Text("COW Faults:").foregroundStyle(.secondary) Text("COW Faults:").foregroundStyle(.secondary)
Text("\(Int(store.kernelCounters.cowFaultsPerSec))/s").bold().monospacedDigit() Text("\(Int(store.kernelCounters.cowFaultsPerSec))/s").bold().monospacedDigit()
} }
HStack { GridRow {
Text("Pageins / Pageouts:").foregroundStyle(.secondary) Text("Pageins / Pageouts:").foregroundStyle(.secondary)
Text("\(Int(store.kernelCounters.pageinsPerSec)) / \(Int(store.kernelCounters.pageoutsPerSec)) /s").bold().monospacedDigit() Text("\(Int(store.kernelCounters.pageinsPerSec)) / \(Int(store.kernelCounters.pageoutsPerSec)) /s").bold().monospacedDigit()
Text("Zero-Fill:").foregroundStyle(.secondary) Text("Zero-Fill:").foregroundStyle(.secondary)
@@ -446,20 +446,20 @@ public struct ContentView: View {
ProgressView(value: min(store.memory.utilizationPercentage / 100.0, 1.0)) ProgressView(value: min(store.memory.utilizationPercentage / 100.0, 1.0))
.tint(store.memory.utilizationPercentage > 85 ? .red : .blue) .tint(store.memory.utilizationPercentage > 85 ? .red : .blue)
VStack(alignment: .leading, spacing: 6) { Grid(alignment: .leading, horizontalSpacing: 20, verticalSpacing: 6) {
HStack { GridRow {
Text("Used:").foregroundStyle(.secondary) Text("Used:").foregroundStyle(.secondary)
Text(formatBytes(store.memory.usedBytes)).bold() Text(formatBytes(store.memory.usedBytes)).bold()
Text("Free:").foregroundStyle(.secondary) Text("Free:").foregroundStyle(.secondary)
Text(formatBytes(store.memory.freeBytes)).bold() Text(formatBytes(store.memory.freeBytes)).bold()
} }
HStack { GridRow {
Text("Wired:").foregroundStyle(.secondary) Text("Wired:").foregroundStyle(.secondary)
Text(formatBytes(store.memory.wiredBytes)) Text(formatBytes(store.memory.wiredBytes))
Text("Compressed:").foregroundStyle(.secondary) Text("Compressed:").foregroundStyle(.secondary)
Text(formatBytes(store.memory.compressedBytes)) Text(formatBytes(store.memory.compressedBytes))
} }
HStack { GridRow {
Text("Swap Used:").foregroundStyle(.secondary) Text("Swap Used:").foregroundStyle(.secondary)
Text(formatBytes(store.memory.swapUsedBytes)) Text(formatBytes(store.memory.swapUsedBytes))
Text("Swap Total:").foregroundStyle(.secondary) Text("Swap Total:").foregroundStyle(.secondary)
@@ -603,10 +603,10 @@ public struct ContentView: View {
Text(s.protocolName) Text(s.protocolName)
} }
TableColumn("Local Endpoint") { s in TableColumn("Local Endpoint") { s in
Text("\(s.localAddress):\(s.localPort)").mmMonospaced() Text("\(s.localAddress):\(s.localPort)").monospaced()
} }
TableColumn("Remote Endpoint") { s in TableColumn("Remote Endpoint") { s in
Text("\(s.remoteAddress):\(s.remotePort)").mmMonospaced() Text("\(s.remoteAddress):\(s.remotePort)").monospaced()
} }
TableColumn("State") { s in TableColumn("State") { s in
Text(s.tcpState).font(.caption).foregroundStyle(s.tcpState == "ESTABLISHED" ? .green : .secondary) Text(s.tcpState).font(.caption).foregroundStyle(s.tcpState == "ESTABLISHED" ? .green : .secondary)
@@ -752,20 +752,20 @@ public struct ContentView: View {
if !store.batteryHealth.hasBattery { if !store.batteryHealth.hasBattery {
Text("Desktop Mac / No battery installed").font(.caption).foregroundStyle(.secondary) Text("Desktop Mac / No battery installed").font(.caption).foregroundStyle(.secondary)
} else { } else {
VStack(alignment: .leading, spacing: 6) { Grid(alignment: .leading, horizontalSpacing: 20, verticalSpacing: 6) {
HStack { GridRow {
Text("Cycle Count:").foregroundStyle(.secondary) Text("Cycle Count:").foregroundStyle(.secondary)
Text("\(store.batteryHealth.cycleCount) / \(store.batteryHealth.designCycleCount)").bold() Text("\(store.batteryHealth.cycleCount) / \(store.batteryHealth.designCycleCount)").bold()
Text("Temperature:").foregroundStyle(.secondary) Text("Temperature:").foregroundStyle(.secondary)
Text(String(format: "%.1f°C", store.batteryHealth.temperature)).bold() Text(String(format: "%.1f°C", store.batteryHealth.temperature)).bold()
} }
HStack { GridRow {
Text("Voltage / Power:").foregroundStyle(.secondary) Text("Voltage / Power:").foregroundStyle(.secondary)
Text("\(String(format: "%.2f V", store.batteryHealth.voltage)) (\(String(format: "%.1f W", store.batteryHealth.watts)))") Text("\(String(format: "%.2f V", store.batteryHealth.voltage)) (\(String(format: "%.1f W", store.batteryHealth.watts)))")
Text("Power Adapter:").foregroundStyle(.secondary) Text("Power Adapter:").foregroundStyle(.secondary)
Text(store.batteryHealth.externalConnected ? "\(store.batteryHealth.adapterWatts)W Connected" : "On Battery") Text(store.batteryHealth.externalConnected ? "\(store.batteryHealth.adapterWatts)W Connected" : "On Battery")
} }
HStack { GridRow {
Text("Capacity:").foregroundStyle(.secondary) Text("Capacity:").foregroundStyle(.secondary)
Text("\(store.batteryHealth.currentCapacity) / \(store.batteryHealth.maxCapacity) mAh") Text("\(store.batteryHealth.currentCapacity) / \(store.batteryHealth.maxCapacity) mAh")
Text("Manufacturer:").foregroundStyle(.secondary) Text("Manufacturer:").foregroundStyle(.secondary)
@@ -798,10 +798,10 @@ public struct ContentView: View {
.background(Color.secondary.opacity(0.15), in: Capsule()) .background(Color.secondary.opacity(0.15), in: Capsule())
} }
TableColumn("Vendor ID") { d in TableColumn("Vendor ID") { d in
Text(String(format: "0x%04x", d.vendorID)).mmMonospaced() Text(String(format: "0x%04x", d.vendorID)).monospaced()
} }
TableColumn("Product ID") { d in TableColumn("Product ID") { d in
Text(String(format: "0x%04x", d.productID)).mmMonospaced() Text(String(format: "0x%04x", d.productID)).monospaced()
} }
TableColumn("Built-In") { d in TableColumn("Built-In") { d in
Text(d.isBuiltIn ? "Yes" : "External").foregroundStyle(d.isBuiltIn ? Color.secondary : Color.blue) Text(d.isBuiltIn ? "Yes" : "External").foregroundStyle(d.isBuiltIn ? Color.secondary : Color.blue)
@@ -962,14 +962,14 @@ public struct ContentView: View {
.font(.title3.bold().monospacedDigit()) .font(.title3.bold().monospacedDigit())
} }
VStack(alignment: .leading, spacing: 6) { Grid(alignment: .leading, horizontalSpacing: 20, verticalSpacing: 6) {
HStack { GridRow {
Text("CPU Power:").foregroundStyle(.secondary) Text("CPU Power:").foregroundStyle(.secondary)
Text(String(format: "%.1f W", store.power.cpuWatts)).bold() Text(String(format: "%.1f W", store.power.cpuWatts)).bold()
Text("GPU Power:").foregroundStyle(.secondary) Text("GPU Power:").foregroundStyle(.secondary)
Text(String(format: "%.1f W", store.power.gpuWatts)).bold() Text(String(format: "%.1f W", store.power.gpuWatts)).bold()
} }
HStack { GridRow {
Text("CPU Voltage:").foregroundStyle(.secondary) Text("CPU Voltage:").foregroundStyle(.secondary)
Text(String(format: "%.2f V", store.power.cpuVoltage)) Text(String(format: "%.2f V", store.power.cpuVoltage))
Text("CPU Current:").foregroundStyle(.secondary) Text("CPU Current:").foregroundStyle(.secondary)
@@ -990,22 +990,24 @@ public struct ContentView: View {
Text("Host Architecture & Kernel") Text("Host Architecture & Kernel")
.font(.headline) .font(.headline)
VStack(alignment: .leading, spacing: 10) { Grid(alignment: .leading, horizontalSpacing: 24, verticalSpacing: 10) {
HStack { GridRow {
Text("Hardware Model:").foregroundStyle(.secondary) Text("Hardware Model:").foregroundStyle(.secondary)
Text(store.hostModel).bold() Text(store.hostModel).bold()
Text("Physical Cores:").foregroundStyle(.secondary) Text("Physical Cores:").foregroundStyle(.secondary)
Text("\(store.physicalCpuCount)").bold() Text("\(store.physicalCpuCount)").bold()
} }
HStack { GridRow {
Text("Darwin Kernel:").foregroundStyle(.secondary) Text("Darwin Kernel:").foregroundStyle(.secondary)
Text(store.kernelVersion).bold() Text(store.kernelVersion).bold()
Text("Logical Cores:").foregroundStyle(.secondary) Text("Logical Cores:").foregroundStyle(.secondary)
Text("\(store.logicalCpuCount)").bold() Text("\(store.logicalCpuCount)").bold()
} }
HStack { GridRow {
Text("Target Architecture:").foregroundStyle(.secondary) Text("Target Architecture:").foregroundStyle(.secondary)
Text("Intel x86_64").bold() Text("Intel x86_64").bold()
Text("Deployment Target:").foregroundStyle(.secondary)
Text("macOS 14.0 (Sonoma)").bold()
} }
} }
} }
@@ -1219,7 +1221,6 @@ public struct ContentView: View {
} }
// MARK: - Process Detail Inspector Sheet // MARK: - Process Detail Inspector Sheet
@MainActor
struct ProcessDetailSheet: View { struct ProcessDetailSheet: View {
let inspector: MMProcessDetailInspector let inspector: MMProcessDetailInspector
let pid: Int32 let pid: Int32
@@ -1248,9 +1249,8 @@ struct ProcessDetailSheet: View {
if selectedDetailTab == "Threads" { if selectedDetailTab == "Threads" {
List(threads.indices, id: \.self) { idx in List(threads.indices, id: \.self) { idx in
let t = threads[idx] let t = threads[idx]
let threadID = "\(t["threadID"] ?? idx)"
HStack { HStack {
Text("Thread \(threadID)").bold() Text("Thread \(t["threadID"] ?? idx)").bold()
Spacer() Spacer()
Text("CPU: \(String(format: "%.1f%%", (t["cpuPercent"] as? Double) ?? 0.0))").monospacedDigit() Text("CPU: \(String(format: "%.1f%%", (t["cpuPercent"] as? Double) ?? 0.0))").monospacedDigit()
Text(t["state"] as? String ?? "").foregroundStyle(.secondary) Text(t["state"] as? String ?? "").foregroundStyle(.secondary)
@@ -1263,16 +1263,11 @@ struct ProcessDetailSheet: View {
} else { } else {
List(sockets.indices, id: \.self) { idx in List(sockets.indices, id: \.self) { idx in
let s = sockets[idx] let s = sockets[idx]
let proto = s["protocol"] as? String ?? "TCP"
let localAddr = (s["localAddress"] as? String) ?? ""
let localPort = (s["localPort"] as? Int) ?? 0
let remoteAddr = (s["remoteAddress"] as? String) ?? ""
let remotePort = (s["remotePort"] as? Int) ?? 0
HStack { HStack {
Text(proto).bold() Text(s["protocol"] as? String ?? "TCP").bold()
Spacer() Spacer()
Text("\(localAddr):\(localPort) → \(remoteAddr):\(remotePort)") Text("\(s["localAddress"] ?? ""):\(s["localPort"] ?? 0) → \(s["remoteAddress"] ?? ""):\(s["remotePort"] ?? 0)")
.mmMonospaced() .monospaced()
Text(s["tcpState"] as? String ?? "").foregroundStyle(.secondary) Text(s["tcpState"] as? String ?? "").foregroundStyle(.secondary)
} }
} }
@@ -1,8 +1,7 @@
import SwiftUI import SwiftUI
@MainActor
public struct QuickGlancePopoverView: View { public struct QuickGlancePopoverView: View {
@ObservedObject var store: SystemTelemetryStore var store: SystemTelemetryStore
public init(store: SystemTelemetryStore) { public init(store: SystemTelemetryStore) {
self.store = store self.store = store
@@ -110,7 +109,9 @@ public struct QuickGlancePopoverView: View {
} }
Spacer() Spacer()
Text(value) Text(value)
.font(.system(size: 13, weight: .semibold, design: .monospaced)) .font(.subheadline)
.fontWeight(.semibold)
.fontDesign(.monospaced)
} }
} }
+14 -15
View File
@@ -5,9 +5,8 @@ import UserNotifications
/// Preferences UI for threshold alert rules. Bound directly to /// Preferences UI for threshold alert rules. Bound directly to
/// `AlertEngine.shared.configuration`, which auto-persists to `UserDefaults`. /// `AlertEngine.shared.configuration`, which auto-persists to `UserDefaults`.
@MainActor
public struct AlertsSettingsView: View { public struct AlertsSettingsView: View {
@ObservedObject private var engine = AlertEngine.shared @Bindable private var engine = AlertEngine.shared
@State private var authorizationStatus: UNAuthorizationStatus = .notDetermined @State private var authorizationStatus: UNAuthorizationStatus = .notDetermined
public init() {} public init() {}
@@ -59,24 +58,24 @@ public struct AlertsSettingsView: View {
Section("CPU Temperature") { Section("CPU Temperature") {
Toggle("High CPU Temperature Alert", isOn: $engine.configuration.cpuTempEnabled) Toggle("High CPU Temperature Alert", isOn: $engine.configuration.cpuTempEnabled)
MMLabeledContent("Threshold") { LabeledContent("Threshold") {
Slider(value: $engine.configuration.cpuTempThresholdC, in: 60...110, step: 1) { Slider(value: $engine.configuration.cpuTempThresholdC, in: 60...110, step: 1) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.cpuTempThresholdC))°C") Text("\(Int(engine.configuration.cpuTempThresholdC))°C")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 48, alignment: .trailing) .frame(width: 48, alignment: .trailing)
} }
} }
Section("Cooling Fans") { Section("Cooling Fans") {
Toggle("Fan Stall Alert", isOn: $engine.configuration.fanStallEnabled) Toggle("Fan Stall Alert", isOn: $engine.configuration.fanStallEnabled)
MMLabeledContent("Alert when CPU above") { LabeledContent("Alert when CPU above") {
Slider(value: $engine.configuration.fanStallTempThresholdC, in: 40...100, step: 1) { Slider(value: $engine.configuration.fanStallTempThresholdC, in: 40...100, step: 1) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.fanStallTempThresholdC))°C") Text("\(Int(engine.configuration.fanStallTempThresholdC))°C")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 48, alignment: .trailing) .frame(width: 48, alignment: .trailing)
} }
Text("Triggers when a fan reports 0 RPM while the CPU is hot.") Text("Triggers when a fan reports 0 RPM while the CPU is hot.")
@@ -86,12 +85,12 @@ public struct AlertsSettingsView: View {
Section("Memory") { Section("Memory") {
Toggle("Low Memory Alert", isOn: $engine.configuration.memoryEnabled) Toggle("Low Memory Alert", isOn: $engine.configuration.memoryEnabled)
MMLabeledContent("Free RAM below") { LabeledContent("Free RAM below") {
Slider(value: $engine.configuration.memoryFreeMBThreshold, in: 100...4096, step: 50) { Slider(value: $engine.configuration.memoryFreeMBThreshold, in: 100...4096, step: 50) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.memoryFreeMBThreshold)) MB") Text("\(Int(engine.configuration.memoryFreeMBThreshold)) MB")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 64, alignment: .trailing) .frame(width: 64, alignment: .trailing)
} }
Toggle("Alert on Critical Memory Pressure", isOn: $engine.configuration.memoryAlertOnCriticalPressure) Toggle("Alert on Critical Memory Pressure", isOn: $engine.configuration.memoryAlertOnCriticalPressure)
@@ -99,32 +98,32 @@ public struct AlertsSettingsView: View {
Section("Storage") { Section("Storage") {
Toggle("Low Disk Space Alert", isOn: $engine.configuration.storageEnabled) Toggle("Low Disk Space Alert", isOn: $engine.configuration.storageEnabled)
MMLabeledContent("Free space below") { LabeledContent("Free space below") {
Slider(value: $engine.configuration.storageFreeGBThreshold, in: 1...100, step: 1) { Slider(value: $engine.configuration.storageFreeGBThreshold, in: 1...100, step: 1) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.storageFreeGBThreshold)) GB") Text("\(Int(engine.configuration.storageFreeGBThreshold)) GB")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 48, alignment: .trailing) .frame(width: 48, alignment: .trailing)
} }
MMLabeledContent("Free percent below") { LabeledContent("Free percent below") {
Slider(value: $engine.configuration.storageFreePercentThreshold, in: 1...50, step: 1) { Slider(value: $engine.configuration.storageFreePercentThreshold, in: 1...50, step: 1) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.storageFreePercentThreshold))%") Text("\(Int(engine.configuration.storageFreePercentThreshold))%")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 48, alignment: .trailing) .frame(width: 48, alignment: .trailing)
} }
} }
Section("Battery") { Section("Battery") {
Toggle("Low Battery Alert", isOn: $engine.configuration.batteryEnabled) Toggle("Low Battery Alert", isOn: $engine.configuration.batteryEnabled)
MMLabeledContent("Charge below") { LabeledContent("Charge below") {
Slider(value: $engine.configuration.batteryPercentThreshold, in: 1...50, step: 1) { Slider(value: $engine.configuration.batteryPercentThreshold, in: 1...50, step: 1) {
EmptyView() EmptyView()
} }
Text("\(Int(engine.configuration.batteryPercentThreshold))%") Text("\(Int(engine.configuration.batteryPercentThreshold))%")
.mmMonospacedDigit() .monospacedDigit()
.frame(width: 48, alignment: .trailing) .frame(width: 48, alignment: .trailing)
} }
Text("Only fires while discharging on battery power.") Text("Only fires while discharging on battery power.")
@@ -132,7 +131,7 @@ public struct AlertsSettingsView: View {
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
} }
.mmFormStyleGrouped() .formStyle(.grouped)
.frame(minWidth: 480, minHeight: 520) .frame(minWidth: 480, minHeight: 520)
.task { await refreshAuthorizationStatus() } .task { await refreshAuthorizationStatus() }
} }
-1
View File
@@ -2,7 +2,6 @@ import XCTest
import SwiftUI import SwiftUI
@testable import MacMonitor @testable import MacMonitor
@MainActor
final class MMMenuBarTests: XCTestCase { final class MMMenuBarTests: XCTestCase {
func testMenuBarStatusViewInitialization() { func testMenuBarStatusViewInitialization() {