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

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.

# `focus`

```elixir
@type focus() :: :chat | :file_viewer
```

Which panel has keyboard focus inside the agentic view.

# `prefix`

```elixir
@type prefix() ::
  nil | :g | :z | :bracket_next | :bracket_prev | Minga.Keymap.Bindings.Node.t()
```

Active prefix key awaiting a follow-up keystroke.

# `search_match`

```elixir
@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.

# `search_state`

```elixir
@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.

# `t`

```elixir
@type t() :: %MingaEditor.Agent.UIState.View{
  active: boolean(),
  chat_width_pct: non_neg_integer(),
  context_estimate: non_neg_integer(),
  diff_baselines: %{required(String.t()) =&gt; 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.

# `toast`

```elixir
@type toast() :: %{
  message: String.t(),
  icon: String.t(),
  level: :info | :warning | :error
}
```

A notification toast.

# `activate`

```elixir
@spec activate(t(), MingaEditor.State.Windows.t(), MingaEditor.State.FileTree.t()) ::
  t()
```

Activates the view, saving the current window layout.

# `cancel_search`

```elixir
@spec cancel_search(t()) :: t()
```

Cancels search and returns nil (caller restores scroll).

# `clear_baselines`

```elixir
@spec clear_baselines(t()) :: t()
```

Clears all diff baselines (called at the start of a new turn).

# `clear_prefix`

```elixir
@spec clear_prefix(t()) :: t()
```

Clears any pending prefix.

# `clear_toasts`

```elixir
@spec clear_toasts(t()) :: t()
```

Clears all toasts.

# `confirm_search`

```elixir
@spec confirm_search(t()) :: t()
```

Confirms search (keeps matches for n/N navigation, disables input).

# `deactivate`

```elixir
@spec deactivate(t()) ::
  {t(), MingaEditor.State.Windows.t() | nil,
   MingaEditor.State.FileTree.t() | nil}
```

Deactivates the view and returns the restored window layout.

# `dismiss_help`

```elixir
@spec dismiss_help(t()) :: t()
```

Dismisses the help overlay.

# `dismiss_toast`

```elixir
@spec dismiss_toast(t()) :: t()
```

Dismisses the current toast. Shows the next one in the queue if any.

# `get_baseline`

```elixir
@spec get_baseline(t(), String.t()) :: String.t() | nil
```

Returns the baseline content for a path, or nil if none recorded.

# `grow_chat`

```elixir
@spec grow_chat(t()) :: t()
```

Grows the chat panel width by one step (clamped at max).

# `new`

```elixir
@spec new() :: t()
```

Creates a new view state with defaults.

# `next_search_match`

```elixir
@spec next_search_match(t()) :: t()
```

Moves to the next search match.

# `prev_search_match`

```elixir
@spec prev_search_match(t()) :: t()
```

Moves to the previous search match.

# `push_toast`

```elixir
@spec push_toast(t(), String.t(), :info | :warning | :error) :: t()
```

Pushes a toast. If no toast is showing, it becomes the current toast.

# `record_baseline`

```elixir
@spec record_baseline(t(), String.t(), String.t()) :: t()
```

Records the baseline content for a file path (first edit only).

# `reset_split`

```elixir
@spec reset_split(t()) :: t()
```

Resets the chat panel width to the configured default.

# `scroll_viewer_down`

```elixir
@spec scroll_viewer_down(t(), pos_integer()) :: t()
```

Scrolls the preview pane down by the given number of lines.

# `scroll_viewer_to_bottom`

```elixir
@spec scroll_viewer_to_bottom(t()) :: t()
```

Scrolls the preview pane to a large offset (renderer clamps to actual content).

# `scroll_viewer_to_top`

```elixir
@spec scroll_viewer_to_top(t()) :: t()
```

Scrolls the preview pane to the top (offset 0).

# `scroll_viewer_up`

```elixir
@spec scroll_viewer_up(t(), pos_integer()) :: t()
```

Scrolls the preview pane up by the given number of lines, clamped at 0.

# `search_input_active?`

```elixir
@spec search_input_active?(t()) :: boolean()
```

Returns true if search input is being typed (vs confirmed).

# `search_query`

```elixir
@spec search_query(t()) :: String.t() | nil
```

Returns the search query, or nil if not searching.

# `search_saved_scroll`

```elixir
@spec search_saved_scroll(t()) :: non_neg_integer() | nil
```

Returns the saved scroll position from before search started.

# `searching?`

```elixir
@spec searching?(t()) :: boolean()
```

Returns true if search is active (either inputting or confirmed with matches).

# `set_focus`

```elixir
@spec set_focus(t(), focus()) :: t()
```

Switches focus to the given panel.

# `set_prefix`

```elixir
@spec set_prefix(t(), prefix()) :: t()
```

Sets the pending prefix for multi-key sequences.

# `set_search_matches`

```elixir
@spec set_search_matches(t(), [search_match()]) :: t()
```

Sets search matches and resets current to 0.

# `shrink_chat`

```elixir
@spec shrink_chat(t()) :: t()
```

Shrinks the chat panel width by one step (clamped at min).

# `start_search`

```elixir
@spec start_search(t(), non_neg_integer()) :: t()
```

Starts a search, saving the current scroll position.

# `toast_visible?`

```elixir
@spec toast_visible?(t()) :: boolean()
```

Returns true if a toast is currently visible.

# `toggle_help`

```elixir
@spec toggle_help(t()) :: t()
```

Toggles the help overlay visibility.

# `update_preview`

```elixir
@spec update_preview(t(), (MingaEditor.Agent.View.Preview.t() -&gt;
                       MingaEditor.Agent.View.Preview.t())) ::
  t()
```

Updates the preview state with the given function.

# `update_search_query`

```elixir
@spec update_search_query(t(), String.t()) :: t()
```

Updates the search query string.

---

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