34 KiB
Image previews for rcom: research notes
Research date: 2026-12-06. This is a read-only research note for the proposed OpenSpec change add-image-previews.
Executive recommendation
Use ratatui-image 12.0.0 for terminal protocols and image 0.25.10 for bounded decoding. Both are actively published, their licenses are compatible with rcom, and their current versions match rcom's Ratatui 0.30.2 / Rust 1.88 baseline. Do not port Yazi's adapter wholesale and do not write three wire protocols in rcom.
A realistic first implementation should:
- render the actual decoded pixels of the selected PNG/JPEG/GIF/BMP/WebP file in both the normal preview pane and the F3 preview overlay; metadata may accompany the image but is not an acceptable successful result by itself;
- treat animated input as one static image, with no animation timer;
- preserve aspect ratio, downscale to the inner preview rectangle, and never crop by default;
- work for local and SSH selections by reading bounded bytes through the existing filesystem port, then decoding locally;
- use Kitty, iTerm2, or Sixel when
ratatui-imagedetects them, with Unicode halfblocks as the normal no-graphics-protocol fallback, so an unsupported terminal still sees the image rather than only metadata; - offer an explicit images-disabled/no-capability text fallback, independent of
IconMode::None; - bound input bytes, source dimensions, decoded allocation, concurrency, and cache size; decode/resize/encode off the UI thread;
- retain rcom's generation/target/session checks and add geometry and terminal-lifecycle identity to prepared rendering state;
- leave SVG, AVIF/HEIF/JXL, PDF/video thumbnails, animation, Überzug++, external Chafa/ImageMagick processes, and a disk thumbnail cache out of the first change.
The native protocols should be described as best-effort terminal integrations, not as correctness proved by headless tests. Halfblocks provide the deterministic, universal baseline. Kitty/iTerm2/Sixel still need a small manual terminal matrix.
1. What Yazi currently does
The official image-preview documentation is at https://yazi-rs.github.io/docs/image-preview/. The source observations below use Yazi main commit 555c65beccf0f81f922c3607d9beff9ecca279a2, dated 2026-12-06; the documentation identifies version 26.9.1.
1.1 Image recognition and preview pipeline
Yazi does not decide that a file is an image solely in its widget:
- Its local MIME fetcher invokes
file -bL --mime-typeand parses the result. The preview rules routeimage/*to the built-inimageplugin; AVIF/HEIF/JXL go through ImageMagick and SVG through a separate converter. Sources: mime-local.lua, default preview rules. - The image plugin waits for the configured
image_delay(30 ms by default), then callsya.image_show(url, job.area). Its preload path can create a cached, resized encoded image. Source: image.lua, defaults. Image::decode_fromguesses the format from content, appliesimage::Limits, reads EXIF orientation, and performs decoding intokio::task::spawn_blocking. Resizing/orientation and driver encoding also run in blocking tasks. Source: image.rs.- The target pixel size is the smaller of the preview area (columns/rows multiplied by terminal cell pixel size) and configured
max_width/max_height(600×900 by default). If cell metrics are unavailable, Yazi uses those configured pixel bounds. Source: image.rs sizing.
Yazi's default decoder limits are 512 MiB and 10,000×10,000 pixels on each axis. They are useful precedents, not necessarily good defaults for a responsive preview in rcom. Source: yazi-default.toml.
1.2 Terminal detection and driver choice
Yazi combines environment hints with actual terminal reports:
- Brand hints come from
TERM,TERM_PROGRAM, and variables such asKITTY_WINDOW_ID,KONSOLE_VERSION,ITERM_SESSION_ID,WEZTERM_EXECUTABLE,GHOSTTY_RESOURCES_DIR,WT_Session, and others. Source: brand.rs. - The probe sends XTVERSION, a Kitty query, a Kitty shared-memory query, DA1, and
CSI 16 t, with tmux passthrough when needed. DA1 attribute 4 records Sixel support;CSI 16 trecords cell pixel dimensions. The initial probe has bounded waits/timeouts rather than waiting forever. Source: probe.rs, emulator.rs report handling. - Kitty and Ghostty select Kitty graphics with Unicode placeholders; Konsole selects Yazi's older Kitty placement approach; iTerm2, WezTerm, VSCode, Tabby and others select the iTerm2 inline protocol; Foot, Windows Terminal and Black Box select Sixel. Unknown terminals use probe results. Source: drivers.rs.
- If no terminal protocol is selected, Yazi tries Überzug++ on X11/supported Wayland compositors and finally external Chafa. The official table and tmux/Zellij caveats are at https://yazi-rs.github.io/docs/image-preview/.
The source's driver lists are priority hints, not a guarantee that every rendering error will retry every later protocol. Drivers::matches ultimately returns one driver. rcom should likewise avoid silently cycling protocols after partial output, which can leave worse artifacts than a clean halfblock fallback.
1.3 What each Yazi driver emits
- Current Kitty (
Kgp): downscales, transmits RGB/RGBA through shared memory when available or 3,072-byte raw chunks encoded as base64, and creates a virtual placement withU=1. It writes U+10EEEE placeholder cells plus row/column diacritics. Erasing writes spaces and issues a quiet Kitty delete. Source: kgp.rs. - Old Kitty (
KgpOld): transmits the image and creates explicit per-cell placements. Yazi avoids it under tmux because of protocol limitations. Source: kgp_old.rs. - iTerm2 (
Iip): re-encodes the resized image as PNG when alpha is present or JPEG otherwise, base64-encodes it, and emits OSC 1337 withinline=1, explicit pixel dimensions anddoNotMoveCursor=1. Source: iip.rs. - Sixel: downscales, quantizes to at most 256 colors (reserving a slot for transparency), and emits a DCS Sixel payload. Source: sixel.rs.
- Chafa: runs
chafawith animation and passthrough disabled and converts its symbol output to text. Source: chafa.rs.
1.4 Cancellation, stale output, resize and resume
Yazi gives each preview a cancellation scope. Starting a new preview cancels the old scope; the async runner selects cancellation versus completion. Its preview signature includes file identity, MIME type and preview Rect, so a layout change is a new preview identity. Sources: preview_mut.rs, preview_sig.rs.
The adapter tracks the shown Rect, erases it on image reset, and has a collision hook so other clearing operations can erase overlapping graphics. Source: adapter.rs.
On resume after a subprocess/suspend, Yazi resets the preview, recreates the terminal, triggers resize/reflow and performs a full render. Source: resume.rs. This is directly relevant to rcom: resetting only Ratatui's buffers is not sufficient for a Kitty protocol object that believes it has already transmitted its image.
2. Crates: APIs, fit and licenses
Versions below are current as of 2026-12-06. “Maintained” here means recent upstream publication/source activity, not a future support guarantee.
| Crate | Current role and useful API | License / compatibility | Recommendation |
|---|---|---|---|
ratatui-image 12.0.0, published 2026-12-04 |
Picker::from_query_stdio, Picker::halfblocks, Picker::new_protocol, Image, StatefulImage, ThreadProtocol; Kitty, iTerm2, Sixel and halfblocks |
MIT; Rust 1.86; Ratatui ^0.30.1; rcom already has Ratatui 0.30.2. manifest |
Use it. It solves Ratatui buffer integration as well as wire encoding. |
image 0.25.10 |
ImageReader::with_guessed_format, guess_format, Limits, DynamicImage, orientation and resizing |
MIT OR Apache-2.0; Rust 1.88 exactly matches rcom. manifest | Use it explicitly with selected format features and custom limits. |
icy_sixel 0.7.0 |
Pure-Rust Sixel encoder/decoder; SixelImage::from_rgba(...).encode() or lower-level sixel_encode |
MIT OR Apache-2.0. manifest | Suitable for a custom Sixel backend, but redundant when using ratatui-image (which already uses icy_sixel 0.5.x). |
yazi-adapter 26.5.6 |
Yazi's path-based global ADAPTOR.image_show(path, Rect) and decoding helpers |
MIT, but published crate requires Rust 1.95 and many Yazi-internal crates/global configuration/TTY state. manifest | Research reference only. It is incompatible with rcom's Rust 1.88 and poorly isolated for local+SFTP byte previews. |
2.1 ratatui-image API choice
The crate's own guide distinguishes two paths: https://docs.rs/ratatui-image/12.0.0/ratatui_image/#widget-choice.
Picker::new_protocol(dynamic_image, Size, Resize::Fit(...))does resize/encoding once and returns a fixedProtocol;Image::new(&protocol)is cheap to render. This is the simplest fit for rcom's current immutable&AppStaterendering, provided prepared protocol state lives in a UI/runtime cache rather than inside the pure reducer.StatefulImageadapts at render time. Its documentation explicitly warns that resize/encoding can block the UI and recommendsThreadProtocol: https://docs.rs/ratatui-image/12.0.0/ratatui_image/struct.StatefulImage.html.ThreadProtocolhas request IDs and rejects superseded resize responses throughupdate_resized_protocol: https://docs.rs/ratatui-image/12.0.0/ratatui_image/thread/struct.ThreadProtocol.html. It is useful, but does not replace rcom's file generation/target/session identity.
For a first change, fixed Protocol + Image is easier to reason about. Prepare it asynchronously for (preview generation, image identity, inner Size, font size, protocol, terminal epoch). If the area changes, retain the decoded source and prepare a replacement off-thread; do not render an oversized old Sixel/iTerm2 protocol into a smaller area. Protocol::needs_placeholder can drive the temporary placeholder. If dynamic resizing later needs to be continuous, move to ThreadProtocol with an actually off-thread resize_encode worker.
Resize::Fit(Some(FilterType::Triangle)) is a good quality/scope default. In the current implementation Fit downscales but does not upscale; Scale is the variant that also enlarges. Source: lib.rs.
2.2 Detection behavior in ratatui-image
Picker::from_query_stdio() must run before any Crossterm/Ratatui event reader. It writes queries to stdout and consumes replies from stdin; an active EventStream would compete for those bytes. API warning: https://docs.rs/ratatui-image/12.0.0/ratatui_image/picker/struct.Picker.html#method.from_query_stdio.
The current implementation:
- sends a one-pixel Kitty
a=qquery, DA1 for Sixel,CSI 16 tfor cell size, and finally the widely supportedCSI 5 nstatus query as a completion marker; - defaults to a 2,000 ms timeout and has
QueryStdioOptions::timeout_ms; - prefers actual I/O capability replies to stale environment hints for Kitty/Sixel; iTerm2 is selected from terminal environment hints because its old custom probe is commented out;
- uses halfblocks if no usable protocol/font metrics are found, and has an explicit
Picker::halfblocks()constructor for tests; - has special handling for WezTerm/Konsole and tmux passthrough.
Sources: cap_parser.rs query/parser, picker.rs selection, environment/tmux hints.
Two rcom-specific cautions:
- Call detection after terminal initialization but before
run_event_loopconstructsEventStream. On editor resume, rcom's current event stream remains alive; do not casually issue another stdio probe there. Invalidate/reprepare the image instead. Refreshing font metrics on resume requires a coordinated pause/recreation of input reading and can be a later enhancement. - Current
detect_tmux_and_outer_protocol_from_envexecutestmux set -p allow-passthrough on. That is a user-visible setting change. rcom should decide this policy explicitly; a conservative first version can select halfblocks under tmux rather than mutate tmux configuration. Yazi's documentation instead asks tmux users to configureallow-passthroughthemselves: https://yazi-rs.github.io/docs/image-preview/#tmux-users.
2.3 Avoid unintended native dependencies
ratatui-image defaults include chafa-dyn, which dynamically links to libchafa. Its primitive halfblock encoder does not need that library. For rcom, start with the equivalent of:
ratatui-image = { version = "12.0.0", default-features = false, features = ["crossterm"] }
image = { version = "0.25.10", default-features = false, features = ["png", "jpeg", "gif", "bmp", "webp"] }
The tokio feature is only needed if rcom chooses ThreadProtocol with Tokio channels. Feature documentation: https://docs.rs/ratatui-image/12.0.0/ratatui_image/#features.
3. Protocol tradeoffs
Authoritative protocol references:
- Kitty graphics, including queries and placements: https://sw.kovidgoyal.net/kitty/graphics-protocol/.
- Kitty Unicode placeholders: https://sw.kovidgoyal.net/kitty/graphics-protocol/#unicode-placeholders.
- Kitty deletion and storage quotas: https://sw.kovidgoyal.net/kitty/graphics-protocol/#deleting-images and https://sw.kovidgoyal.net/kitty/graphics-protocol/#image-persistence-and-storage-quotas.
- iTerm2 inline images: https://iterm2.com/documentation-images.html.
- iTerm2 feature reporting (
FILE, and alsoSxfor Sixel): https://iterm2.com/feature-reporting/. - DEC Sixel format and scrolling behavior: https://www.vt100.net/docs/vt3xx-gp/chapter14.html.
Kitty
Advantages
- RGB/RGBA quality and efficient reuse: transmit once, then represent placements in Ratatui cells using Unicode placeholders.
- Placeholder cells move and disappear with ordinary text, which fits Ratatui's immediate-mode diffing much better than manually positioned permanent placements.
- Direct base64 chunks work over terminal transports; shared memory can reduce local transfer overhead.
ratatui-imagecan also probe optional zlib compression, but its own documentation recommends leaving it off unless bandwidth dominates.
Costs/risks
- The graphics protocol has many partial implementations. Supporting a basic Kitty query does not by itself prove Unicode placeholder support. Kitty now has a feature query for
U=1, but the current crate primarily uses a basic probe plus terminal-specific exclusions. - Terminal-side image IDs and storage are stateful. Dropping a Rust value is not the same as sending Kitty's delete command. Current
ratatui-imagetransmits once per protocol object but exposes no general high-level image-hide/free lifecycle comparable to Yazi's adapter. Random IDs for successive files can consume terminal quota until eviction. Do not claim explicit terminal-memory cleanup in the first spec unless rcom adds a small deletion extension or upstream support. - Suspend/resume or terminal re-creation must invalidate the protocol's “already transmitted” state and recreate it; otherwise Kitty can remain blank after resume.
First-scope verdict: include through ratatui-image; manually test Kitty and Ghostty. Do not implement Yazi's old per-cell Kitty driver for Konsole in rcom.
iTerm2 / OSC 1337
Advantages
- Conceptually simple: inline base64 file data with width/height and aspect-ratio controls. It covers iTerm2 and is also the most reliable choice for WezTerm in
ratatui-image's compatibility matrix. - No application-managed image ID/placement table is required.
Costs/risks
- Base64 adds overhead, and
ratatui-imagecurrently re-encodes to PNG and delivers the full payload on each render. Avoid doing that encoding inFrame::render. - Detection in the current crate is environment-based, not a robust active query. iTerm2's newer feature-reporting protocol has a
FILEcapability, but adopting it is extra parser/event work. - Clearing behavior varies by emulator. iTerm2 3.5 has multipart sequences, but rcom should not add a second custom transport initially.
Sources for the crate behavior: iterm2.rs, compatibility matrix.
First-scope verdict: include through the crate and manually test iTerm2 or WezTerm. Keep selection/redraw encoding bounded and off-thread.
Sixel
Advantages
- Established DEC bitmap format supported by Foot, xterm builds, Windows Terminal and others.
- DA1 attribute 4 gives a relatively standard capability signal; there is no Kitty-like application image-ID database.
Costs/risks
- Palette quantization and encoding cost CPU; full data is sent on each render in
ratatui-image. Transparency is limited and often needs compositing over the terminal background. - The preview area must be protected from ordinary text overdraw. Sixel near the terminal's last line can scroll; this is a known
ratatui-imageissue: https://github.com/ratatui/ratatui-image/issues/57. - Multiplexer support is uneven: Yazi documents tmux build/passthrough requirements and serious current Zellij Sixel problems. Other terminals report support but clear graphics incorrectly.
First-scope verdict: include only because the crate already supplies it; treat it as best-effort and manually test Foot/xterm plus the last-line/resize cases. If this expands QA too much, disabling Sixel and using halfblocks is a legitimate configuration fallback, not a metadata-only success.
Unicode halfblocks (the essential fallback)
ratatui-image uses ▀/▄ and foreground/background RGB colors to represent two vertical pixels per cell. This is still an actual image preview, works without a graphics protocol, and is fully inspectable in Ratatui's TestBackend. It costs resolution and produces many colored cells, and requires Unicode plus usable color output. Its primitive encoder is at halfblocks/primitive.rs.
For TERM=dumb, ASCII-only/no-color output, non-TTY/headless operation, or an explicit image-disable setting, use a clear text image-unavailable/metadata placeholder instead. IconMode::None is not that setting: turning off file icons must not turn off the selected image.
4. Safe bounded decoding and asynchronous design
4.1 Input and allocation limits
rcom currently uses MAX_PREVIEW_BYTES = 64 KiB and ReadFileSystem::read_prefix, whose implementations read at most limit + 1 bytes and set truncated. That port is reusable for local and SSH images, but 64 KiB is not a viable full-image cap.
Recommended pipeline:
- Read a small prefix and use content magic (
image::guess_formatorImageReader::with_guessed_format) as a hint; extension/MIME may be an additional hint, but the decoder must validate content.guess_formatexplicitly does not validate the whole file: https://docs.rs/image/0.25.10/image/fn.guess_format.html. - For a supported image, obtain at most
MAX_IMAGE_BYTESwith the same lookahead mechanism. Iftruncated, return “image too large for preview” plus metadata; never decode a truncated prefix as if it were complete. Metadata size can pre-reject obviously large files but is not a substitute for the read cap. - In a blocking worker, construct
ImageReader<Cursor<Vec<u8>>>, guess from content, and callreader.limits(custom_limits)before decoding. API: https://docs.rs/image/0.25.10/image/struct.ImageReader.html. - Set strict
max_image_widthandmax_image_height, non-strictmax_alloc, and an independent checkedwidth × heightpixel limit. Check arithmetic withchecked_mul; include the subsequent RGBA conversion, resized copy and base64/protocol buffer in the memory budget, not just decoder allocations. - Downscale to the available cell rectangle before terminal encoding. Reject zero-sized images/areas cleanly. Keep only the current decoded image per pane initially; at most a tiny byte-bounded LRU later.
image::Limits semantics matter: width and height are strict; max_alloc is non-strict and some decoders may ignore it. The default max_alloc is 512 MiB and default dimensions are unlimited. Source: https://docs.rs/image/0.25.10/image/struct.Limits.html. Therefore rcom must set all three and must not advertise max_alloc as a hard process-memory sandbox.
Possible conservative starting values to tune in implementation tests (these are rcom recommendations, not Yazi facts): 16 MiB encoded input, 8192 pixels per axis, 32 million total pixels, 256 MiB decoder max_alloc, and one active decoded image per pane. Record the full transient memory estimate in the design before finalizing them.
If hard CPU/time/memory isolation from malicious files is a requirement, an in-process Rust decoder cannot provide it reliably; that needs a separately constrained helper process. That is beyond the first scope.
4.2 Cancellation and stale results
rcom already aborts the previous async preview task per pane and rejects results when preview generation, target, session epoch or endpoint no longer match (src/runtime.rs, src/app/mod.rs::finish_preview). Keep this as the outer correctness boundary.
Add the following image-specific rules:
- A short selection delay/coalescing window (Yazi uses 30 ms) avoids starting full reads for every item during rapid navigation.
- Decode, resize and protocol encoding run off the UI task. Use a small global semaphore or dedicated worker and coalesce queued work per pane; do not let rapid navigation accumulate an unbounded
spawn_blockingqueue. - Check a cancellation token before read, before decode, after decode, before resize/encode and before sending the result. This avoids new work but cannot interrupt a codec already running.
- Every prepared result carries
(pane, preview generation, target, session epoch, image identity, target Size, font size, protocol, terminal epoch). The reducer/runtime accepts only the current identity. Yazi's inclusion of previewRectin its signature is the relevant precedent. - A timeout on an async wrapper is not CPU cancellation. Tokio explicitly states that aborting a running
spawn_blockingtask has no effect and recommends a semaphore for CPU-bound work: https://docs.rs/tokio/1.54.1/tokio/task/fn.spawn_blocking.html. - Worker output is only data placed into current state. Workers must never write escape sequences directly to stdout; only the draw path for the currently accepted protocol may do so. This eliminates late stale terminal writes by construction.
4.3 Resize, overlays, hide and suspend/resume
- Key prepared state by the inner preview area, not the outer bordered
Rect. Recompute when the pane/overlay layout changes; debounce resize storms. - While a replacement is being resized, either show the old image only if it still fits safely or show a placeholder. Never allow an old oversized image to spill over adjacent panes.
- Switching to text/directory/no selection, loading a different image, opening a covering overlay, or disabling images must remove the prepared widget from the draw path and clear its cells. Kitty placeholders then disappear as text; Sixel/iTerm2 need the crate's clearing behavior. Test actual terminals for residue.
- rcom's
TerminalGuard::resumecurrently creates a freshTerminal. Increment a terminal epoch and invalidate prepared protocols at that boundary so Kitty retransmits and every backend gets a full redraw. Yazi resets/recreates/reflows on resume for the same reason. - On normal exit/suspend, leave the alternate screen through the existing guard. Do not add raw terminal writes after the guard is restored.
5. Headless and mock testing without image assets or network
5.1 Deterministic automated tests
Use tiny programmatically generated images (RgbaImage/DynamicImage, or encode a 2×2/4×2 image to an in-memory Cursor<Vec<u8>>). No fixture downloads, external image files, Chafa, ImageMagick or real terminal are needed.
-
Decode/classification tests
- PNG/JPEG magic selects the image path; text and arbitrary binary retain existing behavior.
- Corrupt/truncated image data produces a specific image-unavailable result, not a panic.
- Exact byte cap succeeds; cap+1 returns the too-large fallback; mock local and SFTP filesystems prove no unbounded read.
- Pure dimension/budget functions reject excess width, height, total pixels and arithmetic overflow. Test these separately with generated dimensions/property tests rather than allocating giant images.
- Static GIF/WebP behavior is fixed by the spec; no animation tasks are spawned.
-
Geometry tests
- Wide, tall and tiny generated images preserve aspect ratio and fit within
Size. - Zero-width/zero-height and one-cell areas show a placeholder without panic.
- Growing/shrinking the area invalidates the old protocol; stale resize completions are rejected.
- Wide, tall and tiny generated images preserve aspect ratio and fit within
-
Actual-pixel rendering with Ratatui
TestBackend- Construct
Picker::halfblocks()explicitly; never call stdio detection in unit tests. - Render both the normal preview and F3 overlay. Assert expected
▀/▄cells and known RGB foreground/background values, not merely the presence of “Name/Size” metadata. - Assert borders and neighboring pane text remain intact and the image does not exceed its allocated cells.
TestBackendAPI: https://docs.rs/ratatui/0.30.2/ratatui/backend/struct.TestBackend.html.ratatui-image's own quick start demonstrates exactly this picker/backend combination: https://docs.rs/ratatui-image/12.0.0/ratatui_image/#quick-start.
- Construct
-
Protocol-shape tests, not fake visual claims
- Force each
ProtocolTypeon a test picker and inspect Ratatui cells. Kitty should produce placeholder cells; Sixel/iTerm2 put their escape payload in the first cell and mark the remaining area skipped. - Assert structural properties only. Do not snapshot random Kitty IDs, entire base64 blobs or codec-version-dependent Sixel output.
- These tests prove buffer integration, not that a real emulator displays pixels.
- Force each
-
Capability parser tests
- Feed synthetic Kitty OK, DA1 with/without attribute 4,
CSI 16 t, final status, malformed and garbage responses into a pure parser. - Test no response/timeout with a short injected duration or a mock PTY; do not sleep for the production two-second default.
- Prefer a pure function over an environment map. If tests mutate process environment, serialize them; avoid environment races.
- Upstream parser examples are at cap_parser.rs tests.
- Feed synthetic Kitty OK, DA1 with/without attribute 4,
-
Async/lifecycle tests with controllable mocks
- Block image A with a
Notify/oneshot, complete B first, then release A; only B may become visible. Repeat for target, generation and SSH-session mismatch. - Complete an old-area encode after a new-area encode; the old protocol must be discarded.
- Prove cancellation before a queued blocking job prevents it from starting, and that late completion after cancellation emits nothing visible.
- Use atomic active/max-active counters in a fake codec/worker to prove the concurrency bound.
- A mock terminal/image presenter records hide, invalidate, redraw and resume calls. Switching image→text/directory/no-selection and opening/closing overlays must not leave the old presenter active.
- Block image A with a
-
Icons-off and no-image fallback tests
- With
IconMode::None, the preview title has no icon but the generated image's halfblock pixels are still present. - With images explicitly disabled, ASCII/no-color/
TERM=dumb, or an injected no-presenter capability, the UI shows a sanitized image-unavailable/metadata result and emits no graphics payload. - Corrupt, unsupported and over-limit images follow the same non-panicking fallback while other preview kinds remain unchanged.
- With
5.2 Manual tests that automation cannot replace
Before claiming native-protocol support, run a tiny local smoke matrix:
- Kitty or Ghostty: image quality, rapid selection, overlay hide/show, resize, editor suspend/resume, exit;
- iTerm2 or WezTerm: correct size, no stale image, reasonable redraw bandwidth;
- Foot or Sixel-enabled xterm: transparency/background, bottom-edge behavior, clearing and resize;
- unsupported terminal such as standard Alacritty: halfblocks rather than metadata;
- tmux with the explicitly chosen passthrough policy; local and SSH-selected files;
- rapid
j/k, very large/corrupt files and terminal resize during decoding.
ratatui-image maintains a separate real-terminal screenshot suite and publishes its compatibility matrix at https://github.com/ratatui/ratatui-image#compatibility-matrix. That is useful supporting evidence, but rcom still needs its own lifecycle checks.
6. Suggested OpenSpec boundaries and scenarios
Required first-change behavior
- Given a selected supported image and a usable preview area, when loading completes, the preview displays decoded image pixels fitted to the pane; a metadata-only result is not considered success.
- The same image content path is used by the normal preview and full preview overlay.
- Local and SSH reads have explicit encoded-byte, dimension, pixel and allocation limits; excess produces a safe fallback.
- Image work does not execute synchronously in Ratatui rendering, and superseded reads/decodes/resizes cannot replace current state or write terminal output.
- Terminal protocol detection happens once before the event reader, is bounded, and falls back to actual halfblock pixels; no native support is guessed solely from rcom's icon mode.
- Resize and terminal resume invalidate incompatible prepared state and trigger safe repreparation/full redraw.
- Automated tests demonstrate pixels with a generated in-memory image and
TestBackend, including icons-off and explicit no-image fallback.
Explicitly deferred
- animation and video;
- SVG/PDF and formats requiring external converters;
- Überzug++ X11/Wayland windows and external Chafa;
- custom Kitty-old/multipart-iTerm2/Sixel implementations;
- persistent disk thumbnail cache, preloading neighboring images, and hard sandboxing of codecs;
- claiming that headless tests verify real terminal rendering.
Bottom line
Yazi's important lessons are not its escape sequences alone; they are the surrounding design: content-based image routing, bounded blocking decode, cell-aware sizing, cancellation scopes, area-aware preview identity, explicit image erasure/collision handling, and terminal reset on resume. For rcom, ratatui-image supplies the protocol/buffer layer while rcom should reuse its existing bounded filesystem and latest-generation preview architecture. Halfblocks make “show the selected image” achievable everywhere in a testable first release, while Kitty/iTerm2/Sixel improve quality when the terminal genuinely supports them.