Skip to content

perf(render): read whole-state actions from currentStateRef - #406

Open
NesiciCoding wants to merge 1 commit into
perf/roster-subdomain-splitfrom
perf/platform-state-ref
Open

perf(render): read whole-state actions from currentStateRef#406
NesiciCoding wants to merge 1 commit into
perf/roster-subdomain-splitfrom
perf/platform-state-ref

Conversation

@NesiciCoding

Copy link
Copy Markdown
Owner

Third link in the stacked chain: #403 (domain split) → #405 (roster split) → this (state-ref reads). Stacked on perf/roster-subdomain-split; the diff is exactly this commit.

What changed

connectDatabase, pushAllToDatabase, pullFromDatabase and dismissMigrationPrompt were useCallbacks with a [state] dep — so any dispatch re-created them, re-creating the platform context value and re-rendering every platform consumer (landing page, migration prompt, db-sync UI, admin pages).

They now read currentStateRef.current (a ref the provider already kept in sync via an effect for the reconnect handler) with [] deps. Their identity is now stable across dispatches; the platform value only changes on genuine session changes (landingState, showMigrationPrompt, microsoftUser). This closes the last remaining "re-renders on every dispatch" leak from the domain-split audit.

Verification

  • tsc --noEmit clean, ESLint 0 errors
  • Full suite: 210 files / 2843 tests pass
  • Isolation test extended: a saveStudentRubric dispatch adds zero platform-consumer renders and keeps the three action identities constant — verified the test fails without this change (3 extra platform renders on the dispatch)

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@NesiciCoding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 584e080f-1c1d-4739-90ca-ba5774986451

📥 Commits

Reviewing files that changed from the base of the PR and between 57e5e6a and ed621a0.

📒 Files selected for processing (2)
  • src/context/AppContext.test.tsx
  • src/context/AppContext.tsx

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

connectDatabase, pushAllToDatabase, pullFromDatabase and
dismissMigrationPrompt were useCallbacks with a [state] dep, so ANY
dispatch re-created them, which re-created the platform context value
and re-rendered every platform consumer (landing, migration prompt,
db-sync UI, admin pages).

They now read currentStateRef.current (already kept in sync by an
effect for the reconnect handler) with [] deps, so their identity is
stable across dispatches. The platform value now only changes on
genuine session changes (landingState, showMigrationPrompt,
microsoftUser).

Verified: tsc clean, ESLint 0 errors, full suite 210 files pass, and
the AppContext isolation test now proves a saveStudentRubric dispatch
adds zero platform-consumer renders and keeps the action identities
constant (the test fails without this change).

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
@NesiciCoding
NesiciCoding force-pushed the perf/roster-subdomain-split branch from a741fe9 to 57e5e6a Compare August 11, 2026 21:21
@NesiciCoding
NesiciCoding force-pushed the perf/platform-state-ref branch from a580cd7 to ed621a0 Compare August 11, 2026 21:21
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 71.23% (🎯 65%) 9756 / 13696
🟢 Statements 69.21% (🎯 65%) 11080 / 16008
🟢 Functions 60.57% (🎯 60%) 3335 / 5506
🟢 Branches 61.09% (🎯 58%) 8196 / 13415
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/context/AppContext.tsx 50.59% 32.05% 40.14% 53.05% 243-244, 251, 291-310, 392-403, 437, 483, 486, 498, 501, 534, 556, 564, 577, 584-590, 608-903, 908, 1384, 1394-1446, 1463-1466, 1509-1516, 1573-1574, 1584-1673, 1683, 1687-1691, 1692-1693, 1707-1710, 1717-1719, 1728-1734, 1761-1792, 1818, 1819, 1820, 1824, 1825, 1826, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1843, 1845, 1846, 1847, 1852, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1863, 1898-1899, 1930-1931, 1950, 2083-2091, 2102-2111, 2117-2120, 2125, 2128, 2130, 2135, 2141-2148, 2153, 2156, 2160-2167, 2205-2209, 2223-2225, 2255, 2267-2270, 2274, 2277, 2280, 2283, 2286, 2290, 2294, 2299, 2303-2306, 2309-2312, 2315-2318, 2321-2324, 2327-2330, 2333-2338, 2343-2346, 2349, 2352, 2356-2358, 2363, 2366, 2369, 2372, 2377-2379, 2382, 2385, 2388, 2393, 2396, 2402-2426, 2433-2434, 2438, 2442-2448, 2454, 2458-2466, 2470, 2474, 2478-2479, 2483-2484, 2488, 2492, 2496-2497, 2501, 2504, 2506, 2510, 2514, 2518, 2521, 2523, 2527, 2531-2532, 2535, 2537, 2541, 2545, 2549, 2553-2554, 2558, 2562, 2566, 2570, 2573, 2575, 2581-2582, 2586-2587, 2591-2593, 2597, 2601, 2605, 2609-2623, 2629-2644, 2655, 2657, 2660, 2662-2663, 2667, 2671, 2675-2676, 2680, 2685-2698
Generated in workflow #1179 for commit ed621a0 by the Vitest Coverage Report Action

Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 12, 2026
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.

1 participant