Skip to content

fix(record): resync replaces grown sheets instead of re-sending the tail - #42

Merged
mayberryzane merged 1 commit into
mainfrom
fix/record-resync-replaces-grown-sheets
Oct 10, 2026
Merged

mayberryzane merged 1 commit into
mainfrom
fix/record-resync-replaces-grown-sheets

Conversation

@mayberryzane

@mayberryzane mayberryzane commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

When the insertRule patch 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.ts inserts 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/replay and replayer.test.ts pass (239 tests); typecheck passes.

🤖 Generated with Claude Code


Note

Overview
Fixes stylesheet resync when the insertRule patch 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.

resyncCssomStyleSheets now 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 tail adds. The unused styleSheetAddRule import 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.

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
mayberryzane marked this pull request as ready for review October 9, 2026 23:41
@mayberryzane
mayberryzane requested a review from Vadman97 October 9, 2026 23:41
@mayberryzane
mayberryzane merged commit b40a4fb into main Oct 10, 2026
15 checks passed
@mayberryzane
mayberryzane deleted the fix/record-resync-replaces-grown-sheets branch October 10, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants