Instructions for AI coding agents working on OSView.
OSView is a native macOS system monitoring app built with SwiftUI. It displays real-time CPU, Memory, GPU, Network, and Disk metrics in a floating panel widget. Inspired by the classic IRIX gr_osview tool.
MVVM pattern with clear separation:
Models/ → Data structures (SystemMetrics.swift)
ViewModels/ → MetricsViewModel aggregates all monitors
Views/ → SwiftUI views, one per metric type
Services/ → Monitor classes wrapping system APIs
Utilities/ → Settings, FloatingPanel
Data flow:
System APIs (IOKit, Mach, Darwin)
↓
Services (CPUMonitor, MemoryMonitor, etc.)
↓
MetricsViewModel (@Published properties)
↓
Views (@ObservedObject)
- @MainActor on ViewModels and Settings
- @unchecked Sendable on Monitor classes
- Static
.zerofactory on all metric structs - Colors defined as static extensions on
ColorinSettings.swift - MARK comments to organize code sections
- Define model in
Models/SystemMetrics.swift - Create monitor in
Services/NewMonitor.swift - Add
@Publishedproperty toMetricsViewModel - Create view in
Views/NewView.swift - Add visibility toggle to
Settings.swiftandSettingsView.swift - Integrate in
ContentView.swift
| Task | Files |
|---|---|
| Metrics polling | MetricsViewModel.swift |
| UI appearance | Views/*.swift, Settings.swift |
| Window behavior | FloatingPanel.swift, OSViewApp.swift |
| User preferences | Settings.swift, SettingsView.swift |
- ProcessorKit - CPU usage (external Swift package)
- IOKit - GPU and Disk stats
- Darwin/Mach - Memory and Network stats
# Build release
xcodebuild -project OSView.xcodeproj -scheme OSView -configuration Release -derivedDataPath build clean build
# Output
build/Build/Products/Release/OSView.app- Keep views small and composable
- Use
MetricBarView,SegmentedBarView,CompactBarViewfor consistency - Metrics should have both raw values and computed percentages
- Handle edge cases in rate calculations (elapsed time bounds, nil values)
- Test with
#Previewmacros