DalaDev.Tui.State (dala_dev v0.4.0)

Copy Markdown View Source

State struct and pure navigation logic for the dala_dev TUI.

All state transitions are pure functions: handle_key(state, key) -> state. No side effects, no processes — just data transformation.

Summary

Functions

Returns the breadcrumb trail for the current view.

Returns the items for the currently active detail tab.

Processes a key press and returns the updated state.

Returns the items shown in the navigation panel.

Creates a new state with loaded devices, tasks, and remote info.

Types

t()

@type t() :: %DalaDev.Tui.State{
  current_tab: :devices | :tasks | :output | :debug,
  detail_selected: non_neg_integer(),
  devices: [DalaDev.Tui.Devices.t()],
  focus: :nav | :detail,
  last_run_output: String.t() | nil,
  loading: boolean(),
  nav_selected: non_neg_integer(),
  refreshing: boolean(),
  remotes: [DalaDev.Tui.Remote.t()],
  selected_device: DalaDev.Tui.Devices.t() | nil,
  selected_remote: DalaDev.Tui.Remote.t() | nil,
  selected_task: DalaDev.Tui.Tasks.t() | nil,
  show_help: boolean(),
  status_message: String.t() | nil,
  tasks: [DalaDev.Tui.Tasks.t()],
  version_info: map() | nil
}

Functions

detail_items(state)

@spec detail_items(t()) :: [term()]

Returns the items for the currently active detail tab.

device_detail(device)

@spec device_detail(DalaDev.Tui.Devices.t()) :: [String.t()]

handle_key(state, key)

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

Processes a key press and returns the updated state.

new(devices \\ [], tasks \\ [], remotes \\ [])

Creates a new state with loaded devices, tasks, and remote info.

remote_detail(remote)

@spec remote_detail(DalaDev.Tui.Remote.t()) :: [String.t()]

task_detail(task)

@spec task_detail(DalaDev.Tui.Tasks.t()) :: [String.t()]