Repository navigation
fix: stop repeated preview refreshes during rapid edits - #5612
Merged
Merged
Conversation
0hmX
marked this pull request as ready for review
October 27, 2026 18:41
0hmX
marked this pull request as draft
October 27, 2026 18:41
0hmX
marked this pull request as ready for review
October 27, 2026 18:45
0hmX
commented
Oct 28, 2026
0hmX
commented
Oct 28, 2026
seveibar
approved these changes
Oct 28, 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.
0hmx@dots
Rapid filesystem saves currently trigger an immediate file-server upload for every watcher event. This can rebuild the browser preview repeatedly, echo browser-originated writes back to the server, and leave concurrent uploads in flight.
Coalesce saves with a 250 ms trailing debounce and a 1 s maximum wait. Sync one batch at a time, reading current file contents when processing it and retaining edits received during an upload. Keep Chokidar's 100 ms atomic-save normalization explicit, suppress unchanged-content uploads (including browser writeback), and drain active work before shutting down the HTTP server. New local dependencies are uploaded before their importing source.
The delay is an interaction tradeoff, not a universal standard: Chokidar documents atomic saves, webpack documents aggregating saves before rebuilding, and Lodash documents trailing debounce with maxWait. A bounded batch avoids the indefinite postponement that an unbounded quiet-period wait can cause during continuous edits.
Validation on macOS with Bun 1.3.14:
The companion runframe PR #5927 handles active/pending render scheduling and keeps the previous completed preview visible. This CLI change also works with existing runframe versions. The full CLI command suite was not run locally; all five hosted Linux test shards, Windows tests, smoke init, formatting, types, dependency policy, and dependency ownership checks passed on
3c8cc4672f36ec12787655433edd3db0f76f5114. No board-design changes are included.Each PR can be reviewed independently. The combined behavior reaches standard CLI installations after the runframe fix is released and incorporated into the standalone browser bundle distributed with tscircuit; both changes are already active together in the tested local installation.
Review feedback addressed in
3c8cc46: store cached contents consistently as byte buffers, removing the newtypeof/Buffer.isBufferguard, and split every added coalescing test into a separate file with shared fixture setup.