MingaEditor.Agent.Events (Minga v0.1.0)

Copy Markdown View Source

Handles agent session events, updating EditorState directly.

Agent events (status changes, deltas, tool activity, errors) arrive from the agent session process. Each handler reads and writes the agent and agentic fields on EditorState through AgentAccess, returning the updated state and a list of effects for the Editor GenServer to apply.

Summary

Functions

Applies one coalesced batch of stream deltas (#2289).

Types

effect()

@type effect() ::
  :render
  | {:render, pos_integer()}
  | {:log_message, String.t()}
  | {:log_warning, String.t()}
  | :sync_agent_buffer
  | {:update_tab_label, String.t()}
  | {:compact_session, pid()}

Functions

handle(state, delta)

@spec handle(MingaEditor.State.t(), term()) :: {MingaEditor.State.t(), [effect()]}

handle_batch(state, batch)

@spec handle_batch(MingaEditor.State.t(), [term()]) ::
  {MingaEditor.State.t(), [effect()]}

Applies one coalesced batch of stream deltas (#2289).

MingaEditor.Agent.Ingest accumulates {:text_delta, _}, {:thinking_delta, _} and {:tool_update, _, _, _} events arriving within a coalescing window and forwards them here as a single batch. Applying the batch once means one bump_message_version, one :sync_agent_buffer, and one render request per window instead of per delta, which keeps the Editor mailbox shallow under streaming load. The per-delta state transitions (auto-scroll, shell preview updates) are folded in arrival order so the visible result matches the unbatched path.