Chapter 2 of 18

rata new and the first window

Every Elyra app starts the same way: rata new, a frontend build, rata codegen, and cargo run. Freddy does all four and then looks at what he got.

Getting rata

The guide starts after this step: it does not say how to install rata. What the repository does say is that rata is the binary of the ratatosk crate in the framework's repository, and since nothing is published to a registry, Cargo can install it straight from a release tag. This is plain Cargo, not a command from the guide, and it was run for this course against v0.50.2:

cargo install --locked --git https://github.com/kwhorne/elyra-framework --tag v0.50.2 ratatosk

The getting started guide lists what you need: Rust 1.94 or newer with Cargo, and Node.js 20.19+ or 22.12+ with npm for the frontend. rata help lists the commands.

rata new

rata new freddy-notes
cd freddy-notes

That generates a self-contained workspace. Freddy's has these files, which is what rata new 0.50.2 wrote when this course was made:

Cargo.toml          # depends on the framework's release tag
elyra.toml          # rata's configuration
.gitignore          # build output, and .elyra/ (chapter 11)
src/main.rs         # the app: App::new(), commands, providers
app/                # the Svelte 5 frontend (Vite)
  index.html
  package.json      # @elyra/runtime and @elyra/ui from the release
  vite.config.js
  svelte.config.js
  public/icon.svg   # the app's icon, in the About window
  src/main.js       # imports @elyra/ui's tokens.css
  src/App.svelte
  src/Router.svelte
  src/routes.js
  src/NavCount.svelte
  src/pages/Home.svelte
  src/pages/NotFound.svelte
  src/resources/index.js
  src/theme.js
  src/app.css

Three lines in it matter more than they look. Cargo.toml depends on the framework by tag, and app/package.json points @elyra/runtime and @elyra/ui, the framework's Svelte components, at the tarballs attached to the same release, because npm cannot install a subdirectory of a git repository:

elyra = { git = "https://github.com/kwhorne/elyra-framework", tag = "v0.50.2" }

"@elyra/runtime": "https://github.com/kwhorne/elyra-framework/releases/download/v0.50.2/elyra-runtime-0.50.2.tgz",
"@elyra/ui": "https://github.com/kwhorne/elyra-framework/releases/download/v0.50.2/elyra-ui-0.50.2.tgz"

src/main.rs names the app for the system, with .identifier(..) and .about(..), and its main returns elyra::Result<()>, so a configuration problem stops the app with a message before a window opens. Upgrading the framework later means moving all three to the new tag, and installing rata again from it. rata new --elyra <path> instead wires a project to a local checkout of the framework, for working on the framework itself.

The first run

rata new prints the next steps, and they are the guide's quick start:

(cd app && npm install && npm run build)   # build the frontend
rata codegen                                # generate typed bindings
cargo run                                   # launch

For this course the first three steps were run on a fresh project: the frontend built, rata codegen wrote app/src/bindings.ts, and the app compiled. cargo run then opens the window: titled freddy-notes, as src/main.rs sets it, with a Svelte page inside it and a single binary behind it.

While he works, Freddy does not want to rebuild the frontend for every change. rata dev runs the frontend's dev server next to the app, so a change to a Svelte file shows at once; the CLI page has the details. The getting started guide walks through the same steps.

The look

The window Freddy opened is dark. main.js imports @elyra/ui/tokens.css, the framework's design tokens: about twenty colours (--elyra-bg, --elyra-text, --elyra-accent and the rest), a radius, a spacing and a font, dark by default and light under data-theme="light". The scaffold's theme.js sets that attribute: auto follows the system, and light or dark is the user's choice, kept between launches. Freddy changes the accent in app.css, once per theme:

:root { --elyra-accent: #2ac3de; }
:root[data-theme="light"] { --elyra-accent: #0f7f93; }

Every @elyra/ui component is drawn from these tokens, and so is anything Freddy builds on them, so the whole app follows the theme together. The tokens page lists them; chapter 6 is where the components start doing his work.

What runs where

The architecture page explains what Freddy just started. The event loop and the webview live on the main thread, which macOS requires. Commands run on an async runtime, each on its own task, so a slow one never freezes the window. The page talks to Rust only through the bridge, and Rust pushes to the page through an event bus whose batches the frontend collects over a long-poll it holds open.

Why it feels fast. There is no interpreter between Freddy's code and the machine, and nothing on the bridge is JSON: arguments go over as a compact MessagePack array and results come back as MessagePack maps. Chapter 3 is about writing the code on both ends of that bridge.

What you learned

  • rata is the ratatosk crate's binary; the guide does not document installing it, and plain Cargo can install it from a release tag.
  • rata new scaffolds a Rust app and a Svelte 5 frontend that depend on one release, by tag and by two tarballs, @elyra/runtime and @elyra/ui.
  • The first run is: build the frontend, rata codegen, cargo run; rata dev keeps the frontend live while you work.
  • The window lives on the main thread, and each command on its own task.
  • The look is @elyra/ui's design tokens, dark or light, changed in app.css.
Next: in Chapter 3 Freddy writes his first command and calls it from Svelte.