Repository navigation
[0.0.26] fix(runtime): render kitty placeholder previews, pixel winsize, alt image planes (#2442, #2453) - #2458
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 4 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ba7e803 to
d51e63e
Compare
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review verdict — PR #2458 @ d51e63e0
Reviewer: separate agent (hermes guard dispatch), static review of the diff only, no builds run.
Gap-fill: this PR had no recorded review verdict at this head. All line cites are commit content (git show d51e63e0:…).
Checks
- (a) Placeholder run rendering: the terminal consumes runs rather than emitting them (only the new fixture encodes U+10EEEE + row/col diacritics, and its 10-mark table matches
rowcolumn-diacritics.txt). Mapping is absolute — span origin isgrid_col - tile_coland each run cropsrect ∩ full ∩ viewportin content pixels, so there is no per-cell index math and no off-by-one:crates/bitty-rich/src/kitty_unicode.rs:136-165,crates/bitty-runtime/src/runtime/present.rs:4850-4875. Overrun is clipped twice (cols = cells.len().min(room)atkitty_unicode.rs:122, then thefull/viewport intersect). - (b) Vertical centering:
fit_aspect_rectis integer-only,fw/fhclamped>= 1, insets non-negative by construction, i32 clamps saturating (kitty_place.rs:1153-1180). When the panel is smaller than the image it downscales correctly; when the panel is much larger, the fill-one-axis/center-the-other rule can place the image wholly outside the panel (finding 3). - (c) Alternate image planes: transitions are detected at three layers (SetMode hook
runtime/pty.rs:1455, present latchpresent.rs:2050, pre-mutation sync); both?47/?1049go throughMode::AlternateScreen*; stash/restore is order-preserving and the epoch bump blocks cross-plane async lands (kitty_images.rs:1636-1675). No descriptor leak on close (retire_kitty_origin,kitty_images.rs:1677, called frompanes.rs:568,872). Image bytes are not plane-tagged, so alt payload lingers (finding 1). - (d) Cache/id lifecycle: raster cache invalidated on every swap and on failed-display discard; keys bind image id + generation + frame + geometry, so no stale-id reuse (
kitty_images.rs:1671,1696). Stash is invisible to admission (finding 2). - (e) PTY: unix forwards pixels through
PtySizeon bothopenptyand resize and reads them back viaTIOCGWINSZ; Windows caches only, which is honest since ConPTY has no winsize (platform/unix.rs:50,205,platform/windows.rs:189). LegacyPty::resizezeroing pixels is the sharp edge (finding 5). - (f) Test honesty: strong —
kitty_preview_pipeline.rsasserts real opaque-pixel bounds/counts (80×76 run, 90×90 letterbox at +2), alt hide→restore bit-identical, failed replacement → zero red pixels. Two expectations are self-referential (finding 6) and one pin was weakened (finding 3).
VERDICT: APPROVE-WITH-NITS
- medium —
runtime/kitty_images.rs:1636(leave branch): only descriptors move; stored image bytes have no plane tag, so a fullscreen viewer's alt payloads stay under the origin's image/byte quota after?1049land, via S5 no-cross-origin eviction, can starve other panes until FIFO eviction. Pre-existing, not a regression — sweep images whose last referencing descriptor was dropped at leave, or add a plane tag; at minimum document and test it. - medium —
bitty-rich/src/kitty_place.rs:2523:check_shared_placement_quotacounts only the live layer, so with a full main plane stashed an origin can hold 2× the 32-placement cap and the global set can reach 2×KITTY_PLACE_MAX_ITEMS, whilekitty_placement_count(kitty_images.rs:181) reports the stash — admission and observability disagree; pass dormant counts into the preflight. - low —
tests/kitty_images_present.rs:323:kitty_last_frame_images() <= 1silently drops the old== 1pin to accommodate a 1×1 image centered ~622k px below ar=u16::MAXrect. Assert the actual value (0) with the rationale, or clamp the inset so the first cell of the fitted rect stays inside the panel. - low —
present.rs:4771: rustdoc says "alternate-screen origins keep the existing suppression … prototypes stay inert", but the code paints them and the new alt test asserts a paint — fix the doc (same stale claim at the pause-policy line above). - low —
bitty-pty/src/pty.rs:102:resize()now forwards0,0, wiping pixel geometry for any embedder/test caller still on the legacy API (spawn_smokecodifies the wipe) — retain last-known pixels when0/0is passed, or deprecate. - low —
tests/float_stacked_occlusion.rs:514andtests/kitty_animation.rsdest_first_pixel: expected geometry is computed by callingfit_aspect_rect, i.e. the code under test, so a wrong fit passes; hardcode the small expected rects.
No files modified; nothing built or run by the reviewer.
d51e63e to
7994551
Compare
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review verdict — PR #2458 delta @ 79945510
Reviewer: separate agent (hermes guard dispatch). Delta review of d51e63e0..79945510 (the earlier verdict covered d51e63e0), static read only — no builds or gates run by the reviewer.
VERDICT: APPROVE (no blocking findings)
- Earlier blockers are addressed: per-row blit truncation is fixed by gathering runs per image into
KittyUnicodeRunGroupand rasterizing once (present.rs~4998,unicode_rect_union~632), and the bodilessa=p,U=1case now resolves pixels through thefind_root_for_originfallback, so the canonicala=tthena=p,U=1sequence paints. - No render-path panics:
unwrap()/expect()hits are confined totests/kitty_preview_pipeline.rs; production additions use fail-closedunwrap_or/clamped bounds (present.rs:655,:735). Nounsafe,todo!,unimplemented!,panic!. - No blocking findings.
Non-blocking (follow-up, not merge-gating):
- The alt-plane claim (
kitty_place.rs:199-207, "detach/re-attach with the plane") is doc-only in this delta and has no test inkitty_preview_pipeline.rs; the two added tests cover the tall-span and two-step-transmit cases only. - New rustdoc links to
KittyImageLayer::take_virtuals_for/restore_virtuals(kitty_place.rs:203-204,:843-846) are not introduced by this diff — confirm the symbols exist so the intra-doc links do not dangle in a docs build. - The sparse/gap mask path (
mask_uncovered_unicode_pixels) has no direct test; the one-blit tests appear to use full-bleed coverage.
Note on gate semantics: CI green is the gate here; this verdict was produced by reading the diff, not by running gates.
Xuepoo
left a comment
There was a problem hiding this comment.
Independent review verdict — PR #2458 delta @ 79945510
Reviewer: separate agent, build-backed (not static-only). Delta is d51e63e0..79945510
(tree-identical to 7dc57bd3, so this is exactly the review-fix commit). Throwaway
worktree /tmp/opencode/review-2458b + CARGO_TARGET_DIR=.targets/review-2458b,
both removed. No files modified, nothing merged.
VERDICT: APPROVE — no blocking findings. Two merge blockers remain, neither a
code defect (see Merge notes).
Gates actually run
| gate | result |
|---|---|
cargo nextest run -p bitty-runtime -p bitty-rich -p bitty-pty --locked |
3314 passed, 2 skipped |
--test kitty_preview_pipeline --test kitty_unicode_placeholders --test kitty_images_present --test kitty_animation --test kitty_local_mediums |
101/101 |
-p bitty-rich -E 'test(/kitty/)' |
86/86 |
cargo fmt --check |
clean |
act / just ci-local were not run (per instruction); clippy and the cross-platform
gates are CI's.
1. P1 — placeholder union raster (present.rs:619-780, :4956-5170)
- No truncation >32 rows.
tall_placeholder_span_paints_every_row_with_one_blit
(50-row span, 80x950 px) asserts 1 blit, all 76000 px red, full 950 px height. Passes.
Gather-then-blit means the per-frame blit counter is charged once per image, so spans
of any height reach the paint; the cap now only drops images (fail-closed), never rows. - No overpaint between sparse runs. I wrote two throwaway probes (removed): two runs
on one row with greenABbetween them, and runs on image rows 0/2 with greenXYon
row 1. Both:kitty_last_frame_images() == 1, red count exactly the two runs
(4 cells, 684 px), zero red pixels inside the gap cells, gap glyphs visible.
mask_uncovered_unicode_pixelszeroes straight-alpha pixels outside the run rects;
(0,0,0,0)is a no-op in both straight and premultiplied compositing, so the mask is
sound. The glyph pass blanks only placeholder cells (present.rs:2871-2878), so gap
text is still emitted underneath. - Cache key.
KittyRasterKey::for_image(stored, frame_no, full, union)still binds
image id + generation + frame + src dims + full + emitted window, so a geometry or
re-transmit change can never hit a stale entry. Only the dense branch inserts
(present.rs:5108-5137); a masked raster is never admitted, so a later full-bleed
union cannot be served the gap-masked bytes. Plane swaps,d=a,d=i, ED clears and
failed replacements still callinvalidate_kitty_raster_cache. - Direct-placement budget unchanged. The direct loop is untouched (one blit /
visible-area bytes per placement, shared 32-blit / 64-MiB counters) and still runs
after the placeholder call; placeholders simply consume 1 instead of N slots. - Non-blocking: sparse groups bypass the raster cache, so a static sparse image re-scales
and re-masks once per present (bounded by the viewport and byneedadmission; yazi's
shape is dense and cached). A union larger than the 64-MiB frame budget drops the image
fail-closed — the same outcome a direct placement of that size already has.
2. P2 — bodiless a=p,U=1 on the alt plane (pty.rs:1115-1126)
- Ordering.
state.applyrecords truth first, thensync_kitty_screen()
(kitty_images.rs:1670, idempotent swap at:1636) runs before the rich
registration — the same sync-before-mutate discipline as
kitty_display_image_owned_with_wire(kitty_images.rs:683). The SetMode hook
(pty.rs:1465-1473) matches both alt variants, andbitty-vtonly produces two
(47/1047 ->AlternateScreen, 1049 ->AlternateScreenClearAndRestore), so an
in-batch?1049hthena=plands on alt. - Teardown. Leave clears alt placements + prototypes and restores the main stash;
retire_kitty_origindrops the stash and the alt marker.virtual_alt_screen_registers_on_the_alt_plane
asserts 1 bodiless prototype on alt, 2 after the combined form, 0 after?1049l, and
main registration works again. Passes. - Main-screen regression. Same path, sync early-returns when no transition is
pending; every main-screen placeholder test passes (virtual_bodiless_registers_and_resolves_without_blits,
the two-step test, allkitty_unicode_placeholders).
3. P2 — canonical two-step (a=t then a=p,U=1)
- Paint resolves
proto.image.or_else(find_root_for_origin(origin, proto.wire_image))
(present.rs:5020-5027). The lookup is origin-scoped, returns the newest stored image
for that wire id, andNonefori=0, evicted, or deleted images. - Wrong origin. Probe: pane transmits
i=55, the primary registers a bodiless
prototype for 55 and prints runs -> 0 red pixels. No cross-origin borrow. - Lifetime / no stale reuse. Probe: transmit 55, bodiless register, 2-cell run paints
(342 px), thena=d,d=i,i=55-> 0 red pixels on the next tick.
delete_by_wire(None, ..)drops bodiless prototypes by wire id regardless of the
image: Nonelink (kitty_place.rs:2585-2590), and the cache key's generation field
rules out a stale raster after a same-id re-transmit. - Combined
a=T,U=1keeps its linked handle; the wire-map fallback only fills the
bodiless gap, so no behavior change for the form that already worked.
4. P3s
kitty_images_present.rs:323back toassert_eq!(rt.kitty_last_frame_images(), 0)
with the centering rationale; the 1x1 source lands ~622k px below the viewport, so zero
blits is the correct fail-closed pin. Passes.- Stale alt-suppression wording is gone from
present.rs,kitty_place.rs,
kitty_images.rs; the alt doc now states the live-plane contract. One cosmetic
leftover: thevirtual_prototype_clear_scopes_match_truthcomment still says
"d=a/alt-suppression" (kitty_place.rs:3711) even though thed=aclaim it makes is
still true (truth'sAllVisiblealso retains virtual prototypes). Non-blocking. - Commit body has real newlines and wraps <= 74 columns.
Merge notes (not delta defects)
Quality gates (1)is red on this head, but the log is runner disk exhaustion
(rustc-LLVM ERROR: IO failure on output stream: No space left on device, sccache/rustc),
whileQuality gates (2)and every other gate in the same run passed. Re-run required
before merge; it does not implicate this delta.- PR is
BEHINDmain (mergeable: MERGEABLE, no conflicts). Per check policy it needs
an update/rebase before merge. - CodeRabbit posted only a review-limit notice; 0 inline comments on the PR, nothing
to disposition.
…geometry (#2442, #2453) - Register spanless U=1 prototypes (a=T,U=1 with no c=/r=): yazi 26.x's exact KGP shape; the span derives from decoded pixels. - Paint real images behind U+10EEEE runs: resolve each run against its prototype, fit the image into the placement span preserving aspect ratio, and blit the run's crop (one blit per row). - Keep separate main/alt image planes per origin: stash main on alt entry, register/paint alt entries live, clear alt and restore main on leave, including local-medium delete epochs. - Answer XTWINOPS 14t/16t for the draining pane frame, not the focused leaf. - Report TIOCGWINSZ pixel geometry on PTY spawn and resize so kitty +kitten icat no longer reports 'does not support ... pixels'. - Letterbox direct placements into a requested c=/r= rect (centered, aspect preserved) instead of stretching. - Drop a previous rendered placement when a same-id display fails to decode/read; blank placeholder glyphs so pending images never paint as tofu/black bands. - Regression tests: direct PNG, yazi placeholder shape, alt-plane cycle, resize repaint, 14t/16t pane routing, PTY pixel winsize, failed and missing replacements.
- Paint the visible union of one placeholder image once instead of one blit per row: a span taller than KITTY_PRESENT_MAX_BLITS_PER_FRAME (32) was truncated at the cap and starved direct placements queued behind it. Runs are grouped per image, unioned and clipped to the viewport, and gaps between sparse runs are masked transparent so the image never paints over grid text. Direct-placement budget semantics are unchanged. - Drop the alternate-screen gate on bodiless a=p,U=1 registration and sync the plane first, so the prototype lands on the alt plane and dies with it, exactly like the combined a=T,U=1 form. - Resolve bodiless prototypes through the origin-scoped wire map at paint time, so the canonical a=t then a=p,U=1 two-step form paints. - Tests: 50-row placeholder span on a tall grid (one blit, every row painted), two-step transmit plus bodiless paint, bodiless alt-plane registration, and the maximal-row placement pin back to exactly zero blits. - Refresh stale alternate-screen doc comments in present.rs, kitty_place.rs, and kitty_images.rs.
7994551 to
46272d1
Compare
Summary
Fixes kitty image previews end to end for yazi 26.x, chafa, and
kitty +kitten icat. Four layers were involved, not one:U=1shape was never registered — yazi sendsa=T,C=1,U=1,f=32,s=160,v=120,i=<id>with noc=/r=. Corerefused spanless prototypes and registered nothing.
U+10EEEEruns resolved torects, but the present path only blitted direct placements. yazi paints
exclusively through placeholders.
while alt was active (
SuppressedAlternateScreen), even though kittykeeps a separate image plane per screen and fullscreen apps are expected
to display images there.
icatpixel reporting was zero —TIOCGWINSZwas populated withpixel_width = pixel_height = 0on spawn/resize; icat reads thosefields directly (not XTWINOPS) and fails with
Terminal does not support reporting screen sizes in pixels.Root cause + spec citations
bitty/recording/references/kitty/docs/graphics-protocol.rst:567-700(Unicode placeholders,
U=1,U+10EEEE, row/column diacritics).:538-541,:601-602— a client-requestedc/rrect isletterboxed/pillarboxed with aspect ratio preserved (centered), not
stretched.
:1164-1169— alternate-screen image plane is cleared on entry andseparate from main; images are legal while alt is active.
:158-182— XTWINOPS14t/16tshapes.kittens/icat/main.go:249is reached fromtty.GetSize(ioctl), notCSI 14t; that is why 14t being answered did not help icat.What changed
U=1registers withcols = rows = 0; the span derivesfrom decoded pixels (
ceil(px / cell)), exactly yazi's shape.prototype, the image is fitted into the span with aspect preserved, and
the run's cell crop is blitted (one blit per run/row, existing
32-blit / 64-MiB frame budget).
?1049h,alt entries register/paint live, alt is dropped and main restored on
?1049l; local-medium delete epochs bump on every transition so aworker cannot cross planes. Pane teardown/respawn drops both.
fed_grid_view()),not whichever leaf has focus.
PtyBuilder::pixel_size) and everyresize path (
Pty::resize_pixels), including the fullscreen/restoreresync in
layout_focus;Pty::size_pixelsintrospection. The pixelaxes are compared alongside cells, so a stale zero-pixel winsize is
repaired even when the cell size already matches.
c/rrectpreserving aspect ratio and center the result (letterbox).
the previous rendered placement/prototype for that origin; placeholder
glyphs are blanked in the glyph pass so a pending/failed image never
shows as tofu or a black band.
metrics every frame; the new test pins one image at the new centered
origin after a split move.
Evidence (real tools, headless PTY harness)
Captured yazi 26.5.6 KGP bytes (no
c=/r=; area atCSI 3;51H,10x4 placeholders):
chafa -f kittyicat --print-window-size333x418(kernel 37x22 @ 9x19)Raw capture:
recording/kitty-preview-2442-2453/in the task worktree(gitignored). The synthetic regressions replay the same shape without the
100 KB payload.
Tests
New
crates/bitty-runtime/tests/kitty_preview_pipeline.rs(8 tests):a=T,U=1, no span) registers and paints real image pixels14t/16tanswer the draining pane, not the focused leafTIOCGWINSZpixel axesAlso
bitty-pty::spawn_smoke::pty_reports_pixel_geometry_through_winsizeand new
fit_aspect_rect/unicode_run_rect.fullunit coverage.Validation:
cargo nextest run -p bitty-runtime -p bitty-rich -p bitty-pty→ 3307 passed, 2 skipped;
cargo fmt --check;RUSTFLAGS="-D warnings" cargo clippy -p bitty-pty -p bitty-rich -p bitty-runtime --all-targets;cargo check --workspace --all-targets;bitty-terminalkitty/pane tests57/57.
Priority: P1 | Area: runtime | Labels: fix,P1,area:runtime | Milestone: 0.0.26 | RFC: - | Task: CTX-1448
Closes #2442
Closes #2453