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, the proposed rewrite with its :stream vs :tool source tracking, and the :proposed terminal state.

Summary

Types

proposal_source()

@type proposal_source() :: :stream | :tool | nil

status()

@type status() :: :input | :thinking | :proposed | :error

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(),
  prompt: String.t(),
  proposal_source: proposal_source(),
  proposed_rewrite: String.t(),
  scroll: non_neg_integer(),
  selection_range: {non_neg_integer(), non_neg_integer()},
  session_pid: pid() | nil,
  status: status()
}

Functions

active(store, buffer_pid)

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

See MingaEditor.InlineOverlay.Store.active/2.

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()

See MingaEditor.InlineOverlay.Prompt.append_input/2.

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()

See MingaEditor.InlineOverlay.Prompt.backspace/1.

dismiss(store, buffer_pid)

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

See MingaEditor.InlineOverlay.Store.dismiss/2.

fail(edit, message)

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

Marks the edit as failed.

header(inline_edit)

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

Returns the prompt header.

mark_thinking(edit)

@spec mark_thinking(t()) :: t()

Refreshes the visible thinking status.

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

Creates a new inline edit for a selected line range.

proposed(edit)

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

Marks the edit as proposed.

put(store, edit)

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

See MingaEditor.InlineOverlay.Store.put/2.

scroll(edit, delta)

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

See MingaEditor.InlineOverlay.Prompt.scroll/2.

session?(store, session_pid)

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

See MingaEditor.InlineOverlay.Store.session?/2.

set_proposal(edit, proposed)

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

Replaces the proposed replacement text from the constrained rewrite tool.

thinking(edit, session_pid)

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

Marks the edit as thinking.