OpenCode V2 image previews show gray boxes in cmux
Symptom
OpenCode V2 image previews render as solid gray boxes in cmux. The same dragged screenshot renders correctly when OpenCode runs in standalone Ghostty.
This affects both prompt attachments and submitted-message previews, so enabling prompt.image_preview and session.image_preview does not fix it.
Environment
- OpenCode V2 2.0.3
- OpenTUI 0.5.10 (also present on current 0.5.11)
- cmux 0.64.23
- no tmux or zellij layer
Reproduction
- Run OpenCode V2 in cmux.
- Enable prompt and session image previews.
- Drag a PNG screenshot into the prompt and submit it.
- Observe a correctly sized gray rectangle instead of the image.
- Run the same OpenCode build in Ghostty; the image renders.
A raw Kitty protocol probe narrows the failure:
- combined transmit-and-display (
a=T) renders - separate transmit and placement (
a=t, thena=p) at OpenTUI's current z-index does not render - the same separate placement at
z=-1renders
Cause
OpenTUI emits Kitty placements at approximately z=-1500000000 + placement_id. The Kitty graphics protocol reserves z-indices below INT32_MIN / 2 (-1,073,741,824) for images below cells with non-default background colors.
OpenCode's image preview container paints such a background, so the image is correctly placed underneath it and only the gray container remains visible.
Expected behavior
Inline images should remain below terminal text but above non-default cell backgrounds. A z-index in Kitty's normal negative range preserves text overlay without hiding the image behind its container.
Source: anomalyco/opentui