Direct accessors for agent state on EditorState.
Agent-related state is split across three locations:
state.shell_state.agent(MingaEditor.State.Agent) — rendering cache for the user's current view. Holdsruntime(status),error,pending_approval,spinner_timer, andbuffer. Repopulated on every tab/card switch from the active session'sMingaAgent.Session.editor_snapshot/1. Not the source of truth for the session pid.- The active session pid lives on
Tab.session(Traditional shell) orCard.session(Board shell).session/1reads it throughShell.active_session/1. state.workspace.agent_ui(Agent.UIState) — full UI state wrapping Panel and View. Per-tab.state.workspace.agent_ui.panel(UIState.Panel) — prompt editing and chat display.state.workspace.agent_ui.view(UIState.View) — layout, search, preview, toasts.
This module provides read/write functions so callers don't need to know the field layout.
Summary
Functions
Returns the agent session lifecycle state.
Returns the full agent UI state (wrapping Panel and View).
Returns the agent UI focus.
Returns true if the agent panel input is focused.
Returns the agent panel state (prompt editing and chat display).
Returns the agent session pid for the user's current view, or nil.
Updates agent session lifecycle state via a transform function.
Updates the full agent UI state. Prefer update_panel/2 or update_view/2.
Updates just the panel sub-struct via a transform function.
Updates just the view sub-struct via a transform function.
Returns the agent view state (layout, search, preview, toasts).
Functions
@spec agent(MingaEditor.State.t() | map()) :: MingaEditor.State.Agent.t()
Returns the agent session lifecycle state.
@spec agent_ui(MingaEditor.State.t() | map()) :: MingaEditor.Agent.UIState.t()
Returns the full agent UI state (wrapping Panel and View).
@spec focus(MingaEditor.State.t() | map()) :: atom()
Returns the agent UI focus.
@spec input_focused?(MingaEditor.State.t() | map()) :: boolean()
Returns true if the agent panel input is focused.
@spec panel(MingaEditor.State.t() | map()) :: MingaEditor.Agent.UIState.Panel.t()
Returns the agent panel state (prompt editing and chat display).
@spec session(MingaEditor.State.t() | map()) :: pid() | nil
Returns the agent session pid for the user's current view, or nil.
Reads through the shell behaviour: Traditional returns the active tab's
session, Board returns the zoomed card's session. The session pid is
owned by the tab/card; state.shell_state.agent only caches the
rendering fields (status, error, pending_approval) for that session.
@spec update_agent(MingaEditor.State.t() | map(), (MingaEditor.State.Agent.t() -> MingaEditor.State.Agent.t())) :: MingaEditor.State.t() | map()
Updates agent session lifecycle state via a transform function.
@spec update_agent_ui(MingaEditor.State.t() | map(), (MingaEditor.Agent.UIState.t() -> MingaEditor.Agent.UIState.t())) :: MingaEditor.State.t() | map()
Updates the full agent UI state. Prefer update_panel/2 or update_view/2.
@spec update_panel( MingaEditor.State.t() | map(), (MingaEditor.Agent.UIState.Panel.t() -> MingaEditor.Agent.UIState.Panel.t()) ) :: MingaEditor.State.t() | map()
Updates just the panel sub-struct via a transform function.
@spec update_view( MingaEditor.State.t() | map(), (MingaEditor.Agent.UIState.View.t() -> MingaEditor.Agent.UIState.View.t()) ) :: MingaEditor.State.t() | map()
Updates just the view sub-struct via a transform function.
@spec view(MingaEditor.State.t() | map()) :: MingaEditor.Agent.UIState.View.t()
Returns the agent view state (layout, search, preview, toasts).