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.

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.

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.

Marks an orphaned remote tab projection as disconnected.

Clears lifecycle fields for an orphaned agent tab after its session exits.

Creates a new agent tab.

Creates a new file tab.

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

Refreshes any background-subagent 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 and logical file projection.

Sets the attention flag (agent needs user input).

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.

Toggles whether this tab is pinned in the tab strip.

Types

agent()

@type agent() :: %MingaEditor.State.Tab{
  context: term(),
  group_id: term(),
  id: term(),
  kind: :agent,
  label: term(),
  payload: MingaEditor.State.Tab.Agent.t(),
  pinned?: term()
}

agent_status()

@type agent_status() :: MingaEditor.State.Workspace.agent_status()

Agent tab status.

connection_status()

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.

file()

@type file() :: %MingaEditor.State.Tab{
  context: term(),
  group_id: term(),
  id: term(),
  kind: :file,
  label: term(),
  payload: MingaEditor.State.Tab.File.t(),
  pinned?: term()
}

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() :: file() | agent()

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.

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.

mark_orphan_remote_disconnected(tab)

@spec mark_orphan_remote_disconnected(agent()) :: agent()

Marks an orphaned remote tab projection as disconnected.

mark_orphan_session_down(tab, status)

@spec mark_orphan_session_down(agent(), agent_status()) :: agent()

Clears lifecycle fields for an orphaned agent tab after its session exits.

new_agent(id, label \\ "Agent")

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

Creates a new agent tab.

new_file(id, label \\ "")

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

Creates a new file tab.

project_agent_lifecycle(tab, workspace)

@spec project_agent_lifecycle(agent(), MingaEditor.State.Workspace.agent()) :: agent()

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

refresh_session_pid(tab, old_pid, new_pid)

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

Refreshes any background-subagent 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 and logical file projection.

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() | 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.

toggle_pinned(tab)

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

Toggles whether this tab is pinned in the tab strip.