Skip to content

perf: fix XP race condition and eliminate ChallengeLayout drag re-renders - #19

Merged
Jhong098 merged 3 commits into
mainfrom
claude/review-github-issues-nh61P
May 3, 2026
Merged

perf: fix XP race condition and eliminate ChallengeLayout drag re-renders#19
Jhong098 merged 3 commits into
mainfrom
claude/review-github-issues-nh61P

Conversation

@Jhong098

@Jhong098 Jhong098 commented May 3, 2026

Copy link
Copy Markdown
Owner
  • 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

Closes #14, #15, #10

https://claude.ai/code/session_017P7S4SuivspHeeXfok7WzX

claude added 2 commits May 3, 2026 23:41
…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
@vercel

vercel Bot commented May 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
poly-sd Ready Ready Preview, Comment May 3, 2026 11:52pm

@codecov-commenter

codecov-commenter commented May 3, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.50%. Comparing base (90ec301) to head (3d0b03e).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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
@Jhong098
Jhong098 merged commit 4270002 into main May 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: consolidate recordCompletion DB round-trips into a single RPC

3 participants