Skip to content

perf(mosaic): re-render only the table rows whose selection changes - #10624

Open
alexcarpenter wants to merge 1 commit into
carp/mosaic-option-storefrom
carp/mosaic-table-row-cache
Open

alexcarpenter wants to merge 1 commit into
carp/mosaic-option-storefrom
carp/mosaic-table-row-cache

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Selecting a Table row re-rendered every row, because each row read the selection and expanded state from the table context, which changed on every click. Rows now read that state from a store through useStore (added in #10621), and the context value stays stable, so only the rows whose state changed re-render.

  • Time from a row checkbox click to the next frame, in Chromium at 4× CPU (median):

    Rows Before After
    10 27ms 8ms
    50 96ms 8ms
    200 344ms 13ms
  • The feature tables (organization members, requests and invitations, API keys) show 10 rows per page, so they already missed a frame on every selection.

  • Event handlers that only need the current selection read it with store.get() when the event fires, so they don't subscribe.

Stacked on #10621.

Checklist

  • pnpm test runs as expected (@clerk/mosaic).
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other: performance

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Nov 3, 2026 11:07pm UTC
swingset Ready Ready Preview Nov 3, 2026 11:07pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@changeset-bot

changeset-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 401320e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clerk/mosaic Patch
@clerk/swingset Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@blacksmith-sh

blacksmith-sh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Differs Row selection reaches the next frame faster

Differs — Selection got much faster with identical end state, but at 200 rows the median is 42.5ms after (still over two frames), not the claimed 13ms, even though this machine ran the before case faster than the PR's numbers.

Merge-base

Click latency before

This PR 401320e9

Click latency after

Benchmarked table

Also checked · 2 match

Matches Only the clicked row re-renders
Matches Select all, range and keyboard selection still work

Proof on 401320e9 · Did Proof get it right? Yes · No

View full Proof report

This branch was successfully deployed

2 active deployments
Preview – swingset — 401320e9 Deployed Nov 3, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 401320e9 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant