Skip to content

fix(cli): spec-compliant terminal image rendering + Windows clipboard… - #974

Open
smarpitm wants to merge 1 commit into
CodebuffAI:mainfrom
smarpitm:fix/terminal-image-rendering
Open

fix(cli): spec-compliant terminal image rendering + Windows clipboard…#974
smarpitm wants to merge 1 commit into
CodebuffAI:mainfrom
smarpitm:fix/terminal-image-rendering

Conversation

@smarpitm

@smarpitm smarpitm commented Aug 11, 2026

Copy link
Copy Markdown

What

Fixes terminal inline image rendering so attached photos display correctly in kitty-capable terminals, and hardens Windows clipboard image paste.

Why

Photos attached via /image or Ctrl+V could render "distorted":

  1. Kitty graphics protocol spec violations — the final chunk omitted the required m=0 terminator and every chunk repeated a=T/full control data, so terminals treated each chunk as a new image (fragmented display). The format id was also hardcoded to f=100 (PNG) even for the JPEG payloads the compression step produces.
  2. iTerm2 size param sent the base64 length instead of the decoded byte length (minus padding).
  3. Detection missed WezTerm / Ghostty / Warp / Konsole, which all support kitty graphics.
  4. Windows paste failed silently on machines without powershell.exe (no pwsh fallback).

Changes

  • cli/src/utils/terminal-images.ts — spec-compliant kitty chunking (m=0 on the last chunk, control data only on the first), format id derived from the real media type, iTerm2 size = decoded bytes, detection for WezTerm/Ghostty/Warp/Konsole (case-insensitive).
  • cli/src/utils/clipboard-image.tspwsh fallback when powershell.exe is missing, normalized string output.
  • cli/src/components/blocks/image-block.tsx, image-card.tsx — pass mediaType to the renderer.
  • New tests: terminal-images.test.ts (sequence conformance against the kitty spec), image-pipeline-integrity.test.ts (verifies image processing never corrupts payloads).
  • test/setup-scm-loader.ts — no-op stub so bun test in the cli package works in the public mirror (referenced by cli/bunfig.toml but missing from the public repo).

Validation

  • bun run typecheck (cli) clean.
  • 25 new tests + 152 related tests pass.

Note

DeepSeek V4 Flash (the default model) is multimodal: false and reads images via the server-side describe pipeline — for best results with photos, use MiniMax M3 / GPT-5.6 Luna / MiMo 2.5.

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