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

File-backed snapshots for large-file diff review.

When a file exceeds the `:agent_diff_size_threshold` config, the before/after
content is written to temp files instead of held in memory. The DiffReview
reads lines lazily from these files. Temp files are cleaned up when the
diff review is dismissed or the session ends.

# `t`

```elixir
@type t() :: {:memory, String.t()} | {:file, String.t()}
```

A diff snapshot, either memory-backed or file-backed.

# `cleanup`

```elixir
@spec cleanup(t()) :: :ok
```

Cleans up temp files for file-backed snapshots.

# `content`

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

Returns the raw content from a snapshot.

# `from_content`

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

Creates a snapshot from file content. If the content exceeds the threshold,
writes it to a temp file. Otherwise, keeps it in memory.

# `lines`

```elixir
@spec lines(t()) :: [String.t()]
```

Returns the lines from a snapshot.

---

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