# `MingaEditor.Agent.Events`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/agent/events.ex#L1)

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.

# `effect`

```elixir
@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()}
```

# `handle`

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

# `handle_batch`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
