Skip to content

fix: include terminal images in screenshots #56

Description

@kitlangton

Problem

ui.screenshot() omits OpenTUI <image> renderables. Image-preview scenarios therefore produce screenshots with neither the bitmap nor reliable visual evidence of the image surface, even when the effective TUI config enables image previews.

Environment

  • opencode-drive v1.4.3
  • Installed npm version: 1.4.3 (latest)
  • Drive source: 3d451b503094bbc9f32e5115eba5afc83fe500ae (origin/main, 0 commits ahead/behind)
  • OpenCode target: origin/v2 / PR fixture based on 70853b1e5b

Deterministic reproduction

  1. Start a scripted Drive instance with tuiConfig: { session: { image_preview: true } }.
  2. Admit or render a session message containing an inline image/png attachment.
  3. Wait for the message to appear.
  4. Call ui.screenshot("timeline-image-preview").

The generated .opencode/tui.jsonc was read back during the run and contained:

{
  "session": {
    "image_preview": true
  }
}

Expected

The PNG includes the terminal image preview, matching what a real image-capable TUI displays.

Actual

The PNG contains only text cells and backgrounds. The image bitmap is absent.

Root cause

OpenCode Drive delegates ui.screenshot() to OpenCode simulation. packages/simulation/src/frontend/png.ts builds a canvas exclusively from renderer.currentRenderBuffer.getSpanLines(). CapturedFrame contains text spans (text, fg, bg, attributes, width) but no terminal image placements or pixel payloads, so terminal graphics cannot be represented by the screenshot exporter.

This is not a stale-version or config issue.

Suggested direction

Expose image placements from the test renderer/capture protocol and composite them in SimulationPng.screenshot, or provide a separate capture path that records the renderer output including terminal graphics. If the test renderer cannot expose image planes, Drive should document/reject image screenshot assertions rather than silently producing incomplete evidence.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions