Skip to content

[CTX-1841] fix(runtime): report presented for a painted column band (bitty#2191) - #3181

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1841/band-presented
Nov 15, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1841/band-presented

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

bitty.ui.state(handle) reported presented = false for a chrome band that the
host paints in a column slot (left/right).

The presentation rule lived in one table next to the placement decision:

  • crates/bitty-runtime/src/runtime/band_slots.rs:205 — slot_state_rule
  • consumed at crates/bitty-runtime/src/plugin_runtime/services.rs:3377 — ui_block_state

Pre-fix that table was:

match slot {
    UiSlot::Top | UiSlot::Bottom => SlotStateRule::BandVisibility,
    UiSlot::Overlay => SlotStateRule::OverlayCapture,
    UiSlot::Tabline | UiSlot::Left | UiSlot::Right | UiSlot::Terminal => {
        SlotStateRule::NeverPresented
    }
}

left/right were still grouped with the unhosted slots (tabline,
terminal) — a leftover from before the vertical band host took them in #3165.
So the flag keyed on slot identity, not on content: a Column scene that
ui_slot_placement routes to UiSlotPlacement::Band(BandEdge::Left/Right), that
band_scene_matches admits, that column_band_plan grants columns to, and that
paint_chrome_bands paints row-by-row, fell into the NeverPresented arm and
returned presented: false, focused: false. The mount itself succeeded, so the
plugin was told "your band exists but is not on screen" while it was on screen.

The fix

SlotStateRule::BandVisibility now covers both band axes:

UiSlot::Top | UiSlot::Bottom | UiSlot::Left | UiSlot::Right => SlotStateRule::BandVisibility,

The rule is the content gate the paint path already uses
(band_is_visible, band_host.rs:611): presented iff the flattened band content
has text. The axis decides the painted shape (one row per band vs one row per
root child of a Column/List root), not whether anything paints. That is
sound on the column axis because a column band's thickness is
column_band_width (the widest root child, band_host.rs:624): non-empty
content ⇒ non-zero width the column plan can grant, and zero width ⇒ every child
flattened to nothing, i.e. the same empty content this gate refuses.

Untouched: layout, exclusive-zone/bounds arithmetic, stacking, diagnostics, the
mount and update gates, and the focused = presented && window_focused wiring.
No new capability, verb, or public API — only the existing private-ish
SlotStateRule table changed value for two hosted slots.

The existing tabline_has_no_band_visibility_rule unit test was retargeted, not
weakened: its "only row bands use the content rule" clause (which encoded the
bug) is replaced by two axis-neutral assertions over all slots — BandVisibility
iff the placement is Band(_), and NeverPresented iff the placement is
Unsupported(_) — plus the unchanged tabline / overlay assertions. That is
strictly more coverage (it now pins all four edges) and no assertion was
dropped.

Why the painted slot really is painted (test, not prose)

crates/bitty-runtime/tests/band_column_presented.rs, test
ui_state_reports_presented_for_a_painted_column_band, drives the plugin bridge
end to end (bitty.ui.mount → bitty.ui.state on a Lua plugin) and then feeds
the same live mounts (ui_blocks_with_handles → ChromeBands::from_mounts /
BandMount) to a real Runtime with a 120×40 window, so the flag is compared
against a committed band:

  • plugin_band_column_budget() == (7, 3) and visible_band_column(Left, 0) == Some(0),
    visible_band_column(Right, 0) == Some(113) — the column ranges that reserve
    and clip the paint;
  • exactly one BandEdge::Left and one BandEdge::Right origin published by the
    presented frame, carrying those columns (published_band_origins), while two
    mounts exist per those edges (the contentless one committed nothing);
  • visible_band_count(Top) == 1 / visible_band_row(Top, 0) == Some(0) — the
    row band path is unchanged.

False cases asserted in the same test: contentless column band
(Column[Text ""]) and contentless row band stay presented = false
(focused = false); a Row root offered to left stays
E_UI_COMPONENT_INVALID and stores no block (ui_blocks_with_handles().len() == 5,
not 6); emptying the live left band via ui.update flips it to false and
restoring it flips it back, so the flag follows content rather than the slot.

A/B red/green (same test, same target dir)

Pre-fix (both fixed source files reverted to HEAD, test file present):

running 1 test
test ui_state_reports_presented_for_a_painted_column_band ... FAILED

failures:

---- ui_state_reports_presented_for_a_painted_column_band stdout ----

thread 'ui_state_reports_presented_for_a_painted_column_band' (1388362) panicked at crates/bitty-runtime/tests/band_column_presented.rs:248:5:
a painted left column band must report presented = true

failures:
    ui_state_reports_presented_for_a_painted_column_band

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
error: test failed, to rerun pass `-p bitty-runtime --test band_column_presented`

Post-fix (sources restored, sha256sum -c OK):

running 1 test
test ui_state_reports_presented_for_a_painted_column_band ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s

Gates

$ cargo fmt --all --check
fmt exit=0
$ cargo clippy -p bitty-runtime --all-targets --offline -- -D warnings
    Checking bitty-runtime v0.0.42 (...)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 29.86s
clippy exit=0
$ cargo test -p bitty-runtime --test band_column_presented --offline
running 1 test
test ui_state_reports_presented_for_a_painted_column_band ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s
$ cargo test -p bitty-runtime --lib band --offline
test result: ok. 63 passed; 0 failed; 0 ignored; 0 measured; 1604 filtered out; finished in 0.10s
$ cargo +1.85 check -p bitty-runtime --tests --offline
    Checking bitty-runtime v0.0.42 (...)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 31.61s
$ RUSTFLAGS="-D warnings" cargo check -p bitty-runtime --tests --target x86_64-pc-windows-gnu --offline
    Checking bitty-runtime v0.0.42 (...)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 24.77s

Neighbouring band suites, re-run because the rule covers their slots:

plugin_ui                 26 passed; 0 failed
band_column_input          7 passed; 0 failed
band_four_edge_geometry    4 passed; 0 failed
chrome_bands_render       13 passed; 0 failed
band_groups_hover         21 passed; 0 failed

No Cargo.toml dependency edge changed, so no Cargo.lock movement.

Residual

  • presented is a content predicate, matching the row bands' pre-existing
    semantics, not a per-frame compositor grant. A column band in a window too
    narrow for any column share (column_band_plan grants nothing), or a row band
    in a window too short for its row budget, still reports presented = true
    while the paint path skips it. That asymmetry is unchanged for top/bottom
    and newly symmetric for left/right; making the flag a true per-frame grant
    needs a band-geometry source shared into PluginServices (it currently only
    gets a window-focus flag) — out of scope here and a new surface, so not done.
  • band_is_visible stays the single content gate; whether a zero-width column
    band should instead be reported through a distinct rule variant is not worth a
    second variant while the two predicates coincide by construction
    (hover/region/origin paths already treat them identically).
  • Separate, still tracked: BandOverlayAnchor resolves hover tooltips against a
    row band only (issue [0.1.0][area:ui] Route input to the left/right chrome bands and bound an unfittable band #3171 known gap).

Related #2191

Summary by CodeRabbit

  • Bug Fixes
    • Left and right column bands now report their presentation state consistently with top and bottom bands. Bands with content are reported as presented, empty bands remain unpresented, and hiding or restoring a band updates its reported state.
    • Column bands now follow the same visibility rules as row bands, while invalid row-shaped content remains rejected in a column slot.

…bitty#2191)

`slot_state_rule` still grouped `left`/`right` with the unhosted slots
(`tabline`, `terminal`), so `ui.state` reported `presented = false` for a
column band the vertical band host admits at mount, grants columns to, and
paints. The rule now keys on the band content gate (`band_is_visible`) for both
axes, exactly like the row bands: the axis decides the painted shape (one row
per band vs one row per root child), not whether anything paints, and a
column band's thickness is the widest root child, so non-empty content is
exactly what the column plan can grant.

The false cases stay false: contentless bands (flattened text empty, hence
zero width), the `E_UI_COMPONENT_INVALID` direction-mismatch refusal, and the
unhosted slots. No layout, bound, or diagnostic changed.

Adds `tests/band_column_presented.rs`: a plugin-mounted `left`/`right` column
scene reports `presented`/`focused` true, emptying the band flips both to
false, and the same live mounts gain a granted column range plus a published
origin on a real `Runtime` (so the flag is checked against a committed band).
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Left and right bands now use the same content-based presentation rule as top and bottom bands. A new regression test checks their reported state, visibility changes, and runtime layout.

Changes: Column band presentation state

Layer / File(s) Summary
Apply presentation rules to column bands
crates/bitty-runtime/src/runtime/band_slots.rs, crates/bitty-runtime/src/plugin_runtime/services.rs
Left and right slots now use the BandVisibility rule. Comments and unit tests describe and check the rule across band and unsupported placements.
Verify column band state and layout
crates/bitty-runtime/tests/band_column_presented.rs
The regression test checks presentation and focus state for populated and empty bands, hide and restore behavior, invalid placement, and runtime layout and origins.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

  • bitty-terminal/bitty#2478 — Its vertical-layout tracking includes left and right band behavior, which this change addresses in part.

Possibly related PRs

  • bitty-terminal/bitty#3119 — It introduced the bitty.ui.state query and band presentation rules that this change extends to left and right bands.

Suggested labels: fix, area:runtime

Merge Risk: Minimal · up to d9d2a

Left and right bands now report presented state from their content, matching top and bottom bands. The change is narrow and comes with a regression test. No merge-blocking risk was found.

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: column (left/right) bands now report presented when painted, which matches the summary's change to band visibility and the new column-band regression test. The title's…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: column (left/right) bands now report presented when painted, which matches the summary's change to band visibility and the new column-band regression test. The title's "fix(runtime)" prefix and ticket tag are acceptable. The title is about 80 characters, which is slightly long but still clear and specific.

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: ac250fd2-9e65-4cb1-84d8-6502c6374997
Commits

Reviewing files that changed from the base of the PR and between 631f1f9 and d9d2adc.

Files selected for processing: 3

  • crates/bitty-runtime/src/plugin_runtime/services.rs
  • crates/bitty-runtime/src/runtime/band_slots.rs
  • crates/bitty-runtime/tests/band_column_presented.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 guard review (third-party agent, read-only)

Reviewed d9d2adc0ba787c14fb75546f72d3ea5be662292a (base 631f1f9c). Head was re-read immediately before posting and had not moved. I did not wait on CI.

# Check Verdict Evidence
1 Defect reality PASS base band_slots.rs:205-212: Top|Bottom => BandVisibility, Tabline|Left|Right|Terminal => NeverPresented, while base :161 already routed Left => Band(Left). Head band_slots.rs:222-227 splits the arm. The flag was keyed on slot identity, and the pre-fix comment ("No host surface in this build", base :210) was already false for left/right after #3165 — cause as stated.
2 Fix soundness PASS services.rs:3377-3390 still calls the same one gate band_is_visible (band_host.rs:611), which is the predicate visible_edge_bands/paint filter on (present.rs:6281, band_host.rs:2007-2040). Empty content ⇒ never in the paint plan, so no false negative is possible by construction; fully-empty column content also gives column_band_width == 0 and is skipped by column_band_plan. Counterexamples probed, see R1/R2 — both are over-report, not under-report.
3 No collateral change PASS Diff is 3 files, +450/−33. Row path identical (top/bottom already BandVisibility); Overlay/Tabline rules unchanged; no geometry, budget, diagnostics, capability or error-code touch. Retargeted test band_slots.rs:632-676 drops nothing: old "unsupported ⇒ NeverPresented" is kept and strengthened to iff; only the "only row bands" clause (which encoded the bug) is replaced by an all-edges clause.
4 Test discrimination PASS Independently reproduced, not taken from the body: copied head into my own scratch, reverted only the two src files from d9d2adc0^, separate CARGO_TARGET_DIR. Red at tests/band_column_presented.rs:248: a painted left column band must report presented = true. Restored head files (sha256 eed09de…/7e5663c…, identical to lane) → ok, 1 passed in 0.10s.
5 Gates / platform PASS Re-ran locally: fmt --check clean for the three PR files; clippy -p bitty-runtime --all-targets -D warnings clean (27.3s); targeted test green; --lib band 63 passed; cargo +1.85 check --tests ok; RUSTFLAGS=-D warnings … --target x86_64-pc-windows-gnu --tests ok (24.8s). No let-chains, no new cfg, div_ceil/is_some_and are pre-1.85.
6 Scope + honest residual PASS No Cargo.toml/Cargo.lock movement, no reformatting outside the touched hunks. Residual correctly frames presented as a content predicate, not a compositor grant — though its trigger is stated more narrowly than reality (R2).

Residuals (non-blocking)

  • R1 — doc claim is false for zero-width content. band_slots.rs:196-200 says "a zero width means every child flattened to nothing". Probed in my copy: UiNode::text("\u{200B}\u{200B}") gives band_is_visible == true, column_band_width == 0, left budget (0,0), visible_band_column_count(Left) == 0 — so presented = true for a band with zero thickness. Same residual class as the disclosed one, but the doc sentence should be softened (zero cell width, not empty flatten).
  • R2 — residual trigger is understated. The body limits the "reports true while unpainted" case to "a window too narrow for any column share". It is wider: any inward band past its edge's share. Probed 120×40 with three 30-column left bands: budget left = 60, visible_band_column_count(Left) == 2, visible_band_column(Left, 2) == None — the third contentful band is dropped while the window is roomy and still reports presented = true. Worth naming "edge share exhausted (stacking order)" in the residual, or filing the follow-up that makes presented a grant.
  • Neither breaks the acceptance contract of this PR (no false negatives, content gate matches the paint gate); both are the direction the body already declares out of scope. Not requesting changes.

VERDICT: APPROVE

@Xuepoo
Xuepoo merged commit a8abf31 into main Nov 15, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1841/band-presented branch November 15, 2026 19:19
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