Skip to content

terminal/osc: accept iTerm2 OSC 1337 File= inline images (parser-only)#375

Draft
deblasis wants to merge 1 commit into
windowsfrom
kitten-into-wintty/iterm2-images
Draft

terminal/osc: accept iTerm2 OSC 1337 File= inline images (parser-only)#375
deblasis wants to merge 1 commit into
windowsfrom
kitten-into-wintty/iterm2-images

Conversation

@deblasis
Copy link
Copy Markdown
Owner

The OSC 1337 dispatcher already routed File=, FilePart=, FileEnd=, and MultipartFile= keys into the "unimplemented" log arm (osc/parsers/iterm2.zig:166), so wintty silently dropped iTerm2 inline-image escape sequences and treated the base64 payload as text the cursor can never reach.

This PR adds parser-side handling for the single-shot File= case.

Behavior

  • Split the value on the first : into options and base64 payload.
  • Walk the options for inline=1 (case-insensitive); reject otherwise.
    iTerm2 treats non-inline File= as a download-to-disk, which has no wintty analog.
  • Emit a new iterm2_image_transmit OSC Command carrying the raw base64 string.
  • Stream dispatch logs the byte count.

Deferred to follow-ups

  • Base64 decode + kitty graphics command synthesis (the bit that actually renders).
  • Multipart: FilePart, FileEnd, MultipartFile.
  • Geometry hints: width, height, preserveAspectRatio, size.
  • JPEG/GIF support (Ghostty's image decoder is PNG-only today).

Tests

Seven new OSC: 1337: File ... cases cover:

  • inline=1 happy path
  • extra options before inline (name, size)
  • missing inline rejected (download semantic)
  • explicit inline=0 rejected
  • no payload separator (no :)
  • empty payload
  • case-insensitive Inline=1

Verification

  • Windows: zig build test -Dtest-filter=1337 -> 91/92 pass, 1 skipped
  • Mac (macbookale): zig build test-lib-vt -Dtest-filter=1337 -> 93/95 pass, 2 skipped
  • Linux (ubuntinovm): zig build test-lib-vt -Dtest-filter=1337 -> 93/95 pass, 2 skipped

A smoke probe lives in wintty-smoke/probe-iterm2-image.ps1 (out of tree); it emits a tiny PNG via OSC 1337 and confirms the parser hit via the debug log.

Test plan

  • zig build test passes on Windows
  • zig build test-lib-vt passes on Mac
  • zig build test-lib-vt passes on Linux
  • Follow-up PR: base64 decode + kitty graphics synthesis
  • Follow-up PR: multipart + geometry hints

The OSC 1337 dispatcher already routed File=, FilePart=, FileEnd=, and
MultipartFile= keys into the "unimplemented" log arm, so wintty would
silently drop iTerm2 inline-image escape sequences and treat the
base64 payload as text the cursor can never reach.

Add parser-side handling for the single-shot File= case:
- Split the value on the first ':' into options and base64 payload.
- Walk the options for inline=1 (case-insensitive); reject otherwise
  (iTerm2 treats non-inline as a download-to-disk which has no
  wintty analog).
- Emit a new iterm2_image_transmit OSC Command carrying the raw
  base64 string.

Stream dispatch logs the byte count for now. Base64 decode + kitty
graphics command synthesis that actually renders the image is a
follow-up. Multipart (FilePart, FileEnd, MultipartFile) and geometry
hints (width, height, preserveAspectRatio, size) are also follow-ups.
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.

1 participant