omp packages

@kcurtet/pi-image-preview0.1.1

Hover previews for image paths in the pi coding agent: chips above the editor and in the transcript, kitty/iTerm2 inline rendering, /images viewer

kcurtet Published 7 days ago MIT ~441 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-image-preview

Hover previews for image paths in the pi coding agent — inspired by better-claude/image-preview.

▣ 1 screenshot.png 1920×1080   hover: preview · click: open · /images

Paste an image, type an image path, or let the agent create one — and a row of chips appears. Hover a chip and the picture floats open right there, drawn by your terminal itself. Click it and it opens in your system's viewer.

✨ Features

Chip row above the editor

While you type, pi-image-preview watches your draft (poll every 400 ms) and lists every image it mentions — pasted screenshots (/tmp/pi-clipboard-*.png), paths you typed, anything that exists on disk:

▣ 1 screenshot.png 1920×1080  ▣ 2 chart.png 640×480   hover: preview · click: open
──────────────────────────────────────────────
❯ what is wrong in this screenshot? /tmp/screenshot.png

Chips under sent messages and tool results

After you send a prompt — and after any tool call that produces or touches an image (a screenshot the agent took, a chart it generated, a read of an image file) — the same chips appear in the transcript. They survive resume: reopen the session and they are still there.

❯ take a screenshot and tell me what you see
  ⚙ bash: grim shot.png && ...
  ▣ 1 shot.png 1920×1080          ← automatic
  ⚙ read: shot.png
  [inline image — native pi rendering]

Hover preview

Put the pointer on any chip and a floating preview opens next to it — no click, no focus stealing, nothing moves. Move away and it closes. The picture renders through your terminal's native image protocol:

Terminal Rendering
kitty, Ghostty, WezTerm kitty graphics protocol
iTerm2, others iTerm2 protocol
No image support informative card (name, size, format)

Non-PNG images (JPEG, WebP, GIF, BMP) are converted automatically for kitty terminals.

Click to open

Click a chip and the image opens in your system's viewer — open on macOS, explorer on Windows, xdg-open on Linux.

/images — keyboard-only viewer

A picker over every image seen this session (draft, sent, tool-produced), then a full viewer:

q / esc    close
o          open externally
← / →      navigate (p / n also work)

Works in any terminal, mouse or not.

📦 Install

pi install git:github.com/kcurtet/pi-image-preview

Update with pi update --extensions, remove with pi remove git:github.com/kcurtet/pi-image-preview.

🔍 How it works

  • A 400 ms poll reads the editor text; path-like tokens are resolved against the filesystem and real images are loaded with magic-byte MIME detection (≤ 25 MB, max 12 at once).
  • Chips are pi-tui MouseRegion components; the preview is a non-capturing overlay hosting pi-tui's Image component, positioned above the pointer.
  • tool_result events are scanned for image paths (tool output + path / command / file_path inputs), deduplicated per session, and recorded as custom entries with an entry renderer — that is what makes transcript chips persist across resume.
  • The /images history keeps the last 24 images. Everything is cleaned up on session_shutdown.

⚠️ Limits

  • Only paths that exist as local files are detected; URLs are not fetched.
  • Chips appear under the tool after it finishes; streaming partials are not scanned.

📄 License

MIT