Preview pane state machine for the agentic view.
The right pane of the agentic view reacts to agent tool activity. This module manages a discriminated union of content types:
:empty- no content yet (welcome state){:shell, command, output, status}- shell command output (streaming or done){:diff, DiffReview.t()}- unified diff from a file edit{:file, path, content}- file content from a read_file tool
The preview updates in response to tool events: ToolStart sets a loading state, ToolUpdate streams partial output, ToolEnd finalizes, and ToolFileChanged triggers diff mode.
Scroll state is tracked here so each content type preserves its own scroll position. Auto-follow pauses when the user scrolls manually and resumes on the next tool event.
Summary
Types
The content currently displayed in the preview pane.
Shell command execution status.
Preview pane state.
Functions
Clears the preview to empty state.
Returns true if the preview is showing a diff review.
Returns the DiffReview if the preview is in diff mode, nil otherwise.
Returns true if the preview is showing a directory listing.
Returns true if the preview is empty.
Marks the shell command as complete.
Creates a new empty preview state.
Scrolls down. Delegates to Minga.Editing.scroll_down/2.
Pins to bottom. Delegates to Minga.Editing.pin_to_bottom/1.
Scrolls to top. Delegates to Minga.Editing.scroll_to_top/1.
Scrolls up. Delegates to Minga.Editing.scroll_up/2.
Sets the preview to show a diff review.
Sets the preview to show a directory listing.
Sets the preview to show file content.
Sets the preview to show shell command output (streaming).
Returns true if the preview is showing shell output.
Updates the diff review within the preview.
Updates the shell output with new partial content.
Types
@type content() :: :empty | {:shell, command :: String.t(), output :: String.t(), shell_status()} | {:diff, MingaEditor.Agent.DiffReview.t()} | {:file, path :: String.t(), content :: String.t()} | {:directory, path :: String.t(), entries :: [String.t()]}
The content currently displayed in the preview pane.
@type shell_status() :: :running | :done | :error
Shell command execution status.
@type t() :: %MingaEditor.Agent.View.Preview{ content: content(), scroll: Minga.Editing.Scroll.t() }
Preview pane state.
Functions
Clears the preview to empty state.
Returns true if the preview is showing a diff review.
@spec diff_review(t()) :: MingaEditor.Agent.DiffReview.t() | nil
Returns the DiffReview if the preview is in diff mode, nil otherwise.
Returns true if the preview is showing a directory listing.
Returns true if the preview is empty.
@spec finish_shell(t(), String.t(), shell_status()) :: t()
Marks the shell command as complete.
@spec new() :: t()
Creates a new empty preview state.
@spec scroll_down(t(), pos_integer()) :: t()
Scrolls down. Delegates to Minga.Editing.scroll_down/2.
Pins to bottom. Delegates to Minga.Editing.pin_to_bottom/1.
Scrolls to top. Delegates to Minga.Editing.scroll_to_top/1.
@spec scroll_up(t(), pos_integer()) :: t()
Scrolls up. Delegates to Minga.Editing.scroll_up/2.
@spec set_diff(t(), MingaEditor.Agent.DiffReview.t()) :: t()
Sets the preview to show a diff review.
Sets the preview to show a directory listing.
Sets the preview to show file content.
Sets the preview to show shell command output (streaming).
Returns true if the preview is showing shell output.
@spec update_diff(t(), (MingaEditor.Agent.DiffReview.t() -> MingaEditor.Agent.DiffReview.t())) :: t()
Updates the diff review within the preview.
Updates the shell output with new partial content.