Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Refactor: Store list column data in central registry

Maximilian Roos71f99410eb5d
diff --git a/src/commands/list/columns.rs b/src/commands/list/columns.rs
new file mode 100644
index 000000000..7749ddc1f
--- /dev/null
+++ b/src/commands/list/columns.rs
@@ -0,0 +1,145 @@
+/// Logical identifier for each column rendered by `wt list`.
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
+pub enum ColumnKind {
+ Branch,
+ WorkingDiff,
+ AheadBehind,
+ BranchDiff,
+ States,
+ Path,
+ Upstream,
+ Time,
+ CiStatus,
+ Commit,
+ Message,
+}
+
+/// Differentiates between diff-style columns with plus/minus symbols and those with arrows.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum DiffVariant {
+ Signs,
+ Arrows,
+}
+
+/// Static metadata describing a column's behavior in both layout and rendering.
+#[derive(Clone, Copy, Debug)]
+pub struct ColumnSpec {
+ pub kind: ColumnKind,
+ pub header: &'static str,
+ pub base_priority: u8,
+ pub requires_show_full: bool,
+ pub requires_fetch_ci: bool,
+ pub display_index: u8,
+}
+
+impl ColumnSpec {
+ pub const fn new(
+ kind: ColumnKind,
+ header: &'static str,
+ base_priority: u8,
+ requires_show_full: bool,
+ requires_fetch_ci: bool,
+ display_index: u8,
+ ) -> Self {
+ Self {
+ kind,
+ header,
+ base_priority,
+ requires_show_full,
+ requires_fetch_ci,
+ display_index,
+ }
+ }
+}
+
+/// Static registry of all possible columns in display order.
+pub const COLUMN_SPECS: &[ColumnSpec] = &[
+ ColumnSpec::new(
+ ColumnKind::Branch,
+ super::layout::HEADER_BRANCH,
+ 1,
+ false,
+ false,
+ 0,
+ ),
+ ColumnSpec::new(
+ ColumnKind::WorkingDiff,
+ super::layout::HEADER_WORKING_DIFF,
+ 2,
+ false,
+ false,
+ 1,
+ ),
+ ColumnSpec::new(
+ ColumnKind::AheadBehind,
+ super::layout::HEADER_AHEAD_BEHIND,
+ 3,
+ false,
+ false,
+ 2,
+ ),
+ ColumnSpec::new(
+ ColumnKind::BranchDiff,
+ super::layout::HEADER_BRANCH_DIFF,
+ 4,
+ true,
+ false,
+ 3,
+ ),
+ ColumnSpec::new(
+ ColumnKind::States,
+ super::layout::HEADER_STATE,
+ 5,
+ false,
+ false,
+ 4,
+ ),
+ ColumnSpec::new(
+ ColumnKind::Path,
+ super::layout::HEADER_PATH,
+ 6,
+ false,
+ false,
+ 5,
+ ),
+ ColumnSpec::new(
+ ColumnKind::Upstream,
+ super::layout::HEADER_UPSTREAM,
+ 7,
+ false,
+ false,
+ 6,
+ ),
+ ColumnSpec::new(
+ ColumnKind::Time,
+ super::layout::HEADER_AGE,
+ 8,
+ false,
+ false,
+ 7,
+ ),
+ ColumnSpec::new(
+ ColumnKind::CiStatus,
+ super::layout::HEADER_CI,
+ 9,
+ false,
+ true,
+ 8,
+ ),
+ ColumnSpec::new(
+ ColumnKind::Commit,
+ super::layout::HEADER_COMMIT,
+ 10,
+ false,
+ false,
+ 9,
+ ),
+ ColumnSpec::new(
+ ColumnKind::Message,
+ super::layout::HEADER_MESSAGE,
+ 11,
+ false,
+ false,
+ 10,
+ ),
+];
diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rs
index c8841313e..5a3082271 100644
--- a/src/commands/list/layout.rs
+++ b/src/commands/list/layout.rs
@@ -107,7 +107,10 @@ use crate::display::{find_common_prefix, get_terminal_width};
use std::path::{Path, PathBuf};
use unicode_width::UnicodeWidthStr;
-use super::model::ListItem;
+use super::{
+ columns::{COLUMN_SPECS, ColumnKind, ColumnSpec, DiffVariant},
+ model::ListItem,
+};
/// Width of short commit hash display (first 8 hex characters)
const COMMIT_HASH_WIDTH: usize = 8;
@@ -195,16 +198,6 @@ pub struct DiffWidths {
pub deleted_digits: usize, // Second part: - for diffs, ↓ for arrows
}
-impl DiffWidths {
- pub fn zero() -> Self {
- Self {
- total: 0,
- added_digits: 0,
- deleted_digits: 0,
- }
- }
-}
-
pub struct ColumnWidths {
pub branch: usize,
pub time: usize,
@@ -215,8 +208,6 @@ pub struct ColumnWidths {
pub branch_diff: DiffWidths,
pub upstream: DiffWidths,
pub states: usize,
- pub commit: usize,
- pub path: usize,
}
/// Tracks which columns have actual data (vs just headers)
@@ -230,64 +221,130 @@ pub struct ColumnDataFlags {
pub ci_status: bool,
}
-/// Column types for allocation
-#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-enum ColumnType {
- Branch,
- WorkingDiff,
- AheadBehind,
- BranchDiff,
- States,
- Path,
- Upstream,
- Time,
- CiStatus,
- Commit,
- Message,
+const EMPTY_PENALTY: u8 = 10;
+
+fn column_has_data(kind: ColumnKind, flags: &ColumnDataFlags) -> bool {
+ match kind {
+ ColumnKind::Branch => true,
+ ColumnKind::WorkingDiff => flags.working_diff,
+ ColumnKind::AheadBehind => flags.ahead_behind,
+ ColumnKind::BranchDiff => flags.branch_diff,
+ ColumnKind::States => flags.states,
+ ColumnKind::Path => true,
+ ColumnKind::Upstream => flags.upstream,
+ ColumnKind::Time => true,
+ ColumnKind::CiStatus => flags.ci_status,
+ ColumnKind::Commit => true,
+ ColumnKind::Message => true,
+ }
}
-/// Describes a column for priority-based allocation
-struct ColumnDescriptor {
- column_type: ColumnType,
- base_priority: u8,
- has_data: bool,
+#[derive(Clone, Copy, Debug)]
+pub struct DiffDigits {
+ pub added: usize,
+ pub deleted: usize,
}
-impl ColumnDescriptor {
- /// Calculate final priority: base_priority + empty_penalty
- fn priority(&self) -> u8 {
- const EMPTY_PENALTY: u8 = 10;
- if self.has_data {
- self.base_priority
- } else {
- self.base_priority + EMPTY_PENALTY
+impl From<DiffWidths> for DiffDigits {
+ fn from(widths: DiffWidths) -> Self {
+ Self {
+ added: widths.added_digits,
+ deleted: widths.deleted_digits,
}
}
}
-/// Absolute column positions for guaranteed alignment
#[derive(Clone, Copy, Debug)]
-pub struct ColumnPositions {
- pub branch: usize,
- pub working_diff: usize,
- pub ahead_behind: usize,
- pub branch_diff: usize,
- pub states: usize,
- pub path: usize,
- pub upstream: usize,
- pub time: usize,
- pub ci_status: usize,
- pub commit: usize,
- pub message: usize,
+pub enum ColumnFormat {
+ Text,
+ Diff {
+ digits: DiffDigits,
+ variant: DiffVariant,
+ },
+}
+
+#[derive(Clone, Debug)]
+pub struct ColumnLayout {
+ pub kind: ColumnKind,
+ pub header: &'static str,
+ pub start: usize,
+ pub width: usize,
+ pub format: ColumnFormat,
}
pub struct LayoutConfig {
- pub widths: ColumnWidths,
- pub positions: ColumnPositions,
+ pub columns: Vec<ColumnLayout>,
pub common_prefix: PathBuf,
pub max_message_len: usize,
}
+#[derive(Clone, Copy, Debug)]
+struct ColumnIdeal {
+ width: usize,
+ format: ColumnFormat,
+}
+
+impl ColumnIdeal {
+ fn text(width: usize) -> Option<Self> {
+ if width == 0 {
+ None
+ } else {
+ Some(Self {
+ width,
+ format: ColumnFormat::Text,
+ })
+ }
+ }
+
+ fn diff(widths: DiffWidths, variant: DiffVariant) -> Option<Self> {
+ if widths.total == 0 {
+ None
+ } else {
+ Some(Self {
+ width: widths.total,
+ format: ColumnFormat::Diff {
+ digits: widths.into(),
+ variant,
+ },
+ })
+ }
+ }
+}
+
+#[derive(Clone, Copy)]
+struct ColumnCandidate<'a> {
+ spec: &'a ColumnSpec,
+ priority: u8,
+}
+
+#[derive(Clone, Copy)]
+struct PendingColumn<'a> {
+ spec: &'a ColumnSpec,
+ width: usize,
+ format: ColumnFormat,
+}
+
+fn ideal_for_column(
+ spec: &ColumnSpec,
+ widths: &ColumnWidths,
+ max_path_width: usize,
+ commit_width: usize,
+) -> Option<ColumnIdeal> {
+ match spec.kind {
+ ColumnKind::Branch => ColumnIdeal::text(widths.branch),
+ ColumnKind::States => ColumnIdeal::text(widths.states),
+ ColumnKind::Path => ColumnIdeal::text(max_path_width),
+ ColumnKind::Time => ColumnIdeal::text(widths.time),
+ ColumnKind::CiStatus => ColumnIdeal::text(widths.ci_status),
+ ColumnKind::Commit => ColumnIdeal::text(commit_width),
+ ColumnKind::Message => None,
+ ColumnKind::WorkingDiff => ColumnIdeal::diff(widths.working_diff, DiffVariant::Signs),
+ ColumnKind::AheadBehind => ColumnIdeal::diff(widths.ahead_behind, DiffVariant::Arrows),
+ ColumnKind::BranchDiff => ColumnIdeal::diff(widths.branch_diff, DiffVariant::Signs),
+ ColumnKind::Upstream => ColumnIdeal::diff(widths.upstream, DiffVariant::Arrows),
+ }
+}
+
pub fn calculate_column_widths(
items: &[ListItem],
fetch_ci: bool,
@@ -404,8 +461,6 @@ pub fn calculate_column_widths(
branch_diff,
upstream,
states: final_states,
- commit: fit_header(HEADER_COMMIT, COMMIT_HASH_WIDTH),
- path: 0, // Path width calculated later in responsive layout
};
let data_flags = ColumnDataFlags {
@@ -449,244 +504,127 @@ pub fn calculate_responsive_layout(
.unwrap_or(0);
let max_path_width = fit_header(HEADER_PATH, path_data_width);
- let spacing = 2;
let commit_width = fit_header(HEADER_COMMIT, COMMIT_HASH_WIDTH);
- // Priority-based allocation using scoring model: final_priority = base_priority + modifiers
- // Base priorities (1-11) defined by user need hierarchy
- // Empty penalty (+10) pushes empty columns to priorities 12-21
- //
- // Priority order (from high to low):
- // 1. branch - identity (what is this?)
- // 2. working_diff - uncommitted changes (CRITICAL: do I need to commit?)
- // 3. ahead_behind - commits difference (CRITICAL: am I ahead/behind?)
- // 4. branch_diff - line diff in commits (work volume in those commits)
- // 5. states - special states like [rebasing], (conflicts) (rare but urgent when present)
- // 6. path - location (where is this?)
- // 7. upstream - tracking configuration (sync context)
- // 8. time - recency (nice-to-have context)
- // 9. ci_status - CI/PR status (contextual when available)
- // 10. commit - hash (reference info, rarely needed)
- // 11. message - description (nice-to-have, space-hungry)
-
+ let spacing = 2;
let mut remaining = terminal_width;
- let mut widths = ColumnWidths {
- branch: 0,
- time: 0,
- ci_status: 0,
- message: 0,
- ahead_behind: DiffWidths::zero(),
- working_diff: DiffWidths::zero(),
- branch_diff: DiffWidths::zero(),
- upstream: DiffWidths::zero(),
- states: 0,
- commit: 0,
- path: 0,
- };
- // Build column allocation list with priorities
- let mut columns = [
- ColumnDescriptor {
- column_type: ColumnType::Branch,
- base_priority: 1,
- has_data: true,
- },
- ColumnDescriptor {
- column_type: ColumnType::WorkingDiff,
- base_priority: 2,
- has_data: data_flags.working_diff,
- },
- ColumnDescriptor {
- column_type: ColumnType::AheadBehind,
- base_priority: 3,
- has_data: data_flags.ahead_behind,
- },
- ColumnDescriptor {
- column_type: ColumnType::BranchDiff,
- base_priority: 4,
- has_data: data_flags.branch_diff,
- },
- ColumnDescriptor {
- column_type: ColumnType::States,
- base_priority: 5,
- has_data: data_flags.states,
- },
- ColumnDescriptor {
- column_type: ColumnType::Path,
- base_priority: 6,
- has_data: true,
- },
- ColumnDescriptor {
- column_type: ColumnType::Upstream,
- base_priority: 7,
- has_data: data_flags.upstream,
- },
- ColumnDescriptor {
- column_type: ColumnType::Time,
- base_priority: 8,
- has_data: true,
- },
- ColumnDescriptor {
- column_type: ColumnType::CiStatus,
- base_priority: 9,
- has_data: data_flags.ci_status,
- },
- ColumnDescriptor {
- column_type: ColumnType::Commit,
- base_priority: 10,
- has_data: true,
- },
- ColumnDescriptor {
- column_type: ColumnType::Message,
- base_priority: 11,
- has_data: true,
- },
- ];
-
- // Sort by final priority (includes empty penalty)
- columns.sort_by_key(|col| col.priority());
-
- // Message width constants (used in allocation and expansion)
+ let mut candidates: Vec<ColumnCandidate> = COLUMN_SPECS
+ .iter()
+ .filter(|spec| {
+ (!spec.requires_show_full || show_full) && (!spec.requires_fetch_ci || fetch_ci)
+ })
+ .map(|spec| ColumnCandidate {
+ spec,
+ priority: if column_has_data(spec.kind, &data_flags) {
+ spec.base_priority
+ } else {
+ spec.base_priority + EMPTY_PENALTY
+ },
+ })
+ .collect();
+
+ candidates.sort_by_key(|candidate| candidate.priority);
+
const MIN_MESSAGE: usize = 20;
const PREFERRED_MESSAGE: usize = 50;
const MAX_MESSAGE: usize = 100;
- // Allocate columns in priority order
- for (idx, col) in columns.iter().enumerate() {
- let is_first = idx == 0;
+ let mut pending: Vec<PendingColumn> = Vec::new();
- match col.column_type {
- ColumnType::Branch => {
- widths.branch =
- try_allocate(&mut remaining, ideal_widths.branch, spacing, is_first);
- }
- ColumnType::WorkingDiff => {
- let allocated = try_allocate(
- &mut remaining,
- ideal_widths.working_diff.total,
- spacing,
- is_first,
- );
- if allocated > 0 {
- widths.working_diff = ideal_widths.working_diff;
- }
- }
- ColumnType::AheadBehind => {
- let allocated = try_allocate(
- &mut remaining,
- ideal_widths.ahead_behind.total,
- spacing,
- is_first,
- );
- if allocated > 0 {
- widths.ahead_behind = ideal_widths.ahead_behind;
- }
- }
- ColumnType::BranchDiff if show_full => {
- let allocated = try_allocate(
- &mut remaining,
- ideal_widths.branch_diff.total,
- spacing,
- is_first,
- );
- if allocated > 0 {
- widths.branch_diff = ideal_widths.branch_diff;
- }
- }
- ColumnType::States => {
- widths.states =
- try_allocate(&mut remaining, ideal_widths.states, spacing, is_first);
- }
- ColumnType::Path => {
- widths.path = try_allocate(&mut remaining, max_path_width, spacing, is_first);
- }
- ColumnType::Upstream => {
- let allocated = try_allocate(
- &mut remaining,
- ideal_widths.upstream.total,
- spacing,
- is_first,
- );
- if allocated > 0 {
- widths.upstream = ideal_widths.upstream;
- }
- }
- ColumnType::Time => {
- widths.time = try_allocate(&mut remaining, ideal_widths.time, spacing, is_first);
- }
- ColumnType::CiStatus if fetch_ci => {
- widths.ci_status =
- try_allocate(&mut remaining, ideal_widths.ci_status, spacing, is_first);
+ for candidate in candidates {
+ let spec = candidate.spec;
+
+ if spec.kind == ColumnKind::Message {
+ let is_first = pending.is_empty();
+ let spacing_cost = if is_first { 0 } else { spacing };
+
+ if remaining <= spacing_cost {
+ continue;
}
- ColumnType::Commit => {
- widths.commit = try_allocate(&mut remaining, commit_width, spacing, is_first);
+
+ let available = remaining - spacing_cost;
+ let mut message_width = 0;
+
+ if available >= PREFERRED_MESSAGE {
+ message_width = PREFERRED_MESSAGE.min(ideal_widths.message);
+ } else if available >= MIN_MESSAGE {
+ message_width = available.min(ideal_widths.message);
}
- ColumnType::Message => {
- let message_width = if remaining >= PREFERRED_MESSAGE + spacing {
- PREFERRED_MESSAGE
- } else if remaining >= MIN_MESSAGE + spacing {
- remaining.saturating_sub(spacing).min(ideal_widths.message)
- } else {
- 0
- };
-
- if message_width > 0 {
- remaining = remaining.saturating_sub(message_width + spacing);
- widths.message = message_width.min(ideal_widths.message);
- }
+
+ if message_width > 0 {
+ remaining = remaining.saturating_sub(message_width + spacing_cost);
+ pending.push(PendingColumn {
+ spec,
+ width: message_width,
+ format: ColumnFormat::Text,
+ });
}
- _ => {} // Skip columns that don't meet visibility conditions (show_full, fetch_ci)
+
+ continue;
+ }
+
+ let Some(ideal) = ideal_for_column(spec, &ideal_widths, max_path_width, commit_width)
+ else {
+ continue;
+ };
+
+ let allocated = try_allocate(&mut remaining, ideal.width, spacing, pending.is_empty());
+ if allocated > 0 {
+ pending.push(PendingColumn {
+ spec,
+ width: allocated,
+ format: ideal.format,
+ });
}
}
- // Expand message with any leftover space (up to MAX_MESSAGE total)
- if widths.message > 0 && widths.message < MAX_MESSAGE && remaining > 0 {
- let expansion = remaining.min(MAX_MESSAGE - widths.message);
- widths.message += expansion;
+ let mut max_message_len = 0;
+ if let Some(message_col) = pending
+ .iter_mut()
+ .find(|col| col.spec.kind == ColumnKind::Message)
+ {
+ if message_col.width < MAX_MESSAGE && remaining > 0 {
+ let expansion = remaining.min(MAX_MESSAGE - message_col.width);
+ message_col.width += expansion;
+ }
+ max_message_len = message_col.width;
}
- let final_max_message_len = widths.message;
+ pending.sort_by_key(|col| col.spec.display_index);
- // Calculate absolute column positions (with 2-space gaps between columns)
let gap = 2;
- let mut pos = 0;
-
- // Helper closure to advance position for a column
- // Returns the column's start position, or 0 if column is hidden (width=0)
- let mut advance = |width: usize| -> usize {
- if width == 0 {
- return 0;
- }
- let column_pos = if pos == 0 { 0 } else { pos + gap };
- pos = column_pos + width;
- column_pos
- };
+ let mut position = 0;
+ let mut columns = Vec::new();
- let positions = ColumnPositions {
- branch: advance(widths.branch),
- working_diff: advance(widths.working_diff.total),
- ahead_behind: advance(widths.ahead_behind.total),
- branch_diff: advance(widths.branch_diff.total),
- states: advance(widths.states),
- path: advance(widths.path),
- upstream: advance(widths.upstream.total),
- time: advance(widths.time),
- ci_status: advance(widths.ci_status),
- commit: advance(widths.commit),
- message: advance(widths.message),
- };
+ for col in pending {
+ let start = if columns.is_empty() {
+ 0
+ } else {
+ position + gap
+ };
+ position = start + col.width;
+
+ columns.push(ColumnLayout {
+ kind: col.spec.kind,
+ header: col.spec.header,
+ start,
+ width: col.width,
+ format: col.format,
+ });
+ }
LayoutConfig {
- widths,
- positions,
+ columns,
common_prefix,
- max_message_len: final_max_message_len,
+ max_message_len,
}
}
#[cfg(test)]
mod tests {
use super::*;
+ use crate::commands::list::columns::ColumnKind;
use std::path::PathBuf;
#[test]
@@ -800,49 +738,46 @@ mod tests {
let items = vec![super::ListItem::Worktree(info)];
let layout = calculate_responsive_layout(&items, false, false);
- let pos = &layout.positions;
- let widths = &layout.widths;
-
- // Test key invariants of position calculation
- // 1. Branch always starts at position 0
- assert_eq!(pos.branch, 0, "Branch must start at position 0");
-
- // 2. States may be visible in Phase 2 (empty but shown if space allows)
- // Since we have plenty of space in wide terminal, states should be visible
assert!(
- pos.states > 0,
- "States column should be visible in Phase 2 (empty but shown if space)"
+ !layout.columns.is_empty(),
+ "At least one column should be visible"
);
- // 3. For visible columns, verify correct spacing
- // Each visible column should be at: previous_position + previous_width + gap(2)
- let gap = 2;
+ let mut columns_iter = layout.columns.iter();
+ let first = columns_iter.next().expect("branch column should exist");
+ assert_eq!(
+ first.kind,
+ ColumnKind::Branch,
+ "Branch column should be first"
+ );
+ assert_eq!(first.start, 0, "Branch should begin at position 0");
- if widths.working_diff.total > 0 && pos.working_diff > 0 {
+ let mut previous_end = first.start + first.width;
+ for column in columns_iter {
assert_eq!(
- pos.working_diff,
- pos.branch + widths.branch + gap,
- "Working diff position should follow branch with 2-space gap"
+ column.start,
+ previous_end + 2,
+ "Columns should be separated by a 2-space gap"
);
+ previous_end = column.start + column.width;
}
- if widths.ahead_behind.total > 0 && pos.ahead_behind > 0 {
- let prev_col_end = if pos.working_diff > 0 {
- pos.working_diff + widths.working_diff.total
- } else {
- pos.branch + widths.branch
- };
- assert_eq!(
- pos.ahead_behind,
- prev_col_end + gap,
- "Ahead/behind position should follow previous visible column with 2-space gap"
- );
- }
+ let states_visible = layout
+ .columns
+ .iter()
+ .any(|col| col.kind == ColumnKind::States);
+ assert!(
+ states_visible,
+ "States column should be visible in wide layout"
+ );
- // 4. Path must be visible and have position > 0 (it's always shown)
- assert!(pos.path > 0, "Path column must be visible");
- assert!(widths.path > 0, "Path column must have width > 0");
+ let path_column = layout
+ .columns
+ .iter()
+ .find(|col| col.kind == ColumnKind::Path)
+ .expect("Path column must be present");
+ assert!(path_column.width > 0, "Path column must have width > 0");
}
#[test]
@@ -884,39 +819,36 @@ mod tests {
let items = vec![super::ListItem::Worktree(info)];
let layout = calculate_responsive_layout(&items, false, false);
- let pos = &layout.positions;
- // Branch should be at 0
- assert_eq!(pos.branch, 0, "Branch always starts at position 0");
-
- // With new two-phase allocation, empty columns are shown in Phase 2 if space allows
- // Since we have a wide terminal (80 chars default) and minimal data, at least some empty columns should be visible
-
- // Early Phase 2 columns should be visible (highest priority empty columns)
assert!(
- pos.working_diff > 0,
- "Working diff should be visible in Phase 2 (empty but shown if space)"
- );
- assert!(
- pos.ahead_behind > 0,
- "Ahead/behind should be visible in Phase 2 (empty but shown if space)"
+ layout
+ .columns
+ .first()
+ .map(|col| col.kind == ColumnKind::Branch && col.start == 0)
+ .unwrap_or(false),
+ "Branch column should start at position 0"
);
- // Later Phase 2 columns might not fit (depending on terminal width)
- // Just verify that at least some empty columns are visible
- let empty_columns_visible = pos.working_diff > 0
- || pos.ahead_behind > 0
- || pos.branch_diff > 0
- || pos.states > 0
- || pos.upstream > 0;
+ let empty_columns_visible = [
+ ColumnKind::WorkingDiff,
+ ColumnKind::AheadBehind,
+ ColumnKind::BranchDiff,
+ ColumnKind::States,
+ ColumnKind::Upstream,
+ ]
+ .iter()
+ .any(|kind| layout.columns.iter().any(|col| &col.kind == kind));
assert!(
empty_columns_visible,
"At least some empty columns should be visible in Phase 2"
);
- // Path should be visible (always has data)
- assert!(pos.path > 0, "Path should be visible");
+ let path_visible = layout
+ .columns
+ .iter()
+ .any(|col| col.kind == ColumnKind::Path);
+ assert!(path_visible, "Path should always be visible");
}
#[test]
@@ -960,36 +892,26 @@ mod tests {
let items = vec![super::ListItem::Worktree(info)];
let layout = calculate_responsive_layout(&items, false, false);
- let pos = &layout.positions;
- let widths = &layout.widths;
-
- // With two-phase allocation, empty columns are allocated in Phase 2 (after data columns)
- // Phase 1: branch (data), path (data), time (data), commit (data), message (data)
- // Phase 2: working_diff (empty), ahead_behind (empty), branch_diff (empty), states (empty), upstream (empty), ci_status (empty)
- // In Phase 1, path comes after branch immediately (since all middle columns have no data)
- // Branch, path, time, commit, message are allocated first
-
- // Path should come early since it has data and is allocated in Phase 1
+ let path_visible = layout
+ .columns
+ .iter()
+ .any(|col| col.kind == ColumnKind::Path);
assert!(
- pos.path > 0,
+ path_visible,
"Path should be visible (allocated in Phase 1)"
);
- // With the corrected Phase 2 allocation, empty columns only show if space remains AFTER message
- // In this test with 80 character width and minimal data:
- // - Branch, path, time, commit get allocated in Phase 1
- // - Message gets allocated next (before empty columns)
- // - Empty columns only allocated if space remains after message
-
- // Message should be allocated (it comes before empty columns now)
+ let message_visible = layout
+ .columns
+ .iter()
+ .any(|col| col.kind == ColumnKind::Message);
assert!(
- widths.message > 0,
+ message_visible,
"Message should be allocated before empty columns"
);
- // Empty columns may or may not be visible depending on space remaining after message
- // This is acceptable - message has priority over empty columns
- // No assertion needed here - it's correct for empty columns to not show if message takes the space
+ // Empty columns may or may not be visible depending on space remaining after message.
+ // This is acceptable - message has priority over empty columns.
}
}
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index e50958d03..46a75cdbc 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -1,4 +1,5 @@
mod ci_status;
+mod columns;
mod layout;
mod model;
mod render;
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index 6a9c5da5a..5c272b6f9 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -3,11 +3,8 @@ use anstyle::{AnsiColor, Color, Style};
use worktrunk::styling::{ADDITION, CURRENT, DELETION, StyledLine, println};
use super::ci_status::{CiStatus, PrStatus};
-use super::layout::{
- DiffWidths, HEADER_AGE, HEADER_AHEAD_BEHIND, HEADER_BRANCH, HEADER_BRANCH_DIFF, HEADER_CI,
- HEADER_COMMIT, HEADER_MESSAGE, HEADER_PATH, HEADER_STATE, HEADER_UPSTREAM, HEADER_WORKING_DIFF,
- LayoutConfig,
-};
+use super::columns::{ColumnKind, DiffVariant};
+use super::layout::{ColumnFormat, DiffDigits, LayoutConfig};
use super::model::ListItem;
/// Format ahead/behind counts as plain text with ANSI colors (for json-pretty)
@@ -89,114 +86,93 @@ pub fn format_ci_status_plain(pr_status: &PrStatus) -> String {
format!("{}● {}{}", style, status_str, style.render_reset())
}
-/// Format arrow-based counts (e.g., "↑6 ↓1") with alignment
-/// Down arrows always appear at the same column position by reserving space for ahead part
-fn format_arrow_column(
- ahead: usize,
- behind: usize,
- widths: &DiffWidths,
- green: Style,
- red: Style,
-) -> StyledLine {
- let mut segment = StyledLine::new();
-
- if ahead > 0 || behind > 0 {
- // Always reserve full width for ahead part (↑ + max_digits)
- if ahead > 0 {
- let ahead_str = format!("↑{}", ahead);
- segment.push_styled(&ahead_str, green);
- // Pad ahead part to fixed width
- let ahead_padding = widths.added_digits.saturating_sub(ahead.to_string().len());
- if ahead_padding > 0 {
- segment.push_raw(" ".repeat(ahead_padding));
- }
- } else {
- // Reserve full space when ahead is zero
- segment.push_raw(" ".repeat(1 + widths.added_digits));
- }
+#[derive(Clone, Copy)]
+enum ValueAlign {
+ Left,
+ Right,
+}
- // Always add separator space
- segment.push_raw(" ");
-
- // Always reserve full width for behind part (↓ + max_digits)
- if behind > 0 {
- let behind_str = format!("↓{}", behind);
- segment.push_styled(&behind_str, red);
- // Pad behind part to fixed width
- let behind_padding = widths
- .deleted_digits
- .saturating_sub(behind.to_string().len());
- if behind_padding > 0 {
- segment.push_raw(" ".repeat(behind_padding));
- }
- } else {
- // Reserve full space when behind is zero
- segment.push_raw(" ".repeat(1 + widths.deleted_digits));
- }
+#[derive(Clone, Copy)]
+struct DiffRenderConfig {
+ positive_symbol: &'static str,
+ negative_symbol: &'static str,
+ align: ValueAlign,
+}
- // Pad to total width if header is wider than data
- // (e.g., "Commits" header = 7, but data "↓50" = 5)
- segment.pad_to(widths.total);
- } else {
- segment.push_raw(" ".repeat(widths.total));
+fn diff_render_config(variant: DiffVariant) -> DiffRenderConfig {
+ match variant {
+ DiffVariant::Signs => DiffRenderConfig {
+ positive_symbol: "+",
+ negative_symbol: "-",
+ align: ValueAlign::Right,
+ },
+ DiffVariant::Arrows => DiffRenderConfig {
+ positive_symbol: "↑",
+ negative_symbol: "↓",
+ align: ValueAlign::Left,
+ },
}
-
- segment
}
-/// Format diff values as styled segments (right-aligned with attached signs)
-fn format_diff_column(
- added: usize,
- deleted: usize,
- widths: &DiffWidths,
- green: Style,
- red: Style,
+fn format_diff_like_column(
+ positive: usize,
+ negative: usize,
+ digits: DiffDigits,
+ total_width: usize,
+ variant: DiffVariant,
+ positive_style: Style,
+ negative_style: Style,
) -> StyledLine {
- let mut diff_segment = StyledLine::new();
+ let config = diff_render_config(variant);
+ let mut segment = StyledLine::new();
- if added > 0 || deleted > 0 {
- // Always maintain full column width for alignment
- // Format: [padding] [+nnn] [ ] [-nnn]
- let content_width = (1 + widths.added_digits) + 1 + (1 + widths.deleted_digits);
- let left_padding = widths.total.saturating_sub(content_width);
+ if positive == 0 && negative == 0 {
+ segment.push_raw(" ".repeat(total_width));
+ return segment;
+ }
- if left_padding > 0 {
- diff_segment.push_raw(" ".repeat(left_padding));
- }
+ let positive_width = 1 + digits.added;
+ let negative_width = 1 + digits.deleted;
+ let content_width = positive_width + 1 + negative_width;
+ let extra_padding = total_width.saturating_sub(content_width);
- // Added part: show value or spaces
- if added > 0 {
- let added_part = format!(
- "{:>width$}",
- format!("+{}", added),
- width = 1 + widths.added_digits
- );
- diff_segment.push_styled(added_part, green);
- } else {
- // Blank space to maintain alignment
- diff_segment.push_raw(" ".repeat(1 + widths.added_digits));
- }
+ if matches!(config.align, ValueAlign::Right) && extra_padding > 0 {
+ segment.push_raw(" ".repeat(extra_padding));
+ }
- // Space between added and deleted
- diff_segment.push_raw(" ");
+ if positive > 0 {
+ let value = format!("{}{}", config.positive_symbol, positive);
+ let formatted = match config.align {
+ ValueAlign::Right => format!("{:>width$}", value, width = positive_width),
+ ValueAlign::Left => format!("{:<width$}", value, width = positive_width),
+ };
+ segment.push_styled(formatted, positive_style);
+ } else {
+ segment.push_raw(" ".repeat(positive_width));
+ }
- // Deleted part: show value or spaces
- if deleted > 0 {
- let deleted_part = format!(
- "{:>width$}",
- format!("-{}", deleted),
- width = 1 + widths.deleted_digits
- );
- diff_segment.push_styled(deleted_part, red);
- } else {
- // Blank space to maintain alignment
- diff_segment.push_raw(" ".repeat(1 + widths.deleted_digits));
- }
+ segment.push_raw(" ");
+
+ if negative > 0 {
+ let value = format!("{}{}", config.negative_symbol, negative);
+ let formatted = match config.align {
+ ValueAlign::Right => format!("{:>width$}", value, width = negative_width),
+ ValueAlign::Left => format!("{:<width$}", value, width = negative_width),
+ };
+ segment.push_styled(formatted, negative_style);
} else {
- diff_segment.push_raw(" ".repeat(widths.total));
+ segment.push_raw(" ".repeat(negative_width));
+ }
+
+ if matches!(config.align, ValueAlign::Left) && extra_padding > 0 {
+ segment.pad_to(segment.width() + extra_padding);
}
- diff_segment
+ if segment.width() < total_width {
+ segment.pad_to(total_width);
+ }
+
+ segment
}
fn append_line(target: &mut StyledLine, source: StyledLine) {
@@ -211,13 +187,6 @@ fn push_blank(line: &mut StyledLine, width: usize) {
}
}
-fn push_diff(line: &mut StyledLine, added: usize, deleted: usize, widths: &DiffWidths) {
- append_line(
- line,
- format_diff_column(added, deleted, widths, ADDITION, DELETION),
- );
-}
-
/// Format CI status indicator using the statusline.sh color scheme
fn format_ci_status(pr_status: &PrStatus) -> StyledLine {
let mut segment = StyledLine::new();
@@ -256,77 +225,14 @@ pub fn format_all_states(item: &ListItem) -> String {
}
pub fn format_header_line(layout: &LayoutConfig) {
- let widths = &layout.widths;
- let positions = &layout.positions;
let style = Style::new();
let mut line = StyledLine::new();
- // Use absolute positions for guaranteed alignment
- push_header_at(
- &mut line,
- HEADER_BRANCH,
- widths.branch,
- positions.branch,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_WORKING_DIFF,
- widths.working_diff.total,
- positions.working_diff,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_AHEAD_BEHIND,
- widths.ahead_behind.total,
- positions.ahead_behind,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_BRANCH_DIFF,
- widths.branch_diff.total,
- positions.branch_diff,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_STATE,
- widths.states,
- positions.states,
- style,
- );
- push_header_at(&mut line, HEADER_PATH, widths.path, positions.path, style);
- push_header_at(
- &mut line,
- HEADER_UPSTREAM,
- widths.upstream.total,
- positions.upstream,
- style,
- );
- push_header_at(&mut line, HEADER_AGE, widths.time, positions.time, style);
- push_header_at(
- &mut line,
- HEADER_CI,
- widths.ci_status,
- positions.ci_status,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_COMMIT,
- widths.commit,
- positions.commit,
- style,
- );
- push_header_at(
- &mut line,
- HEADER_MESSAGE,
- widths.message,
- positions.message,
- style,
- );
+ for column in &layout.columns {
+ line.pad_to(column.start);
+ let header = format!("{:width$}", column.header, width = column.width);
+ line.push_styled(header, style);
+ }
println!("{}", line.render());
}
@@ -342,16 +248,6 @@ fn optional_reason_state(label: &str, reason: Option<&str>) -> Option<String> {
}
/// Push a header at an absolute column position
-fn push_header_at(line: &mut StyledLine, label: &str, width: usize, position: usize, style: Style) {
- if width > 0 {
- // Pad to absolute position
- line.pad_to(position);
- // Add header content padded to width
- let header = format!("{:width$}", label, width = width);
- line.push_styled(header, style);
- }
-}
-
/// Check if a branch is potentially removable (nothing ahead, no uncommitted changes)
fn is_potentially_removable(item: &ListItem) -> bool {
let counts = item.counts();
@@ -369,8 +265,6 @@ pub fn format_list_item_line(
layout: &LayoutConfig,
current_worktree_path: Option<&std::path::PathBuf>,
) {
- let widths = &layout.widths;
-
let head = item.head();
let commit = item.commit_details();
let counts = item.counts();
@@ -401,150 +295,142 @@ pub fn format_list_item_line(
text_style
};
- // Start building the line using absolute column positions
let mut line = StyledLine::new();
- let positions = &layout.positions;
-
- // Branch name (dimmed if removable)
- if widths.branch > 0 {
- line.pad_to(positions.branch);
- let branch_text = format!("{:width$}", item.branch_name(), width = widths.branch);
- if let Some(style) = text_style {
- line.push_styled(branch_text, style);
- } else {
- line.push_raw(branch_text);
- }
- }
-
- // Working tree diff (worktrees only)
- if widths.working_diff.total > 0 {
- line.pad_to(positions.working_diff);
- if let Some(info) = worktree_info {
- let (wt_added, wt_deleted) = info.working_tree_diff;
- push_diff(&mut line, wt_added, wt_deleted, &widths.working_diff);
- } else {
- push_blank(&mut line, widths.working_diff.total);
- }
- }
-
- // Ahead/behind (commits difference) - green ahead, dim red behind
- if widths.ahead_behind.total > 0 {
- line.pad_to(positions.ahead_behind);
- if !item.is_primary() && (counts.ahead > 0 || counts.behind > 0) {
- let dim_deletion = DELETION.dimmed();
- append_line(
- &mut line,
- format_arrow_column(
- counts.ahead,
- counts.behind,
- &widths.ahead_behind,
- ADDITION,
- dim_deletion,
- ),
- );
- } else {
- push_blank(&mut line, widths.ahead_behind.total);
- }
- }
-
- // Branch diff (line diff in commits)
- if widths.branch_diff.total > 0 {
- line.pad_to(positions.branch_diff);
- if !item.is_primary() {
- push_diff(&mut line, branch_diff.0, branch_diff.1, &widths.branch_diff);
- } else {
- push_blank(&mut line, widths.branch_diff.total);
- }
- }
-
- // States (includes conflicts)
- if widths.states > 0 {
- line.pad_to(positions.states);
- let states = format_all_states(item);
- if !states.is_empty() {
- let states_text = format!("{:width$}", states, width = widths.states);
- line.push_raw(states_text);
- } else {
- push_blank(&mut line, widths.states);
- }
- }
-
- // Path (worktrees only)
- if widths.path > 0 {
- line.pad_to(positions.path);
- if let Some(info) = worktree_info {
- let path_str = shorten_path(&info.worktree.path, &layout.common_prefix);
- let path_text = format!("{:width$}", path_str, width = widths.path);
- if let Some(style) = text_style {
- line.push_styled(path_text, style);
- } else {
- line.push_raw(path_text);
+ for column in &layout.columns {
+ line.pad_to(column.start);
+
+ match (column.kind, column.format) {
+ (ColumnKind::Branch, _) => {
+ let branch_text = format!("{:width$}", item.branch_name(), width = column.width);
+ if let Some(style) = text_style {
+ line.push_styled(branch_text, style);
+ } else {
+ line.push_raw(branch_text);
+ }
+ }
+ (ColumnKind::WorkingDiff, ColumnFormat::Diff { digits, variant }) => {
+ if let Some(info) = worktree_info {
+ let (wt_added, wt_deleted) = info.working_tree_diff;
+ let segment = format_diff_like_column(
+ wt_added,
+ wt_deleted,
+ digits,
+ column.width,
+ variant,
+ ADDITION,
+ DELETION,
+ );
+ append_line(&mut line, segment);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::AheadBehind, ColumnFormat::Diff { digits, variant }) => {
+ if !item.is_primary() && (counts.ahead > 0 || counts.behind > 0) {
+ let dim_deletion = DELETION.dimmed();
+ let segment = format_diff_like_column(
+ counts.ahead,
+ counts.behind,
+ digits,
+ column.width,
+ variant,
+ ADDITION,
+ dim_deletion,
+ );
+ append_line(&mut line, segment);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::BranchDiff, ColumnFormat::Diff { digits, variant }) => {
+ if !item.is_primary() {
+ let segment = format_diff_like_column(
+ branch_diff.0,
+ branch_diff.1,
+ digits,
+ column.width,
+ variant,
+ ADDITION,
+ DELETION,
+ );
+ append_line(&mut line, segment);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::States, _) => {
+ let states = format_all_states(item);
+ if !states.is_empty() {
+ let states_text = format!("{:width$}", states, width = column.width);
+ line.push_raw(states_text);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::Path, _) => {
+ if let Some(info) = worktree_info {
+ let path_str = shorten_path(&info.worktree.path, &layout.common_prefix);
+ let path_text = format!("{:width$}", path_str, width = column.width);
+ if let Some(style) = text_style {
+ line.push_styled(path_text, style);
+ } else {
+ line.push_raw(path_text);
+ }
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::Upstream, ColumnFormat::Diff { digits, variant }) => {
+ if let Some((_remote_name, upstream_ahead, upstream_behind)) = upstream.active() {
+ let dim_deletion = DELETION.dimmed();
+ let segment = format_diff_like_column(
+ upstream_ahead,
+ upstream_behind,
+ digits,
+ column.width,
+ variant,
+ ADDITION,
+ dim_deletion,
+ );
+ append_line(&mut line, segment);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::Time, _) => {
+ let time_str = format!(
+ "{:width$}",
+ format_relative_time(commit.timestamp),
+ width = column.width
+ );
+ line.push_styled(time_str, Style::new().dimmed());
+ }
+ (ColumnKind::CiStatus, _) => {
+ if let Some(pr_status) = item.pr_status() {
+ let mut ci_segment = format_ci_status(pr_status);
+ ci_segment.pad_to(column.width);
+ append_line(&mut line, ci_segment);
+ } else {
+ push_blank(&mut line, column.width);
+ }
+ }
+ (ColumnKind::Commit, _) => {
+ let commit_text = format!("{:width$}", short_head, width = column.width);
+ line.push_styled(commit_text, Style::new().dimmed());
+ }
+ (ColumnKind::Message, _) => {
+ let msg = truncate_at_word_boundary(&commit.commit_message, layout.max_message_len);
+ let msg_start = line.width();
+ line.push_styled(msg, Style::new().dimmed());
+ line.pad_to(msg_start + column.width);
+ }
+ // Fallback for diff columns when format is unexpectedly Text
+ (_, _) => {
+ push_blank(&mut line, column.width);
}
- } else {
- push_blank(&mut line, widths.path);
- }
- }
-
- // Upstream tracking
- if widths.upstream.total > 0 {
- line.pad_to(positions.upstream);
- if let Some((_remote_name, upstream_ahead, upstream_behind)) = upstream.active() {
- let dim_deletion = DELETION.dimmed();
- // TODO: Handle show_remote_names when implemented
- append_line(
- &mut line,
- format_arrow_column(
- upstream_ahead,
- upstream_behind,
- &widths.upstream,
- ADDITION,
- dim_deletion,
- ),
- );
- } else {
- push_blank(&mut line, widths.upstream.total);
- }
- }
-
- // Age (Time)
- if widths.time > 0 {
- line.pad_to(positions.time);
- let time_str = format!(
- "{:width$}",
- format_relative_time(commit.timestamp),
- width = widths.time
- );
- line.push_styled(time_str, Style::new().dimmed());
- }
-
- // CI status
- if widths.ci_status > 0 {
- line.pad_to(positions.ci_status);
- if let Some(pr_status) = item.pr_status() {
- let mut ci_segment = format_ci_status(pr_status);
- ci_segment.pad_to(widths.ci_status);
- append_line(&mut line, ci_segment);
- } else {
- push_blank(&mut line, widths.ci_status);
}
}
- // Commit (short HEAD) - always dimmed (reference info)
- if widths.commit > 0 {
- line.pad_to(positions.commit);
- line.push_styled(short_head, Style::new().dimmed());
- }
-
- // Message
- if widths.message > 0 {
- line.pad_to(positions.message);
- let msg = truncate_at_word_boundary(&commit.commit_message, layout.max_message_len);
- let msg_start = line.width();
- line.push_styled(msg, Style::new().dimmed());
- // Pad to correct visual width (not character count - important for unicode!)
- line.pad_to(msg_start + widths.message);
- }
-
println!("{}", line.render());
}
@@ -555,67 +441,88 @@ mod tests {
#[test]
fn test_format_diff_column_pads_to_total_width() {
- // Test that diff column is padded to total width when content is smaller
+ use super::super::columns::DiffVariant;
// Case 1: Single-digit diffs with total=6 (to fit "WT +/-" header)
- let widths = DiffWidths {
- total: 6,
- added_digits: 1,
- deleted_digits: 1,
+ let digits = DiffDigits {
+ added: 1,
+ deleted: 1,
};
- let result = format_diff_column(1, 1, &widths, ADDITION, DELETION);
+ let total = 6;
+ let result =
+ format_diff_like_column(1, 1, digits, total, DiffVariant::Signs, ADDITION, DELETION);
assert_eq!(
result.width(),
- 6,
+ total,
"Diff '+1 -1' should be padded to 6 chars"
);
// Case 2: Two-digit diffs with total=8
- let widths = DiffWidths {
- total: 8,
- added_digits: 2,
- deleted_digits: 2,
+ let digits = DiffDigits {
+ added: 2,
+ deleted: 2,
};
- let result = format_diff_column(10, 50, &widths, ADDITION, DELETION);
+ let total = 8;
+ let result = format_diff_like_column(
+ 10,
+ 50,
+ digits,
+ total,
+ DiffVariant::Signs,
+ ADDITION,
+ DELETION,
+ );
assert_eq!(
result.width(),
- 8,
+ total,
"Diff '+10 -50' should be padded to 8 chars"
);
// Case 3: Asymmetric digit counts with total=9
- let widths = DiffWidths {
- total: 9,
- added_digits: 3,
- deleted_digits: 2,
+ let digits = DiffDigits {
+ added: 3,
+ deleted: 2,
};
- let result = format_diff_column(100, 50, &widths, ADDITION, DELETION);
+ let total = 9;
+ let result = format_diff_like_column(
+ 100,
+ 50,
+ digits,
+ total,
+ DiffVariant::Signs,
+ ADDITION,
+ DELETION,
+ );
assert_eq!(
result.width(),
- 9,
+ total,
"Diff '+100 -50' should be padded to 9 chars"
);
// Case 4: Zero diff should also pad to total width
- let widths = DiffWidths {
- total: 6,
- added_digits: 1,
- deleted_digits: 1,
+ let digits = DiffDigits {
+ added: 1,
+ deleted: 1,
};
- let result = format_diff_column(0, 0, &widths, ADDITION, DELETION);
- assert_eq!(result.width(), 6, "Empty diff should be 6 spaces");
+ let total = 6;
+ let result =
+ format_diff_like_column(0, 0, digits, total, DiffVariant::Signs, ADDITION, DELETION);
+ assert_eq!(result.width(), total, "Empty diff should be 6 spaces");
}
#[test]
fn test_format_diff_column_right_alignment() {
// Test that diff values are right-aligned within the total width
- let widths = DiffWidths {
- total: 6,
- added_digits: 1,
- deleted_digits: 1,
+ use super::super::columns::DiffVariant;
+
+ let digits = DiffDigits {
+ added: 1,
+ deleted: 1,
};
+ let total = 6;
- let result = format_diff_column(1, 1, &widths, ADDITION, DELETION);
+ let result =
+ format_diff_like_column(1, 1, digits, total, DiffVariant::Signs, ADDITION, DELETION);
let rendered = result.render();
// Strip ANSI codes to check alignment
@@ -736,72 +643,66 @@ mod tests {
}
#[test]
- fn test_arrow_column_alignment_invariant() {
- // Test that arrow columns maintain consistent width regardless of values
- // This ensures down arrows always appear at the same horizontal position
- use super::super::layout::DiffWidths;
- use super::format_arrow_column;
+ fn test_arrow_variant_alignment_invariant() {
+ use super::super::columns::DiffVariant;
use worktrunk::styling::{ADDITION, DELETION};
- let widths = DiffWidths {
- total: 7, // "↑99 ↓99" = 1+2+1+1+2 = 7
- added_digits: 2,
- deleted_digits: 2,
+ let digits = DiffDigits {
+ added: 2,
+ deleted: 2,
};
+ let total = 7;
let dim_deletion = DELETION.dimmed();
-
- // All these cases should produce identical width (vertical alignment)
- let test_cases = vec![
- (0, 0, "both zero"),
- (1, 0, "only ahead"),
- (0, 1, "only behind"),
- (1, 1, "both single digit"),
- (99, 99, "both max digits"),
- (5, 44, "mixed digits"),
- ];
-
- for (ahead, behind, description) in test_cases {
- let result = format_arrow_column(ahead, behind, &widths, ADDITION, dim_deletion);
- assert_eq!(
- result.width(),
- 7,
- "Arrow column ({ahead}, {behind}) [{description}] should always be width 7"
+ let cases = [(0, 0), (1, 0), (0, 1), (1, 1), (99, 99), (5, 44)];
+
+ for (ahead, behind) in cases {
+ let result = format_diff_like_column(
+ ahead,
+ behind,
+ digits,
+ total,
+ DiffVariant::Arrows,
+ ADDITION,
+ dim_deletion,
);
+ assert_eq!(result.width(), total);
}
}
#[test]
- fn test_arrow_column_with_header_wider_than_data() {
- // Reproduces the actual bug: when header is wider than data
- // - No ahead values (max_ahead_digits = 0)
- // - Max behind is 50 (max_behind_digits = 2)
- // - data_width = 1 + 0 + 1 + 1 + 2 = 5
- // - header "Commits" = 7
- // - total = max(5, 7) = 7
- use super::super::layout::DiffWidths;
- use super::format_arrow_column;
+ fn test_arrow_variant_respects_header_width() {
+ use super::super::columns::DiffVariant;
use worktrunk::styling::{ADDITION, DELETION};
- let widths = DiffWidths {
- total: 7, // To fit "Commits" header
- added_digits: 0, // No ahead values
- deleted_digits: 2, // Max behind is 50
+ let digits = DiffDigits {
+ added: 0,
+ deleted: 2,
};
+ let total = 7;
let dim_deletion = DELETION.dimmed();
- // Empty column should be 7 spaces
- let empty = format_arrow_column(0, 0, &widths, ADDITION, dim_deletion);
- assert_eq!(empty.width(), 7, "Empty column should be 7 spaces");
-
- // Column with only behind should also be 7!
- let behind_only = format_arrow_column(0, 50, &widths, ADDITION, dim_deletion);
- assert_eq!(
- behind_only.width(),
- 7,
- "Column with behind=50 should be 7 chars (currently {} - THIS IS THE BUG)",
- behind_only.width()
+ let empty = format_diff_like_column(
+ 0,
+ 0,
+ digits,
+ total,
+ DiffVariant::Arrows,
+ ADDITION,
+ dim_deletion,
+ );
+ assert_eq!(empty.width(), total);
+
+ let behind_only = format_diff_like_column(
+ 0,
+ 50,
+ digits,
+ total,
+ DiffVariant::Arrows,
+ ADDITION,
+ dim_deletion,
);
+ assert_eq!(behind_only.width(), total);
}
}
diff --git a/tests/snapshots/integration__integration_tests__list__detached_head.snap b/tests/snapshots/integration__integration_tests__list__detached_head.snap
index e7163d0a4..89eeb2e45 100644
--- a/tests/snapshots/integration__integration_tests__list__detached_head.snap
+++ b/tests/snapshots/integration__integration_tests__list__detached_head.snap
@@ -11,17 +11,16 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpT8O5UQ/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJH8m4X/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-(detached) .  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+(detached) .  10 months ago b834638e Initial commit
Showing 1 worktree
diff --git a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap
index a61c10b9a..fb4c95e51 100644
--- a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap
+++ b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap
@@ -11,18 +11,17 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdhHn78/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpd5BKZp/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-locked-no-reason (locked) ./locked-no-reason 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+locked-no-reason (locked) ./locked-no-reason 10 months ago b834638e Initial commit
Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap b/tests/snapshots/integration__integration_tests__list__locked_worktree.snap
index a2162e421..cdfa376e4 100644
--- a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__list__locked_worktree.snap
@@ -11,18 +11,17 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpen0wq9/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpD0P3mr/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch State Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-locked-feature (locked: Testing lock functionality) ./locked-feature 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+locked-feature (locked: Testing lock functionality) ./locked-feature 10 months ago b834638e Initial commit
Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap b/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap
index 377b405fb..d4e8792ba 100644
--- a/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap
+++ b/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap
@@ -11,21 +11,20 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp4sGxpp/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmppziP7W/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-medium-name  ./medium-name  10 months ago b834638e Initial commit
-short  ./short  10 months ago b834638e Initial commit
-very-long-branch-name-here ./very-long-branch-name-here 10 months ago b834638e Initial commit
-with-changes  ./with-changes  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+medium-name  ./medium-name  10 months ago b834638e Initial commit
+short  ./short  10 months ago b834638e Initial commit
+very-long-branch-name-here ./very-long-branch-name-here 10 months ago b834638e Initial commit
+with-changes  ./with-changes  10 months ago b834638e Initial commit
Showing 5 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap
index 148d2bc5f..61961ac35 100644
--- a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap
+++ b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap
@@ -11,19 +11,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKY61Ed/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpuD3mV0/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago b834638e Initial commit
-feature-a ./feature-a 10 months ago b834638e Initial commit
-feature-b ./feature-b 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago b834638e Initial commit
+feature-a ./feature-a 10 months ago b834638e Initial commit
+feature-b ./feature-b 10 months ago b834638e Initial commit
Showing 3 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__single_worktree.snap b/tests/snapshots/integration__integration_tests__list__single_worktree.snap
index 777a24bf5..f5aaaf708 100644
--- a/tests/snapshots/integration__integration_tests__list__single_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__list__single_worktree.snap
@@ -11,17 +11,16 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp50pjPK/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpFw5VR4/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  .  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  .  10 months ago b834638e Initial commit
Showing 1 worktree
diff --git a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
index fee5b93fc..69b71e62c 100644
--- a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
+++ b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
@@ -11,18 +11,17 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpxUiV7K/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp6lDVtj/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo  10 months ago e4614cb7 Fix bug with café ☕ handling
-feature-test ↓1 ./feature-test 10 months ago 0c53695b Add support for 日本語 and émoji 🎉
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago e4614cb7 Fix bug with café ☕ handling
+feature-test ↓1 ./feature-test 10 months ago 0c53695b Add support for 日本語 and émoji 🎉
Showing 2 worktrees, 1 behind
diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap
index a09bf621f..defcd3f1b 100644
--- a/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap
@@ -12,21 +12,20 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpA02oY6/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmprjE1E1/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-feature-with-worktree  ./feature-with-worktree 10 months ago b834638e Initial commit
-another-branch  10 months ago b834638e Initial commit
-feature-without-worktree 10 months ago b834638e Initial commit
-fix-bug  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+feature-with-worktree  ./feature-with-worktree 10 months ago b834638e Initial commit
+another-branch  10 months ago b834638e Initial commit
+feature-without-worktree 10 months ago b834638e Initial commit
+fix-bug  10 months ago b834638e Initial commit
Showing 2 worktrees, 3 branches
diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap
index b6921385a..14abeb403 100644
--- a/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag_none_available.snap
@@ -12,19 +12,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpa5vrA2/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpjntpHU/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago b834638e Initial commit
-feature-a ./feature-a 10 months ago b834638e Initial commit
-feature-b ./feature-b 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago b834638e Initial commit
+feature-a ./feature-a 10 months ago b834638e Initial commit
+feature-b ./feature-b 10 months ago b834638e Initial commit
Showing 3 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap b/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap
index f9ba3c549..335c26d57 100644
--- a/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag_only_branches.snap
@@ -12,20 +12,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpQ3fU33/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLGUNBB/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  .  10 months ago b834638e Initial commit
-branch-alpha 10 months ago b834638e Initial commit
-branch-beta  10 months ago b834638e Initial commit
-branch-gamma 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  .  10 months ago b834638e Initial commit
+branch-alpha 10 months ago b834638e Initial commit
+branch-beta  10 months ago b834638e Initial commit
+branch-gamma 10 months ago b834638e Initial commit
Showing 1 worktrees, 3 branches
diff --git a/tests/snapshots/integration__integration_tests__security__path_with_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__path_with_directive_not_executed.snap
index 8f2ebfbb1..7d69a9669 100644
--- a/tests/snapshots/integration__integration_tests__security__path_with_directive_not_executed.snap
+++ b/tests/snapshots/integration__integration_tests__security__path_with_directive_not_executed.snap
@@ -11,17 +11,16 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJZMdo2/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpia02SL/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  .  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  .  10 months ago b834638e Initial commit
Showing 1 worktree
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
index 866df09c9..686818ab3 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_empty_diffs.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpPEBGe4/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpD3Wti0/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-also-no-changes ./also-no-changes 10 months ago b834638e Initial commit
-no-changes  ./no-changes  10 months ago b834638e Initial commit
-with-changes +1 -1 ./with-changes 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+also-no-changes ./also-no-changes 10 months ago b834638e Initial commit
+no-changes  ./no-changes  10 months ago b834638e Initial commit
+with-changes +1 -1 ./with-changes 10 months ago b834638e Initial commit
Showing 4 worktrees, 1 with changes
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
index 988a5ab85..babcc02ee 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_extreme_diffs.snap
@@ -11,19 +11,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKdCsDD/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpVSmAt5/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago b834638e Initial commit
-huge  ./huge  10 months ago b834638e Initial commit
-tiny +1 -1 ./tiny 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago b834638e Initial commit
+huge  ./huge  10 months ago b834638e Initial commit
+tiny +1 -1 ./tiny 10 months ago b834638e Initial commit
Showing 3 worktrees, 1 with changes
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
index 79d76e44a..f3a1f53ca 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__alignment_varying_diffs.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmplPTfTH/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpsjEWMM/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-feature-large  ./feature-large  10 months ago b834638e Initial commit
-feature-medium ./feature-medium 10 months ago b834638e Initial commit
-feature-small  ./feature-small  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+feature-large  ./feature-large  10 months ago b834638e Initial commit
+feature-medium ./feature-medium 10 months ago b834638e Initial commit
+feature-small  ./feature-small  10 months ago b834638e Initial commit
Showing 4 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap
index 3f2ae3f0b..32929c95e 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__long_branch_names.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp7WY6vu/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpMLL9UK/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-another-extremely-long-name-here ./another-extremely-long-name-here 10 months ago b834638e Initial commit
-short  ./short  10 months ago b834638e Initial commit
-very-long-feature-branch-name  ./very-long-feature-branch-name  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+another-extremely-long-name-here ./another-extremely-long-name-here 10 months ago b834638e Initial commit
+short  ./short  10 months ago b834638e Initial commit
+very-long-feature-branch-name  ./very-long-feature-branch-name  10 months ago b834638e Initial commit
Showing 4 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap
index 0b40b1ca1..7a09d5005 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__mixed_length_branch_names.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpGNTDtD/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpezb2TA/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Path Age Commit Message
-main  ./test-repo  10 months ago b834638e Initial commit
-long  ./extremely-long-branch-name-that-might-cause-layout-issues 10 months ago b834638e Initial commit
-medium ./medium-length-name  10 months ago b834638e Initial commit
-x  ./x  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo  10 months ago b834638e Initial commit
+long  ./extremely-long-branch-name-that-might-cause-layout-issues 10 months ago b834638e Initial commit
+medium ./medium-length-name  10 months ago b834638e Initial commit
+x  ./x  10 months ago b834638e Initial commit
Showing 4 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap
index 7af7f6711..d26790f45 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__short_branch_names.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9i77HL/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp2Cxj2S/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago b834638e Initial commit
-a  ./a  10 months ago b834638e Initial commit
-bb  ./bb  10 months ago b834638e Initial commit
-ccc  ./ccc  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago b834638e Initial commit
+a  ./a  10 months ago b834638e Initial commit
+bb  ./bb  10 months ago b834638e Initial commit
+ccc  ./ccc  10 months ago b834638e Initial commit
Showing 4 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_120.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_120.snap
index bd7b0c6bc..43f61030f 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_120.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_120.snap
@@ -11,19 +11,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLd88cn/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdqSGge/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ Path Age Commit Message
-main  ./test-repo 10 months ago a7bc47ca Initial commit with a reasonably long message
-feature-a ./feature-a 10 months ago a7bc47ca Initial commit with a reasonably long message
-feature-b ./feature-b 10 months ago a7bc47ca Initial commit with a reasonably long message
+Branch Working ± Main ↕ State Path Age Commit Message
+main  ./test-repo 10 months ago a7bc47ca Initial commit with a reasonably long message
+feature-a ./feature-a 10 months ago a7bc47ca Initial commit with a reasonably long message
+feature-b ./feature-b 10 months ago a7bc47ca Initial commit with a reasonably long message
Showing 3 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_150.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_150.snap
index 4072b9fcb..d531e7975 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_150.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_150.snap
@@ -11,19 +11,18 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZUMn7V/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp1vNcd6/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago a7bc47ca Initial commit with a reasonably long message
-feature-a ./feature-a 10 months ago a7bc47ca Initial commit with a reasonably long message
-feature-b ./feature-b 10 months ago a7bc47ca Initial commit with a reasonably long message
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago a7bc47ca Initial commit with a reasonably long message
+feature-a ./feature-a 10 months ago a7bc47ca Initial commit with a reasonably long message
+feature-b ./feature-b 10 months ago a7bc47ca Initial commit with a reasonably long message
Showing 3 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
index 25a7b59fa..344141c59 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__unicode_branch_names.snap
@@ -11,20 +11,19 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmphLxyVi/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpTOwVgg/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago b834638e Initial commit
-cafe  ./café  10 months ago b834638e Initial commit
-naive  ./naïve  10 months ago b834638e Initial commit
-resume ./résumé  10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
+main  ./test-repo 10 months ago b834638e Initial commit
+cafe  ./café  10 months ago b834638e Initial commit
+naive  ./naïve  10 months ago b834638e Initial commit
+resume ./résumé  10 months ago b834638e Initial commit
Showing 4 worktrees