Skip to content

gpui-rhai 0.2.0

Choose a tag to compare

@eddix eddix released this 11 Oct 15:31
· 235 commits to main since this release

gpui-rhai 0.2.0

Release date: 2026-10-11. Runtime API moves to 3; gpui-pre/core/platform remain
0.3.7 and MSRV remains 1.95. Upgrade core, registry and CLI together.

0.2.0 introduces a design system for productivity tools and separates it from
the runtime. The specification lives in docs/design/; the
Gallery is its acceptance application.

What changes

Runtime: neutral. The runtime no longer knows any design vocabulary. Themes
are an open token registry; components declare the tokens and environment
values they read, and preparation validates the active theme against the
mounted components. Typography roles and lengths are open names; lengths can
vary with environment values (density, size) set by .env(#{ ... }) and
resolved during native rendering. Color expressions (mix, alpha,
readable) evaluate after all layers merge. An application can bring its own
design without the official token base (examples/byod_treemap).

L0: the token base. registry/tokens.rhai (installed as ui/tokens.rhai)
holds the design language: CJK-aware typography (body 14/22), control roles,
the spacing scale and relationship aliases (unit, related, group,
section), metrics.* in comfortable and compact density, radius roles and
derived colors. Bundled palettes contain colors only.

L1: 64 components (62 rebuilt, List and TabBar new) on one set of contracts (size and density as two
axes, one content inset, a 2px ink focus frame, four marker silhouettes for
Button, Tag, Badge and Kbd, "normal is quiet" status color).

L2: layouts and patterns. layouts/ (Stack, Inline, Toolbar, Region) and
patterns/ (Section, DescriptionList, Stat, FormLayout, InlineState, DataView,
ListDetail, AppShell with F6 regions).

Composition audit and profiles. ScriptViewHandle::composition_audit
checks committed geometry: row height mismatch, text edges, nested spacing,
solid actions per group, mixed type in a row, painted contrast, unresolved
fonts. A profile (gpui-rhai init --profile productivity,
EmbeddedScriptView::profile_source) chooses the rules; without one only
correctness is checked.

Keyboard. Every interactive component is one tab stop; the runtime keeps
overlay trigger wrappers, key-routing containers and tooltip panels out of the
tab order.

Gallery. gpui-rhai gallery opens the new Gallery, a Rhai application on
AppShell with 85 pages, four keyboard scenes and a live audit count. Every page
passes the audit in both densities. Stories remain as development fixtures
behind --story.

Migration from 0.1.x

Hosts (Rust)

  • ScriptViewHost::overlay_placement(view_id, key) returns
    Result<Option<PlacementResult>, OverlayLookupError>: overlays are now
    identified by the component instance that declared them, and the lookup
    reports a key that several instances use. Name one with
    overlay_placement_in(view_id, instance_path, key). Code that builds
    OverlayNodeSpec or LayerNodeSpec by hand sets owner: None.
  • Capability handlers may override call_with to read the call's origin, view
    and component (see docs/capabilities.md); call keeps working. Code that
    builds an AsyncDelivery, ActionInvocation or PendingEvent by hand sets
    origin (an InvocationOrigin; the default is Lifecycle).
  • Component and primitive schemas take an optional doc: Rust code that
    builds ObjectField, EventSchema or SlotSchema with a struct literal
    adds doc: None, or uses EventSchema::new(payload) and with_doc.
  • A match on UiContextError handles the new ForeignAsyncHandle
    variant (cancelling another component's task or subscription).
  • RuntimeEngine::definition_source (and gpui-rhai metadata) writes
    definitions with parameter names, doc comments and readable types; run
    gpui-rhai metadata again to refresh an editor's copy.
  • Official registry components need the token base:
    EmbeddedScriptView::new(...).token_base(gpui_rhai_registry::TOKEN_BASE_SOURCE).
    Projects using the CLI get ui/tokens.rhai from gpui-rhai update. Without
    it, preparation fails with the list of missing tokens.
  • Optional: .profile_source(...) with the bundled productivity profile to
    enable the composition audit; composition_audit(cx) returns the findings.
  • Removed from gpui-rhai-cli: the gallery_app module (the Rust Gallery
    shell). The test-support feature still exists and gates nothing. Removed
    from gpui-rhai-registry: GALLERY_NAVIGATION_SOURCE and
    GALLERY_SOURCE_VIEW_SOURCE. Added: TOKEN_BASE_SOURCE, BUNDLED_PROFILES,
    the layouts/ and patterns/ source tables and GALLERY_SOURCES_BY_ID.
  • gpui-rhai gallery --list prefixes each line with page or story.
  • To draw the title bar in Rhai, hide the platform bar in the window options
    (TitlebarOptions { appears_transparent: true, traffic_light_position, .. })
    and, on macOS, also set WindowOptions::app_owns_titlebar_drag = true:
    without it AppKit still owns the title strip, so pressing a button in the bar
    starts a native window move and a quick double press zooms the window
    (headless tests cannot show this). Then allow drag areas for that view
    (ScriptViewConfig::window_drag_areas or
    ScriptApplication::window_drag_areas); see embedding.
    Other views keep drag areas inert.
  • Theme lengths depend on environment values: ThemeTokens.spacing and
    radii hold Variable<Length> (a fixed value or a by_env table), no longer
    Length. A Host that reads a token for its own native chrome resolves it:
    theme.tokens.resolve_length(Length::token("radius.md")?, &environment)
    (Environment::EMPTY uses the declared defaults), or
    Variable::resolve(&environment, &tokens.environment) on a
    length_token(...).
  • Hosts that load user themes: palette themes are colors only. Spacing,
    metrics, typography and radius come from the token base; a radius
    preference is the corners environment value
    (ThemeTokenOverrides::environment_defaults), not a radius override.
    load_theme_source loads a palette alone, without the token base, so its
    result has no spacing and fails token requirements; validate a user theme
    with load_theme_with_layers(engine, Some(&token_base), ...) and
    ThemeVariant::require, as preparation does.
  • ScriptViewHandle::last_error keeps a failure until a successful reload or an
    acknowledgement; a later successful event no longer clears it. A Host with
    its own error panel calls the new ScriptViewHandle::clear_error when the
    user dismisses it. Code that polled last_error to see whether the latest
    event worked should check the result of that event instead (automation
    commands return their own failure).

Component source

  • Module headers declare "runtime_api": { "min_inclusive": 3, "max_exclusive": 4 } (header and define_component metadata). Components
    should also declare tokens and environment; see the
    authoring guide.
  • Copied official components: run gpui-rhai update and review the conflicts;
    every component changed.
  • gpui-rhai check requires a purpose comment at the top of a component
    source instead of a // Props: line; the schema documents props, events and
    slots through doc (authoring guide).

Props and defaults

Component 0.1.x 0.2.0
Button default variant primary default secondary; set variant: "primary" on the one primary action; new action, shortcut
Badge dot default false dot default true (the square lamp); new emphasis (subtle/strong)
Card elevated removed; variant: "outline" for cards on a raised surface
Combobox row_height, trigger_height removed; use size (or an inherited size environment) and density
Command, CommandDialog row_height removed; rows follow metrics.row; items may bind action
Tag — new facet segment and close_label
Kbd — new keys and appearance (keycap/inline)
Tabs — new panel (false makes a view switcher) and size
Popover — new align (start/center/end)
Input, InputGroup, ButtonGroup, ToggleGroup — new size
Input — new appearance: "embedded" for a search line that heads a panel
Alert info lamp in accent info lamp in text_muted
Menu, ContextMenu a row without action left the menu open every activated row closes it (not Enter on a submenu row)
ContextMenu pointer only also Shift+F10 / menu key; with on_open_change the trigger area is a tab stop
AlertDialog Escape and backdrop emitted only open_change(false) cancel first
Table, List no keyboard menu without a selection mode on_context_request makes them a tab stop for Shift+F10
Button loading_text prefixed the label it replaces the label and the accessible name
Spinner speed_ms default 850 optional; follows motion_duration("ambient") (1100 in the token base)
Select, Combobox clear label "Clear" / "Clear selection" localized common.clear
Chart surface fill and a 1px border frame no fill or frame; give the root a background (and a border) to restore them
SplitPane panes laid out as blocks panes are flex columns: content that may shrink now fits the pane instead of overflowing it; new handle_hover, handle_drag parts
Combobox, Select a selected value not among options threw accepted; the trigger shows the raw value
Label required part styled the whole label it styles only the asterisk
Input, Textarea, Select, Combobox, DatePicker, InputGroup side padding metrics.control_pad metrics.field_pad: text starts half the control height plus 1px from the edge (md comfortable 15); Textarea's vertical padding is metrics.multiline_pad
Dialog 378 wide (a 90% cap applied to its own wrapper) 420 as declared, capped at 90% of the window; new title_visible
CommandDialog — the search spans the panel (an embedded lg Input) and the panel has no padding (dialog_part_styles.panel adds it back); new title_visible, on_escape, width, command_part_styles, dialog_part_styles
Collapsible, Accordion content_height required, in pixels omit it to fit the content, or pass a Length
Table — numeric columns; keyboard selection; frameless; a column without its own value shows only its adornments; a column's typography ("code" for identifiers); group headers in the label voice; on_context_request for row menus
Slider, RangeSlider 240-wide track inside a stretching root a 240-wide unit; give the root part a width to change it
Icon declares check, close, search also help, info, warning
TitleBar subtitle on a second line title and subtitle on one line
Menu, ContextMenu, IconButton, Tooltip — new action
FormLayout (new) — controls keep their own width (give wide fields a width); helper text sits a unit under the control
DataView (new) — footer fields sit a group apart; loading and empty states replace the body; toolbar.fill, toolbar.size and inset reach Toolbar and Region; bleed: false keeps the side inset for a body whose rows have none
List, TabBar (new) — List: keyed, virtualized rows with Table's selection and keyboard model. TabBar: document tabs joined to the panel under them
Toolbar (new) — fill takes the width between the groups (a search or query field); a field in filters is as wide as its content
Region (new) — the body clips; scroll: true scrolls it with an overlay scrollbar (scrollbar, scrollbar_* parts); external_title for a title drawn elsewhere
Resizable resize payload {x,y,width,height,handle} {x,y,width,height}, the next rect as is; store it directly; grips, line, line_inset
SplitPane — handle (a decorative grip above both panes), line, line_inset; one line at the separator; collapsing a pane keeps the other mounted

Themes

A copied ui/tokens.rhai must declare the corners environment value
(gpui-rhai update brings the new token base): official components that read
radius tokens declare it, and preparation fails with the missing value
otherwise. To ship a corner style, set its default in the token file or with
ThemeTokenOverrides::environment_defaults; .env(#{ corners: ... }) changes
it for a subtree.

The same holds for the tokens added later in this release: metrics.field_pad
and metrics.multiline_pad (read by every field) and tabbar.background and
tabbar.active (TabBar). A Host or theme that adjusted field padding through
metrics.control_pad overrides metrics.field_pad instead; control_pad
now pads only buttons, tabs and toggles.

Palette themes should contain colors only. Typography, spacing, metrics and
radius come from the token base; a 0.1 theme that still defines them overrides
the base and opts out of "switching palette never changes layout". Spacing
gains xl; typography roles change size (body 14/22, caption 12/18) and add
control_small, control_regular and the mono label voice. Derived colors
(table.selection, tabs.foreground, text.*, control.hover, tag.facet,
scrollbar.*) are computed by the token base and may be overridden by name.

Application scripts

  • Components inside a virtual item (Table rows, VirtualList and Sortable items)
    now have an Item[<item key>] segment in their instance path. Their state
    resets once after the upgrade; diagnostics and Host lookups that spell such a
    path gain the segment. A component key inside a row no longer needs the row
    key in it.
  • SplitPane slot content sits in a sized wrapper (since 0.1.8, which keeps the
    caller's node identity): a start or end node that relied on receiving the
    pane size now sizes to its content. Make slot content fill its wrapper
    (width(relative(1.0)).height(relative(1.0))), notably a SplitPane nested in
    another.
  • Do not name script functions after built-ins (index_of, contains,
    filter, split, …): Rhai resolves a script function before a built-in, also
    inside imported components; x.f(a, b) reaches a script fn f(a, b).
    gpui-rhai check now warns about such entry functions (builtin-shadow).
  • Prefer layouts and patterns over hand-written rows with literal sizes; the
    productivity profile reports literal geometry in application source.
  • A Region body taller than the region is clipped, not scrolled (0.1 page
    helpers usually scrolled): set scroll: true, or let a Table or virtual
    list scroll itself.
  • ctx.scroll_into_view scrolls a direct child of the container just enough
    to show it; it aligned the child to the start. A node mounted in the same
    transaction is revealed on the next frame instead of reporting an error.
  • bind_parent_signal binds the nearest ancestor that declares the key; the
    owner declares its signal before it renders the collection that binds it.
  • self_start and self_end no longer mirror in an RTL row (they moved a
    node to the other end of the row's vertical cross axis); in a column they
    still do. A stylesheet rule or part_styles entry with padding(x),
    margin(x), border(x) or radius(x) now also replaces the part's logical
    edges, as the same chain does.
  • Change callbacks no longer receive proposals that change nothing (SplitPane
    resize, Slider and RangeSlider change, SelectionArea
    selection_change). Input without on_submit lets Enter reach its
    ancestors.
  • Re-registering an action keeps its enabled state; image(handle) and
    directional_image fail at once on a handle of another kind, and
    theme_color rejects a malformed path when called.
  • TextInput's change arrives once per committed IME composition, not per
    composition step. A Chart with spec.brush emits select on release for a
    click.
  • New in scripts: .signal_style, .group_hover, .translate_wheel, and
    take_focus and tap on the sortable item primitive; the
    script API lists every native function.
  • Coding agents: gpui-rhai skills .claude/skills (or .agents/skills)
    writes the two skills for this version; npx skills add eddix/gpui-rhai
    installs them from the repository.
  • Overriding Table's group_label part for a quieter group header is no longer
    needed: group headers use the label voice. An overlay panel that holds focus
    itself shows a 2px frame; restyle or hide it through the focus_frame part
    of Dialog, Sheet, Popover, Menu, DatePicker or Combobox.

Field reports

Both were checked against this branch without changing the projects.

disktree-rhai (a 0.1.8 application with its own design, no official
components). Built in a temporary copy through cargo --config path
overrides. Three changes were needed:

  1. runtime_api 2 → 3 in app.toml and module headers: the only change caused
    by 0.2.0.
  2. ScriptViewHost::new_with_policy → new: the project used an API that never
    shipped in a release; it loses its window-close q policy.
  3. .expression_depth_limits(64, 128) on the Host: the 0.1.8 defaults (64/32)
    are unchanged and its deep view functions exceed 32.

With these, its 45 tests passed and its own skin rendered unchanged: the
runtime carries no design assumptions.

oh-my-byted (pins =0.1.7, uses registry components). A read-only scan of
its sources at 4733fb0 (2026-10-01) finds what an upgrade needs; nothing was
built or run:

  • bins/omb-gui: add .token_base(gpui_rhai_registry::TOKEN_BASE_SOURCE) to
    each of the four EmbeddedScriptView::new assemblies in src/main.rs;
    consider the productivity profile.
  • Widgets with their own components (examples/demo/widgets/tasks,
    controls) declare runtime_api 2..3; change to 3..4.
  • Seven widgets pass trigger_height: ui::control_h() to Combobox (ten
    calls); remove it. stdlib/ui.rhai hard-codes geometry (control_h() = 28,
    fixed widths, its own page and toolbar); compact density already gives
    28px controls, and Region, Toolbar and DataView replace the helpers.
  • All fourteen Button(#{ ... }) calls already set variant, so the new
    secondary default changes nothing there.

Known gaps

  • An Input keeps painting its selection in the selection tint after focus
    moves to another field. Found in the candidate's real-window checks; not
    changed yet.
  • IME preedit and VoiceOver are checked by hand, not by the real-window
    scripts in scripts/macos-real-window.
  • Focus visibility: clicking a Table row leaves no focus frame on it (the
    arrow keys still act on the table); a focused List with a selection mode and
    nothing selected shows no frame; a ContextMenu trigger area without its own
    control is a tab stop with no frame; an AppShell region is a tab stop before
    its controls.
  • gpui-rhai check reports a call to a host extension, such as
    gpui_rhai::HostSlot, as unknown; the application runs (#141).
  • Planned for 0.2.1: #133, #134, #136, #137, #139, #142 and #143.