fix: detect Kitty graphics on Ghostty/WezTerm when probe misses (#113)#121
Merged
Conversation
Image rendering gated entirely on a runtime Kitty graphics probe, and the only fallback when that probe missed was KITTY_WINDOW_ID. Ghostty and WezTerm never set that variable, so any probe miss (e.g. a slow first-frame/GPU init, or a reply arriving after the read deadline) left them with no image support even though both fully implement the protocol — hence images failed to show on Ghostty while working in kitty. - Add Environment.looksLikeKittyGraphicsTerminal() as the single source of truth for terminals that reliably support the protocol by identity, and use it for both the probe candidate set and the fallback. Outside a multiplexer (which may strip graphics), trust that identity when the probe misses. This also rescues kitty-over-SSH (TERM=xterm-kitty, no KITTY_WINDOW_ID). - Widen the graphics probe deadline 180ms -> 500ms so the reply, which is queued behind the other startup sequences, is captured more reliably. - Match the probe id as a whole comma-delimited field so a reply for image 99312 is not mistaken for probe id 9931. - Add unit tests for the probe response parser and the identity helper.
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.
Images didn't render on Ghostty/WezTerm because Kitty graphics support was only set by a runtime probe, and the one fallback when that probe missed was KITTY_WINDOW_ID, which those terminals never set (kitty does, so it recovered).
Fix:
Environment.looksLikeKittyGraphicsTerminal()and use it for both the probe candidates and the fallback, so outside a multiplexer we trust the terminal's identity when the probe misses. This also covers kitty over SSH.Added 6 unit tests. Build is clean and all 443 tests pass.
Separate follow-up, not in this PR: the example draws via Kitty
t=fwith the relative pathassets/cat.png, which the terminal opens against its own cwd. Sending bytes in-band witht=dwould be more robust.