fix(tui): keep kitty image redraws inside TUI#4261
Merged
Conversation
badlogic
reviewed
May 7, 2026
|
|
||
| const KITTY_SEQUENCE_PATTERN = /\x1b_G([^;\x1b]*);/g; | ||
|
|
||
| function extractKittyImageIds(line: string): number[] { |
Collaborator
There was a problem hiding this comment.
this will scan the full base64 image payload. not ideal, but probably better than api breaking alternatives, e.g. Tui becoming an image (id) registry, and Image requiring a refernce to tui to allocate/delete image ids.
Collaborator
|
Follow-up: I replaced the Kitty image ID scan with a bounded parser. It now reads only the first Kitty sequence header on a rendered line to extract Validation:
|
larsboes
pushed a commit
to larsboes/pi-mono
that referenced
this pull request
May 11, 2026
fix(tui): keep kitty image redraws inside TUI
larsboes
pushed a commit
to larsboes/pi-mono
that referenced
this pull request
May 17, 2026
fix(tui): keep kitty image redraws inside TUI
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 images are not normal text, so clearing a TUI line does not necessarily remove the old graphic. I have a repro extension which forces image rendering corruption by drawing inside a reduced scroll region: Kitty moved the terminal cursor after placing the image, while the TUI also thought it owned cursor positioning, so later redraws happened from the wrong place and stale image placements remained visible.
This change keeps cursor movement under TUI control by asking Kitty not to move the cursor after placement (
C=1) and then manually restoring the cursor to where the TUI expects it. Additionally it always assigns Kitty images an id, remembers ids from the previous render, and deletes old placements before redrawing changed or full frames. I did not found a way to do this without ids to remove the graphic.This also takes out the cmux image disabling because I verified that this now works with cmux too.
Fixes #4208.