Skip to content

Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) with Kitty-first priority#5493

Merged
tig merged 29 commits into
developfrom
tig/add-kitty-graphics-protocol-support
Jun 19, 2026
Merged

Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) with Kitty-first priority#5493
tig merged 29 commits into
developfrom
tig/add-kitty-graphics-protocol-support

Conversation

@tig

@tig tig commented Jun 15, 2026

Copy link
Copy Markdown
Member

Fixes

Adds Kitty graphics protocol support as a Kitty-first raster backend for ImageView, with Sixel retained as the fallback and cell rendering unchanged when no raster protocol is available.

Also updates the raster graphics surface area and demos:

  • Adds Kitty detection, encoding, output dispatch, and protocol-aware raster rendering.
  • Keeps UseSixel / IsUsingSixel as obsolete compatibility shims over UseRasterGraphics.
  • Fixes ImageView: zoom keybindings are unusable on macOS and collide with PageUp/PageDown paging #5494 with Mac-safe zoom/reset bindings (+, =, -, 0; PageUp/PageDown still work).
  • Refactors the UICatalog Mandelbrot scenario into MandelbrotImageView, where zoom/pan/reset re-render fractal coordinates instead of scaling a static bitmap.
  • Updates raster graphics API/deep-dive docs for Kitty-first behavior, driver capabilities, and ImageView usage.

Validation covers Kitty encoder/detector/output behavior, Kitty-vs-Sixel priority and resolution selection, ImageView zoom bindings, Images scenario nullability contracts, and the standard build/test suites.

- Add KittyGraphicsSupportResult, KittyGraphicsSupportDetector, KittyGraphicsEncoder
  in Terminal.Gui/Drawing/Kitty/ (same namespace as Sixel types)
- Extend IDriver/DriverImpl with KittyGraphicsSupport property and event
- Detect Kitty terminal at startup in MainLoopCoordinator (KITTY_WINDOW_ID /
  TERM_PROGRAM=kitty|ghostty env vars; no ANSI queuing required)
- Add EncodedKitty to RasterImageCommand; OutputBase dispatches to Kitty APC
  or Sixel DCS based on UseKittyGraphics flag
- Add protocol-agnostic UseRasterGraphics / IsUsingRasterGraphics on ImageView;
  mark UseSixel and IsUsingSixel [Obsolete] with functional redirects
- Rename DrawSixel → DrawRasterImage (handles both protocols)
- When both Kitty and Sixel are available, Sixel is preferred for backward
  compatibility with existing deployments (e.g. Windows Terminal)
- Add 17 unit tests: KittyGraphicsEncoderTests, KittyGraphicsSupportDetectorTests,
  KittyGraphicsSupportResultTests, plus 3 OutputBase Kitty tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 650534949c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Terminal.Gui/Drivers/Output/OutputBase.cs Outdated

This comment was marked as outdated.

…orted; align GetActiveResolution with CreateRenderRequest

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copilot finished work on behalf of tig June 15, 2026 22:54
@tig

tig commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@copilot remember, WinPrint is still in dev. The whole reason I'm adding kitty is because of Mac support. Unless i misunderstand, kitty is simply better.

This comment was marked as outdated.

Copilot finished work on behalf of tig June 16, 2026 02:32
@tig

tig commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@copilot yes and file an issue for WinPrint to refactor based on this pr

This comment was marked as outdated.

Copilot AI changed the title Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) alongside Sixel Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) with Kitty-first priority Jun 16, 2026
Copilot finished work on behalf of tig June 16, 2026 02:51
@tig

tig commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@copilot fix #5494 in this pr.

tig added 2 commits June 18, 2026 09:48
@tig tig changed the title Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) with Kitty-first priority; fix ImageView zoom keybindings (#5494) Fixes #5489. Add Kitty graphics protocol support (Kitty, Ghostty) with Kitty-first priority Jun 18, 2026
@tig tig requested a review from Copilot June 18, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.

Comment thread Examples/UICatalog/Scenarios/Images/Images.cs Outdated
Comment thread Examples/UICatalog/Scenarios/Images/Images.cs Outdated
Comment thread Examples/UICatalog/Scenarios/Images/Images.cs Outdated
Comment thread Terminal.Gui/Drawing/Kitty/KittyGraphicsSupportDetector.cs Outdated
tig and others added 4 commits June 18, 2026 10:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Terminal.Gui into tig/add-kitty-graphics-protocol-support
Replace the static frame with an animated capture: resize the image
view so its top-left corner fills the top-left of the display, then
keyboard-zoom into the left antenna (mini-Mandelbrot satellite), pan
around at depth, and zoom back out. Recorded via tuirec with the Sixel
raster protocol forced (Auto prefers Kitty, which agg cannot render).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@YourRobotOverlord YourRobotOverlord left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing I found was a nit: shadows do not overlay the image.

Image

This is awesome, images are soo much faster now, and they just work on every terminal emulator I've tried (the image above is kitty running through WSLg on Arch under WSL on Win 11).

@tig

tig commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

The only thing I found was a nit: shadows do not overlay the image.

Image This is awesome, images are soo much faster now, and they just work on every terminal emulator I've tried (the image above is kitty running through WSLg on Arch under WSL on Win 11).

Kitty or sixel?

@YourRobotOverlord

Copy link
Copy Markdown
Collaborator

Kitty or sixel?

Depends which part the question addresses, lol
The clipping nit appears on both sixel and kitty.

The image display speed is interesting; your Mandelbrot scenario renders quite fast with both sixel and kitty, but loading then resizing even a small image in the Images scenario is very slow and spikes my CPU when using sixel, but buttery-smooth using kitty.

@tig

tig commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

Kitty or sixel?

Depends which part the question addresses, lol

The clipping nit appears on both sixel and kitty.

The image display speed is interesting; your Mandelbrot scenario renders quite fast with both sixel and kitty, but loading then resizing even a small image in the Images scenario is very slow and spikes my CPU when using sixel, but buttery-smooth using kitty.

Kitty is just a better protocol.

Hopefully WT will support it eventually.

In the meantime, the scenario I care about is displaying rendered graphics like Mandelbrot and it works amazingly well with either which kinda shocking to me.

@BDisp BDisp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants