-
-
Notifications
You must be signed in to change notification settings - Fork 764
feat: incremental rendering #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
a6ca093 to
a427701
Compare
a427701 to
d71d019
Compare
|
Hello, I'm also having this same flickering problem, however I tested your changes and am still having no luck with stopping the flicker (quite severe in this example) flickering.mp4It seems to become a problem when a) I'm rendering boxes, b) the box height is > 15ish. Here is the same example with 15 box height.......... noflickering.mp4Any ideas? Much appreciated :) |
Hey @blakemckeany! The flickering still being present in your example makes sense. This PR uses a line-based diff to determine which lines to re-render. However in your example, since the colors are changing across columns, this PR (and all of the ones before me) won't prevent flickering because every line will have a line change due to the color and thus get wiped and re-rendered. We could look at a character-based diffing strategy in the longer term to handle these cases but that does add a considerable amount of complexity. I view this PR as an incremental step towards that. Think we can get this merged first and I could look at something more inclusive of all cases as a followup. |
Hi @wu-json this makes a lot of sense! Thanks for taking the time to look into it and agree that this is a good first step towards the larger goal. I'll continue to look into this as well and help out where I can |
|
@sindresorhus Anything else I need to do here to get this in? |
|
If you run |
|
I'd like to see a few more tests:
|
|
@sindresorhus Ready for a second scan. |
|
AI review:
Tests: coverage is good; add a couple of edge cases
Small refactors (readability, fewer footguns)
|
|
@sindresorhus Just addressed all of the review comments above. |
|
I'm not confident in the changes, so I think it should be made opt-in for now through a |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
|
@sindresorhus Ready for another review. |
Summary
Implements incremental rendering by only re-writing lines in the output that have changed.
Problem
The current render implementation erases and re-draws all content on each turn. This can result in flickering in some applications.
There have been other attempts at solving this issue (#751, #413, #708) but they seem to be abandoned.
Impact
Before Incremental Rendering
Notice the stutter in the beginning as the processes startup.
Screen.Recording.2025-09-29.at.9.41.57.PM.mov
After Incremental Rendering
Screen.Recording.2025-09-29.at.9.42.51.PM.mov