Reduce per-move gameplay lag - #70
Merged
Merged
Conversation
scope the board move spring per region (header, top row, tableau, tripeaks, pyramid, canfield) keyed on the state slice each renders, so one move no longer opens an animation transaction over the whole board. make cardview equatable so cards whose rendered inputs are unchanged skip re-evaluation; the card's tilt participates as a value captured at init since the binding defeats swiftui's memberwise diff. move the debounced autosave's sanitize and json encode (up to 200 undo snapshots) off the main thread, leaving only the swiftdata write on the main actor; the pure game-model layer is marked nonisolated to make the background encode legal under the project's mainactor-by-default isolation.
the planner serves klondike, yukon, freecell, forty thieves, and canfield; it never belonged in the klondike folder.
freecell's candidate check was unconditionally true, so every move ran a full greedy win simulation on the main thread just to decide whether the auto-finish button should enable. require same-suit cards within each cascade to sit in foundation order first — a necessary condition for the foundation run that rejects nearly every mid-game position in a single pass, and one the run's own moves can never invalidate, so availability behaves exactly as before.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This was referenced Jul 15, 2026
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.
What Changed
.animation(value: viewModel.state)with the same spring scoped per board region (header, top row, tableau, TriPeaks, Pyramid, Canfield), each keyed on the state slice that region renders, so one move no longer opens an animation transaction over the entire board.CardViewequatable (the card's tilt participates as a value captured at init) so cards whose rendered inputs are unchanged skip body re-evaluation.nonisolatedto make the background encode legal under the project's MainActor-by-default isolation.AutoFinishPlannerfromGame/Klondike/toGame/Shared/since it serves five variants.Why
Noticeable click-to-response lag on macOS during ordinary moves (drawing from the stock in TriPeaks was the repro). Every move armed a 350 ms spring across the whole board, re-evaluated every card view, and later ran a main-thread sanitize and encode of the full undo history. FreeCell additionally simulated a complete greedy win on every move just to enable the Auto Finish button.
Validation