Skip to main content

App

Struct App 

Source
pub struct App {
Show 29 fields pub worktrees: Vec<Worktree>, pub visible: Vec<usize>, pub selected: usize, pub mode: Mode, pub filter: String, pub focus: Pane, pub show_sidebar: bool, pub sidebar_width: u16, pub sort: SortSpec, pub detail_scroll: u16, pub size: (u16, u16), pub keymap: Keymap, pub columns: Vec<Column>, pub show_untracked: bool, pub remove_untracked_blocks: bool, pub nerd_fonts: bool, pub mouse: bool, pub color: bool, pub palette: Palette, pub quit: bool, pub chosen: Option<PathBuf>, pub status_message: Option<String>, pub status_kind: StatusKind, pub too_small: bool, pub jobs: Vec<ActiveJob>, pub spinner_frame: usize, pub pending_jobs: Vec<Effect>, pub branches: Vec<String>, pub default_base: Option<String>, /* private fields */
}
Expand description

The TUI application state.

Fields§

§worktrees: Vec<Worktree>

All worktrees (sorted).

§visible: Vec<usize>

Indices into worktrees currently visible (after filtering).

§selected: usize

Selected index into visible.

§mode: Mode

The current mode.

§filter: String

The active filter string.

§focus: Pane

Which pane has focus.

§show_sidebar: bool

Whether the list (sidebar) pane is shown.

§sidebar_width: u16

The list pane width.

§sort: SortSpec

The current sort.

§detail_scroll: u16

Scroll offset of the detail pane.

§size: (u16, u16)

Terminal size (cols, rows).

§keymap: Keymap

The key bindings.

§columns: Vec<Column>

Columns to render in the list.

§show_untracked: bool

Whether untracked files show ?.

§remove_untracked_blocks: bool

Whether untracked-only files count as “dirty” for the remove guard (the confirm dialog mirrors remove.untracked_blocks, not show_untracked).

§nerd_fonts: bool

Whether Nerd Font glyphs are enabled.

§mouse: bool

Whether mouse support is enabled.

§color: bool

Whether color output is enabled (spec §11 precedence, resolved once).

§palette: Palette

The resolved color palette (preset + [ui.theme] overrides).

§quit: bool

Set when the user quits without switching.

§chosen: Option<PathBuf>

Set to the chosen path when the user switches (Enter).

§status_message: Option<String>

A transient status/error line shown in the status bar.

§status_kind: StatusKind

The severity of status_message, used to color it.

§too_small: bool

Set when the terminal became too small to continue (spec §10).

§jobs: Vec<ActiveJob>

The in-flight background actions (issue #46 overhaul): each runs on its own task and shows a per-row spinner; input is never gated. Empty when idle.

§spinner_frame: usize

The shared spinner animation frame, advanced on each tick while any job is in flight; every per-row job spinner reads it so they animate in sync.

§pending_jobs: Vec<Effect>

Follow-up background actions queued by a just-applied job outcome (e.g. a created worktree with uninitialized submodules under the always policy), drained by the event loop after apply_outcome and spawned as their own jobs. Kept off the render path.

§branches: Vec<String>

Local + remote-tracking branch names offered in the create-prompt options dropdown and used to tab-complete the base ref (best-effort; empty when enumeration fails).

§default_base: Option<String>

The remote-tracking default branch (e.g. origin/main) a new worktree forks from by default, pre-filled into the create-prompt base field (issue #70). None when there is no confident remote default (no origin/HEAD), in which case the base starts empty.

Implementations§

Source§

impl App

Source

pub fn new(worktrees: Vec<Worktree>, config: AppConfig, size: (u16, u16)) -> App

Builds an app over the given worktrees, selecting the current one. All rows start marked loaded; the runtime marks them loading before async enrichment.

Source

pub fn set_status(&mut self, message: impl Into<String>, kind: StatusKind)

Sets the transient status-bar message and its severity (for coloring).

Source

pub fn begin_job(&mut self, key: JobKey, label: impl Into<String>)

Registers a background job on key with a display label (issue #46 overhaul). If a job already targets key it is replaced (the caller guards against conflicts first via App::has_job).

Source

pub fn finish_job(&mut self, key: &JobKey)

Removes the job targeting key once it completes; a no-op if absent.

Source

pub fn has_job(&self, key: &JobKey) -> bool

Whether a background job already targets key (used to refuse a second, conflicting action on the same row).

Source

pub fn job_for(&self, worktree: &Worktree) -> Option<&ActiveJob>

The active job attached to worktree’s row, if any, so the list can render its per-row spinner and label. Matches a Path job by path and a Branch job by the branch-row’s name; New jobs attach to no row.

Source

pub fn tick_spinner(&mut self)

Advances the shared spinner one frame (called on each animation tick); a no-op when no job is in flight.

Source

pub fn any_jobs(&self) -> bool

Whether any background job is in flight (keeps the animation ticker awake).

Source

pub fn job_summary(&self) -> Option<String>

A compact status-bar summary of the in-flight jobs — the count and the first job’s label — so background work stays visible even when its row is scrolled off. None when idle.

Source

pub fn may_apply_mode(&self, home: JobHome) -> bool

Whether a finished job in home context may drive a mode change without clobbering an unrelated modal the user opened while it ran (issue #46 overhaul): true when the user is idle or still in the job’s own modal.

Source

pub fn queue_job(&mut self, effect: Effect)

Queues a follow-up background action for the loop to spawn after the current outcome is applied (e.g. submodule init after a create).

Source

pub fn take_pending_jobs(&mut self) -> Vec<Effect>

Drains the queued follow-up actions (issue #46 overhaul).

Source

pub fn selected_worktree(&self) -> Option<&Worktree>

The currently selected worktree, if any.

Source

pub fn is_loaded(&self, worktree: &Worktree) -> bool

Whether a worktree’s async fields have loaded (else it shows a spinner).

Source

pub fn mark_loading(&mut self)

Marks all rows as loading (clears the loaded set), for the initial render.

Source

pub fn mark_loaded(&mut self, path: PathBuf)

Marks a worktree’s path as loaded.

Source

pub fn detail_visible(&self) -> bool

Whether the detail pane is visible at the current size.

Source

pub fn set_worktrees(&mut self, worktrees: Vec<Worktree>)

Replaces the worktrees (e.g. after a refresh), preserving the selection by path and re-applying the sort and filter.

Source

pub fn move_selection(&mut self, delta: isize)

Moves the selection by delta, clamped to the visible range. Changing the selection resets the detail-pane scroll.

Source

pub fn select_edge(&mut self, last: bool)

Selects the first / last visible row.

Source

pub fn select_row(&mut self, row: usize)

Selects the visible row at display position row, if any.

Source

pub fn scroll_detail(&mut self, delta: isize)

Scrolls the detail pane by delta lines (spec §10), clamped to roughly the selected worktree’s detail content so it cannot scroll into the void.

Source

pub fn cycle_sort(&mut self)

Cycles the sort field (spec §10 sort-cycle).

Source

pub fn reverse_sort(&mut self)

Toggles the sort direction (spec §10 sort-reverse).

Source

pub fn filter_push(&mut self, c: char)

Appends a character to the filter and recomputes the visible set.

Source

pub fn filter_pop(&mut self)

Removes the last filter character.

Source

pub fn clear_filter(&mut self)

Clears the filter.

Source

pub fn select_path(&mut self, path: &Path)

Selects the visible row whose worktree path matches path.

Source

pub fn select_branch(&mut self, branch: &str) -> bool

Selects the visible row for the real worktree on branch, if present. Returns whether a matching visible row was found — false when the row is filtered out or absent, leaving the selection unchanged. Used to focus a freshly created worktree (issue #52).

Source§

impl App

Source

pub fn handle_event(&mut self, event: Event) -> Effect

Handles a terminal event, returning the Effect to perform.

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl UnwindSafe for App

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more