pub struct TuiState {Show 39 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 mouse_capture_enabled: 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 update_status: UpdateStatus,
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>,
pub wave_active: Option<WaveInfo>,
pub wave_active_iteration_idx: Option<usize>,
pub wave_view_active: bool,
pub wave_view_index: usize,
pub guidance_mode: Option<GuidanceMode>,
pub guidance_input: String,
pub guidance_next_queue: Arc<Mutex<Vec<String>>>,
pub events_path: Option<PathBuf>,
pub urgent_steer_path: Option<PathBuf>,
pub guidance_flash: Option<(GuidanceMode, GuidanceResult, Instant)>,
pub subprocess_error: Option<String>,
pub rpc_text_buffer: String,
pub rpc_text_line_count: usize,
/* 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.
mouse_capture_enabled: boolWhether mouse capture is enabled for wheel scrolling. When false, the terminal keeps native drag-to-select behavior.
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.
update_status: UpdateStatusStatus of the asynchronous update check.
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.
wave_active: Option<WaveInfo>Active wave info for header display (only set while a wave is running).
wave_active_iteration_idx: Option<usize>Index into iterations that the active wave belongs to.
Used by wave_info_for_view() to only return wave_active when viewing
the specific iteration that owns the running wave.
wave_view_active: boolWhether the wave worker drill-down view is active.
wave_view_index: usizeIndex of the worker currently being viewed in wave view (0-indexed).
guidance_mode: Option<GuidanceMode>Active guidance input mode (None when not entering guidance).
guidance_input: StringText being typed in guidance input.
guidance_next_queue: Arc<Mutex<Vec<String>>>Queue of guidance messages for the next iteration (drained by loop_runner).
events_path: Option<PathBuf>Path to events.jsonl for writing urgent guidance for the next prompt.
urgent_steer_path: Option<PathBuf>Path to the urgent-steer marker file used to gate ralph emit.
guidance_flash: Option<(GuidanceMode, GuidanceResult, Instant)>Brief flash message after attempting to send guidance. (mode, result, when)
subprocess_error: Option<String>Error message set when subprocess exits before sending any RPC events. When set, the TUI displays an error state instead of empty content.
rpc_text_buffer: StringBuffer for accumulating streaming text deltas received via RPC. Text is rendered as a group when frozen (on tool call, error, or iteration end) rather than rendering each small delta independently.
rpc_text_line_count: usizeNumber of lines in the current iteration buffer that belong to the current (unfrozen) text. When new text arrives, these lines are replaced with a fresh render of the full accumulated text.
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 set_current_branch(&mut self, branch: Option<String>)
pub fn set_current_branch(&mut self, branch: Option<String>)
Sets the git branch displayed by the TUI.
Sourcepub fn current_branch(&self) -> Option<&str>
pub fn current_branch(&self) -> Option<&str>
Returns the git branch displayed by the TUI, if known.
Sourcepub fn set_hat_map(&mut self, hat_map: HashMap<String, (HatId, String)>)
pub fn set_hat_map(&mut self, hat_map: HashMap<String, (HatId, String)>)
Replaces the dynamic topic-to-hat mapping without resetting the rest of the state.
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.
Sourcepub fn start_guidance(&mut self, mode: GuidanceMode)
pub fn start_guidance(&mut self, mode: GuidanceMode)
Enters guidance input mode.
Sourcepub fn cancel_guidance(&mut self)
pub fn cancel_guidance(&mut self)
Cancels guidance input without sending.
Sourcepub fn send_guidance(&mut self) -> bool
pub fn send_guidance(&mut self) -> bool
Sends the current guidance input.
For GuidanceMode::Next, pushes to the shared queue (drained by loop_runner).
For GuidanceMode::Now, writes an urgent-steer marker immediately and
records human.guidance for the next prompt boundary.
Returns true if guidance was sent successfully.
Sourcepub fn is_guidance_active(&self) -> bool
pub fn is_guidance_active(&self) -> bool
Returns true if guidance input is currently active.
Sourcepub fn clear_expired_guidance_flash(&mut self)
pub fn clear_expired_guidance_flash(&mut self)
Clears flash message if it has expired.
Sourcepub fn active_guidance_flash(&self) -> Option<(GuidanceMode, GuidanceResult)>
pub fn active_guidance_flash(&self) -> Option<(GuidanceMode, GuidanceResult)>
Returns active guidance flash (mode + result) if still within display window (2 seconds).
Sourcepub fn set_update_status(&mut self, status: UpdateStatus)
pub fn set_update_status(&mut self, status: UpdateStatus)
Updates the cached result of the asynchronous version check.
Sourcepub fn wave_info_for_wave_view(&self) -> Option<&WaveInfo>
pub fn wave_info_for_wave_view(&self) -> Option<&WaveInfo>
Returns the WaveInfo for the current wave view (public, for header rendering).
Sourcepub fn enter_wave_view(&mut self)
pub fn enter_wave_view(&mut self)
Enters wave worker drill-down view. No-op if no wave data exists.
Sourcepub fn exit_wave_view(&mut self)
pub fn exit_wave_view(&mut self)
Exits wave worker drill-down view.
Sourcepub fn wave_view_next(&mut self)
pub fn wave_view_next(&mut self)
Cycles to the next worker in wave view.
Sourcepub fn wave_view_prev(&mut self)
pub fn wave_view_prev(&mut self)
Cycles to the previous worker in wave view.
Sourcepub fn current_wave_worker_buffer(&self) -> Option<&IterationBuffer>
pub fn current_wave_worker_buffer(&self) -> Option<&IterationBuffer>
Returns the current wave worker buffer (immutable) for rendering.
Sourcepub fn current_wave_worker_buffer_mut(&mut self) -> Option<&mut IterationBuffer>
pub fn current_wave_worker_buffer_mut(&mut self) -> Option<&mut IterationBuffer>
Returns the current wave worker buffer (mutable) for scrolling.
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 UnsafeUnpin 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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