fix: large Kitty direct image transfers over SSH.#360
Merged
Conversation
Xyhlon
added a commit
to Xyhlon/Nixvim
that referenced
this pull request
May 8, 2026
see 3rd/image.nvim#360 for details. also enabled window_overlap_clear_enabled such that open images do not remain when search dialogs are opened. The issue is only triggered for large images.
Owner
|
Hi @Xyhlon, thank you for the PR! |
Contributor
Author
|
Yeah works fine on my machine, but i understand that if they only guarantee this from the official channel you might want to keep it as a default. My suggestion would be an over-writable option so that the users downstream change it if they have performance issues and they get it to work. If that's fine by you i will add this option to the main plugin? |
Without passing `editor_tty`, the image chunks go through Neovim's stdout path, where Neovim redraw/control bytes can interleave with the Kitty graphics payload. This corrupts the base64 stream. Signed-off-by: Maximilian Philipp <maxkon2000@gmail.com>
this makes loading images much snappier and allows for Telescope preview to work smoothly. Also since the fix 3rd#95 freezes the tty io, this becomes necessary. Signed-off-by: Maximilian Philipp <maxkon2000@gmail.com>
This commit introduces a new option `kitty_direct_chunk_size` to allow users to control the chunk size used when transmitting image data via the Kitty graphics protocol. Previously, the chunk size was hardcoded to 65536 bytes; now it defaults to 4096 bytes and can be adjusted per user preference for performance tuning.
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.
First of all this fixes #95 #294 . When running over SSH, the Kitty backend uses direct transfer mode. Large images are split into many base64 chunks and written to the terminal stream. Without passing
editor_tty, those chunks go through Neovim's stdout path, where Neovim redraw/control bytes can interleave with the Kitty graphics payload. This corrupts the base64 stream.I confirmed this with
kitty --dump-bytes: failed large transfers contained Neovim escape sequences inside the image payload. Passingeditor_ttymakes the existing tty write path handle direct transfers and prevents that corruption.This also increases the direct transfer chunk size from 4096 to 65536 bytes. In my test case, this reduced a large image transfer from 1223 Kitty graphics commands to 77 while preserving a valid decoded payload.
To create the dump:
kitty --dump-bytes /tmp/kitty.bytes --dump-commands sh -lc 'ssh faepmac1'then create a large image:
then open a large image with Neovim
To analyze the dump:
Test with ssh and ssh+tmux and just tmux.