Repository navigation
[CTX-1419] feat(ui): reconcile Lua UI composition parity (#2191) - #2385
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 33 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 |
Xuepoo
left a comment
There was a problem hiding this comment.
Review: [CTX-1419] feat(ui): honor overlay style and pin Lua UI parity matrix (#2191)
Verdict: LGTM — the overlay paint path now honors fg/bg/bold through the same closed band token table, the unstyled fast path is preserved byte-for-byte, and the new parity matrix is a real coverage increase with no contract widening.
Reviewed at 18f116d638eebfc8aa021288d359897789c00b5e (4 files, +1356/−64).
Contract checks
- (a) slot set / registration — unchanged.
UiSlotstill carries exactly the accepted closed set (terminal | top | bottom | left | right | tabline | statusline | overlay) atcrates/bitty-lua/src/ui.rs:68-88; the diff adds no variant, no panel registration, no provider hook (git show --stat=ui.rs,ui_bridge.rs,present.rs,lua_ui_parity.rsonly). - (b) component kinds — no widening.
UI_V1_NODE_KINDSstays["Text","Row","Column","List"]andfrom_lua_value(ui.rs:648-677) still matches only those four names; nothing richer is introduced or labelled v1. - (c) capability gating — unchanged and not narrowed.
ui_mountstill gates the L2 surface onui.richand the overlay slot additionally onui.overlay(crates/bitty-runtime/src/plugin_runtime/services.rs:3495-3509), and the update path keeps theui.richgate (:3545). The paint path stays behindset_plugin_overlay, so style painting adds no new grant surface. The doc text explicitly declines to claim overlay click/scroll routing ("not part of the accepted contract yet"), which is the right call. - (d) numeric limits — no invented numbers. New code adds no budgets; the parity test pins the existing constants at the boundary and one past it (
UI_MAX_DEPTH,UI_MAX_NODES,UI_MAX_TEXT_BYTES).UI_MAX_NODES = 2048,UI_MAX_TEXT_BYTES = 256 KiB,UI_MAX_BLOCKS = 64,UI_MAX_AGGREGATED_TEXT_BYTES = 2 MiBall match the accepted scene limits. There is no docs diff in this PR, so nothing was asserted in prose. - (e) hygiene — the diff is on-topic, no debug leftovers (
dbg!/println!/TODO/FIXME) in the new 934-line test file, and the removedextract_text_from_nodewalk has no remaining callers in the touched crate.
Non-blocking notes
UI_MAX_DEPTH = 16(crates/bitty-lua/src/ui.rs:136) is stricter than the accepted scene depth of 32. This is pre-existing and documented in the module header as a deliberate bridge-side budget, and this PR neither changes nor re-litigates it — flagging only so the disparity is not mistaken for drift introduced here.crates/bitty-lua/src/ui.rs:305-311corrects theClickCommandrustdoc from "max 8 args" toUI_CLICK_MAX_ARGS(= 16). The constant is unchanged, so this is a doc/const reconciliation — worth confirming that 16 (not 8) is the intended accepted value, since the old prose said otherwise.OverlayRow.runsretains command bindings that the overlay paint path deliberately does not route. That is documented in the struct comment, but a future routing change should revisit it rather than assumerunsis purely stylistic.
CI (verbatim, gh pr checks 2385)
All legs pass except Windows check and test — pending; VM tier (main) and VM tier (nightly ARM64) are skipping. No failures: Analyze (actions) pass, Analyze (rust) pass, CodeQL pass, CodeRabbit pass (rate limited), Extension pin drift pass, Linux Wayland pass, Linux X11 (xvfb) pass, Supply chain (deny/audit) pass, VM tier (PR) pass, MSRV 1.85 check pass, Quality gates (1) pass, Quality gates (2) pass, macOS ARM64 check and test pass.
Per instructions I did not run cargo/just locally; the verdict rests on the diff, the gating call sites, and the reported CI state. Re-check the pending Windows leg before merge.
Independent review outcome (CTX-1419)Verdict on the reviewed head Findings
Verified good
Notes
Refs #2191 |
…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
…tion (#2191) (#2392) * [CTX-1419] fix(ui): keep overlay pill chrome and inherit root declaration 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 * [CTX-1419] fix(ui): give the empty overlay pill a one-cell width (#2191) * [CTX-1419] fix(ui): drop useless conversions, pin root binding propagation 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
Priority: P1 | Area: ui | Labels: feat,P1,area:ui,area:plugins | Milestone: v0.1.0 | RFC: chrome-surface-api-candidate.md / chrome-band-contract-candidate.md | Task: CTX-1419
Goal
Reconcile the bounded Plugin API v1 Lua UI composition surface with actual Core host behavior for #2191, implement only well-specified parity fixes, and record ambiguous parts as a design note instead of inventing vocabulary.
This PR adds no node kind, property, capability, slot, or error code.
What was audited
crates/bitty-lua/src/ui.rs— v1 kinds (Text/Row/Column/List),fg/bg/bold,on_click/on_scroll, per-itemregion, typedE_UI_COMPONENT_INVALID, and every bound (UI_MAX_DEPTH,UI_MAX_NODES,UI_MAX_TEXT_BYTES, per-generation blocks/aggregate, command/arg/token/region caps).crates/bitty-runtime/src/runtime/band_host.rs,band_slots.rs,present.rs— flatten/inheritance, token resolution, bold double-strike, click/scroll/region routing, overlay paint.crates/bitty-runtime/src/plugin_runtime/services.rs— mount/update gates, block registry budgets.chrome-surface-api-candidate.md,chrome-band-contract-candidate.md,sdk/reference/ui.md.Parity fixes in this PR
overlayslot accepts the sameUiNodevocabulary as a band, butpaint_plugin_overlayrendered only theme defaults:fg/bg/boldwere silently dropped. Overlay rows now paint per flattened run through the same closed host token table as bands (resolve_band_token), with the same synthetic bold double-strike and the same unknown-token fallback +BandHostStats::unknown_tokenscounting.overlay_text_glyphscall), so existing composer/palette scenes are unchanged.OverlayRow/overlay_scene_rowsnow reuseflatten_band_runs, so the two hosted surfaces cannot disagree about inheritance.ui.rs.ClickCommandclaimed "max 128 bytes" command ids and "max 8 args" while the code enforces 64-byte ids and 16 args; corrected to reference the constants, and the module docs now name the additive style/interaction vocabulary and the overlay parity boundary.Tests
New
crates/bitty-runtime/tests/lua_ui_parity.rs(Lua table →UiNode::from_lua_value→ host observation, the exact validator the bridge calls):every_v1_kind_accepts_and_renders— each kind accepted; declared text/style/click/scroll/region reaches the effective span (container inheritance proven forRow/Column/List).property_matrix_drop_one_fails— mutation check: dropping exactly one accepted property (fg,bg,bold,on_click,on_scroll,region) changes the host observation, so the matrix cannot pass vacuously.unsupported_components_fail_typed— 26 cases: excluded/unknown kinds, malformed text/children/style/bindings/args/regions, mismatched click/scroll regions; allvalidation/E_UI_COMPONENT_INVALID.bounds_fail_closed— exact edge accepted and one over rejected for depth (16), nodes (2048), text bytes (256 KiB).slot_placement_is_exhaustive— every accepted slot maps toBand/Overlay/Unsupported; unhosted slots produceruntime/E_UI_UNAVAILABLE;statuslineis not a slot.click_and_scroll_route_through_commands/legacy_span_keeps_primary_button_and_args/regions_are_derived_from_painted_spans— real frame geometry → declared command; host-ownedregion/button/deltamerged last; legacy spans keep the primary-button-only payload; foreign qualifiers denied; region rects clipped to the window.hot_path_is_pure_data— flatten, region emission, and hit-testing run with noPluginRuntime/VM.chrome_gestures_keep_terminal_authority— chrome click/scroll moves no focus or layout, starts no selection, and routes declared args only (no coordinates).crates/bitty-lua/tests/ui_bridge.rsgainslua_component_carries_every_accepted_property(real Lua VM spelling → capturedUiNode, plus a drop-one mutation), andpresent.rsgains five overlay paint tests (token resolution, bold double-strike, unknown-token fallback, unstyled multi-run fast path, styled per-run fills).Verification
just fmt-check— pass.just clippy(workspace, all targets,-D warnings) — pass.cargo nextest run --workspace --locked— 7745 passed, 3 skipped.cargo test --workspace --doc --locked— pass.just scratch-paths— OK.cargo test -p bitty-lua -p bitty-runtime --locked— pass (including 11 new parity tests and 12 overlay paint tests).Local limitation (reported, not hidden): the full
just testrecipe andjust ci-localcould not complete on this host.ci-local/actis prohibited by the task instruction; the remainingjust testlegs were interrupted when the shared/mnt/datafilesystem hit 100% while linking workspace test binaries (concurrent agent builds), not by a test failure. Remote CI on this head is the acceptance gate for the platform/render legs.Not in this PR — documented remainder (design note on #2191)
These are ambiguous or unaccepted contracts; guessing would widen the API:
Column/Listinside a one-row band still flatten horizontally, while the overlay stacks direct children as rows. Multi-row band layout needs an accepted layout/thickness decision and a taller band host.on_click/on_scrollare accepted and retained on the node but not routed: there is no accepted overlay hit-test/geometry contract. Click/scroll routing stays band-only.foreground,background,cursor,selection,accentand falls back on other well-formed names with a counter. Fail-closed unknown-token rejection would narrow behavior before the theme token contract is accepted.tooltipand general layout/style properties (width,padding, ...) are not accepted; unknown optional fields remain tolerated for the accepted additive-minor-version rule.SCN-4/SCN-5aggregation andBAND_MAX_NODES_PER_FRAMEper-frame cap are not implemented; the bridge enforces the same numbers per generation as a strict subset.Docs sync (plugins SDK reference, terminal-platform candidate note, bitty-manual) lands in the owning documentation repositories against the merged commit from this PR.
Refs #2191