Skip to content

Redraw inline images (iTerm2) and clear them on unmount - #13

Merged
planadecu merged 1 commit into
mainfrom
fix/iterm2-redraw-and-clear
Jul 14, 2026
Merged

Redraw inline images (iTerm2) and clear them on unmount#13
planadecu merged 1 commit into
mainfrom
fix/iterm2-redraw-and-clear

Conversation

@planadecu

Copy link
Copy Markdown
Owner

Follow-up to the graphics-lifecycle fixes, covering the iterm2 inline-image format (real iTerm2 + VS Code), which — unlike kitty/ghostty — has no graphics plane or image IDs to double-buffer.

Real iTerm2 — chart vanished after a moment

The inline image lives in the text grid, so the host app's normal Ink repaints (e.g. a live price ticker) erase it, and this component doesn't re-render on those, so nothing redraws it. Fix: re-stamp the cached image on a 120ms interval while mounted. Some flicker is inherent (no image IDs = no atomic swap like kitty); this was accepted as far better than falling back to the chafa look. Skipped for VS Code (its images persist and would stack).

VS Code — chart ghosted over table/log view

VS Code's inline image persists over later text and has no delete command. Fix: on unmount, paint the image's exact cells black so the host's next repaint draws the replacement view over a clean region. (Best-effort for VS Code, which is a non-critical target.)

Inline draws now use absolute positioning (like kitty) so the same coordinates drive the draw, the redraw interval, and the unmount clear. Kitty/ghostty unchanged (still delete buffered image IDs on unmount).

Verification

  • iTerm2: confirmed the chart persists (redraw working). Escape-stream shows re-stamps at ~120ms and the unmount clear firing.
  • Kitty/ghostty: unchanged, still crisp and clean.

🤖 Generated with Claude Code

The iterm2 inline-image format (real iTerm2 and VS Code) doesn't integrate
with Ink's frame lifecycle the way kitty/ghostty do (no graphics plane, no
image IDs to double-buffer).

- Real iTerm2/sixels: the image lives in the text grid, so the host app's
  normal Ink repaints (e.g. a live price ticker) erase it, and this
  component doesn't re-render on those. Re-stamp the cached image on a
  120ms interval so it survives. Some flicker is inherent — without image
  IDs there's no atomic swap like kitty. Skipped for VS Code (its images
  persist and would stack).

- On unmount (switching to a table/log view), paint the image's exact
  cells black so the replacement view draws over a clean region instead of
  the lingering chart. Kitty still deletes its buffered image IDs.

Inline draws now use absolute positioning (like kitty) so the same coords
drive the draw, the redraw interval, and the unmount clear.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SCHVP8VywU8i8JAN4xgLVs
@planadecu
planadecu merged commit 0f6c5b5 into main Jul 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant