Prevent page clear/show flash on kitty when pages have been cleared from memory.#148
Merged
itsjunetime merged 4 commits intomainfrom Apr 24, 2026
Merged
Prevent page clear/show flash on kitty when pages have been cleared from memory.#148itsjunetime merged 4 commits intomainfrom
itsjunetime merged 4 commits intomainfrom
Conversation
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.
Kitty has a special way of displaying images to the terminal. Basically, when you transfer an image for the first time, kitty gives you back an 'id' which you can use to display that same image again. This is very useful for a program like tdf, where many of the images are repeated.
However, kitty also has some limits on how many images it'll store for you - if you send over too many images, it'll start deleting 'old' images, rendering their ids useless. So if you try to use the id of an image that was deleted, kitty will simply respond with an 'image not found'-type error, and you'll have to re-render/re-send the image to get it to actually show.
The Issue
This caused some annoying issues with the way that we would previously display images with kitty. What we would do is:
Pretty simple - if one of the new images failed to display (for whatever reason) there would just be a big blank slot on the UI instead of the image. This meant that whenever we encountered a deleted id, the image UI would go blank for a second due to the image not being found, then flash back into existence once it was re-rendered by our background thread.
On my machine, this process is quick enough to feel very jarring.
The Fix
This PR changes the order of rendering to be:
This ensures that each time we have a 'normal' sequence of events (where there are no dead ids), we still display the new images just as quickly as normal, on top of the old ones (which are then cleared after they're not visible).
However, this is a much better experience when we have dead ids. In this circumstance, the old images still stay there until the new images are ready. On my machine, this normally manifests as a very small (in the order of 100ms, if I had to wildly guess based on playing around with this for just a little bit) delay in displaying the new images each time we run into a dead id.
This is not perfectly ideal, since we still have the delay after trying to display an image, failing to do so, and having to re-render it, but it'll be much better than before.