MingaEditor.UI.Panel.MessageStore (Minga v0.1.0)

Copy Markdown View Source

Structured log entry store for the GUI Messages tab.

Holds up to 1000 structured log entries with level, subsystem, timestamp, text, and optional file path. The GUI protocol encoder reads from this store to send incremental entries to the frontend.

The TUI uses the *Messages* gap buffer, written by MessagesBuffer. Both are fed from :log_message event broadcasts via Minga.Log.

Summary

Functions

Append a structured log entry. Trims to 1000 entries.

Ensures a raw struct has a producer-assigned restart instance.

Returns entries with id > since_id (for incremental protocol sends).

Level byte for protocol encoding.

Mark the last sent ID (called after protocol encode).

Merges the producer's sent cursor without replacing newer entries.

Creates a message stream with a producer-assigned restart instance.

Parse level and subsystem from a log message text prefix.

Resets the consumer send cursor after frontend state is lost.

Subsystem byte for protocol encoding.

Types

level()

@type level() :: :debug | :info | :warning | :error

stream_instance()

@type stream_instance() :: 1..4_294_967_295

subsystem()

@type subsystem() :: :editor | :lsp | :parser | :git | :render | :agent | :zig | :gui

t()

@type t() :: %MingaEditor.UI.Panel.MessageStore{
  entries: [MingaEditor.UI.Panel.MessageStore.Entry.t()],
  last_sent_id: non_neg_integer(),
  next_id: pos_integer(),
  stream_instance: 0 | stream_instance()
}

Functions

append(store, text, level \\ :info, subsystem \\ :editor)

@spec append(t(), String.t(), level(), subsystem()) :: t()

Append a structured log entry. Trims to 1000 entries.

ensure_stream_instance(store)

@spec ensure_stream_instance(t()) :: t()

Ensures a raw struct has a producer-assigned restart instance.

entries_since(message_store, since_id)

@spec entries_since(t(), non_neg_integer()) :: [
  MingaEditor.UI.Panel.MessageStore.Entry.t()
]

Returns entries with id > since_id (for incremental protocol sends).

level_byte(atom)

@spec level_byte(level()) :: non_neg_integer()

Level byte for protocol encoding.

mark_sent(store, id)

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

Mark the last sent ID (called after protocol encode).

merge_sent_cursor(current, emitted)

@spec merge_sent_cursor(t(), t()) :: t()

Merges the producer's sent cursor without replacing newer entries.

new()

@spec new() :: t()

Creates a message stream with a producer-assigned restart instance.

parse_prefix(text)

@spec parse_prefix(String.t()) :: {level(), subsystem(), String.t()}

Parse level and subsystem from a log message text prefix.

reset_sent_cursor(store)

@spec reset_sent_cursor(t()) :: t()

Resets the consumer send cursor after frontend state is lost.

subsystem_byte(atom)

@spec subsystem_byte(subsystem()) :: non_neg_integer()

Subsystem byte for protocol encoding.