Fit-to-screen image scaling (v0.3.0)#2
Merged
Conversation
Replace image_rows() (reserve-only, height capped at the terminal height, which let oversized images overflow onto following text) with placement_cells(), which returns a concrete (cols, rows) box. show.py passes it as Kitty's c=/r= placement keys so Kitty downscales the image to fit the viewport, preserving aspect ratio. Images that already fit are rendered pixel-for-pixel. The vertical fit reserves DRIFT_MARGIN + 2 rows of headroom so a downscaled image plus its anchor offset stay on one screen instead of clipping at the bottom. Also drop the leading PTY newline, which only added an uncommitted top gap. This also applies to Mermaid diagrams, since mermaid.py displays through show.py. Docs (SKILL.md, README, CHANGELOG) updated accordingly.
whallil
force-pushed
the
feature/v0.3.0-fit-to-screen
branch
from
May 30, 2026 21:06
0d88149 to
9dd09ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds fit-to-screen scaling so images (and Mermaid diagrams) larger than the terminal are downscaled to fit instead of overflowing onto following text.
image_rows()(reserve-only, height capped at terminal height → oversized images overflowed) withplacement_cells(), which returns a concrete(cols, rows)box.show.pypasses that box as Kitty'sc=/r=placement keys, so Kitty does the resampling, preserving aspect ratio. Images that already fit render pixel-for-pixel.DRIFT_MARGIN + 2rows of headroom so a downscaled image plus its anchor offset stay on one screen (no clipped bottom).mermaid.pydisplays throughshow.py.Docs
SKILL.md: documents fit-to-screen; replaces the obsolete "taller than screen overflows / not implemented" caveat; adds an honest "vertical placement is approximate" note; adds guidance to keep inline Mermaid diagrams compact (graph LR, few nodes) since tall ones get scaled and can wash out.README.md"Known limitations" updated.CHANGELOG.md[0.3.0];plugin.json→0.3.0.Testing
placement_cells()verified both branches: small 240×120 → native(24,6)(no scaling); tall 400×2970 → scaled(11,36), aspect preserved.Note
The Unicode-placeholder placement approach explored in a worktree was abandoned: the editor filters U+10EEEE (PUA) characters out of stdout, so it never renders. This PR keeps the working direct-paint path and grafts on only the resize logic. Worktree purged.