MingaEditor.Agent.UIState (Minga v0.1.0)

Copy Markdown View Source

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.

t()

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.

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.

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

input_mode()

@type input_mode() :: :insert | :normal | :visual | :visual_line | :operator_pending

Vim mode for the input field when focused.

t()

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

thinking_level()

@type thinking_level() :: String.t()

Thinking level for models that support extended reasoning.

Functions

activate(state, windows, file_tree)

@spec activate(
  t(),
  MingaEditor.State.Windows.t() | nil,
  MingaEditor.State.FileTree.t() | nil
) :: t()

Activates the view, saving the current window layout.

activate(state, windows, file_tree, return_target)

Activates the view with a recorded editor return target.

append_paste_block(state, text)

@spec append_paste_block(t(), String.t()) :: t()

Appends one collapsed paste block and marks the prompt as freshly edited.

attach_prompt_buffer(state, pid)

@spec attach_prompt_buffer(t(), pid()) :: t()

Attaches the process-backed prompt buffer to this UI value.

cancel_search(state)

@spec cancel_search(t()) :: t()

Cancels search.

clear_baselines(state)

@spec clear_baselines(t()) :: t()

Clears all diff baselines.

clear_display(state, message_count)

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

clear_mention_completion(state)

@spec clear_mention_completion(t()) :: t()

Clears the active file mention completion.

clear_prefix(state)

@spec clear_prefix(t()) :: t()

Clears any pending prefix.

clear_return_target(state)

@spec clear_return_target(t()) :: t()

Clears the editor return target.

clear_toasts(state)

@spec clear_toasts(t()) :: t()

Clears all toasts.

confirm_search(state)

@spec confirm_search(t()) :: t()

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

deactivate(state)

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

Deactivates the view and returns the restored window layout.

detach_prompt_buffer(state)

@spec detach_prompt_buffer(t()) :: t()

Forgets a dead prompt buffer while preserving prompt metadata.

dismiss_help(state)

@spec dismiss_help(t()) :: t()

Dismisses the help overlay.

dismiss_toast(state)

@spec dismiss_toast(t()) :: t()

Dismisses the current toast.

engage_auto_scroll(state)

@spec engage_auto_scroll(t()) :: t()

Re-engages auto-scroll. Delegates to Minga.Editing.pin_to_bottom/1.

finish_compaction(state)

@spec finish_compaction(t()) :: t()

Marks compaction as no longer running.

get_baseline(view, path)

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

grow_chat(state)

@spec grow_chat(t()) :: t()

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

mark_paste_expanded(state, index, expanded?)

@spec mark_paste_expanded(t(), non_neg_integer(), boolean()) :: t()

Records whether a paste block is expanded in the process-backed prompt.

new()

@spec new() :: t()

Creates a new UIState with credential-aware panel defaults.

next_search_match(state)

@spec next_search_match(t()) :: t()

Moves to the next search match.

paste_block_index(arg1)

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

paste_block_line_count(blocks, index)

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

paste_placeholder?(line)

@spec paste_placeholder?(String.t()) :: boolean()

Returns true if the given line is a paste placeholder token.

prev_search_match(state)

@spec prev_search_match(t()) :: t()

Moves to the previous search match.

push_toast(state, message, level)

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

Pushes a toast.

record_baseline(state, path, content)

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

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

record_prompt_edit(state)

@spec record_prompt_edit(t()) :: t()

Records metadata shared by ordinary prompt edits.

record_scroll_metrics(state, total_lines, visible_height)

@spec record_scroll_metrics(t(), non_neg_integer(), pos_integer()) :: t()

Records transcript scroll metrics observed during rendering.

remember_prompt(state, text)

@spec remember_prompt(t(), String.t()) :: t()

Records a submitted prompt in newest-first history order.

replace_activity(state, activity)

@spec replace_activity(t(), MingaEditor.Agent.Activity.t()) :: t()

Installs the activity produced by an Activity transition.

replace_edit_timeline(state, timeline)

@spec replace_edit_timeline(t(), MingaEditor.Agent.EditTimeline.t()) :: t()

Installs the timeline produced by an EditTimeline transition.

replace_panel(state, panel)

@spec replace_panel(t(), MingaEditor.Agent.UIState.Panel.t()) :: t()

Installs a complete panel projection produced by a named Panel transition.

replace_preview(state, preview)

@spec replace_preview(t(), MingaEditor.Agent.View.Preview.t()) :: t()

Installs the preview produced by a Preview transition.

replace_view(state, view)

@spec replace_view(t(), MingaEditor.Agent.UIState.View.t()) :: t()

Installs a complete view projection produced by a named View transition.

reset_paste_metadata(state)

@spec reset_paste_metadata(t()) :: t()

Clears collapsed-paste metadata after complete prompt replacement.

reset_prompt_metadata(state)

@spec reset_prompt_metadata(t()) :: t()

Resets prompt history selection and collapsed-paste metadata.

reset_split(state)

@spec reset_split(t()) :: t()

Resets the chat panel width to the configured default.

retire_prompt_buffer(state, pid)

@spec retire_prompt_buffer(t(), pid()) :: t()

Forgets a prompt buffer only when the retiring process owns it.

return_target(active_tab_id, active_buffer, windows, file_tree, keymap_scope, prompt_focused)

Builds a return target from the current editor context.

scroll_down(state, amount)

@spec scroll_down(t(), non_neg_integer()) :: t()

Scrolls the content down. Delegates to Minga.Editing.scroll_down/2.

scroll_to_bottom(state)

@spec scroll_to_bottom(t()) :: t()

Pins chat to bottom. Delegates to Minga.Editing.pin_to_bottom/1.

scroll_to_top(state)

@spec scroll_to_top(t()) :: t()

Scrolls to top. Delegates to Minga.Editing.scroll_to_top/1.

scroll_up(state, amount)

@spec scroll_up(t(), non_neg_integer()) :: t()

Scrolls the content up. Delegates to Minga.Editing.scroll_up/2.

scroll_viewer_down(state, amount)

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

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

scroll_viewer_to_bottom(state)

@spec scroll_viewer_to_bottom(t()) :: t()

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

scroll_viewer_to_top(state)

@spec scroll_viewer_to_top(t()) :: t()

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

scroll_viewer_up(state, amount)

@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?(view)

@spec search_input_active?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()

Returns true if search input is being typed.

search_query(view)

@spec search_query(t() | MingaEditor.Agent.UIState.View.t()) :: String.t() | nil

Returns the search query, or nil if not searching.

search_saved_scroll(view)

@spec search_saved_scroll(t() | MingaEditor.Agent.UIState.View.t()) ::
  non_neg_integer() | nil

Returns the saved scroll position from before search started.

searching?(view)

@spec searching?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()

Returns true if search is active.

select_prompt_history(state, index)

@spec select_prompt_history(t(), integer()) :: t()

Selects one prompt-history position after the workflow replaces text.

set_focus(state, focus)

@spec set_focus(t(), MingaEditor.Agent.UIState.View.focus()) :: t()

Switches focus to the given panel.

set_input_focused(state, focused?)

@spec set_input_focused(t(), boolean()) :: t()

Records whether prompt input owns focus; buffer attachment belongs to PromptBuffer.

set_model_name(state, model)

@spec set_model_name(t(), String.t()) :: t()

Sets the model name.

set_pinned(state, pinned)

@spec set_pinned(t(), boolean()) :: t()

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.

set_prefix(state, prefix)

@spec set_prefix(t(), MingaEditor.Agent.UIState.View.prefix()) :: t()

Sets the pending prefix for multi-key sequences.

set_provider_name(state, provider)

@spec set_provider_name(t(), String.t()) :: t()

Sets the provider name.

set_return_target(state, return_target)

@spec set_return_target(t(), MingaEditor.Agent.UIState.View.return_target() | nil) ::
  t()

Sets the editor return target.

set_scroll(state, offset)

@spec set_scroll(t(), non_neg_integer()) :: t()

Sets the scroll offset to an absolute value. Unpins from bottom.

set_search_matches(state, matches)

@spec set_search_matches(t(), [MingaEditor.Agent.UIState.View.search_match()]) :: t()

Sets search matches and resets current to 0.

set_thinking_level(state, level)

@spec set_thinking_level(t(), String.t()) :: t()

Sets the thinking level.

shrink_chat(state)

@spec shrink_chat(t()) :: t()

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

start_search(state, current_scroll)

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

Starts a search, saving the current scroll position.

tick_spinner(state)

@spec tick_spinner(t()) :: t()

Advances the spinner animation frame.

toast_visible?(view)

@spec toast_visible?(t() | MingaEditor.Agent.UIState.View.t()) :: boolean()

Returns true if a toast is currently visible.

toggle(state)

@spec toggle(t()) :: t()

Toggles panel visibility.

toggle_help(state)

@spec toggle_help(t()) :: t()

Toggles the help overlay visibility.

update_search_query(state, query)

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

Updates the search query string.