Skip to content

test: reactive ui in Rune - #726

Open
makspll wants to merge 4 commits into
agent/reactive-ui-templatesfrom
agent/reactive-ui-rune
Open

makspll wants to merge 4 commits into
agent/reactive-ui-templatesfrom
agent/reactive-ui-rune

Conversation

@makspll

@makspll makspll commented Nov 13, 2026

Copy link
Copy Markdown
Owner

The reactive ui in Rune: the inventory test ported (assets/tests/reactive_ui/inventory_rune, same steps as the Lua one, including the reload) and benchmarks (Components Rune / Template Rune variants of every scenario, with the rune feature).

Nothing in the crate is specific to a language, what Rune needed went into the PRs below: names which are not Rune keywords (when, selected, #714) and dependency lists (#724), since Rune closures handed to BMS can't capture signals or entities.

fn slot(name, entity, is_selected, selected) {
    let ui = import_namespace("reactive_ui");
    let item = ui.watch(entity, state()["Item"]);
    ui.node(#{
        name: `slot_${name}`,
        background_color: ui.when(ui.selected(is_selected, name), "#ffcc00", "#333333"),
        on_click: [|selected, name| selected.set(name), selected, name],
    }, [
        ui.text(#{ text: ui.format("x{}", [ui.path(item, "data.count")]) }),
    ])
}

Rune behaviours the scripts work around (for the docs):

  • a closure ending in a bare local returns nothing: return out;
  • a string can't be compared with (): match
  • if without else as the last expression is ()
  • definitions are kept in state() and defined once in main: calling ui.component again re-renders its instances

First numbers (one round, same machine as the Lua numbers of #725):

bench Components Rune Template Rune Closures Lua Template Lua
inventory mount or unmount 200 4.35 ms 0.83 ms 1.78 ms 0.90 ms
inventory search 3.68 ms 0.79 ms 1.49 ms 0.79 ms
inventory add or remove one 218 µs 178 µs 125 µs 173 µs
inventory select 37 µs 51 µs 22.8 µs 24.4 µs
inventory item count 5.1 µs 5.9 µs 7.7 µs
health tick 8.7 µs 8.6 µs

Components cost 2.4x what they do in Lua (every function call passes its dependencies, and Rune's calls into BMS are slower), templates cost the same in both: no script code runs per row.

@semanticdiff-com

semanticdiff-com Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  assets/macro_benchmarks/reactive_ui/inventory.rn Unsupported file format
  assets/tests/reactive_ui/inventory_rune/inventory.rn Unsupported file format
  assets/tests/reactive_ui/inventory_rune/scenario.bmsscenario Unsupported file format
  benches/benchmarks.rs  0% smaller

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBevy Scripting
Branchagent/reactive-ui-rune
Testbedlinux-gha

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

This branch has not been deployed

No deployments
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