This document defines the current public runtime contract for ash_sdui.
Canonical runtime values
Every generated or runtime-composed screen is described by:
viewbindingsstatecontext
When a view renders through an SDUI layout tree, nodes may also declare:
bindingrefreshvariantstate_key
view
AshSDUI.View is the normalized UI model for a screen.
Major fields:
resourceuinamemodeactionrecipecontextfieldsintentsbindingsqueriesstaterelationshipsassignsrefreshworkflow
Primary entry point:
state
AshSDUI.View.State is the authoritative runtime state shape.
Fields:
queryparamsselectedloadingpendingoptimisticofflineerrorsrefreshworkflowassigns
Definitions:
query: normalized query state for collection-oriented viewsparams: original or normalized request and event paramsselected: canonical list of selected identifiersloading: runtime loading flags keyed by feature or intent namepending: structured metadata for in-flight operations and optimistic workoptimistic: last known optimistic payloads keyed by operation nameoffline: best-effort stale-data flag when the runtime cannot refresh cleanlyerrors: last known runtime errors keyed by operation namerefresh: per-binding or per-view refresh metadataworkflow: workflow state for view-local transitionsassigns: extra runtime state outside the shared contract
Best-practice reading:
loadingremains a compatibility surface for simple loading flagspendingis the primary operation lifecycle surface for new runtime-aware UIoptimisticis for best-effort immediate feedback and rollback bookkeepingofflinemeans the current screen is rendering the last good state after a refresh failureerrorsshould let the UI explain failures without forcing a blank or remounted screen
bindings
ui_binding defines named data sources for a view.
Author-facing source shapes:
{:resource, resource}{:relationship, relationship}{:assign, key}{:context, key}{:runtime, key}{:selection}{:subject}{:event, key}{:poll, source, interval: ms}{:pubsub, topic, ...}{:stream, source, ...}{:actor}{:tenant}
Runtime-resolved binding fields:
refreshupdateupdate_strategysource_kindstatussubscription
Normalized refresh modes:
:manual:params:subscription{:interval, ms}
Normalized update strategies:
:replace:append:prepend:merge:remove
Public binding functions:
AshSDUI.Binding.plan/2AshSDUI.Binding.load/2AshSDUI.Binding.subscription_specs/2AshSDUI.Binding.apply_update/3
context
AshSDUI.Context carries runtime information about the current viewer or
environment.
Current fields:
actortenantlocaleaudiencedeviceassigns
ui_intent
ui_intent defines declarative user actions.
Intent metadata:
namelabelstyleiconcomponent_overridetargetconfirmplacementrequires_actor?visible_whenenabled_whenloading_whenrefreshes
Target families:
{:navigate, path}{:patch, path}{:event, event}{:ash_action, action}{:refresh, binding_or_view}{:select, operation}{:workflow, event}{:custom, module, function}
Primary intent functions:
AshSDUI.LiveResource is the default dispatcher for built-in command types.
Runtime host
AshSDUI.LiveResource is the primary runtime host for generated and
semi-generated screens.
Current responsibilities:
- resolve
AshSDUI.View - plan and load bindings
- mount and refresh runtime state
- register subscriptions
- handle binding-level live updates
- track pending operations, optimistic state, and offline fallback
- host query, refresh, select, workflow, and save event surfaces
- dispatch normalized intents
- render stock recipes or SDUI layout recipes through the same runtime contract
Best-practice expectation:
Generated and semi-generated screens should get immediate action feedback from the runtime host by default. Reach for custom LiveView orchestration only when the interaction model is genuinely more bespoke than the shared contract can describe.
Layout contract
Layouts are serializable trees with this preferred public authoring API:
AshSDUI.Layout.Builder.resource/2AshSDUI.Layout.Builder.resources/3AshSDUI.Layout.fetch/2AshSDUI.Layout.register/2AshSDUI.Layout.save/3AshSDUI.Layout.publish/2AshSDUI.LiveScreen.assign_layout/3
AshSDUI.Layout.Node and AshSDUI.Renderer.TreeNode support these declarative
node metadata fields:
bindingrefreshvariantstate_key
Persisted layout guarantees
Persisted layout nodes store declarative runtime metadata only.
Runtime metadata is encoded inside static_props under an internal
__ash_sdui__ envelope so it can round-trip through stored node records.
Persisted layouts do not store:
- runtime process state
- subscription registrations
- loaded binding values
- refresh status
- workflow progress
- selection state
SDUIRoot injected assigns
AshSDUI.Components.SDUIRoot passes runtime values into layout-rendered
components.
Shared assigns:
nodeviewbindingsstatecontext
Component-facing node assigns:
binding_namebound_valuerefresh_metastate_keystate_slicenode_refreshnode_variant