Skip to content

fix: detect Kitty graphics on Ghostty/WezTerm when probe misses (#113)#121

Merged
meszmate merged 1 commit into
mainfrom
issue-113-ghostty-images
Jun 27, 2026
Merged

fix: detect Kitty graphics on Ghostty/WezTerm when probe misses (#113)#121
meszmate merged 1 commit into
mainfrom
issue-113-ghostty-images

Conversation

@meszmate

@meszmate meszmate commented Jun 27, 2026

Copy link
Copy Markdown
Owner

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:

  • Add 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.
  • Widen the probe read deadline from 180ms to 500ms so the reply gets caught more reliably.
  • Match the probe id as a whole field so a reply for image 99312 isn't taken as id 9931.

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=f with the relative path assets/cat.png, which the terminal opens against its own cwd. Sending bytes in-band with t=d would be more robust.

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.
@meszmate meszmate merged commit 91a56e6 into main Jun 27, 2026
9 checks passed
@meszmate meszmate linked an issue Jun 28, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image cannot show on ghostty

1 participant