Repository navigation
fix(record): resync replaces grown sheets instead of re-sending the tail - #42
Merged
Merged
Conversation
When the insertRule patch has been displaced, the periodic resync topped the replayer up with the rules from the last reported index to the end, assuming missed rules were appended. Libraries that order rules by component (styled-components) insert mid-sheet, so the tail held rules that had only shifted down: the replayer got duplicates and never got the new rules. Replace the replayer's copy of any sheet whose rule count changed instead, as was already done for sheets that shrank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mayberryzane
marked this pull request as ready for review
October 9, 2026 23:41
Vadman97
approved these changes
Oct 10, 2026
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.
When the
insertRulepatch has been displaced, the stylesheet resync re-sent only the tail of each grown sheet. That assumes missed rules were appended. styled-components inserts rules mid-sheet (at each component's group offset), so the replayer received shifted duplicates and never got the new rules. The resync now replaces the replayer's copy of any sheet whose rule count changed, the same path it already used for sheets that shrank.Test: new case in
stylesheet-resync.test.tsinserts a rule mid-sheet while the patch is displaced, then applies the recorded events the way the replayer does and checks the result against the live sheet. It fails without the fix (the copy ends with a duplicated last rule and lacks the inserted one) and passes with it.test/record,test/replayandreplayer.test.tspass (239 tests); typecheck passes.🤖 Generated with Claude Code
Note
Overview
Fixes stylesheet resync when the
insertRulepatch is displaced and the recorder missed CSSOM updates. Previously, a higher live rule count triggered re-sending only the tail of rules, which breaks libraries like styled-components that insert mid-sheet—replays duplicated shifted rules and dropped the new ones.resyncCssomStyleSheetsnow fully replaces the replayer’s copy of any sheet whose rule count no longer matches what was reported (same path already used when a sheet shrank), instead of incremental tailadds. The unusedstyleSheetAddRuleimport is removed.A new integration test simulates mid-sheet insertion while the patch is off, replays recorded stylesheet events like the replayer, and asserts the replayed rules match the live sheet.
Reviewed by Cursor Bugbot for commit 40fb6fd. Bugbot is set up for automated code reviews on this repo. Configure here.