perf: recycle codemirror EditorView across source-mode file opens#238
Merged
Conversation
instead of destroying and recreating the EditorView on every file navigation, keep a module-level singleton and swap its state via view.setState(). also cache resolved language extensions so subsequent opens skip the async dynamic import. - add language cache + getLanguageSupportSync() in codemirror-editor.tsx - extract buildSourceEditorState() factory (pure, no DOM dependency) - add source-view-pool.ts (init/recycle/destroy singleton) - refactor source-editor.tsx lifecycle: refs for all closures, per-file cleanup without view destruction, compartment refresh on setState() - remove key prop from source-mode <Editor> so React reuses the tree - add e2e/latency-benchmark.spec.ts measuring click-to-content latency benchmark results (10 source-mode files, single rep): cold open avg: 125ms -> 84ms (-33%) warm open avg: 80ms -> 76ms (-5%) overall avg: 102ms -> 80ms (-22%) worst case: 314ms -> 104ms (-67%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
replace viewRef.current! with a typed local variable after the init/recycle branch. extract flushPendingWork() helper to eliminate duplicated flush/cancel/autosave logic between per-file and unmount cleanup effects. add diagnostic warning on the reparent path in the source view pool. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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.
No description provided.