fix(client): include sideboard in the bracket-estimate cache key#5188
Merged
matthewevans merged 1 commit intoJul 9, 2026
Merged
Conversation
useBracketEstimate built deckKey from commanders + deck.main only, but the estimate request (and the module cache/effect short-circuit keyed on deckKey) also depends on deck.sideboard. Two decks identical in commanders+main but differing in sideboard produced the same key, so a sideboard change returned the stale estimate for the previous deck. Extract the key into a pure, unit-tested buildBracketDeckKey that also folds in the sideboard (making the effect's dependency comment actually true).
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
matthewevans
approved these changes
Jul 9, 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.
Problem
useBracketEstimate(client/src/hooks/useBracketEstimate.ts) derives adeckKeyused both as the effect's short-circuit guard (if (deckKey === storedKeyRef.current) return;) and as the module cache key. But it was built from commanders +deck.mainonly:The estimate request itself, however, sends the sideboard too:
So two decks identical in commanders + main but differing only in
sideboardproduced the samedeckKey. The effect short-circuits and the cache returns the previous deck's estimate — a sideboard edit silently shows a stale bracket. The effect's own dependency comment even claimed sideboard "content is fully captured bydeckKey", which was false.Fix
Extract the key into a pure, unit-tested
buildBracketDeckKey(client/src/hooks/bracketDeckKey.ts) that folds in the sideboard as well (s:parts). This makes the dependency comment true and keeps the sorted, order-independent behavior. Extraction is what lets the key be tested without standing up the debounced async hook.Tests
Adds
bracketDeckKey.test.ts: a sideboard-only difference now changes the key (fails before the fix — keys are equal); identical decks stay equal; ordering within main/sideboard doesn't matter; a main-deck change and a same-name main-vs-sideboard placement both change the key.Self-contained: only
useBracketEstimate.ts, a new pure helper, and its test; no engine/Rust/protocol changes.Model: claude-opus-4-8