What problem does it solve?
Provides a comprehensive, enforceable set of SwiftUI API usage rules to prevent subtle UI bugs, identity-loss during diffing, stale selection states, and inconsistent UX in the Harness Monitor macOS app.
Core Features & Use Cases
- State management rules: guidance on when to use @State, @Binding, @Observable, @Bindable, @FocusState, @AppStorage and where state should live to avoid stale updates and unnecessary view recomputation.
- View composition & identity: prescriptions to prefer struct views over free functions, extract subviews, avoid closure properties on view structs, and avoid identity-breaking modifier branches.
- Selection and Picker safety: rules to always render matching tags, clamp selections before render, and provide regression test recommendations to prevent invalid selection warnings.
- Button styling and accessibility: enforced use of native glass styles, prohibition of .plain, and requirement that custom behaviors conform to ButtonStyle.
- Drag-and-drop best practices: unconditional .draggable installation, explicit drop rejection feedback, exhaustive DragSession.Phase handling, single-phase drag state, and macOS-only API guidance.
- Navigation, lists, animation, layout, keyboard, window, and commands: targeted recommendations for NavigationStack, List usage, explicit animations, layout primitives, focus management, and macOS window/command patterns.
- Anti-patterns and tests: lists of forbidden patterns (AnyView, work in initializers, index-based ForEach) and expectations for regression and store-level tests.
Quick Start
Ask the assistant to review a SwiftUI view file in apps/harness-monitor-macos/Sources and list any violations of the Harness Monitor SwiftUI API patterns, explaining why each issue breaks identity, state, or UX and suggesting a fix.