perf: fix XP race condition and eliminate ChallengeLayout drag re-renders - #19
Merged
Conversation
…ders - completions.ts: replace 2-trip SELECT+UPDATE XP pattern with the existing atomic increment_xp RPC, eliminating the race condition where concurrent completions could overwrite each other's XP - DraftSaver.tsx: new render-less component that subscribes to the architecture store via Zustand's subscribe() API, outside React's render cycle, so draft saves are debounced correctly without triggering parent re-renders on every drag pixel - ChallengeLayout.tsx: remove nodes/edges subscriptions and inline useEffect; delegate draft saving entirely to <DraftSaver> Closes #14, #15, #10 https://claude.ai/code/session_017P7S4SuivspHeeXfok7WzX
- completions.test.ts: replace mockUpdateEq/mockProfileSingle with mockRpc; add assertion that increment_xp is called with correct user_id_input and amount; add test that no XP RPC fires on repeat pass - DraftSaver.test.tsx: new test covering subscribe-on-mount, trailing debounce (fires after 1500ms), rapid-change debounce reset, and cleanup (unsubscribe + timer cancel) on unmount - vitest.config.ts: extend include glob to pick up .test.tsx files - install jsdom + @testing-library/react as devDependencies for React component rendering in the node test suite https://claude.ai/code/session_017P7S4SuivspHeeXfok7WzX
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19 +/- ##
=======================================
Coverage 72.50% 72.50%
=======================================
Files 11 11
Lines 440 440
Branches 134 134
=======================================
Hits 319 319
Misses 72 72
Partials 49 49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
MobileConfigPanel always renders ConfigPanel in the DOM (inside a BottomSheet), so [data-testid="config-instanceCount"] matched two elements, causing strict-mode locator failures in all three config-panel tests. Scope all config-instanceCount locators to [data-testid="config-panel"] (the desktop sidebar wrapper) so tests run unambiguously on Desktop Chrome viewport. https://claude.ai/code/session_017P7S4SuivspHeeXfok7WzX
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.
existing atomic increment_xp RPC, eliminating the race condition where
concurrent completions could overwrite each other's XP
architecture store via Zustand's subscribe() API, outside React's
render cycle, so draft saves are debounced correctly without
triggering parent re-renders on every drag pixel
useEffect; delegate draft saving entirely to
Closes #14, #15, #10
https://claude.ai/code/session_017P7S4SuivspHeeXfok7WzX