What a component needs to render inside a surface.
:surface_id,:surfaceand:resolver— the surface and its resolved tree (A2UICore.Resolution.NodeResolver);:components— the component map,%{type => function_component};:target— thephx-targetof the surface's events (theA2UIPhoenix.SurfaceLiveComponent);:ui— the surface's local UI state by noderef(the open tab, an open modal, a choice filter); never sent to the agent;:markdown— an optional(String.t() -> Phoenix.HTML.safe())used for body text (nilrenders text as is);:mcp_sandbox— the URL of the MCP App sandbox proxy page (nilusesA2UIPhoenix.Components.MCP.default_sandbox/0).
Custom components receive it as @ctx and use the helpers below to
name their inputs and DOM ids the way the surface expects.
Summary
Functions
A DOM id for node, unique on the page while the node is mounted;
suffix names an element inside the component.
The form name of an input of node: field is the component property
the input writes ("value" by default).
The mounted node with ref, or nil.
A value of the local UI state of node, or default.
Types
@type t() :: %A2UIPhoenix.Context{ components: %{ optional(String.t()) => (map() -> Phoenix.LiveView.Rendered.t()) }, markdown: (String.t() -> Phoenix.HTML.safe()) | nil, mcp_sandbox: String.t() | nil, resolver: A2UICore.Resolution.NodeResolver.t() | nil, surface: A2UICore.State.Surface.t() | nil, surface_id: String.t() | nil, target: term(), ui: %{optional(pos_integer()) => map()} }
Functions
@spec dom_id(t(), A2UICore.Resolution.Node.t() | pos_integer(), String.t() | nil) :: String.t()
A DOM id for node, unique on the page while the node is mounted;
suffix names an element inside the component.
iex> ctx = %A2UIPhoenix.Context{surface_id: "main form"}
iex> A2UIPhoenix.Context.dom_id(ctx, 7, "input")
"a2ui-main_form-7-input"
@spec input_name(A2UICore.Resolution.Node.t() | pos_integer(), String.t()) :: String.t()
The form name of an input of node: field is the component property
the input writes ("value" by default).
iex> A2UIPhoenix.Context.input_name(7)
"a2ui[7][value]"
@spec node(t(), pos_integer()) :: A2UICore.Resolution.Node.t() | nil
The mounted node with ref, or nil.
@spec ui(t(), A2UICore.Resolution.Node.t(), atom(), term()) :: term()
A value of the local UI state of node, or default.