MingaEditor.State.AgentAccess (Minga v0.1.0)

Copy Markdown View Source

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. Holds runtime (status), error, pending_approval, spinner_timer, and buffer. Repopulated on every tab/card switch from the active session's MingaAgent.Session.editor_snapshot/1. Not the source of truth for the session pid.
  • The active session pid lives on Tab.session (Traditional shell) or Card.session (Board shell). session/1 reads it through Shell.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

agent(arg1)

Returns the agent session lifecycle state.

agent_ui(arg1)

Returns the full agent UI state (wrapping Panel and View).

focus(state)

@spec focus(MingaEditor.State.t() | map()) :: atom()

Returns the agent UI focus.

input_focused?(state)

@spec input_focused?(MingaEditor.State.t() | map()) :: boolean()

Returns true if the agent panel input is focused.

panel(arg1)

Returns the agent panel state (prompt editing and chat display).

session(arg1)

@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.

update_agent(state, fun)

Updates agent session lifecycle state via a transform function.

update_agent_ui(state, fun)

This function is deprecated. Use update_panel/2 or update_view/2 for targeted sub-struct updates.

Updates the full agent UI state. Prefer update_panel/2 or update_view/2.

update_panel(state, fun)

Updates just the panel sub-struct via a transform function.

update_view(state, fun)

Updates just the view sub-struct via a transform function.

view(arg1)

Returns the agent view state (layout, search, preview, toasts).