# `MingaEditor.Window.Content`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/window/content.ex#L1)

Polymorphic content reference for window panes.

A window can host any content type: a file buffer, an agent chat session,
a terminal, etc. This module defines the tagged union that replaces the
old `buffer: pid()` field on `Window.t()`.

## Why a tagged tuple instead of a protocol?

Window content references are stored in the window tree, serialized for
tab save/restore, and pattern-matched in the render pipeline. A simple
tagged tuple (`{:buffer, pid}`, `{:agent, session_ref}`) is easier to
serialize, pattern-match, and debug than a protocol struct. The
NavigableContent protocol handles the behavioral polymorphism; this
module handles the identity/reference polymorphism.

## Content types

| Tag | Reference | NavigableContent? | Editable? |
|-----|-----------|-------------------|-----------|
| `:buffer` | `pid()` (Buffer.Server) | Yes (via BufferSnapshot) | Yes |
| `:agent_chat` | `pid()` (Agent.Session) | Yes | No |
| `:agent_prompt` | `pid()` (Buffer.Server) | Yes (via BufferSnapshot) | Yes |
| `:terminal` | `pid()` (future, #122) | Yes (future) | No |
| `:browser` | `reference()` (future, #305) | Yes (future) | No |

Only `:buffer` is implemented today. Other tags are documented here to
show the design direction and will be added as their features land.

# `t`

```elixir
@type t() :: {:buffer, pid()} | {:agent_chat, pid()}
```

A content reference identifying what a window pane displays.

Currently only `:buffer` is used. Other variants will be added as
their features are implemented.

# `agent_chat`

```elixir
@spec agent_chat(pid()) :: t()
```

Creates an agent chat content reference. The pid is the agent's `*Agent*` Buffer.Server.

# `agent_chat?`

```elixir
@spec agent_chat?(t()) :: boolean()
```

Returns true if this content reference is an agent chat.

# `buffer`

```elixir
@spec buffer(pid()) :: t()
```

Creates a buffer content reference.

# `buffer?`

```elixir
@spec buffer?(t()) :: boolean()
```

Returns true if this content reference is a file buffer.

# `buffer_pid`

```elixir
@spec buffer_pid(t()) :: pid() | nil
```

Returns the buffer pid if this is a buffer content reference, nil otherwise.

# `editable?`

```elixir
@spec editable?(t()) :: boolean()
```

Returns true if the content is editable (supports insert mode).

# `pid`

```elixir
@spec pid(t()) :: pid()
```

Returns the underlying pid for any content type.

For `:buffer`, this is the Buffer.Server pid. For `:agent_chat`, this
is the agent's `*Agent*` Buffer.Server pid (used for cursor/scroll).

---

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