Skip to content

An embedding API so another runtime can drive a Rune tree (wasm and desktop) #2555

Backlog

Description

@artile

Clanked by Opus 5.5

Problem. Rune can only be driven from Rust. A UI runtime written in JavaScript, such as Effect UI (Effect-TS/ui), cannot render through Rune without its own glue. To try it, we wrote a small wasm-bindgen crate that exposes mount, send(tree), want_rects and unmount, takes the element tree as JSON each commit, and returns press, input (with a seq counter), submit, focus and layout-rect events. On desktop we did the same over stdio with a child process. Both work: a JS app with a counter, a keyed list of 1,000 rows and a controlled input rendered and handled events through Rune.

Ask. A small, supported embedding API for other runtimes, on the web (wasm) and on desktop:

  • create an app into a given canvas (or window) and get a handle;
  • replace or patch the element tree from outside (a patch format would avoid sending the whole tree each commit: 7 ms of JSON at 1,000 rows, 20 ms at 3,000);
  • receive input events and layout rects with stable element keys;
  • destroy the handle.

Why here. Each outside runtime will otherwise write and maintain its own unofficial bridge against internal APIs that change daily. Related: several apps per page (#2553).

Activity

  1. opencodejr commented on Nov 27, 2026

    @opencodejr
    Contributor

    checked crates/rune/src/app.rs, crates/rune/src/app/web.rs, crates/rune/src/platform/web/page.rs, crates/rune/src/platform/embed.rs, crates/rune/src/runtime/commit.rs, crates/rune/src/memo.rs, and crates/rune-luau/. today rune only drives views from rust (AppSpec<S> returning El, with memo / virtual_rows for subtree reuse and embed::LayerHost limited to apple CAMetalLayer); crates/rune-luau is the only non-rust ui layer, and web is still one app per page (#2553). PLAN.md (§3, §6c) leaves a serializable patch/command boundary as future work, so adding a supported external-runtime embedding api needs two design calls first:

    1. packaging and desktop transport: should this live in a new companion crate (like rune-luau) exposing a rust retained-tree host plus wasm-bindgen bindings on web, and on desktop should rune support a c abi, a stdio/ipc host binary, or just the rust host crate for runtimes to wrap?
    2. patch protocol and v1 surface: should v1 use an incremental flat-id op/patch format (create/update/move/remove, avoiding full-tree json) over a minimal core set of nodes and events (boxes, text, controlled text input with seq, press/focus/submit/layout rects), or align its node/prop vocabulary with rune-luau's @rune/ui schema?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions