State struct and pure navigation logic for the PhoenixGenApi TUI explorer.
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 header.
Clears any notice or error message in the state.
Returns the items for the currently active detail tab.
Processes a key press and returns the updated state.
Returns the list of items shown in the navigation panel.
Creates a new state from introspection data.
Refreshes the introspection data attached to the state. Returns a new state with updated data, preserving navigation context where possible.
Returns the cached search query (updated on search input changes).
Types
@type t() :: %PhoenixGenApiTui.State{ current_function: struct() | nil, current_service: PhoenixGenApiTui.Introspection.ServiceInfo.t() | nil, current_tab: tab(), detail_overlay: struct() | nil, detail_selected: non_neg_integer(), focus: :nav | :detail, introspection: PhoenixGenApiTui.Introspection.t(), last_error: String.t() | nil, nav_selected: non_neg_integer(), nav_stack: [{atom(), tab()}], notice: String.t() | nil, search_input: reference() | nil, search_query: String.t(), searching: boolean(), show_help: boolean() }
@type tab() ::
:functions
| :call_flows
| :cluster
| :health
| :stats
| :rate_limits
| :errors
| :system
Functions
Returns the breadcrumb trail for the header.
Clears any notice or error message in the state.
Returns the items for the currently active detail tab.
Processes a key press and returns the updated state.
Handles vim-style navigation (j/k/h/l), tab switching (tab, 1-6),
enter/esc for selection and back-navigation, ? for help, and / for search.
@spec new(PhoenixGenApiTui.Introspection.t()) :: t()
Creates a new state from introspection data.
Examples
iex> introspection = %PhoenixGenApiTui.Introspection{
...> services: [%PhoenixGenApiTui.Introspection.ServiceInfo{name: MyApp.Services.UserService, functions: []}],
...> call_flows: [], cluster_view: %{}, health_check: %{}, statistics: %{}, rate_limits: %{},
...> status: :ok, loaded_at: 0
...> }
iex> state = PhoenixGenApiTui.State.new(introspection)
iex> state.current_service.name
MyApp.Services.UserService
iex> state.current_tab
:functions
iex> state = PhoenixGenApiTui.State.new(%PhoenixGenApiTui.Introspection{services: [], call_flows: [], cluster_view: %{}, health_check: %{}, statistics: %{}, rate_limits: %{}})
iex> state.current_service
nil
Refreshes the introspection data attached to the state. Returns a new state with updated data, preserving navigation context where possible.
Returns the cached search query (updated on search input changes).