Fix Sendable unsoundness, CancelBag TOCTOU, locker naming, default animation, and add async dispatch API#17
Open
nashysolutions wants to merge 2 commits intoanthony1810:mainfrom
Conversation
…t animation - ScreenState: change open class Sendable to @unchecked Sendable with a doc comment stating the invariant all subclasses must maintain (fixes anthony1810#19) - CancelBag: add async-safe store(task:identifier:) that inserts synchronously within actor isolation, eliminating the TOCTOU window between registration and storage (fixes anthony1810#20) - NonIsolatedActionLocker: add doc comment explicitly marking it not thread-safe and directing users to IsolatedActionLocker for concurrent use (fixes anthony1810#21) - StateUpdatable.updateState: change default animation from .smooth to .none so state mutations from network responses are no longer animated by default; callers can opt in at the call site where animation is intentional (fixes #22) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Feb 24, 2026
Open
The protocol previously only exposed nonisolated receive(action:), which spawns an unstructured fire-and-forget task with no cancellation support. Callers in async contexts (SwiftUI .task, .refreshable) had to reach into conforming types' internal isolatedReceive method to get awaitable dispatch. Adding func send(action: Action) async makes the safe, structured path part of the public contract. receive(action:) is retained for sync contexts (button callbacks, onAppear) where awaiting is not possible (fixes anthony1810#15). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScreenState: changeopen class ScreenState: Sendableto@unchecked Sendablewith a doc comment stating the invariant all subclasses must maintain (@MainActorisolation on all mutable state)CancelBag: addstore(task:identifier:)that registers tasks synchronously within the actor, eliminating the TOCTOU window wherecancelAll()could miss a task that was created but not yet insertedNonIsolatedActionLocker: add documentation explicitly marking it not thread-safe and directing users toIsolatedActionLockerfor concurrent contextsStateUpdatable.updateState: change defaultanimationfrom.smoothto.noneso every network-originated state update is no longer animated; callers opt in at the call site where a visual transition is intentionalScreenActionStore: addfunc send(action: Action) asyncas the primary async dispatch method on the protocol, making structured cancellable dispatch part of the public API;receive(action:)is retained for sync contextsTest plan
CancelBag: confirmcancelAll()called immediately afterstore()cancels the stored taskStateUpdatable: confirm list updates are no longer animated by default; callers needing animation passwithAnimation: .smoothexplicitlysend(action:)compile correctly; existingreceive(action:)implementations are unaffected🤖 Generated with Claude Code