Use Unicode placeholders for kitty graphics inside tmux#7
Open
ibehnam wants to merge 8 commits intomil-ad:mainfrom
Open
Use Unicode placeholders for kitty graphics inside tmux#7ibehnam wants to merge 8 commits intomil-ad:mainfrom
ibehnam wants to merge 8 commits intomil-ad:mainfrom
Conversation
When running inside tmux, images displayed via the kitty graphics protocol appear as overlays on the entire terminal screen rather than being confined to the tmux pane. This is because tmux passthrough sends raw graphics escape sequences to the outer terminal, which renders images at absolute cursor positions without pane awareness. Fix this by implementing the kitty graphics protocol Unicode placeholder method (U+10EEEE). Image data is still transmitted via tmux passthrough, but display uses placeholder characters with diacritical marks encoding row/column positions and the image ID encoded in the foreground RGB color. tmux treats these as normal text, so images stay inside their panes, scroll correctly, and get clipped at pane boundaries. This approach works with both Ghostty and Kitty, which support Unicode placeholders natively. The existing direct display path (outside tmux) is unchanged. Requires `set -g allow-passthrough on` in tmux.conf.
When IPython runs on a remote machine over SSH from a tmux pane, the TMUX env var is not forwarded. Fall back to checking if TERM starts with "tmux" or "screen", which SSH does forward.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TIOCGWINSZ returns 0 for pixel dimensions over SSH, causing ZeroDivisionError. Fall back to 16x8 pixel cell size defaults. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Large single-passthrough DCS sequences can be silently dropped over SSH. Wrapping each chunk separately is the standard pattern for kitty+tmux. Also flush between image transmission and placeholder output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Without q=2 on continuation chunks, kitty sends a response for each, filling the pty input buffer and causing a deadlock over SSH. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per-chunk passthrough caused hangs. Revert to single DCS passthrough wrapping all kitty graphics chunks, which is the same structure that works locally. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Thanks for the PR Behnam jan. I'll take a look soon |
Over SSH, TIOCGWINSZ returns 0 for pixel dimensions, causing the fallback cell sizes to overestimate placeholder grid rows/cols. Add env var overrides for precise control and improve fallbacks from 16/8 to 24/12 to better match modern terminal cell sizes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
You're welcome Milad jan! |
|
I can confirm that tmux anchoring is broken and this fixes it for me |
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.
Summary
a=T,U=1), but display usesU+10EEEEplaceholder characters with diacritical marks encoding row/column positions. The image ID is encoded in the foreground RGB color. tmux treats these as normal text, so images stay inside their panes, scroll correctly, and get clipped at pane boundaries.Changes
utils.py: Addget_char_cell_width()andnum_required_cols()helpers (mirrors existing height/lines helpers)backend.py: Adddisplay_kitty_unicode_placeholder()with two-phase approach:backend.py: Route to Unicode placeholders whenTMUXenv var is setPrerequisites
Requires
allow-passthroughin tmux config:Test plan