MingaEditor.State.InlineAsk (Minga v0.1.0)

Copy Markdown View Source

Ephemeral inline ask overlays keyed by buffer.

Inline asks are presentation state only. They are not persisted and they do not create workspaces until explicitly promoted.

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 ask-specific shape and transitions: the read-only response accumulation and the :answered terminal state.

Summary

Types

status()

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

store()

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

t()

@type t() :: %MingaEditor.State.InlineAsk{
  anchor_line: non_neg_integer(),
  buffer_pid: pid(),
  context_text: String.t(),
  file_label: String.t(),
  file_ref: Minga.Project.FileRef.t(),
  prompt: String.t(),
  response: String.t(),
  scroll: non_neg_integer(),
  selection_range: {non_neg_integer(), non_neg_integer()} | nil,
  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(ask)

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

Builds the read-only prompt sent to the ephemeral agent session.

answered(ask)

@spec answered(t()) :: t()

Marks the ask as answered.

append_input(ask, text)

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

See MingaEditor.InlineOverlay.Prompt.append_input/2.

append_response(ask, delta)

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

Appends response text.

backspace(ask)

@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(ask, message)

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

Marks the ask as failed.

header(inline_ask)

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

Returns the prompt header.

mark_thinking(ask)

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

Refreshes the visible status without changing session ownership.

new(buffer_pid, file_ref, file_label, anchor_line, selection_range \\ nil, context_text \\ "")

Creates a new ask for a buffer.

put(store, ask)

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

See MingaEditor.InlineOverlay.Store.put/2.

scroll(ask, 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.

thinking(ask, session_pid)

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

Marks the ask as thinking.