Repository navigation
refactor(highlight-updates): draw outlines on a canvas, not clones - #40
Merged
Merged
Conversation
The ghost clone copied the updated element into the document, so the page could react to the copy, and each update cloned the whole subtree. Draw boxes on one canvas in a shadow root instead: one per line of a changed text node, from Range.getClientRects(), and the element box for other changes. Nothing is added to the page, and page styles cannot reach it. The boxes follow window scrolls. One frame reports at most 200 updates, and the fade is off when the user prefers reduced motion. The draw function takes its context as a parameter, so it can move to an OffscreenCanvas worker later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A counter and a moving dot driven by a signal and requestAnimationFrame, with a pause button, to watch the update highlight while scrolling or resizing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each refresh of the Ownership and Reactivity panels makes new row, node and edge objects, and the lists were keyed by object, so every refresh rebuilt all of them. An app that writes a signal every frame kept the page at 50 to 67ms frames while one of these panels was open. Key the lists by owner id, node id and edge endpoints instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Draw the update highlight on one canvas instead of cloning the updated elements into the page, and stop the Ownership and Reactivity panels from rebuilding every row on each refresh.
Changes
highlight-updates: the ghost clones are gone. Each update is outlined on one<canvas>in a shadow root onbody. A changed text node gets one box per line it covers, fromRange.getClientRects(). Any other change gets the element's box.canvas.tstakes the 2D context as a parameter, so it can move to an OffscreenCanvas worker later.row.node.id,node.id,from>to). Before, each refresh made new objects and the lists were keyed by object, so every refresh rebuilt every row.createSignal+requestAnimationFrame), with a pause button, to watch the highlight while scrolling or resizing.Proof
Measured in Chrome on the demo with the Frames ticker running and the page width changing every frame:
mainAfter the runs, the same row and node elements are still on the page, and the
ticker-framenode's value updated in place.Drawing 200 boxes, the cap for one frame:
Checks
Roadmap
Cost
clone.ts(296 lines) andoverlay.cssare removed. Net diff without the demo: +441 and -767 lines.Risk
Not done
blob:workers.🤖 Generated with Claude Code