Repository navigation
[CTX-1841] fix(runtime): report presented for a painted column band (bitty#2191) - #3181
Conversation
…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).
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Xuepoo
left a comment
There was a problem hiding this comment.
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-200says "a zero width means every child flattened to nothing". Probed in my copy:UiNode::text("\u{200B}\u{200B}")givesband_is_visible == true,column_band_width == 0, left budget(0,0),visible_band_column_count(Left) == 0— sopresented = truefor 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
leftbands: budgetleft = 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 reportspresented = true. Worth naming "edge share exhausted (stacking order)" in the residual, or filing the follow-up that makespresenteda 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
What was wrong
bitty.ui.state(handle)reportedpresented = falsefor a chrome band that thehost 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_rulecrates/bitty-runtime/src/plugin_runtime/services.rs:3377—ui_block_statePre-fix that table was:
left/rightwere 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
Columnscene thatui_slot_placementroutes toUiSlotPlacement::Band(BandEdge::Left/Right), thatband_scene_matchesadmits, thatcolumn_band_plangrants columns to, and thatpaint_chrome_bandspaints row-by-row, fell into theNeverPresentedarm andreturned
presented: false, focused: false. The mount itself succeeded, so theplugin was told "your band exists but is not on screen" while it was on screen.
The fix
SlotStateRule::BandVisibilitynow covers both band axes:The rule is the content gate the paint path already uses
(
band_is_visible,band_host.rs:611): presented iff the flattened band contenthas text. The axis decides the painted shape (one row per band vs one row per
root child of a
Column/Listroot), not whether anything paints. That issound on the column axis because a column band's thickness is
column_band_width(the widest root child,band_host.rs:624): non-emptycontent ⇒ 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_focusedwiring.No new capability, verb, or public API — only the existing private-ish
SlotStateRuletable changed value for two hosted slots.The existing
tabline_has_no_band_visibility_ruleunit test was retargeted, notweakened: its "only row bands use the content rule" clause (which encoded the
bug) is replaced by two axis-neutral assertions over all slots —
BandVisibilityiff the placement is
Band(_), andNeverPresentediff the placement isUnsupported(_)— plus the unchangedtabline/overlayassertions. That isstrictly 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, testui_state_reports_presented_for_a_painted_column_band, drives the plugin bridgeend to end (
bitty.ui.mount→bitty.ui.stateon a Lua plugin) and then feedsthe same live mounts (
ui_blocks_with_handles→ChromeBands::from_mounts/BandMount) to a realRuntimewith a 120×40 window, so the flag is comparedagainst a committed band:
plugin_band_column_budget() == (7, 3)andvisible_band_column(Left, 0) == Some(0),visible_band_column(Right, 0) == Some(113)— the column ranges that reserveand clip the paint;
BandEdge::Leftand oneBandEdge::Rightorigin published by thepresented frame, carrying those columns (
published_band_origins), while twomounts exist per those edges (the contentless one committed nothing);
visible_band_count(Top) == 1/visible_band_row(Top, 0) == Some(0)— therow band path is unchanged.
False cases asserted in the same test: contentless column band
(
Column[Text ""]) and contentless row band staypresented = false(
focused = false); aRowroot offered toleftstaysE_UI_COMPONENT_INVALIDand stores no block (ui_blocks_with_handles().len() == 5,not 6); emptying the live left band via
ui.updateflips it tofalseandrestoring 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):Post-fix (sources restored,
sha256sum -cOK):Gates
Neighbouring band suites, re-run because the rule covers their slots:
No
Cargo.tomldependency edge changed, so noCargo.lockmovement.Residual
presentedis a content predicate, matching the row bands' pre-existingsemantics, not a per-frame compositor grant. A column band in a window too
narrow for any column share (
column_band_plangrants nothing), or a row bandin a window too short for its row budget, still reports
presented = truewhile the paint path skips it. That asymmetry is unchanged for
top/bottomand newly symmetric for
left/right; making the flag a true per-frame grantneeds a band-geometry source shared into
PluginServices(it currently onlygets a window-focus flag) — out of scope here and a new surface, so not done.
band_is_visiblestays the single content gate; whether a zero-width columnband should instead be reported through a distinct rule variant is not worth a
second variant while the two predicates coincide by construction
(
hover/region/originpaths already treat them identically).BandOverlayAnchorresolves hover tooltips against arow 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