Unified agent UI state wrapping Panel and View sub-structs.
Panel holds prompt editing and chat display state (buffer, history,
scroll, model config, paste blocks). View holds layout, search,
preview, toasts, and diff baselines. Splitting into sub-structs keeps
each under 16 fields while providing a single access point on
EditorState.agent_ui.
Most callers use the functions on this module. Input handlers and renderers read the focused UI value from the editor workspace.
Summary
Types
Vim mode for the input field when focused.
Agent UI state wrapping Panel and View sub-structs.
Thinking level for models that support extended reasoning.
Functions
Activates the view, saving the current window layout.
Activates the view with a recorded editor return target.
Appends one collapsed paste block and marks the prompt as freshly edited.
Attaches the process-backed prompt buffer to this UI value.
Cancels search.
Clears all diff baselines.
Clears the chat display without affecting conversation history.
Clears the active file mention completion.
Clears any pending prefix.
Clears the editor return target.
Clears all toasts.
Confirms search (keeps matches for n/N navigation, disables input).
Deactivates the view and returns the restored window layout.
Forgets a dead prompt buffer while preserving prompt metadata.
Dismisses the help overlay.
Dismisses the current toast.
Re-engages auto-scroll. Delegates to Minga.Editing.pin_to_bottom/1.
Marks compaction as no longer running.
Returns the baseline content for a path, or nil if none recorded.
Grows the chat panel width by one step (clamped at max).
Records whether a paste block is expanded in the process-backed prompt.
Creates a new UIState with credential-aware panel defaults.
Moves to the next search match.
Returns the paste block index for a placeholder line, or nil if not a placeholder.
Returns the line count for a paste block at the given index.
Returns true if the given line is a paste placeholder token.
Moves to the previous search match.
Pushes a toast.
Records the baseline content for a file path (first edit only).
Records metadata shared by ordinary prompt edits.
Records transcript scroll metrics observed during rendering.
Records a submitted prompt in newest-first history order.
Installs the activity produced by an Activity transition.
Installs the timeline produced by an EditTimeline transition.
Installs a complete panel projection produced by a named Panel transition.
Installs the preview produced by a Preview transition.
Installs a complete view projection produced by a named View transition.
Clears collapsed-paste metadata after complete prompt replacement.
Resets prompt history selection and collapsed-paste metadata.
Resets the chat panel width to the configured default.
Forgets a prompt buffer only when the retiring process owns it.
Builds a return target from the current editor context.
Scrolls the content down. Delegates to Minga.Editing.scroll_down/2.
Pins chat to bottom. Delegates to Minga.Editing.pin_to_bottom/1.
Scrolls to top. Delegates to Minga.Editing.scroll_to_top/1.
Scrolls the content up. Delegates to Minga.Editing.scroll_up/2.
Scrolls the preview pane down by the given number of lines.
Scrolls the preview pane to a large offset (renderer clamps to actual content).
Scrolls the preview pane to the top (offset 0).
Scrolls the preview pane up by the given number of lines, clamped at 0.
Returns true if search input is being typed.
Returns the search query, or nil if not searching.
Returns the saved scroll position from before search started.
Returns true if search is active.
Selects one prompt-history position after the workflow replaces text.
Switches focus to the given panel.
Records whether prompt input owns focus; buffer attachment belongs to PromptBuffer.
Sets the model name.
Sets the chat pin flag without moving the scroll offset.
Sets the pending prefix for multi-key sequences.
Sets the provider name.
Sets the editor return target.
Sets the scroll offset to an absolute value. Unpins from bottom.
Sets search matches and resets current to 0.
Sets the thinking level.
Shrinks the chat panel width by one step (clamped at min).
Starts a search, saving the current scroll position.
Advances the spinner animation frame.
Returns true if a toast is currently visible.
Toggles panel visibility.
Toggles the help overlay visibility.
Updates the search query string.
Types
@type input_mode() :: :insert | :normal | :visual | :visual_line | :operator_pending
Vim mode for the input field when focused.
@type t() :: %MingaEditor.Agent.UIState{ panel: MingaEditor.Agent.UIState.Panel.t(), view: MingaEditor.Agent.UIState.View.t() }
Agent UI state wrapping Panel and View sub-structs.
@type thinking_level() :: String.t()
Thinking level for models that support extended reasoning.
Functions
@spec activate( t(), MingaEditor.State.Windows.t() | nil, MingaEditor.State.FileTree.t() | nil ) :: t()
Activates the view, saving the current window layout.
@spec activate( t(), MingaEditor.State.Windows.t() | nil, MingaEditor.State.FileTree.t() | nil, MingaEditor.Agent.UIState.View.return_target() | nil ) :: t()
Activates the view with a recorded editor return target.
Appends one collapsed paste block and marks the prompt as freshly edited.
Attaches the process-backed prompt buffer to this UI value.
Cancels search.
Clears all diff baselines.
@spec clear_display(t(), non_neg_integer()) :: t()
Clears the chat display without affecting conversation history.
Sets display_start_index to the given message count so the renderer
skips all messages before this point. Scrolls to bottom.
Clears the active file mention completion.
Clears any pending prefix.
Clears the editor return target.
Clears all toasts.
Confirms search (keeps matches for n/N navigation, disables input).
@spec deactivate(t()) :: {t(), MingaEditor.State.Windows.t() | nil, MingaEditor.State.FileTree.t() | nil}
Deactivates the view and returns the restored window layout.
Forgets a dead prompt buffer while preserving prompt metadata.
Dismisses the help overlay.
Dismisses the current toast.
Re-engages auto-scroll. Delegates to Minga.Editing.pin_to_bottom/1.
Marks compaction as no longer running.
@spec get_baseline(t() | MingaEditor.Agent.UIState.View.t(), String.t()) :: String.t() | nil
Returns the baseline content for a path, or nil if none recorded.
Grows the chat panel width by one step (clamped at max).
@spec mark_paste_expanded(t(), non_neg_integer(), boolean()) :: t()
Records whether a paste block is expanded in the process-backed prompt.
@spec new() :: t()
Creates a new UIState with credential-aware panel defaults.
Moves to the next search match.
@spec paste_block_index(String.t()) :: non_neg_integer() | nil
Returns the paste block index for a placeholder line, or nil if not a placeholder.
@spec paste_block_line_count( t() | [MingaEditor.Agent.UIState.Panel.paste_block()], non_neg_integer() ) :: non_neg_integer()
Returns the line count for a paste block at the given index.
Returns true if the given line is a paste placeholder token.
Moves to the previous search match.
Pushes a toast.
Records the baseline content for a file path (first edit only).
Records metadata shared by ordinary prompt edits.
@spec record_scroll_metrics(t(), non_neg_integer(), pos_integer()) :: t()
Records transcript scroll metrics observed during rendering.
Records a submitted prompt in newest-first history order.
@spec replace_activity(t(), MingaEditor.Agent.Activity.t()) :: t()
Installs the activity produced by an Activity transition.
@spec replace_edit_timeline(t(), MingaEditor.Agent.EditTimeline.t()) :: t()
Installs the timeline produced by an EditTimeline transition.
@spec replace_panel(t(), MingaEditor.Agent.UIState.Panel.t()) :: t()
Installs a complete panel projection produced by a named Panel transition.
@spec replace_preview(t(), MingaEditor.Agent.View.Preview.t()) :: t()
Installs the preview produced by a Preview transition.
@spec replace_view(t(), MingaEditor.Agent.UIState.View.t()) :: t()
Installs a complete view projection produced by a named View transition.
Clears collapsed-paste metadata after complete prompt replacement.
Resets prompt history selection and collapsed-paste metadata.
Resets the chat panel width to the configured default.
Forgets a prompt buffer only when the retiring process owns it.
@spec return_target( pos_integer() | nil, pid() | nil, MingaEditor.State.Windows.t(), MingaEditor.State.FileTree.t(), Minga.Keymap.Scope.scope_name(), boolean() ) :: MingaEditor.Agent.UIState.View.return_target()
Builds a return target from the current editor context.
@spec scroll_down(t(), non_neg_integer()) :: t()
Scrolls the content down. Delegates to Minga.Editing.scroll_down/2.
Pins chat 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(), non_neg_integer()) :: t()
Scrolls the content up. Delegates to Minga.Editing.scroll_up/2.
@spec scroll_viewer_down(t(), pos_integer()) :: t()
Scrolls the preview pane down by the given number of lines.
Scrolls the preview pane to a large offset (renderer clamps to actual content).
Scrolls the preview pane to the top (offset 0).
@spec scroll_viewer_up(t(), pos_integer()) :: t()
Scrolls the preview pane up by the given number of lines, clamped at 0.
@spec search_input_active?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()
Returns true if search input is being typed.
@spec search_query(t() | MingaEditor.Agent.UIState.View.t()) :: String.t() | nil
Returns the search query, or nil if not searching.
@spec search_saved_scroll(t() | MingaEditor.Agent.UIState.View.t()) :: non_neg_integer() | nil
Returns the saved scroll position from before search started.
@spec searching?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()
Returns true if search is active.
Selects one prompt-history position after the workflow replaces text.
@spec set_focus(t(), MingaEditor.Agent.UIState.View.focus()) :: t()
Switches focus to the given panel.
Records whether prompt input owns focus; buffer attachment belongs to PromptBuffer.
Sets the model name.
Sets the chat pin flag without moving the scroll offset.
Drives the BEAM-authoritative pin state from a frontend that owns its
transcript scroll locally (#2654 pin intents). pinned: true re-follows the
bottom, pinned: false pauses auto-follow, both without disturbing the
concrete offset a round-trip frontend still relies on.
@spec set_prefix(t(), MingaEditor.Agent.UIState.View.prefix()) :: t()
Sets the pending prefix for multi-key sequences.
Sets the provider name.
@spec set_return_target(t(), MingaEditor.Agent.UIState.View.return_target() | nil) :: t()
Sets the editor return target.
@spec set_scroll(t(), non_neg_integer()) :: t()
Sets the scroll offset to an absolute value. Unpins from bottom.
@spec set_search_matches(t(), [MingaEditor.Agent.UIState.View.search_match()]) :: t()
Sets search matches and resets current to 0.
Sets the thinking level.
Shrinks the chat panel width by one step (clamped at min).
@spec start_search(t(), non_neg_integer()) :: t()
Starts a search, saving the current scroll position.
Advances the spinner animation frame.
@spec toast_visible?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()
Returns true if a toast is currently visible.
Toggles panel visibility.
Toggles the help overlay visibility.
Updates the search query string.