MingaEditor.State.Tab (Minga v0.1.0)

Copy Markdown View Source

A single tab in the tab bar.

Each tab has a unique id, a kind (:file or :agent), a display label, and a context map that stores snapshotted per-tab state when the tab is inactive. The active tab's context is "live" on EditorState; inactive tabs carry a frozen snapshot that gets restored when you switch to them.

Context format

The canonical context is a flat map with per-tab fields (buffers, windows, vim state, viewport, etc.) stored directly. Legacy contexts with nested structure are auto-migrated on first restore.

Summary

Types

Agent tab status (nil for file tabs).

Snapshotted per-tab state.

Workspace group id. 0 = manual/ungrouped workspace.

Unique tab identifier.

Tab kind.

t()

A tab.

Functions

Returns true if this is an agent tab.

Returns true if this is a file tab.

Creates a new agent tab.

Creates a new file tab.

Sets the agent status on a tab (for tab bar rendering).

Sets the attention flag (agent needs user input).

Stores a context snapshot into the tab.

Sets the workspace group id.

Updates the tab's label.

Sets the session pid for an agent tab.

Types

agent_status()

@type agent_status() :: :idle | :thinking | :tool_executing | :error | nil

Agent tab status (nil for file tabs).

context()

@type context() :: %{
  optional(:keymap_scope) => atom(),
  optional(:buffers) => term(),
  optional(:windows) => term(),
  optional(:file_tree) => term(),
  optional(:viewport) => term(),
  optional(:mouse) => term(),
  optional(:highlight) => term(),
  optional(:lsp_pending) => term(),
  optional(:completion) => term(),
  optional(:completion_trigger) => term(),
  optional(:injection_ranges) => term(),
  optional(:search) => term(),
  optional(:pending_conflict) => term(),
  optional(:editing) => MingaEditor.VimState.t(),
  optional(:vim) => MingaEditor.VimState.t(),
  optional(:document_highlights) => term(),
  optional(:agent_ui) => term(),
  optional(:mode) => atom(),
  optional(:mode_state) => term(),
  optional(:reg) => term(),
  optional(:marks) => term(),
  optional(:last_jump_pos) => term(),
  optional(:last_find_char) => term(),
  optional(:change_recorder) => term(),
  optional(:macro_recorder) => term()
}

Snapshotted per-tab state.

The context stores per-tab fields directly (buffers, windows, mode, etc.). Empty context means a brand-new tab.

Legacy contexts with nested structure (old snapshot format) or bare fields (oldest format) are auto-migrated on first restore.

group_id()

@type group_id() :: non_neg_integer()

Workspace group id. 0 = manual/ungrouped workspace.

id()

@type id() :: pos_integer()

Unique tab identifier.

kind()

@type kind() :: :file | :agent

Tab kind.

t()

@type t() :: %MingaEditor.State.Tab{
  agent_status: agent_status(),
  attention: boolean(),
  context: context(),
  group_id: group_id(),
  id: id(),
  kind: kind(),
  label: String.t(),
  session: pid() | nil
}

A tab.

Functions

agent?(tab)

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

Returns true if this is an agent tab.

file?(tab)

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

Returns true if this is a file tab.

new_agent(id, label \\ "Agent")

@spec new_agent(id(), String.t()) :: t()

Creates a new agent tab.

new_file(id, label \\ "")

@spec new_file(id(), String.t()) :: t()

Creates a new file tab.

set_agent_status(tab, status)

@spec set_agent_status(t(), agent_status()) :: t()

Sets the agent status on a tab (for tab bar rendering).

set_attention(tab, value)

@spec set_attention(t(), boolean()) :: t()

Sets the attention flag (agent needs user input).

set_context(tab, context)

@spec set_context(t(), context()) :: t()

Stores a context snapshot into the tab.

set_group(tab, group_id)

@spec set_group(t(), group_id()) :: t()

Sets the workspace group id.

set_label(tab, label)

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

Updates the tab's label.

set_session(tab, pid)

@spec set_session(t(), pid() | nil) :: t()

Sets the session pid for an agent tab.