MingaEditor.State.InlineEdit (Minga v0.1.0)

Copy Markdown View Source

Ephemeral inline edit overlays keyed by buffer.

The shared per-buffer store mechanics (active/2, put/2, dismiss/2, session?/2) and prompt-input mechanics (append_input/2, backspace/1, scroll/2) live in MingaEditor.InlineOverlay.Store and MingaEditor.InlineOverlay.Prompt and are reused here. This module owns only the edit-specific shape and transitions: the selection/original text, tagged proposal data, and the :proposed terminal state.

Summary

Functions

Builds the constrained rewrite prompt.

Appends proposed replacement text streamed by the assistant.

Marks the edit as failed.

Returns the prompt header.

Installs proposed replacement text from the constrained rewrite tool.

Creates a new inline edit for a selected line range.

Marks the edit as proposed.

Constructs a proposed streamed rewrite for direct tests.

Marks the edit as thinking.

Types

phase()

@type phase() ::
  :input
  | {:running, pid(), proposal()}
  | {:proposed, proposal()}
  | {:failed, String.t()}

proposal()

@type proposal() :: :none | {:stream, String.t()} | {:tool, String.t()}

store()

@type store() :: %{required(pid()) => t()}

t()

@type t() :: %MingaEditor.State.InlineEdit{
  buffer_pid: pid(),
  file_label: String.t(),
  file_ref: Minga.Project.FileRef.t(),
  original_text: String.t(),
  phase: phase(),
  prompt: String.t(),
  scroll: non_neg_integer(),
  selection_range: {non_neg_integer(), non_neg_integer()}
}

Functions

active(store, buffer_pid)

@spec active(store(), pid() | nil) :: t() | nil

agent_prompt(edit)

@spec agent_prompt(t()) :: String.t()

Builds the constrained rewrite prompt.

append_input(edit, text)

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

append_proposal(edit, delta)

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

Appends proposed replacement text streamed by the assistant.

backspace(edit)

@spec backspace(t()) :: t()

dismiss(store, buffer_pid)

@spec dismiss(store(), pid() | nil) :: {store(), pid() | nil}

fail(edit, message)

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

Marks the edit as failed.

failed?(edit)

@spec failed?(t()) :: boolean()

header(inline_edit)

@spec header(t()) :: String.t()

Returns the prompt header.

input?(edit)

@spec input?(t()) :: boolean()

install_proposal(edit, proposed)

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

Installs proposed replacement text from the constrained rewrite tool.

new(buffer_pid, file_ref, file_label, arg, original_text)

Creates a new inline edit for a selected line range.

phase(inline_edit)

@spec phase(t()) :: phase()

proposal(inline_edit)

@spec proposal(t()) :: proposal()

proposed(edit)

@spec proposed(t()) :: t()

Marks the edit as proposed.

proposed(edit, rewrite)

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

Constructs a proposed streamed rewrite for direct tests.

proposed?(edit)

@spec proposed?(t()) :: boolean()

put(store, edit)

@spec put(store(), t()) :: store()

rewrite(edit)

@spec rewrite(t()) :: String.t()

running?(edit)

@spec running?(t()) :: boolean()

scroll(edit, delta)

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

scrollable?(edit)

@spec scrollable?(t()) :: boolean()

session?(store, session_pid)

@spec session?(store(), pid()) :: boolean()

session_pid(arg1)

@spec session_pid(t() | term()) :: pid() | nil

thinking(edit, session_pid)

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

Marks the edit as thinking.