Layout, search, preview, and toast state for the agent UI.
Holds the data for the full-screen agentic view (focus, split sizing,
preview pane, search, toasts, diff baselines, context estimate). This is
the "view" half of the agent UI, separated from prompt editing concerns
in UIState.Panel.
Most callers interact through UIState functions rather than accessing
this struct directly.
Summary
Types
Which panel has keyboard focus inside the agentic view.
Active prefix key awaiting a follow-up keystroke.
A search match: message index, byte start, byte end.
Search state for the chat panel.
Layout, search, preview, and toast state.
A notification toast.
Functions
Activates the view, saving the current window layout.
Cancels search and returns nil (caller restores scroll).
Clears all diff baselines (called at the start of a new turn).
Clears any pending prefix.
Clears all toasts.
Confirms search (keeps matches for n/N navigation, disables input).
Deactivates the view and returns the restored window layout.
Dismisses the help overlay.
Dismisses the current toast. Shows the next one in the queue if any.
Returns the baseline content for a path, or nil if none recorded.
Grows the chat panel width by one step (clamped at max).
Creates a new view state with defaults.
Moves to the next search match.
Moves to the previous search match.
Pushes a toast. If no toast is showing, it becomes the current toast.
Records the baseline content for a file path (first edit only).
Resets the chat panel width to the configured default.
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 (vs confirmed).
Returns the search query, or nil if not searching.
Returns the saved scroll position from before search started.
Returns true if search is active (either inputting or confirmed with matches).
Switches focus to the given panel.
Sets the pending prefix for multi-key sequences.
Sets search matches and resets current to 0.
Shrinks the chat panel width by one step (clamped at min).
Starts a search, saving the current scroll position.
Returns true if a toast is currently visible.
Toggles the help overlay visibility.
Updates the preview state with the given function.
Updates the search query string.
Types
@type focus() :: :chat | :file_viewer
Which panel has keyboard focus inside the agentic view.
@type prefix() :: nil | :g | :z | :bracket_next | :bracket_prev | Minga.Keymap.Bindings.Node.t()
Active prefix key awaiting a follow-up keystroke.
@type search_match() :: {msg_index :: non_neg_integer(), col_start :: non_neg_integer(), col_end :: non_neg_integer()}
A search match: message index, byte start, byte end.
@type search_state() :: %{ query: String.t(), matches: [search_match()], current: non_neg_integer(), saved_scroll: non_neg_integer(), input_active: boolean() }
Search state for the chat panel.
@type t() :: %MingaEditor.Agent.UIState.View{ active: boolean(), chat_width_pct: non_neg_integer(), context_estimate: non_neg_integer(), diff_baselines: %{required(String.t()) => String.t()}, focus: focus(), help_visible: boolean(), pending_prefix: prefix(), preview: MingaEditor.Agent.View.Preview.t(), saved_file_tree: MingaEditor.State.FileTree.t() | nil, saved_windows: MingaEditor.State.Windows.t() | nil, search: search_state() | nil, toast: toast() | nil, toast_queue: term() }
Layout, search, preview, and toast state.
A notification toast.
Functions
@spec activate(t(), MingaEditor.State.Windows.t(), MingaEditor.State.FileTree.t()) :: t()
Activates the view, saving the current window layout.
Cancels search and returns nil (caller restores scroll).
Clears all diff baselines (called at the start of a new turn).
Clears any pending prefix.
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.
Dismisses the help overlay.
Dismisses the current toast. Shows the next one in the queue if any.
Returns the baseline content for a path, or nil if none recorded.
Grows the chat panel width by one step (clamped at max).
@spec new() :: t()
Creates a new view state with defaults.
Moves to the next search match.
Moves to the previous search match.
Pushes a toast. If no toast is showing, it becomes the current toast.
Records the baseline content for a file path (first edit only).
Resets the chat panel width to the configured default.
@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.
Returns true if search input is being typed (vs confirmed).
Returns the search query, or nil if not searching.
@spec search_saved_scroll(t()) :: non_neg_integer() | nil
Returns the saved scroll position from before search started.
Returns true if search is active (either inputting or confirmed with matches).
Switches focus to the given panel.
Sets the pending prefix for multi-key sequences.
@spec set_search_matches(t(), [search_match()]) :: t()
Sets search matches and resets current to 0.
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.
Returns true if a toast is currently visible.
Toggles the help overlay visibility.
@spec update_preview(t(), (MingaEditor.Agent.View.Preview.t() -> MingaEditor.Agent.View.Preview.t())) :: t()
Updates the preview state with the given function.
Updates the search query string.