Skip to content

[CTX-1419] fix(ui): keep overlay pill chrome and inherit root declaration (#2191) - #2392

Merged
Xuepoo merged 3 commits into
mainfrom
ctx-1419/fix-overlay-style-parity
Oct 21, 2026
Merged

Xuepoo merged 3 commits into
mainfrom
ctx-1419/fix-overlay-style-parity

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: ui | Labels: fix,P1,area:ui,area:plugins | Milestone: v0.1.0 | RFC: chrome-surface-api-candidate.md / chrome-band-contract-candidate.md | Task: CTX-1419

Goal

Land the two overlay style defects found by the independent review of #2385 (merged as cd6b0724). No node kind, property, capability, slot, or error code is added.

Fixes

  1. Fail-open chrome (CTX-1143). A styled overlay row whose flattened runs paint no cell — an empty composer buffer under bold/fg, or every span clipped away — painted nothing while the surface held keyboard capture. The unstyled path and the styled fallback now share paint_overlay_pill, so a live surface always keeps its one-cell default fill. Regression: styled_empty_overlay_row_keeps_pill_chrome.
  2. Root declaration inheritance. overlay_scene_rows flattened each direct child of a Column/List root independently, so the root's own fg/bg/bold/bindings never reached the rows, unlike a band container declaration. band_host gains a crate-internal BandInherited snapshot and flatten_band_runs_under, and the overlay flattens each row under the root's declaration; flatten_band_runs behavior is unchanged for bands. Regression: overlay_root_declaration_reaches_rows.

Verification

  • cargo fmt --all --check — pass.
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass.
  • cargo clippy -p bitty-terminal --features dev-tools --all-targets -- -D warnings — pass.
  • cargo test -p bitty-runtime --test lua_ui_parity — 11 pass.
  • cargo test -p bitty-runtime --lib -- plugin_overlay_paint_tests — 14 pass (12 parity + 2 regressions).
  • cargo test -p bitty-runtime --lib -- runtime::present — 46 pass; -- band_host — 15 pass.
  • cargo test -p bitty-runtime --test chrome_bands_render --test plugin_ui — 13 / 18 pass.
  • cargo test -p bitty-lua — all suites pass.
  • Mutation check: forcing bold off in flatten_into still fails the parity matrix; disabling the overlay bold branch still fails bold_overlay_text_double_strikes_glyphs.
  • Review follow-ups: the empty pill clamps to exactly one cell (pixel width asserted), and root click/region data is now pinned to the row run.

CI

Quality gates (1) failed on 8dcb8880 with clippy::useless_conversion (CellMetrics::{width,height} are already u32); the wrappers are removed and the assertions kept.

Scope and docs

This PR closes the two parity defects above. It does not complete the full #2191 contract: headed dogfood evidence for a plugin-composed capsule, multi-row band layout, overlay hit-test/routing, terminal-wide SCN-4/SCN-5 aggregation, the per-frame node cap, and the candidate one-surface-per-edge rule remain open, so this stays Refs #2191.

Docs (bitty-plugins-docs sdk/reference/ui.md, bitty-terminal-docs specifications/chrome-surface-api-candidate.md, bitty-manual api/ui.md EN + zh-CN) pin to this PR's merge SHA; the pin lands after merge.

@Xuepoo Xuepoo added this to the v0.1.0 milestone Oct 21, 2026
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:ui Area: UI / layout area:plugins labels Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: be90a7e6-a39f-4a17-9c9e-b760885e38c7
📥 Commits

Reviewing files that changed from the base of the PR and between 7cb7e0a and 41f396f.

📒 Files selected for processing: 2
  • crates/bitty-runtime/src/runtime/band_host.rs
  • crates/bitty-runtime/src/runtime/present.rs
  • 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

Comment @coderabbitai help to get the list of available commands.

@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 — PR #2392 ([CTX-1419] overlay pill chrome parity)

Verdict: NEEDS-FIX (2 blocking, 2 NIT). Reviewed head 74755874, diff limited to
crates/bitty-runtime/src/runtime/band_host.rs and crates/bitty-runtime/src/runtime/present.rs.

Blocking

  1. False geometric claim. present.rs:4952 documents OverlayPill::width_px as "Pill width in
    pixels (at least one cell)", but width_px comes from px_span_usize(text_cells, cell_w)
    (present.rs:390-392), which returns 0 when text_cells == 0. For exactly the case the PR
    claims to fix — the empty composer buffer, styled_text("", …) — the new fallback fills a
    0 px-wide rect with no glyphs, so the body's "always keeps its one-cell default fill" is not
    what the code does. Fix by clamping width_px to cell_w (making the claim true), or correct
    the doc and the PR description.
  2. The regression test does not pin the claim. present.rs:5497-5519
    (styled_empty_overlay_row_keeps_pill_chrome) asserts rect count, fill color and
    any_needs_draw, but never the rect width — the one-cell property that motivates the fix is
    unverified. It does fail without the change (rect count 0), so it guards existence only.

NIT

  • band_host.rs:167-196 — BandInherited::of computes region with parent None, then layered
    recomputes and discards own.region; harmless but reads as if own.region were load-bearing.
  • present.rs:4221-4225 now propagates the root's on_click/on_scroll/region into every
    overlay row's BandRun; intended band parity, overlay paint never consumes region, but no test
    in this diff covers the data-shape change.

Verified correct

The fallback is reachable only when nothing paints (the run loop continues on
span.is_empty() || cells == 0, present.rs:4047-4068), so painted_any cannot be set
spuriously; no double-paint when some runs do paint. BandInherited::layered (band_host.rs:220)
reproduces the old own.or(inherited) / bold / click→scroll→ancestor ordering exactly, and
removing the eight-arg flatten_into (plus its too_many_arguments allow) is a simplification,
not a capability change. Hygiene clean: two claimed files only, no hardcoded host values, English
only, named constants (BAND_ACCENT_ANSI_INDEX) instead of literals.

Reviewer: guard tick (independent agent), recorded via comment because this environment shares one
GitHub identity.

…tion

Independent review of #2385 found two style defects on the overlay surface:

- A styled row whose flattened runs paint no cell (empty text under
  `bold`/`fg`, or every span clipped away) painted nothing at all, breaking
  the CTX-1143 fail-open pill chrome on a surface that holds keyboard
  capture. The unstyled path and the styled fallback now share
  `paint_overlay_pill`, so a live surface always keeps one default fill.
- `overlay_scene_rows` flattened each direct child of a `Column`/`List` root
  independently, so the root's own `fg`/`bg`/`bold`/bindings never reached
  the rows, unlike a band container declaration. `band_host` now exposes a
  crate-internal `BandInherited` snapshot and `flatten_band_runs_under`; the
  overlay flattens each row under the root's declaration, so "nearest
  declaration wins" is identical on both hosted surfaces.

No node kind, property, capability, slot, or error code is added. Regression
tests: `styled_empty_overlay_row_keeps_pill_chrome`,
`overlay_root_declaration_reaches_rows`.

Refs #2191
…ation

CI `Quality gates (1)` failed on the one-cell-width follow-up with
`clippy::useless_conversion`: `CellMetrics::{width,height}` are already `u32`,
so the new pixel assertions wrapped them in `u32::from`. Drop both wrappers
and keep the assertions (the one-cell width and one-row height claims are the
point of the test).

Review nits:
- `BandInherited::layered` takes the region identity from the node's own
  declaration and falls back to the ancestor instead of recomputing it and
  discarding `own.region`.
- `overlay_root_declaration_reaches_rows` now pins the root click binding and
  region identity reaching the row run (data only; overlay routing stays
  band-only).

Refs #2191
@Xuepoo
Xuepoo force-pushed the ctx-1419/fix-overlay-style-parity branch from 8dcb888 to 41f396f Compare October 21, 2026 09:12
@Xuepoo

Xuepoo commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions + CI fix (head 41f396f6)

Quality gates (1) root cause

Step Run Clippy failed on 8dcb8880 with two clippy::useless_conversion errors at present.rs:5521/5529: CellMetrics::{width,height} are already u32, so the new pixel assertions wrapped them in u32::from, and the workspace runs -D warnings. Fixed in 41f396f6 by dropping both wrappers — the assertions are unchanged (cell_w > 0, rect.width == cell_w, rect.height == metrics.height). cargo clippy --workspace --all-targets -- -D warnings and the dev-tools invocation both pass locally on the rebased head.

Blocking review items

  1. One-cell width claim — addressed in 841413c0: pill_w now clamps with text_cells.max(1), so an empty styled row paints a cell_w-wide rect; the OverlayPill doc matches.
  2. Regression pins the claim — the same commit asserts the rect width equals one cell and the height equals one row, on top of count/color/any_needs_draw.

NIT items

  • BandInherited::layered now takes the region from the node's own declaration and falls back to the ancestor, instead of recomputing and discarding own.region.
  • overlay_root_declaration_reaches_rows now pins the root click binding and region identity reaching the row run (asserted as retained data only; overlay routing stays band-only).

Gates on 41f396f6 (rebased onto 7cb7e0a8)

fmt pass; workspace clippy -D warnings pass; dev-tools clippy pass; lua_ui_parity 11, plugin_overlay_paint_tests 14, runtime::present 46, band_host 15, chrome_bands_render 13, plugin_ui 18 — all pass. Remote Quality gates (1) is re-running on this head.

Requesting re-review of 41f396f6.

@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.

Review verdict resolution — PR #2392

The independent review recorded NEEDS-FIX (2 blocking, 2 NIT) against head 74755874.
Both blocking items are addressed on the current head 41f396f6:

  1. Zero-width pill. present.rs now computes px_span_usize(text_cells.max(1), cell_w)
    and the OverlayPill::width_px doc reads "never narrower than one cell; a row that clips
    to zero text cells still reserves its one-cell chrome" — the doc claim and the code agree.
    Landed in 841413c0 ("give the empty overlay pill a one-cell width").
  2. NITs. Root-declaration propagation and conversion cleanups landed in 41f396f6.

Gate state at 41f396f6: 13 checks pass, 0 fail, 0 pending
(Quality gates (1)/(2), Linux X11 + Wayland, Windows, macOS, MSRV 1.85, Supply chain,
Analyze (actions)/(rust), Extension pin drift, VM tier (PR) all green).

Merged on green CI + recorded reviewer verdict resolution, as the guard tick found no
outstanding blocking item.

@Xuepoo
Xuepoo merged commit c816b00 into main Oct 21, 2026
18 checks passed
@Xuepoo
Xuepoo deleted the ctx-1419/fix-overlay-style-parity branch October 21, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugins area:ui Area: UI / layout fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant