Skip to content

Conversation

@mesolimbo
Copy link
Owner

Motivation

  • Reduce latency for the iTerm2 GUI path by avoiding expensive RGB->JPEG work when a palette fits into 256 colors, improving responsiveness on macOS without changing UI appearance.

Description

  • Add a cached palette byte buffer _ITERM2_PALETTE_BYTES and a helper _get_iterm2_palette_bytes() to produce a 256-color palette suitable for paletted PNGs in gui/sixel.py.
  • Update pixels_to_iterm2() to prefer paletted PNG encoding (1 byte per pixel) when the color table fits in 256 entries and to fall back to the existing JPEG path for large palettes.
  • Invalidate the new palette cache when dynamic image colors change by updating register_image_colors() and invalidate_iterm2_color_cache() to clear _ITERM2_PALETTE_BYTES as well as the color table.
  • Adjust documentation/comments to reflect the new paletted-PNG optimization and keep behavior unchanged for non-iTerm2 or PIL-missing environments.

Testing

  • No automated tests were run as part of this change.

Codex Task

@mesolimbo
Copy link
Owner Author

Merged #22 instead

@mesolimbo mesolimbo closed this Jan 21, 2026
@mesolimbo mesolimbo deleted the codex/optimize-iterm2-sixel-gui-performance branch January 21, 2026 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants