pub struct TuiState {Show 24 fields
pub pending_hat: Option<(HatId, String)>,
pub pending_backend: Option<String>,
pub iteration: u32,
pub prev_iteration: u32,
pub loop_started: Option<Instant>,
pub iteration_started: Option<Instant>,
pub last_event: Option<String>,
pub last_event_at: Option<Instant>,
pub show_help: bool,
pub in_scroll_mode: bool,
pub search_query: String,
pub search_forward: bool,
pub max_iterations: Option<u32>,
pub idle_timeout_remaining: Option<Duration>,
pub iterations: Vec<IterationBuffer>,
pub current_view: usize,
pub following_latest: bool,
pub new_iteration_alert: Option<usize>,
pub search_state: SearchState,
pub loop_completed: bool,
pub final_iteration_elapsed: Option<Duration>,
pub final_loop_elapsed: Option<Duration>,
pub task_counts: TaskCounts,
pub active_task: Option<TaskSummary>,
/* private fields */
}Expand description
Observable state derived from loop events.
Fields§
§pending_hat: Option<(HatId, String)>Which hat will process next event (ID + display name).
pending_backend: Option<String>Backend expected for the next iteration (used when metadata is missing).
iteration: u32Current iteration number (0-indexed, display as +1).
prev_iteration: u32Previous iteration number (for detecting changes).
loop_started: Option<Instant>When loop began.
iteration_started: Option<Instant>When current iteration began.
last_event: Option<String>Most recent event topic.
last_event_at: Option<Instant>Timestamp of last event.
show_help: boolWhether to show help overlay.
in_scroll_mode: boolWhether in scroll mode.
search_query: StringCurrent search query (if in search input mode).
search_forward: boolSearch direction (true = forward, false = backward).
max_iterations: Option<u32>Maximum iterations from config.
idle_timeout_remaining: Option<Duration>Idle timeout countdown.
iterations: Vec<IterationBuffer>Content buffers for each iteration.
current_view: usizeIndex of the iteration currently being viewed (0-indexed).
following_latest: boolWhether to automatically follow the latest iteration.
new_iteration_alert: Option<usize>Alert about a new iteration (shown when viewing history and new iteration arrives). Contains the iteration number to alert about. Cleared when navigating to latest.
search_state: SearchStateSearch state for finding and navigating matches in iteration content.
loop_completed: boolWhether the loop has completed (received loop.terminate event).
final_iteration_elapsed: Option<Duration>Frozen elapsed time when loop completed (timer stops at this value).
final_loop_elapsed: Option<Duration>Frozen total elapsed time when loop completed (footer timer stops).
task_counts: TaskCountsAggregate task counts for display in TUI widgets.
active_task: Option<TaskSummary>Currently active task (if any) for display in TUI widgets.
Implementations§
Source§impl TuiState
impl TuiState
Sourcepub fn with_hat_map(hat_map: HashMap<String, (HatId, String)>) -> Self
pub fn with_hat_map(hat_map: HashMap<String, (HatId, String)>) -> Self
Creates state with a custom hat map for dynamic topic-to-hat resolution. Timer starts immediately at creation.
Sourcepub fn get_pending_hat_display(&self) -> String
pub fn get_pending_hat_display(&self) -> String
Returns formatted hat display (emoji + name).
Sourcepub fn get_loop_elapsed(&self) -> Option<Duration>
pub fn get_loop_elapsed(&self) -> Option<Duration>
Time since loop started.
Sourcepub fn get_iteration_elapsed(&self) -> Option<Duration>
pub fn get_iteration_elapsed(&self) -> Option<Duration>
Time since iteration started, or frozen value if loop completed.
Sourcepub fn iteration_changed(&self) -> bool
pub fn iteration_changed(&self) -> bool
True if iteration changed since last check.
Sourcepub fn get_task_counts(&self) -> &TaskCounts
pub fn get_task_counts(&self) -> &TaskCounts
Returns a reference to the current task counts.
Sourcepub fn get_active_task(&self) -> Option<&TaskSummary>
pub fn get_active_task(&self) -> Option<&TaskSummary>
Returns a reference to the active task, if any.
Sourcepub fn set_task_counts(&mut self, counts: TaskCounts)
pub fn set_task_counts(&mut self, counts: TaskCounts)
Updates the task counts.
Sourcepub fn set_active_task(&mut self, task: Option<TaskSummary>)
pub fn set_active_task(&mut self, task: Option<TaskSummary>)
Sets the active task.
Sourcepub fn has_open_tasks(&self) -> bool
pub fn has_open_tasks(&self) -> bool
Returns true if there are any open tasks.
Sourcepub fn get_task_progress_display(&self) -> String
pub fn get_task_progress_display(&self) -> String
Returns a formatted string for task progress display (e.g., “3/5 tasks”).
Sourcepub fn start_new_iteration(&mut self)
pub fn start_new_iteration(&mut self)
Starts a new iteration, creating a new IterationBuffer. If following_latest is true, current_view is updated to the new iteration. If not following, sets the new_iteration_alert to notify the user.
Sourcepub fn start_new_iteration_with_metadata(
&mut self,
hat_display: Option<String>,
backend: Option<String>,
)
pub fn start_new_iteration_with_metadata( &mut self, hat_display: Option<String>, backend: Option<String>, )
Starts a new iteration with optional metadata for hat and backend display.
Sourcepub fn finish_latest_iteration(&mut self)
pub fn finish_latest_iteration(&mut self)
Finalizes the latest iteration’s elapsed time if it isn’t already set.
Sourcepub fn current_iteration_hat_display(&self) -> Option<&str>
pub fn current_iteration_hat_display(&self) -> Option<&str>
Returns the hat display for the currently viewed iteration, if available.
Sourcepub fn current_iteration_backend(&self) -> Option<&str>
pub fn current_iteration_backend(&self) -> Option<&str>
Returns the backend display for the currently viewed iteration, if available.
Sourcepub fn current_iteration(&self) -> Option<&IterationBuffer>
pub fn current_iteration(&self) -> Option<&IterationBuffer>
Returns a reference to the currently viewed iteration buffer.
Sourcepub fn current_iteration_mut(&mut self) -> Option<&mut IterationBuffer>
pub fn current_iteration_mut(&mut self) -> Option<&mut IterationBuffer>
Returns a mutable reference to the currently viewed iteration buffer.
Sourcepub fn current_iteration_lines_handle(
&self,
) -> Option<Arc<Mutex<Vec<Line<'static>>>>>
pub fn current_iteration_lines_handle( &self, ) -> Option<Arc<Mutex<Vec<Line<'static>>>>>
Returns a shared handle to the current iteration’s lines buffer.
This allows stream handlers to write directly to the buffer, enabling real-time streaming to the TUI during execution.
Sourcepub fn latest_iteration_lines_handle(
&self,
) -> Option<Arc<Mutex<Vec<Line<'static>>>>>
pub fn latest_iteration_lines_handle( &self, ) -> Option<Arc<Mutex<Vec<Line<'static>>>>>
Returns a shared handle to the latest iteration’s lines buffer.
This should be used when writing output from the currently executing iteration, regardless of which iteration the user is viewing. This prevents output from being written to the wrong iteration when the user is reviewing an older iteration.
Navigates to the next iteration (if not at the last one). If reaching the last iteration, re-enables following_latest and clears alerts.
Navigates to the previous iteration (if not at the first one). Disables following_latest when navigating backwards.
Sourcepub fn total_iterations(&self) -> usize
pub fn total_iterations(&self) -> usize
Returns the total number of iterations.
Sourcepub fn search(&mut self, query: &str)
pub fn search(&mut self, query: &str)
Searches for the given query in the current iteration’s content. Populates matches with (line_index, char_offset) pairs. Search is case-insensitive.
Sourcepub fn next_match(&mut self)
pub fn next_match(&mut self)
Navigates to the next match, cycling back to the first if at the end.
Sourcepub fn prev_match(&mut self)
pub fn prev_match(&mut self)
Navigates to the previous match, cycling to the last if at the beginning.
Sourcepub fn clear_search(&mut self)
pub fn clear_search(&mut self)
Clears the search state.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TuiState
impl RefUnwindSafe for TuiState
impl Send for TuiState
impl Sync for TuiState
impl Unpin for TuiState
impl UnwindSafe for TuiState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more