Skip to content

[CTX-1919] fix(runtime): stop the bottom band pooling the remainder under its glyphs - #3285

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1919/fix-band-content-row
Nov 20, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1919/fix-band-content-row

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3282

Root cause

bitty#3263 anchored the bottom band stack to the window's physical bottom
inset and let the innermost band absorb the sub-cell remainder at its top, so
its granted rect is cell_h + remainder tall. paint_band_row used that
full granted height for both the per-run FillRect and the glyph origin, so
the cell row was pinned to the rect's top and the absorbed remainder landed
as pure band fill BELOW the glyphs — measured on 0.0.46: band rect 39 px =
cell 30 + remainder 9, capsule fill 38 rows, glyph ink pinned at the rect
top. Not fixable in the plugin: BandContent carries no height and every
run shares the band rect.

Fix

Paint, hit-testing and tooltip anchoring now read the band's painted cell
row
(BandPixelGeometry::cell_row): exactly one cell row, bottom-aligned
inside the granted rect, with the absorbed remainder left as window
background above it.

  • paint_band_row uses it for the per-run fills, the glyph origin and the
    shared chrome rule.
  • plugin_band_cell_hit hit-tests the same cell row, so paint and
    interaction stay one mapping: a painted row answers its own band, and one
    pixel outside the painted row is not band chrome.
  • The bottom-anchored overlay stack shifts by the same slack
    (content_drop) and its card clips at the painted cell row, so anchored
    rows still end on the band's painted edge.
  • Exact-multiple surfaces, top bands, column bands and bands without slack
    keep the granted rect unchanged.

Regression

bottom_band_glyphs_sit_in_the_painted_cell_row pins the glyph row itself:
the first and last foreground ink rows inside the painted cell row equal an
exact-multiple control's ink offsets (glyph pixels are alpha-blended, so
the observable is a pixel over the band's own fill that differs from it).
The remainder fixtures in band_bottom_inset.rs now pin the painted band
being exactly one cell row bottom-aligned on the inset with the absorbed
remainder as window background, plus paint/hit agreement; a present
regression pins the anchored card ending on the painted cell row.

Discrimination proof

Pre-fix production sources at c8584db, regression tests kept:

test bottom_band_glyphs_sit_in_the_painted_cell_row ... FAILED
assertion `left == right` failed: glyph origin: the ink starts at the
painted cell row's own top, not the granted rect's: left: 1, right: 8

band_bottom_is_the_physical_inset_on_a_remainder_surface and
stacked_bottom_bands_tile_the_zone_with_no_seam also fail; the
exact-multiple control and the container/winsize guards stay green on both
trees.

Local gates

  • cargo fmt --check -p bitty-runtime — pass
  • cargo clippy -p bitty-runtime --all-targets --offline -- -D warnings — pass
  • cargo test -p bitty-runtime --offline -- band — pass (251 test binaries, 0 failed)
  • cargo test -p bitty-runtime --offline --test band_bottom_inset — pass (8/8)
  • cargo test -p bitty-runtime --offline --lib — pass (1720/1720)
  • cargo +1.85 check -p bitty-runtime --tests --offline (MSRV) — pass

UX reference

One-row status chrome follows the ghostty/kitty-class convention: a one-row
bar occupies exactly one cell row and stays flush with the window's bottom
inset; sub-cell slack is window background, never extra bar padding.
Deviation: none — the fix restores exactly that. The remainder above the
innermost band stays background rather than being distributed, which keeps
the inset anchor from bitty#3263 intact.

Out of scope: the pane grid's own bottom-heavy centering (bitty#3284) is a
separate lane and is not touched here.

Summary by CodeRabbit

  • Bug Fixes
    • Bottom bands now paint a single cell row aligned with the bottom edge, even when their allocated area is taller. Any extra space remains window background.
    • Tooltips, overlays, clipping, and pointer hit areas now align with the painted band row.
    • Improved consistency in how text and other content appear when bottom bands have extra allocated space.

…nder its glyphs

bitty#3282: the innermost bottom band absorbs the sub-cell remainder into
its granted rect (bitty#3263), and paint used that full granted height for
the per-run fills, the glyph origin and the shared chrome rule, so the
absorbed remainder landed as dead band fill below the glyphs.

Paint, hit-testing and tooltip anchoring now read the band's painted cell
row (BandPixelGeometry::cell_row): exactly one cell row, bottom-aligned
inside the granted rect, with the absorbed remainder left as window
background above it. Every other edge, an exact-multiple surface and a
band without slack keep the granted rect; the bottom-anchored overlay
stack follows the same slack (content_drop) so its card still ends on the
band's painted edge.

band_bottom_inset.rs now pins the painted extent, hit-test agreement and
the glyph row itself (first/last foreground ink offsets against an
exact-multiple control); a present regression pins the anchored card
ending on the painted cell row.
@Xuepoo Xuepoo added this to the v0.1.0 milestone Nov 20, 2026
@Xuepoo Xuepoo added fix Bug fix area:runtime Area: runtime orchestration P2 Priority: medium labels Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Bottom bands with excess granted height now paint one cell row aligned to the bottom inset. Hit testing, chrome rules, and anchored overlays use that painted row. Regression tests cover remainder surfaces, stacked bands, tooltips, and glyph placement.

Changes: Bottom-band painted geometry

Layer / File(s) Summary
Compute and apply painted row geometry
crates/bitty-runtime/src/runtime/band_geometry.rs, crates/bitty-runtime/src/runtime/band_host.rs, crates/bitty-runtime/src/runtime/present.rs
BandPixelGeometry now provides the painted cell row and the excess height above it. Band painting, hit testing, chrome rules, and bottom-anchored overlays use the painted geometry.
Validate remainder and stacked bands
crates/bitty-runtime/src/runtime/present.rs, crates/bitty-runtime/tests/band_bottom_inset.rs
Regression tests check bottom alignment, background above the painted row, stacked-band extents, tooltip alignment, hit testing, and glyph ink placement.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • bitty-terminal/bitty#3266: Defines the shared physical-pixel band geometry that this change uses and adjusts for painting bottom bands.
Merge Risk: Minimal · up to 17e5a

Bottom bands now paint one cell row flush with the bottom inset, and hit testing and tooltips follow the painted row. No actionable merge-blocking risk was identified, and tests cover the changed behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the bottom band no longer paints the sub-cell remainder under its glyphs. The raw summary and PR objectives confirm the change centers on bottom-band painting, hit-tes…
Linked Issues check Passed [#3282] Requirement: with remainder > 0, a bottom band's fills and glyphs occupy one cell row flush with the bottom inset. At head, BandPixelGeometry::cell_row (band_geometry.rs) returns a bottom band…
Out of Scope Changes check Passed All changed areas trace to #3282. band_geometry.rs adds cell_row and content_drop. band_host.rs switches the band hit-test to cell_row. present.rs applies content_drop to bottom-anchored overlays and …
Full details: Title check

Explanation

The title names the main change: the bottom band no longer paints the sub-cell remainder under its glyphs. The raw summary and PR objectives confirm the change centers on bottom-band painting, hit-testing, and anchoring to a one-cell-row geometry (BandPixelGeometry::cell_row). The title uses a bracketed ticket prefix and a conventional fix(runtime) scope, which is acceptable. It is a single sentence, specific, and matches the changeset.

Full details: Linked Issues check

Explanation

[#3282] Requirement: with remainder > 0, a bottom band's fills and glyphs occupy one cell row flush with the bottom inset. At head, BandPixelGeometry::cell_row (band_geometry.rs) returns a bottom band rect of height cell_h, shifted down by the slack (granted.height - cell_h), so the painted row ends at the granted rect's bottom edge (the inset). The absorbed remainder stays above the row as window background. Requirement: paint and hit-testing agree. The PR summary states that paint_band_row and plugin_band_cell_hit (band_host.rs) both read cell_row, and the hit-test change is consistent with that. Requirement: exact-multiple, top, column, and stacked bands keep current behavior. cell_row returns the granted rect when edge != Bottom, when cell_h is 0, or when granted.height <= cell_h, and content_drop returns 0 in those cases. Requirement: regression pins the glyph row. The PR describes bottom_band_glyphs_sit_in_the_painted_cell_row, which compares ink offsets against an exact-multiple control, and reports a pre-fix failure at c8584db. Limits: the consumer diffs (present.rs, band_host.rs, band_bottom_inset.rs) could not be read because the changed blobs were unavailable. Those call-site and test conclusions rest on the PR summary and description, not on direct source reads. The tooltip anchor on remainder surfaces now shifts by content_drop. The issue asks that the tooltip anchor keep its current behavior. This shift is limited to remainder surfaces, and exact-multiple surfaces are unchanged.

Full details: Out of Scope Changes check

Explanation

All changed areas trace to #3282. band_geometry.rs adds cell_row and content_drop. band_host.rs switches the band hit-test to cell_row. present.rs applies content_drop to bottom-anchored overlays and card clipping. band_bottom_inset.rs and the new glyph-row test pin the behavior. The pane-grid centering change (#3284) is explicitly excluded in the PR description and summary. No unrelated file change is described. The consumer and test diffs were not directly readable, so this verdict relies on the PR summary for those files.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8918781c-dcf8-4fe9-be97-6418d30ccbbf
Commits

Reviewing files that changed from the base of the PR and between c8584db and 17e5ada.

Files selected for processing: 4

  • crates/bitty-runtime/src/runtime/band_geometry.rs
  • crates/bitty-runtime/src/runtime/band_host.rs
  • crates/bitty-runtime/src/runtime/present.rs
  • crates/bitty-runtime/tests/band_bottom_inset.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of PR #3285 (CTX-1919, issue #3282 — bottom band pools the sub-cell remainder under its glyphs). Reviewed head: 17e5ada, re-read via the API after the last check; the head did not move during this review. Worked read-only on the lane worktree; all mutation evidence below is from a scratch clone.

1. Full-diff read — PASS. c8584db..17e5ada touches exactly the four claimed files (band_geometry.rs +54, band_host.rs +5/-1, present.rs +91, tests/band_bottom_inset.rs +164; 291+/23-); no unrelated files, and layout_focus.rs / pane-grid centering (issue #3284) are not touched. The fix implements the criteria: BandPixelGeometry::cell_row bottom-aligns exactly one cell row inside the granted rect and leaves the absorbed remainder above it as window background (crates/bitty-runtime/src/runtime/band_geometry.rs:208-231); the per-run fill, the glyph origin (rect.x, rect.y) and the chrome rule all paint that cell row (crates/bitty-runtime/src/runtime/present.rs:6685-6697, 6724-6738); the hit-test reads the same cell row (crates/bitty-runtime/src/runtime/band_host.rs:2440); the tooltip anchor shifts by content_drop and the card clips at the painted cell row (present.rs:6986-6991, 7023-7025).

2. Hit-test parity — PASS. plugin_band_cell_hit resolves a row band through geometry.cell_row(...) (band_host.rs:2440) — the identical call paint_band_row uses for its fill and glyph origin (present.rs:6685) — so every painted row answers its own band. BandPixels::contains is half-open (band_geometry.rs:94-100), so one pixel above or below the painted row is not band chrome. The tests pin it: assert_hit_matches_paint probes every painted row for its own edge and asserts first-1 and last+1 both miss (crates/bitty-runtime/tests/band_bottom_inset.rs:274-298), exercised at :441, :525 and :636.

3. Stacked bands + tooltip anchor — PASS. Exact multiples keep the granted rect (cell_row returns it unchanged when granted.height <= cell_h, band_geometry.rs:220-222; content_drop is 0 there). Top bands keep the granted rect (edge != Bottom early return, band_geometry.rs:216-218); column bands are untouched — the hit path still uses area_band (band_host.rs:2441) and column paint was not modified. Stacked tiling: only the innermost band absorbs the remainder, at its top (band_geometry.rs:366-379), so each band paints its own one-cell row and the painted stack tiles [inset - n*cell_h, inset) with no seam — pinned at tests/band_bottom_inset.rs:502-525 (two contiguous cell rows, absorbed remainder as background above). The anchored overlay follows the painted row: y_offset gains content_drop (present.rs:6986-6991) and the card clips at cell_row(...).y (present.rs:7023-7025), pinned by bottom_band_tooltip_ends_on_the_painted_cell_row (present.rs:10570).

4. Mutation discrimination — PASS (scratch clone, own CARGO_TARGET_DIR). Clone at 17e5ada, only the three production files (band_geometry.rs, band_host.rs, present.rs) reverted to c8584db, regression tests kept. Exactly the three claimed tests go red:

  • bottom_band_glyphs_sit_in_the_painted_cell_row — band_bottom_inset.rs:839 "glyph origin: the ink starts at the painted cell row's own top, not the granted rect's" left: 1, right: 8 (the claimed red line, reproduced verbatim);
  • band_bottom_is_the_physical_inset_on_a_remainder_surface — :411 "the painted band starts one cell above the inset" left: Some(369), right: Some(376);
  • stacked_bottom_bands_tile_the_zone_with_no_seam — :503 "the painted stack starts two cells above the inset" left: Some(350), right: Some(357).
    The other five tests (exact-multiple control, top band, container/grid guard, fractional DPI, PTY winsize) stay green on the reverted tree — controls green on both trees, as claimed. With the fix restored the full file is 8/8 green and the tree is identical to the PR head (empty git diff 17e5ada4).

5. Independent gates on the PR head — PASS. cargo clippy -p bitty-runtime --all-targets --offline -- -D warnings exit 0; cargo test -p bitty-runtime --offline --test band_bottom_inset 8 passed / 0 failed; cargo +1.85 check -p bitty-runtime --tests --offline exit 0. The new present.rs regression also passes on the head (cargo test --lib bottom_band_tooltip_ends_on_the_painted_cell_row — 1 passed).

6. MSRV/lint defect scan — PASS. The new code has no let-chains, no if-let match guards, no new consts, no #[allow] papering over warnings; all comments are English; no hardcoded host paths, usernames or ports (grep over the full diff is clean). cell_row/content_drop use plain guards and saturating conversions (band_geometry.rs:216-248).

7. Test-quality scan — PASS. No sizing tautology: the glyph regression compares the remainder fixture's ink offsets against a separately constructed exact-multiple control runtime (band_bottom_inset.rs:815), not against its own inputs; the tooltip test asserts its fixture precondition first (present.rs:10609, 10614) and then pins the card's bottom edge to the painted row (present.rs:10633). ink_rows_over_fill (band_bottom_inset.rs:251-261) has a real one-pixel failure mode: it returns exact row indices, so a one-row drift moves the first/last ink row and flips the offset assertions — demonstrated by the 7 px drift failing as left: 1, right: 8. Every named test fails on the pre-fix tree (check 4), so none is unfailable.

8. PR hygiene — PASS. Exactly one closing directive ("Closes #3282", body); title carries the literal "[CTX-1919]" prefix; labels fix / P2 / area:runtime; milestone v0.1.0.

9. CI snapshot (record only). At review time: 8 pass, 8 pending, 3 skipping (CodeQL / VM tier main / VM tier nightly ARM64). Pending legs were not waited on and do not affect this verdict.

10. Reviewed head. 17e5ada — quoted at the top and re-read from the API after the final check; unchanged, so this review is not stale.

Residual non-blocking observations (not part of the verdict):

  • A row band's hit rect still spans the full granted width (the unclaimed trailing region past the painted text hits). This is pre-existing, documented behavior (band_host.rs:2378-2384) and unchanged by this PR; the parity criterion concerns rows.
  • The BandPixels doc line "paint emits a fill at exactly this rect (so the rect is the band's damage)" (band_geometry.rs:72-74) predates the granted-rect vs painted-cell-row split; cell_row's own docs describe the split correctly, but that older line could use a touch-up in a follow-up.
  • content_drop re-derives the height - cell_h slack that cell_row also computes; a future refactor could share the arithmetic. No action needed.

VERDICT: APPROVE

@Xuepoo
Xuepoo merged commit e365129 into main Nov 20, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1919/fix-band-content-row branch November 20, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Area: runtime orchestration fix Bug fix P2 Priority: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[runtime] Bottom band pools the sub-cell remainder inside the painted capsule strip

1 participant