Skip to content

[0.2.0] kitty graphics are parsed but never painted: inline images render as blank boxes #2875

Closed

Description

@Xuepoo

Priority: P1 | Area: render | Labels: feat,P1,area:render | Milestone: v0.2.0 | RFC: none | Task: none

Owner report: a Neovim Markdown preview that renders diagrams as inline images shows a blank floating window in Bitty, while Ghostty paints the diagram. The plugin is the kitty-graphics path (image.nvim-style: the plugin opens a floating window and transmits an image with APC G).

State of the code today:

  • bitty-vt parses APC G and bitty-term-state stores images, placements and animation frames (state.rs::kitty_graphics, placement.rs), including virtual prototypes and a=q handling.
  • The comment at crates/bitty-term-state/src/state.rs:2103 states the gap explicitly: "Unknown actions stay stored-not-painted downstream".
  • crates/bitty-render has no image paint path: no texture upload, no placement compositing; the cells stay empty (or a placeholder is drawn).
  • The runtime still answers a=q queries, so a plugin is told images are supported and commits to the blank rendering instead of falling back to a text backend.

Consequence: every kitty-graphics consumer (Neovim image plugins, chafa/viu in kitty mode, yazi previews, kitten icat-style tools) shows an empty rectangle, and the floating overlay that hosts the image leaves the surrounding UI looking broken.

Scope:

  1. Decode the transmitted payloads the protocol already accepts (f=24/f=32 raw RGBA/RGB, f=100 PNG, chunked m=1 continuations), with the existing bounds (max image bytes, dimensions) and fail-closed behaviour.
  2. Upload each decoded image once into a texture cache keyed by image id + frame, evict on a=d/delete-all/scrollback drop and under memory pressure.
  3. Composite placements (a=p, a=T, virtual U=1 spans, z= layering, X=/Y= pixel offsets, source rects x/y/w/h) in the present pass, above/below text according to z, clipped to the viewport and to the pane bounds.
  4. Honour q= reply suppression and answer a=q with the truth: either full support, or report the unsupported action so plugins fall back.
  5. Animation: a=a/a=c frames at the smallest useful cadence, no unbounded queue.
  6. A11y/scene contract: an image cell must keep a text fallback (placeholder character) for screen readers and for bitty ctl terminal text.

Acceptance: replaying a recorded image.nvim session produces the same visible diagram in Bitty as in Ghostty at the same pane size; deleting the window frees the texture; a terminal without GPU still shows the documented placeholder rather than a blank hole.

Activity

  1. added this to the v0.2.0 milestone on Nov 4, 2026
  2. added
    feat
    P1
    area:render
    on Nov 4, 2026
  3. Xuepoo commented on Nov 4, 2026

    @Xuepoo
    ContributorAuthor

    Status (guard tick 2026-11-04): PR #2881 merged (squash 52b83a6f, CTX-1689) after an independent guard review and a fully green gate (17 pass / 0 fail / 0 pending, incl. Windows, MSRV 1.85, M1 + compat aggregates). Delivered: a=p paints a stored image through the rich pixel layer (with p= replace semantics and a=d,d=i clearing), below-text layering via ImagePaintLayer (z<0 → under glyphs, above cell backgrounds) in software, headless GPU and real-GPU paths, and U+FFFC fallback text for U+10EEEE image cells so a11y/AI snapshots stay readable.

    Deliberately deferred and still open on this issue: a=a/a=c animation playback re-verification, relative a=p (P=/Q=) painting (no parent-anchor model in the rich layer yet), and the recorded image.nvim/Ghostty parity replay, which needs a real compositor this headless environment cannot run.

  4. Xuepoo commented on Nov 5, 2026

    @Xuepoo
    ContributorAuthor

    Status (guard tick 2026-11-05): PR #2894 merged (squash 2f1be92a, CTX-1705) after an independent review (VERDICT: APPROVE, 9 checks, failure-sensitivity proven by three local reverts) and a fully green gate (17 pass / 0 fail / 3 skipped, incl. Windows, MSRV 1.85, M1 + compat aggregates).

    Delivered in #2894:

    • a=q truthfulness for PNG: a probe now runs the decoder's own payload gate (precheck_png_payload, crates/bitty-rich/src/kitty_decode.rs:395, called from crates/bitty-runtime/src/runtime/kitty_images.rs:2226), so an oversized/invalid IHDR probe answers a refusal instead of ;OK followed by a refused transmit. Raw f=24/f=32 probes were already truthful.
    • Text fallback for direct placements: a=p/a=T own no grid cell, so bitty ctl terminal text and the devtools grid snapshot returned an empty grid. ImageCellSpan + grid_text_from_snapshot_with_images (crates/bitty-runtime/src/inspect.rs:391,418) with Runtime::kitty_image_cell_spans_for_view/_for_primary (kitty_images.rs:1953,1984) now emit U+FFFC for covered blank cells only; text under an image is preserved (ctl/apply.rs, runtime.rs:2770).
    • Animation: the bounds already existed (KITTY_ANIM_MAX_FRAMES=256, 33 ms quantum floor, MAX_STEPS_PER_TICK=4, leftover dropped — crates/bitty-term-state/src/placement.rs:96,112,122,463); the gap was coverage, now pinned by a test that a tick changes presented pixels and wraps back to frame 1.

    Still open against this issue (unchanged by #2894):

    • alt-screen animation pause policy (documented, not decided, crates/bitty-runtime/src/runtime/present.rs:6331+);
    • the acceptance replay itself: a recorded image.nvim session matching Ghostty at the same pane size — needs a real compositor/GPU session, not headless RGBA;
    • devtools-surface end-to-end IPC test for the new text fallback;
    • review follow-ups F2–F6 from the PR review (duplicated PNG gate, header-only/corrupt-stream probe still answers OK, footprint seam omits scroll_offset/cursor_follow_window_start, PNG arm of the probe⇒paint contract split across two tests, minor column_covered rescan).

    Merged so far on this issue: #2881 (a=p paint + z layering + a=d clearing), #2893 (relative P=/Q= placements), #2894 (this).

  5. added a commit that references this issue on Nov 5, 2026
  6. Xuepoo commented on Nov 7, 2026

    @Xuepoo
    ContributorAuthor

    New field evidence from the owner (Bitty 0.0.35), which splits this into two different failures:

    1. Inline images do not paint at all. neovim on ~/Documents/skills/git-paper.md with an inline LaTeX renderer (image.nvim / snacks style): Ghostty paints the formula in place of the source; Bitty leaves the raw $$\Sigma = \{0,1\}^8$$ text visible, i.e. the placement is received but nothing is drawn, so the concealed source is not covered.

    2. A floating-window image paints, but with the wrong geometry. Moving the cursor next to the formula opens the plugin's preview float: the formula does render there, but the image is positioned oddly and its content overflows the box instead of being scaled/clipped to the float's cell rect.

    So the placement path is not uniformly dead: a placement inside an overlay/floating panel reaches the screen while a placement in the main grid does not. That is a useful bisect — the difference is likely which surface/view the blit is attached to (main-grid placements may be dropped before the image pass, or attached to a leaf whose retained list does not carry images), while the overlay path happens to work but ignores the destination rect for scaling.

    Acceptance for this issue should therefore cover both: an inline placement paints over the cells it names, and a placement inside a floating panel is scaled/clipped to that panel's content rect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:renderfeat

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions