perf(ui): memo reactive scope by editor version + eval guard (SBX-0) - #263
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Every reactive block calls
computeScopein its own unmemoized render body, so a doc with B reactive blocks and F formulas does O(B×F)new Functioncompiles per keystroke. Nothing prevents a new evaluator from landing. Precondition for the OB-146 sandbox (a per-eval QuickJS VM is only viable once this collapses). Board: SBX-0.Solution
(a) Memoize
computeScopekeyed on the editor version counter, shared across all reactive call sites — one scope computation per (doc version, render pass). (b) Addno-new-func/no-evalto eslint with explicit per-line disables at the known evaluator sites, so a 6th cannot land silently. New deps: none. No behavior change.Before / After
new Function/evalNo visual change.
Test procedure
pnpm --filter @book.dev/ui test(kit/reactive: 16 files, 152 tests) — incl. a call-count spy asserting computeScope runs once/version.new Function('')anywhere →pnpm --filter @book.dev/ui linterrors.Operational notes
Verify: ui lint + typecheck + tests + build green. Gate: code (Quinn).
🤖 Generated with Claude Code
https://claude.ai/code/session_018RUicirLRuuZvjJN13N6yN