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 typed context 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 MingaEditor.State.Tab.Context, a struct with explicit workspace fields. Restore still accepts legacy maps for migration, including empty maps for brand-new tabs.

Summary

Types

Agent tab status (nil for file tabs).

Remote connection status for a tab backed by a remote session.

Snapshotted per-tab state.

Workspace id. 0 = manual workspace.

Unique tab identifier.

Tab kind.

Legacy context map accepted at migration boundaries.

t()

A tab.

Functions

Returns true if this is an agent tab.

Returns true when this tab projects a background sub-agent.

Clears agent lifecycle projection data from this tab.

Clears projected remote metadata from this tab.

Returns the display label including any remote server prefix.

Drops all snapshotted extension-owned feature state.

Drops all snapshotted feature state owned by a source.

Returns true if this is a file tab.

Marks this tab as the UI projection of a background sub-agent.

Creates a new agent tab.

Creates a new file tab.

Refreshes any session pid references after a managed restart.

Returns true when this tab is backed by a remote session.

Removes a dead buffer pid from this tab's context snapshot.

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

Sets the attention flag (agent needs user input).

Updates remote connection status for the tab.

Stores a context snapshot into the tab.

Sets the logical file identity for a file tab.

Sets the workspace group id.

Updates the tab's label.

Sets whether this tab is pinned in the tab strip.

Projects workspace-owned remote metadata onto this tab for display.

Marks the tab as backed by a remote agent session.

Sets the session pid for an agent tab.

Toggles whether this tab is pinned in the tab strip.

Types

agent_status()

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

Agent tab status (nil for file tabs).

connection_status()

@type connection_status() :: :connected | :disconnected | :ended | :unavailable | nil

Remote connection status for a tab backed by a remote session.

context()

@type context() :: MingaEditor.State.Tab.Context.t()

Snapshotted per-tab state.

Stores per-tab workspace fields in an explicit struct. Empty context means a brand-new tab.

group_id()

@type group_id() :: non_neg_integer()

Workspace id. 0 = manual workspace.

id()

@type id() :: pos_integer()

Unique tab identifier.

kind()

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

Tab kind.

legacy_context()

@type legacy_context() :: MingaEditor.State.Tab.Context.legacy()

Legacy context map accepted at migration boundaries.

t()

@type t() :: %MingaEditor.State.Tab{
  agent_status: agent_status(),
  attention: boolean(),
  background_subagent: MingaAgent.Subagent.Handle.t() | nil,
  connection_status: connection_status(),
  context: context(),
  file_ref: Minga.Project.FileRef.t() | nil,
  group_id: group_id(),
  id: id(),
  kind: kind(),
  label: String.t(),
  pinned?: boolean(),
  remote_session_id: String.t() | nil,
  server_name: String.t() | nil,
  session: pid() | nil
}

A tab.

Functions

agent?(tab)

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

Returns true if this is an agent tab.

background_subagent?(tab)

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

Returns true when this tab projects a background sub-agent.

clear_agent_projection(tab)

@spec clear_agent_projection(t()) :: t()

Clears agent lifecycle projection data from this tab.

clear_remote_projection(tab)

@spec clear_remote_projection(t()) :: t()

Clears projected remote metadata from this tab.

display_label(tab)

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

Returns the display label including any remote server prefix.

drop_extension_feature_state_sources(tab)

@spec drop_extension_feature_state_sources(t()) :: t()

Drops all snapshotted extension-owned feature state.

drop_feature_state_source(tab, source)

@spec drop_feature_state_source(t(), MingaEditor.FeatureState.source()) :: t()

Drops all snapshotted feature state owned by a source.

file?(tab)

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

Returns true if this is a file tab.

mark_background_subagent(tab, handle)

@spec mark_background_subagent(t(), MingaAgent.Subagent.Handle.t()) :: t()

Marks this tab as the UI projection of a background sub-agent.

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.

refresh_session_pid(tab, old_pid, new_pid)

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

Refreshes any session pid references after a managed restart.

remote?(tab)

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

Returns true when this tab is backed by a remote session.

scrub_buffer(tab, pid)

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

Removes a dead buffer pid from this tab's context snapshot.

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_connection_status(tab, status)

@spec set_connection_status(t(), connection_status()) :: t()

Updates remote connection status for the tab.

set_context(tab, context)

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

Stores a context snapshot into the tab.

set_file_ref(tab, file_ref)

@spec set_file_ref(t(), Minga.Project.FileRef.t() | nil) :: t()

Sets the logical file identity for a file 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_pinned(tab, value)

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

Sets whether this tab is pinned in the tab strip.

set_remote_projection(tab, remote_session)

@spec set_remote_projection(t(), MingaEditor.State.Workspace.RemoteSession.t()) :: t()

Projects workspace-owned remote metadata onto this tab for display.

set_remote_session(tab, server_name, session_id, pid)

@spec set_remote_session(t(), String.t(), String.t(), pid()) :: t()

Marks the tab as backed by a remote agent session.

set_session(tab, pid)

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

Sets the session pid for an agent tab.

toggle_pinned(tab)

@spec toggle_pinned(t()) :: t()

Toggles whether this tab is pinned in the tab strip.