# `MingaEditor.StatusBar.Data`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/status_bar/data.ex#L1)

Tagged-union data struct for the global status bar.

Computed once per frame from editor state and consumed by both rendering
paths: `Chrome.TUI` feeds it to `Modeline.render/5` as cell draws;
`Emit.GUI` encodes it as the 0x76 structured opcode for SwiftUI.

The two variants reflect the two kinds of focused window content:
- `{:buffer, t:buffer_data()}` — a normal buffer window
- `{:agent, t:agent_data()}` — an agent chat window

# `agent_data`

```elixir
@type agent_data() :: %{
  mode: Minga.Mode.mode(),
  mode_state: Minga.Mode.state() | nil,
  model_name: String.t(),
  session_status: MingaEditor.State.Agent.status(),
  message_count: non_neg_integer(),
  macro_recording: {true, String.t()} | false,
  agent_status: MingaEditor.State.Agent.status(),
  agent_theme_colors: MingaEditor.UI.Theme.Agent.t() | nil,
  cursor_line: non_neg_integer(),
  cursor_col: non_neg_integer(),
  line_count: non_neg_integer(),
  file_name: String.t(),
  filetype: atom(),
  dirty: boolean(),
  git_branch: String.t() | nil,
  git_diff_summary: git_diff_summary(),
  diagnostic_counts:
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
    | nil,
  diagnostic_hint: String.t() | nil,
  lsp_status: lsp_status(),
  parser_status: parser_status(),
  buf_index: pos_integer(),
  buf_count: non_neg_integer(),
  status_msg: String.t() | nil
}
```

Data for a focused agent chat window. Includes background buffer context so the status bar layout stays stable across mode switches.

# `buffer_data`

```elixir
@type buffer_data() :: %{
  mode: Minga.Mode.mode(),
  mode_state: Minga.Mode.state() | nil,
  cursor_line: non_neg_integer(),
  cursor_col: non_neg_integer(),
  line_count: non_neg_integer(),
  file_name: String.t(),
  filetype: atom(),
  dirty: boolean(),
  git_branch: String.t() | nil,
  git_diff_summary: git_diff_summary(),
  diagnostic_counts:
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
    | nil,
  diagnostic_hint: String.t() | nil,
  lsp_status: lsp_status(),
  parser_status: parser_status(),
  buf_index: pos_integer(),
  buf_count: non_neg_integer(),
  macro_recording: {true, String.t()} | false,
  agent_status: MingaEditor.State.Agent.status(),
  agent_theme_colors: MingaEditor.UI.Theme.Agent.t() | nil,
  status_msg: String.t() | nil
}
```

Data for a focused buffer window.

# `git_diff_summary`

```elixir
@type git_diff_summary() ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer()} | nil
```

Git diff summary: {added, modified, deleted} line counts.

# `lsp_status`

```elixir
@type lsp_status() :: :ready | :initializing | :starting | :error | :none
```

LSP connection status.

# `parser_status`

```elixir
@type parser_status() :: :available | :unavailable | :restarting
```

Parser availability status.

# `t`

```elixir
@type t() :: {:buffer, buffer_data()} | {:agent, agent_data()}
```

Tagged union: buffer or agent variant.

# `cursor_line_diagnostic_hint`

```elixir
@spec cursor_line_diagnostic_hint(pid() | nil, non_neg_integer()) :: String.t() | nil
```

Returns the first diagnostic message on the given cursor line, formatted
as a human-readable hint string (icon + message + source). Returns nil
if no diagnostics exist on that line.

Used by the GUI status bar center segment to show diagnostic context
when idle (no status message, no active minibuffer).

# `diagnostic_modeline_data`

```elixir
@spec diagnostic_modeline_data(pid() | nil) ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
  | nil
```

Returns the diagnostic count 4-tuple for the active buffer, or nil.

# `from_state`

```elixir
@spec from_state(MingaEditor.State.t() | map()) :: t()
```

Builds the status bar data from the current editor state.

Inspects the active window's content type and returns the appropriate
tagged variant. Called once per render frame before the Chrome stage.

# `git_modeline_data`

```elixir
@spec git_modeline_data(pid() | nil) :: {String.t() | nil, git_diff_summary()}
```

Returns {branch_name | nil, diff_summary | nil} for the status bar.

# `to_modeline_data`

```elixir
@spec to_modeline_data(t()) :: MingaEditor.Shell.Traditional.Modeline.modeline_data()
```

Converts a `StatusBar.Data.t()` to the map shape expected by `Modeline.render/5`.

Both variants carry the same buffer fields and produce identical modeline data.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
