MingaEditor.Agent.DiffSnapshot (Minga v0.1.0)

Copy Markdown View Source

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.

Summary

Types

t()

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

Functions

Cleans up temp files for file-backed snapshots.

Returns the raw content from a snapshot.

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

Returns the lines from a snapshot.

Types

t()

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

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

Functions

cleanup(arg)

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

Cleans up temp files for file-backed snapshots.

content(arg)

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

Returns the raw content from a snapshot.

from_content(content)

@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(arg)

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

Returns the lines from a snapshot.