# `MingaEditor.State.InlineEdit`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/state/inline_edit.ex#L1)

Ephemeral inline edit overlays keyed by buffer.

The shared per-buffer store mechanics (`active/2`, `put/2`, `dismiss/2`,
`session?/2`) and prompt-input mechanics (`append_input/2`, `backspace/1`,
`scroll/2`) live in `MingaEditor.InlineOverlay.Store` and
`MingaEditor.InlineOverlay.Prompt` and are reused here. This module owns
only the edit-specific shape and transitions: the selection/original text,
the proposed rewrite with its `:stream` vs `:tool` source tracking, and the
`:proposed` terminal state.

# `proposal_source`

```elixir
@type proposal_source() :: :stream | :tool | nil
```

# `status`

```elixir
@type status() :: :input | :thinking | :proposed | :error
```

# `store`

```elixir
@type store() :: %{required(pid()) =&gt; t()}
```

# `t`

```elixir
@type t() :: %MingaEditor.State.InlineEdit{
  buffer_pid: pid(),
  file_label: String.t(),
  file_ref: Minga.Project.FileRef.t(),
  original_text: String.t(),
  prompt: String.t(),
  proposal_source: proposal_source(),
  proposed_rewrite: String.t(),
  scroll: non_neg_integer(),
  selection_range: {non_neg_integer(), non_neg_integer()},
  session_pid: pid() | nil,
  status: status()
}
```

# `active`

```elixir
@spec active(store(), pid() | nil) :: t() | nil
```

# `agent_prompt`

```elixir
@spec agent_prompt(t()) :: String.t()
```

Builds the constrained rewrite prompt.

# `append_input`

```elixir
@spec append_input(t(), String.t()) :: t()
```

# `append_proposal`

```elixir
@spec append_proposal(t(), String.t()) :: t()
```

Appends proposed replacement text streamed by the assistant.

# `backspace`

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

# `dismiss`

```elixir
@spec dismiss(store(), pid() | nil) :: {store(), pid() | nil}
```

# `fail`

```elixir
@spec fail(t(), String.t()) :: t()
```

Marks the edit as failed.

# `header`

```elixir
@spec header(t()) :: String.t()
```

Returns the prompt header.

# `mark_thinking`

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

Refreshes the visible thinking status.

# `new`

```elixir
@spec new(
  pid(),
  Minga.Project.FileRef.t(),
  String.t(),
  {non_neg_integer(), non_neg_integer()},
  String.t()
) :: t()
```

Creates a new inline edit for a selected line range.

# `proposed`

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

Marks the edit as proposed.

# `put`

```elixir
@spec put(store(), t()) :: store()
```

# `scroll`

```elixir
@spec scroll(t(), integer()) :: t()
```

# `session?`

```elixir
@spec session?(store(), pid()) :: boolean()
```

# `set_proposal`

```elixir
@spec set_proposal(t(), String.t()) :: t()
```

Replaces the proposed replacement text from the constrained rewrite tool.

# `thinking`

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

Marks the edit as thinking.

---

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