Fix out-of-band graphics lifecycle (kitty/iterm2/vscode) - #12
Merged
Conversation
Kitty/ghostty images live in a separate graphics plane that text repaints never erase, and the double-buffer only deletes the previous image on the next render. When the host app unmounts the chart (e.g. switching to a table or log view), no further render happens, so the last chart lingered on screen over whatever replaced it. Add an unmount cleanup that deletes both buffered kitty image IDs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SCHVP8VywU8i8JAN4xgLVs
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.
Out-of-band graphics (kitty/ghostty/iterm2/sixels) are written straight to the terminal, outside Ink's frame diff, so they don't clear or redraw with Ink's lifecycle. Different terminals fail differently. This fixes all three observed cases (verified in glassnode-terminal).
1. Kitty / ghostty — chart ghosts after leaving chart view
Kitty images live in a separate graphics plane that text repaints never erase; the double-buffer only deletes the previous image on the next render, which never comes once the chart unmounts. Fix: delete both buffered image IDs on unmount.
2. Real iTerm2 — chart vanishes after a moment
The inline image lives in the text grid, so the host app's normal Ink repaints (e.g. a live price ticker — measured ~1400 eraseLines in a few seconds) erase it, and the component doesn't re-render on those, so nothing redraws it. Fix: re-stamp the cached image on a 120ms interval while mounted.
3. VS Code — chart ghosts over table/log view
VS Code's inline image persists over later text instead of erasing. Inline images have no delete command, so fix: blank the exact cells the image occupied, on unmount. The redraw interval from (2) is scoped out for VS Code (its images persist and would stack).
Inline draws now use absolute positioning (like kitty) so the same coordinates drive the draw, the redraw interval, and the unmount blank.
Verification
🤖 Generated with Claude Code