MingaEditor.Renderer.State (Minga v0.1.0)

Copy Markdown View Source

Complete long-lived state owned by MingaEditor.Renderer.Server.

Renderer caches, font registration, frontend acknowledgement state, resident windows, buffer monitors, and coalesced frame credit live here. Public transitions centralize lifecycle cleanup so window close, buffer replacement, reset, and exact monitor :DOWN all discard the same state.

Summary

Functions

Accepts changed semantic work and blocks an identical terminally rejected intent.

Clears rejection visibility after reconnect or another external state change.

Consumes matching one-shot evidence and returns its concrete adapted intent.

Drops all state for the exact monitored buffer death.

Constructs renderer state with injected process dependencies.

Returns frame credit and queues the next semantic frame through the state owner.

Drops windows absent from the latest intent and monitors each live buffer once.

Records adapted-retry evidence only for the matching outstanding transaction.

Releases the outstanding acknowledgement lease without committing its output.

Resets frontend-retained state and re-hydrates every resident in a fresh epoch.

Returns the currently visible terminal frontend failure, if any.

Enters a visible terminal frontend failure while preserving acknowledged caches.

Types

ack_lease()

@type ack_lease() :: %{
  generation: non_neg_integer(),
  seq: non_neg_integer(),
  timer_ref: reference(),
  output: MingaEditor.RenderPipeline.Input.t(),
  intent: MingaEditor.RenderPipeline.Intent.t(),
  pushed_at: integer()
}

editor_ref()

@type editor_ref() :: pid() | atom() | nil

frame_work()

pipeline()

t()

@type t() :: %MingaEditor.Renderer.State{
  ack_timeout_ms: pos_integer(),
  awaiting_ack: ack_lease() | nil,
  buffer_monitors: %{optional(pid()) => reference()},
  buffer_versions: %{optional(pid()) => non_neg_integer()},
  caches: MingaEditor.Renderer.Caches.t(),
  editor_pid: editor_ref(),
  font_registry: MingaEditor.UI.FontRegistry.t(),
  in_flight: frame_work() | nil,
  message_store: MingaEditor.UI.Panel.MessageStore.t() | nil,
  pending: frame_work() | nil,
  pipeline: pipeline(),
  rejection_state: MingaEditor.Renderer.RejectionState.t(),
  render_token: reference() | nil,
  rendering?: boolean(),
  require_ack?: boolean(),
  resident_windows: %{
    optional(MingaEditor.Window.id()) =>
      MingaEditor.Renderer.ResidentWindowState.t()
  },
  stale_retry_count: non_neg_integer()
}

Functions

accept_intent(state, intent)

@spec accept_intent(t(), MingaEditor.RenderPipeline.Intent.t()) ::
  {:accepted, t()} | {:blocked, t()}

Accepts changed semantic work and blocks an identical terminally rejected intent.

clear_rejection(state)

@spec clear_rejection(t()) :: t()

Clears rejection visibility after reconnect or another external state change.

consume_adaptation(state, generation, frame_seq)

@spec consume_adaptation(t(), non_neg_integer(), non_neg_integer()) ::
  {:ok, t(), MingaEditor.RenderPipeline.Intent.t()} | :error

Consumes matching one-shot evidence and returns its concrete adapted intent.

drop_buffer_down(state, ref, buffer)

@spec drop_buffer_down(t(), reference(), pid()) :: {t(), boolean()}

Drops all state for the exact monitored buffer death.

new(opts)

@spec new(keyword()) :: t()

Constructs renderer state with injected process dependencies.

queue_frame(state, work)

@spec queue_frame(t(), frame_work()) :: t()

Returns frame credit and queues the next semantic frame through the state owner.

reconcile_windows(state, intent)

@spec reconcile_windows(t(), MingaEditor.RenderPipeline.Intent.t()) :: t()

Drops windows absent from the latest intent and monitors each live buffer once.

record_adaptation(state, generation, frame_seq, descriptor, adapted)

Records adapted-retry evidence only for the matching outstanding transaction.

release_credit(state)

@spec release_credit(t()) :: t()

Releases the outstanding acknowledgement lease without committing its output.

reset_frontend(state, reason \\ :reset_required)

Resets frontend-retained state and re-hydrates every resident in a fresh epoch.

terminal_failure(state)

@spec terminal_failure(t()) :: MingaEditor.Renderer.RejectionState.terminal() | nil

Returns the currently visible terminal frontend failure, if any.

terminal_failure(state, last_good_frame_seq, reason)

@spec terminal_failure(t(), non_neg_integer(), atom()) :: t()

Enters a visible terminal frontend failure while preserving acknowledged caches.