Cross-platform observation delivery + WebAssembly build support - #152
Cross-platform observation delivery + WebAssembly build support#1520xLeif wants to merge 0 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors platform-specific checks (#if !os(Linux) && !os(Windows)) to use feature-based checks (canImport) across the codebase, and adds a detailed note regarding a known Swift-on-Linux runtime crash (Issue #151). It also introduces notifyChange() calls to several state setters to ensure proper observation. However, a critical thread-safety issue was identified: because these state setters (such as StoredState, FileState, SyncState, and DependencySlice) are not restricted to @MainActor, they can be invoked from background threads. This would trigger a main-thread assertion in notifyChange() and crash the application. It is highly recommended to make notifyChange() thread-safe or dispatch it to the main thread.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
1c54db2 to
b47b388
Compare
b47b388 to
515e7c3
Compare
Makes AppState's reactivity work everywhere Swift's Observation runs, and unblocks WebAssembly.
#150 — observation delivery off Apple
The Observation framework is cross-platform, but AppState only delivered changes on Apple: state setters write to the untracked
Cache, and the Combine bridgeconsume(object: cache)(Apple-only) callednotifyChange(). On Linux/Windows/wasm there was no bridge, sowithObservationTracking { … } onChange:never fired.Now every mutation path (State / StoredState / FileState / SyncState / SecureState / DependencySlice) calls
notifyChange()directly on all platforms, and the Combine cache bridge is removed so Apple still fires exactly once. Observation tests are un-gated to run cross-platform (Apple-only SecureState/SyncState assertions guarded individually) — CI now exercises observation on Linux.#149 — WebAssembly build
Combine-gated
#if !os(Linux) && !os(Windows)guards (import Combine, the cancellable bag,consume,@ObservedDependency, OSLog/SwiftUI) includedos(WASI). Switched the Combine/OSLog/SwiftUI ones tocanImport(...). Keychain (SecureState) and iCloud KV (SyncState) stay Apple-only.Verification
163 tests pass on macOS, against both published Cache 2.1.2 and the WASM/Linux-fixed Cache branch.
Sequencing
Full WebAssembly build and Linux collection-typed state also need the Cache fix — 0xLeif/Cache#30. Recommend merging + releasing that first, then bumping AppState's Cache pin. #150 observation delivery is AppState-only and verified by this PR's Linux CI independently.
Addresses #149, #150, #151.