Skip to content

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

Reorder list columns for clarity and consistency

Maximilian Roos142893e8c051
diff --git a/src/commands/list/columns.rs b/src/commands/list/columns.rs
index 7749ddc1f..49889da8e 100644
--- a/src/commands/list/columns.rs
+++ b/src/commands/list/columns.rs
@@ -1,4 +1,5 @@
/// Logical identifier for each column rendered by `wt list`.
+#[allow(dead_code)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ColumnKind {
Branch,
@@ -15,6 +16,7 @@ pub enum ColumnKind {
}
/// Differentiates between diff-style columns with plus/minus symbols and those with arrows.
+#[allow(dead_code)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum DiffVariant {
Signs,
@@ -22,6 +24,7 @@ pub enum DiffVariant {
}
/// Static metadata describing a column's behavior in both layout and rendering.
+#[allow(dead_code)]
#[derive(Clone, Copy, Debug)]
pub struct ColumnSpec {
pub kind: ColumnKind,
@@ -53,6 +56,7 @@ impl ColumnSpec {
}
/// Static registry of all possible columns in display order.
+#[allow(dead_code)]
pub const COLUMN_SPECS: &[ColumnSpec] = &[
ColumnSpec::new(
ColumnKind::Branch,
@@ -111,27 +115,27 @@ pub const COLUMN_SPECS: &[ColumnSpec] = &[
6,
),
ColumnSpec::new(
- ColumnKind::Time,
- super::layout::HEADER_AGE,
+ ColumnKind::Commit,
+ super::layout::HEADER_COMMIT,
8,
false,
false,
7,
),
ColumnSpec::new(
- ColumnKind::CiStatus,
- super::layout::HEADER_CI,
+ ColumnKind::Time,
+ super::layout::HEADER_AGE,
9,
false,
- true,
+ false,
8,
),
ColumnSpec::new(
- ColumnKind::Commit,
- super::layout::HEADER_COMMIT,
+ ColumnKind::CiStatus,
+ super::layout::HEADER_CI,
10,
false,
- false,
+ true,
9,
),
ColumnSpec::new(
diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rs
index 5a3082271..804d57ef7 100644
--- a/src/commands/list/layout.rs
+++ b/src/commands/list/layout.rs
@@ -107,10 +107,7 @@ use crate::display::{find_common_prefix, get_terminal_width};
use std::path::{Path, PathBuf};
use unicode_width::UnicodeWidthStr;
-use super::{
- columns::{COLUMN_SPECS, ColumnKind, ColumnSpec, DiffVariant},
- model::ListItem,
-};
+use super::model::ListItem;
/// Width of short commit hash display (first 8 hex characters)
const COMMIT_HASH_WIDTH: usize = 8;
@@ -198,6 +195,16 @@ 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,
@@ -208,6 +215,8 @@ 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)
@@ -221,130 +230,64 @@ pub struct ColumnDataFlags {
pub ci_status: bool,
}
-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,
- }
+/// Column types for allocation
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum ColumnType {
+ Branch,
+ WorkingDiff,
+ AheadBehind,
+ BranchDiff,
+ States,
+ Path,
+ Upstream,
+ Time,
+ CiStatus,
+ Commit,
+ Message,
}
-#[derive(Clone, Copy, Debug)]
-pub struct DiffDigits {
- pub added: usize,
- pub deleted: usize,
+/// Describes a column for priority-based allocation
+struct ColumnDescriptor {
+ column_type: ColumnType,
+ base_priority: u8,
+ has_data: bool,
}
-impl From<DiffWidths> for DiffDigits {
- fn from(widths: DiffWidths) -> Self {
- Self {
- added: widths.added_digits,
- deleted: widths.deleted_digits,
+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
}
}
}
+/// Absolute column positions for guaranteed alignment
#[derive(Clone, Copy, Debug)]
-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 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 struct LayoutConfig {
- pub columns: Vec<ColumnLayout>,
+ pub widths: ColumnWidths,
+ pub positions: ColumnPositions,
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,
@@ -461,6 +404,8 @@ 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 {
@@ -504,127 +449,244 @@ 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);
- let spacing = 2;
- let mut remaining = terminal_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. commit - hash (reference info, precedes age for clarity)
+ // 9. time - recency (nice-to-have context)
+ // 10. ci_status - CI/PR status (contextual when available)
+ // 11. message - description (nice-to-have, space-hungry)
- 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);
+ 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::Commit,
+ base_priority: 8,
+ has_data: true,
+ },
+ ColumnDescriptor {
+ column_type: ColumnType::Time,
+ base_priority: 9,
+ has_data: true,
+ },
+ ColumnDescriptor {
+ column_type: ColumnType::CiStatus,
+ base_priority: 10,
+ has_data: data_flags.ci_status,
+ },
+ 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)
const MIN_MESSAGE: usize = 20;
const PREFERRED_MESSAGE: usize = 50;
const MAX_MESSAGE: usize = 100;
- let mut pending: Vec<PendingColumn> = Vec::new();
-
- 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 };
+ // Allocate columns in priority order
+ for (idx, col) in columns.iter().enumerate() {
+ let is_first = idx == 0;
- if remaining <= spacing_cost {
- continue;
+ match col.column_type {
+ ColumnType::Branch => {
+ widths.branch =
+ try_allocate(&mut remaining, ideal_widths.branch, 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::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;
+ }
}
-
- if message_width > 0 {
- remaining = remaining.saturating_sub(message_width + spacing_cost);
- pending.push(PendingColumn {
- spec,
- width: message_width,
- format: ColumnFormat::Text,
- });
+ 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;
+ }
}
-
- 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,
- });
+ 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);
+ }
+ ColumnType::Commit => {
+ widths.commit = try_allocate(&mut remaining, commit_width, spacing, is_first);
+ }
+ 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);
+ }
+ }
+ _ => {} // Skip columns that don't meet visibility conditions (show_full, fetch_ci)
}
}
- 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;
+ // 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;
}
- pending.sort_by_key(|col| col.spec.display_index);
+ let final_max_message_len = widths.message;
+ // Calculate absolute column positions (with 2-space gaps between columns)
let gap = 2;
- let mut position = 0;
- let mut columns = Vec::new();
+ let mut pos = 0;
- 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,
- });
- }
+ // 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 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),
+ commit: advance(widths.commit),
+ time: advance(widths.time),
+ ci_status: advance(widths.ci_status),
+ message: advance(widths.message),
+ };
LayoutConfig {
- columns,
+ widths,
+ positions,
common_prefix,
- max_message_len,
+ max_message_len: final_max_message_len,
}
}
#[cfg(test)]
mod tests {
use super::*;
- use crate::commands::list::columns::ColumnKind;
use std::path::PathBuf;
#[test]
@@ -738,46 +800,49 @@ 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!(
- !layout.columns.is_empty(),
- "At least one column should be visible"
+ pos.states > 0,
+ "States column should be visible in Phase 2 (empty but shown if space)"
);
- 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");
+ // 3. For visible columns, verify correct spacing
+ // Each visible column should be at: previous_position + previous_width + gap(2)
+ let gap = 2;
- let mut previous_end = first.start + first.width;
- for column in columns_iter {
+ if widths.working_diff.total > 0 && pos.working_diff > 0 {
assert_eq!(
- column.start,
- previous_end + 2,
- "Columns should be separated by a 2-space gap"
+ pos.working_diff,
+ pos.branch + widths.branch + gap,
+ "Working diff position should follow branch with 2-space gap"
);
- previous_end = column.start + column.width;
}
- let states_visible = layout
- .columns
- .iter()
- .any(|col| col.kind == ColumnKind::States);
- assert!(
- states_visible,
- "States column should be visible in wide layout"
- );
+ 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 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");
+ // 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");
}
#[test]
@@ -819,36 +884,39 @@ 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!(
- layout
- .columns
- .first()
- .map(|col| col.kind == ColumnKind::Branch && col.start == 0)
- .unwrap_or(false),
- "Branch column should start at position 0"
+ 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)"
);
- 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));
+ // 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;
assert!(
empty_columns_visible,
"At least some empty columns should be visible in Phase 2"
);
- let path_visible = layout
- .columns
- .iter()
- .any(|col| col.kind == ColumnKind::Path);
- assert!(path_visible, "Path should always be visible");
+ // Path should be visible (always has data)
+ assert!(pos.path > 0, "Path should be visible");
}
#[test]
@@ -892,26 +960,36 @@ 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)
- let path_visible = layout
- .columns
- .iter()
- .any(|col| col.kind == ColumnKind::Path);
+ // 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
assert!(
- path_visible,
+ pos.path > 0,
"Path should be visible (allocated in Phase 1)"
);
- let message_visible = layout
- .columns
- .iter()
- .any(|col| col.kind == ColumnKind::Message);
+ // 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)
assert!(
- message_visible,
+ widths.message > 0,
"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.
+ // 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
}
}
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 46a75cdbc..fe2a53306 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -14,7 +14,7 @@ use render::{
format_list_item_line,
};
use worktrunk::git::{GitError, Repository};
-use worktrunk::styling::println;
+use worktrunk::styling::{ADDITION, DELETION, println};
/// Helper to enrich common display fields shared between worktrees and branches
fn enrich_common_fields(
@@ -30,8 +30,20 @@ fn enrich_common_fields(
let upstream_display = upstream
.active()
- .and_then(|(_, upstream_ahead, upstream_behind)| {
- format_ahead_behind_plain(upstream_ahead, upstream_behind)
+ .map(|(_, upstream_ahead, upstream_behind)| {
+ // Always show arrows for upstream (even ↑0 ↓0) to distinguish from no remote
+ format_ahead_behind_plain(upstream_ahead, upstream_behind).unwrap_or_else(|| {
+ let dim_deletion = DELETION.dimmed();
+ format!(
+ "{}↑{}{} {}↓{}{}",
+ ADDITION,
+ 0,
+ ADDITION.render_reset(),
+ dim_deletion,
+ 0,
+ dim_deletion.render_reset()
+ )
+ })
});
let ci_status_display = pr_status.as_ref().map(format_ci_status_plain);
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index 5c272b6f9..398f3feb4 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -3,8 +3,11 @@ use anstyle::{AnsiColor, Color, Style};
use worktrunk::styling::{ADDITION, CURRENT, DELETION, StyledLine, println};
use super::ci_status::{CiStatus, PrStatus};
-use super::columns::{ColumnKind, DiffVariant};
-use super::layout::{ColumnFormat, DiffDigits, LayoutConfig};
+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::model::ListItem;
/// Format ahead/behind counts as plain text with ANSI colors (for json-pretty)
@@ -86,93 +89,114 @@ pub fn format_ci_status_plain(pr_status: &PrStatus) -> String {
format!("{}● {}{}", style, status_str, style.render_reset())
}
-#[derive(Clone, Copy)]
-enum ValueAlign {
- Left,
- Right,
-}
+/// 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();
-#[derive(Clone, Copy)]
-struct DiffRenderConfig {
- positive_symbol: &'static str,
- negative_symbol: &'static str,
- align: ValueAlign,
-}
+ 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));
+ }
-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,
- },
+ // 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));
+ }
+
+ // 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));
}
+
+ segment
}
-fn format_diff_like_column(
- positive: usize,
- negative: usize,
- digits: DiffDigits,
- total_width: usize,
- variant: DiffVariant,
- positive_style: Style,
- negative_style: Style,
+/// 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,
) -> StyledLine {
- let config = diff_render_config(variant);
- let mut segment = StyledLine::new();
-
- if positive == 0 && negative == 0 {
- segment.push_raw(" ".repeat(total_width));
- return segment;
- }
+ let mut diff_segment = StyledLine::new();
- 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);
+ 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 matches!(config.align, ValueAlign::Right) && extra_padding > 0 {
- segment.push_raw(" ".repeat(extra_padding));
- }
+ if left_padding > 0 {
+ diff_segment.push_raw(" ".repeat(left_padding));
+ }
- 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));
- }
+ // 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));
+ }
- segment.push_raw(" ");
+ // Space between added and deleted
+ diff_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);
+ // 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));
+ }
} else {
- segment.push_raw(" ".repeat(negative_width));
- }
-
- if matches!(config.align, ValueAlign::Left) && extra_padding > 0 {
- segment.pad_to(segment.width() + extra_padding);
+ diff_segment.push_raw(" ".repeat(widths.total));
}
- if segment.width() < total_width {
- segment.pad_to(total_width);
- }
-
- segment
+ diff_segment
}
fn append_line(target: &mut StyledLine, source: StyledLine) {
@@ -187,6 +211,13 @@ 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();
@@ -225,14 +256,77 @@ 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();
- for column in &layout.columns {
- line.pad_to(column.start);
- let header = format!("{:width$}", column.header, width = column.width);
- line.push_styled(header, style);
- }
+ // 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_COMMIT,
+ widths.commit,
+ positions.commit,
+ 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_MESSAGE,
+ widths.message,
+ positions.message,
+ style,
+ );
println!("{}", line.render());
}
@@ -248,6 +342,16 @@ 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();
@@ -265,6 +369,8 @@ 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();
@@ -295,142 +401,151 @@ pub fn format_list_item_line(
text_style
};
+ // Start building the line using absolute column positions
let mut line = StyledLine::new();
- 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);
+ 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);
}
+ } 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 {
+ // No remote tracking - show blank
+ push_blank(&mut line, widths.upstream.total);
+ }
+ }
+
+ // Commit (short HEAD) - always dimmed (reference info)
+ if widths.commit > 0 {
+ line.pad_to(positions.commit);
+ line.push_styled(short_head, Style::new().dimmed());
+ }
+
+ // 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);
+ }
+ }
+
+ // 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());
}
@@ -441,88 +556,67 @@ mod tests {
#[test]
fn test_format_diff_column_pads_to_total_width() {
- use super::super::columns::DiffVariant;
+ // Test that diff column is padded to total width when content is smaller
// Case 1: Single-digit diffs with total=6 (to fit "WT +/-" header)
- let digits = DiffDigits {
- added: 1,
- deleted: 1,
+ let widths = DiffWidths {
+ total: 6,
+ added_digits: 1,
+ deleted_digits: 1,
};
- let total = 6;
- let result =
- format_diff_like_column(1, 1, digits, total, DiffVariant::Signs, ADDITION, DELETION);
+ let result = format_diff_column(1, 1, &widths, ADDITION, DELETION);
assert_eq!(
result.width(),
- total,
+ 6,
"Diff '+1 -1' should be padded to 6 chars"
);
// Case 2: Two-digit diffs with total=8
- let digits = DiffDigits {
- added: 2,
- deleted: 2,
+ let widths = DiffWidths {
+ total: 8,
+ added_digits: 2,
+ deleted_digits: 2,
};
- let total = 8;
- let result = format_diff_like_column(
- 10,
- 50,
- digits,
- total,
- DiffVariant::Signs,
- ADDITION,
- DELETION,
- );
+ let result = format_diff_column(10, 50, &widths, ADDITION, DELETION);
assert_eq!(
result.width(),
- total,
+ 8,
"Diff '+10 -50' should be padded to 8 chars"
);
// Case 3: Asymmetric digit counts with total=9
- let digits = DiffDigits {
- added: 3,
- deleted: 2,
+ let widths = DiffWidths {
+ total: 9,
+ added_digits: 3,
+ deleted_digits: 2,
};
- let total = 9;
- let result = format_diff_like_column(
- 100,
- 50,
- digits,
- total,
- DiffVariant::Signs,
- ADDITION,
- DELETION,
- );
+ let result = format_diff_column(100, 50, &widths, ADDITION, DELETION);
assert_eq!(
result.width(),
- total,
+ 9,
"Diff '+100 -50' should be padded to 9 chars"
);
// Case 4: Zero diff should also pad to total width
- let digits = DiffDigits {
- added: 1,
- deleted: 1,
+ let widths = DiffWidths {
+ total: 6,
+ added_digits: 1,
+ deleted_digits: 1,
};
- 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");
+ let result = format_diff_column(0, 0, &widths, ADDITION, DELETION);
+ assert_eq!(result.width(), 6, "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
- use super::super::columns::DiffVariant;
-
- let digits = DiffDigits {
- added: 1,
- deleted: 1,
+ let widths = DiffWidths {
+ total: 6,
+ added_digits: 1,
+ deleted_digits: 1,
};
- let total = 6;
- let result =
- format_diff_like_column(1, 1, digits, total, DiffVariant::Signs, ADDITION, DELETION);
+ let result = format_diff_column(1, 1, &widths, ADDITION, DELETION);
let rendered = result.render();
// Strip ANSI codes to check alignment
@@ -643,66 +737,72 @@ mod tests {
}
#[test]
- fn test_arrow_variant_alignment_invariant() {
- use super::super::columns::DiffVariant;
+ 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;
use worktrunk::styling::{ADDITION, DELETION};
- let digits = DiffDigits {
- added: 2,
- deleted: 2,
+ let widths = DiffWidths {
+ total: 7, // "↑99 ↓99" = 1+2+1+1+2 = 7
+ added_digits: 2,
+ deleted_digits: 2,
};
- let total = 7;
let dim_deletion = DELETION.dimmed();
- 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,
+
+ // 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"
);
- assert_eq!(result.width(), total);
}
}
#[test]
- fn test_arrow_variant_respects_header_width() {
- use super::super::columns::DiffVariant;
+ 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;
use worktrunk::styling::{ADDITION, DELETION};
- let digits = DiffDigits {
- added: 0,
- deleted: 2,
+ let widths = DiffWidths {
+ total: 7, // To fit "Commits" header
+ added_digits: 0, // No ahead values
+ deleted_digits: 2, // Max behind is 50
};
- let total = 7;
let dim_deletion = DELETION.dimmed();
- 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,
+ // 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()
);
- 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 89eeb2e45..fb7e7e743 100644
--- a/tests/snapshots/integration__integration_tests__list__detached_head.snap
+++ b/tests/snapshots/integration__integration_tests__list__detached_head.snap
@@ -11,16 +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/.tmpJH8m4X/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpAQ4ZZ5/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 ↕ Commit Age Message
+(detached) .  b834638e 10 months ago 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 fb4c95e51..92e8538f0 100644
--- a/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap
+++ b/tests/snapshots/integration__integration_tests__list__locked_no_reason.snap
@@ -11,17 +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/.tmpd5BKZp/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmphW21WR/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
-locked-no-reason (locked) ./locked-no-reason 10 months ago b834638e Initial commit
+Branch Working ± Main ↕ State Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+locked-no-reason (locked) ./locked-no-reason b834638e 10 months ago 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 cdfa376e4..453eacfff 100644
--- a/tests/snapshots/integration__integration_tests__list__locked_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__list__locked_worktree.snap
@@ -11,17 +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/.tmpD0P3mr/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpHGdb5g/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
-locked-feature (locked: Testing lock functionality) ./locked-feature 10 months ago b834638e Initial commit
+Branch State Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+locked-feature (locked: Testing lock functionality) ./locked-feature b834638e 10 months ago Initial commit
Showing 2 worktrees
diff --git a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap b/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
index 839bf12ac..970ca10a4 100644
--- a/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
+++ b/tests/snapshots/integration__integration_tests__list__long_commit_message.snap
@@ -15,14 +15,14 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp8WdVkp/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpRWwm2S/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago 1310bfb9 Short message
-feature-a ↓1 ./feature-a 10 months ago f078644e This is a very long commit message that should test how the...
+Branch Working ± Main ↕ State Path Remote ↕ Commit Age Message
+main  ./test-repo 1310bfb9 10 months ago Short message
+feature-a ↓1 ./feature-a f078644e 10 months ago This is a very long commit message that should test how the...
Showing 2 worktrees, 1 behind
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 d4e8792ba..c19fb7f64 100644
--- a/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap
+++ b/tests/snapshots/integration__integration_tests__list__many_worktrees_varied.snap
@@ -11,20 +11,21 @@ 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/.tmppziP7W/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmplpFTE6/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
-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 ± Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+medium-name  ./medium-name  b834638e 10 months ago Initial commit
+short  ./short  b834638e 10 months ago Initial commit
+very-long-branch-name-here ./very-long-branch-name-here b834638e 10 months ago Initial commit
+with-changes  ./with-changes  b834638e 10 months ago 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 61961ac35..91c790dae 100644
--- a/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap
+++ b/tests/snapshots/integration__integration_tests__list__multiple_worktrees.snap
@@ -11,18 +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/.tmpuD3mV0/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpeeNy30/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 ↕ Commit Age Message
+main  ./test-repo b834638e 10 months ago Initial commit
+feature-a ./feature-a b834638e 10 months ago Initial commit
+feature-b ./feature-b b834638e 10 months ago 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 f5aaaf708..968cd5bcf 100644
--- a/tests/snapshots/integration__integration_tests__list__single_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__list__single_worktree.snap
@@ -11,16 +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/.tmpFw5VR4/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmmmnEf/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 ↕ Commit Age Message
+main  .  b834638e 10 months ago 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 69b71e62c..aad2ba04c 100644
--- a/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
+++ b/tests/snapshots/integration__integration_tests__list__unicode_commit_message.snap
@@ -11,17 +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/.tmp6lDVtj/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9yaE9g/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 ↕ Commit Age Message
+main  ./test-repo  e4614cb7 10 months ago Fix bug with café ☕ handling
+feature-test ↓1 ./feature-test 0c53695b 10 months ago 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 defcd3f1b..e5d74389a 100644
--- a/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_branches_flag.snap
@@ -12,20 +12,21 @@ 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/.tmprjE1E1/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp3QczPR/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-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 ↕ Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+feature-with-worktree  ./feature-with-worktree b834638e 10 months ago Initial commit
+another-branch  b834638e 10 months ago Initial commit
+feature-without-worktree b834638e 10 months ago Initial commit
+fix-bug  b834638e 10 months ago 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 14abeb403..83dce88f9 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,18 +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/.tmpjntpHU/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpN8KrFB/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 ↕ Commit Age Message
+main  ./test-repo b834638e 10 months ago Initial commit
+feature-a ./feature-a b834638e 10 months ago Initial commit
+feature-b ./feature-b b834638e 10 months ago 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 335c26d57..efd57a057 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,19 +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/.tmpLGUNBB/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpEnMgSA/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 ↕ Commit Age Message
+main  .  b834638e 10 months ago Initial commit
+branch-alpha b834638e 10 months ago Initial commit
+branch-beta  b834638e 10 months ago Initial commit
+branch-gamma b834638e 10 months ago Initial commit
Showing 1 worktrees, 3 branches
diff --git a/tests/snapshots/integration__integration_tests__security__commit_message_with_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__commit_message_with_directive_not_executed.snap
index d1b8d6096..83040b34b 100644
--- a/tests/snapshots/integration__integration_tests__security__commit_message_with_directive_not_executed.snap
+++ b/tests/snapshots/integration__integration_tests__security__commit_message_with_directive_not_executed.snap
@@ -15,14 +15,14 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpbbInkc/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpk7A90X/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Working ± Main ↕ State Path Remote ↕ Age Commit Message
-main  ./test-repo 10 months ago [SHA] Fix bug __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked4
-feature ./feature  10 months ago [SHA] Fix bug __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked4
+Branch Working ± Main ↕ State Path Remote ↕ Commit Age Message
+main  ./test-repo [SHA] 10 months ago Fix bug __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked4
+feature ./feature  [SHA] 10 months ago Fix bug __WORKTRUNK_EXEC__echo PWNED > /tmp/hacked4
Showing 2 worktrees
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 7d69a9669..79858616b 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,16 +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/.tmpia02SL/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpIMr0iE/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 ↕ Commit Age Message
+main  .  b834638e 10 months ago 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 686818ab3..2304da2ec 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,19 +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/.tmpD3Wti0/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcZqocT/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 ↕ Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+also-no-changes ./also-no-changes b834638e 10 months ago Initial commit
+no-changes  ./no-changes  b834638e 10 months ago Initial commit
+with-changes +1 -1 ./with-changes b834638e 10 months ago 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 babcc02ee..9587707e9 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,18 +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/.tmpVSmAt5/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpX257lV/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 ↕ Commit Age Message
+main  ./test-repo b834638e 10 months ago Initial commit
+huge  ./huge  b834638e 10 months ago Initial commit
+tiny +1 -1 ./tiny b834638e 10 months ago 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 f3a1f53ca..c9ac7492d 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,19 +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/.tmpsjEWMM/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpNR8qGX/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 ↕ Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+feature-large  ./feature-large  b834638e 10 months ago Initial commit
+feature-medium ./feature-medium b834638e 10 months ago Initial commit
+feature-small  ./feature-small  b834638e 10 months ago 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 32929c95e..64e981629 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,19 +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/.tmpMLL9UK/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpqUyNS3/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
-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 Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+another-extremely-long-name-here ./another-extremely-long-name-here b834638e 10 months ago Initial commit
+short  ./short  b834638e 10 months ago Initial commit
+very-long-feature-branch-name  ./very-long-feature-branch-name  b834638e 10 months ago 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 7a09d5005..459894b22 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,19 +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/.tmpezb2TA/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpfERshv/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
-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 Path Commit Age Message
+main  ./test-repo  b834638e 10 months ago Initial commit
+long  ./extremely-long-branch-name-that-might-cause-layout-issues b834638e 10 months ago Initial commit
+medium ./medium-length-name  b834638e 10 months ago Initial commit
+x  ./x  b834638e 10 months ago 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 d26790f45..f75dbe594 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,19 +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/.tmp2Cxj2S/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpWIWzLM/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 ↕ Commit Age Message
+main  ./test-repo b834638e 10 months ago Initial commit
+a  ./a  b834638e 10 months ago Initial commit
+bb  ./bb  b834638e 10 months ago Initial commit
+ccc  ./ccc  b834638e 10 months ago 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 43f61030f..25359e62f 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,18 +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/.tmpdqSGge/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYOvNzO/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-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
+Branch Working ± Main ↕ Path Commit Age Message
+main  ./test-repo a7bc47ca 10 months ago Initial commit with a reasonably long message
+feature-a ./feature-a a7bc47ca 10 months ago Initial commit with a reasonably long message
+feature-b ./feature-b a7bc47ca 10 months ago 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 d531e7975..7806fc2bb 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,18 +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/.tmp1vNcd6/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpSpV3TE/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 ↕ Commit Age Message
+main  ./test-repo a7bc47ca 10 months ago Initial commit with a reasonably long message
+feature-a ./feature-a a7bc47ca 10 months ago Initial commit with a reasonably long message
+feature-b ./feature-b a7bc47ca 10 months ago Initial commit with a reasonably long message
Showing 3 worktrees
diff --git a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_80.snap b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_80.snap
index 9f9f5cef9..ecad9bcf9 100644
--- a/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_80.snap
+++ b/tests/snapshots/integration__integration_tests__spacing_edge_cases__terminal_width_80.snap
@@ -15,15 +15,15 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKVhUmm/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpDGWdAv/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-Branch Path Age Commit Message
-main  ./test-repo 10 months ago a7bc47ca Initial commit with a...
-feature-a ./feature-a 10 months ago a7bc47ca Initial commit with a...
-feature-b ./feature-b 10 months ago a7bc47ca Initial commit with a...
+Branch Path Commit Age Message
+main  ./test-repo a7bc47ca 10 months ago Initial commit with a...
+feature-a ./feature-a a7bc47ca 10 months ago Initial commit with a...
+feature-b ./feature-b a7bc47ca 10 months ago Initial commit with a...
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 344141c59..31200ef54 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,19 +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/.tmpTOwVgg/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpXhDl57/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 ↕ Commit Age Message
+main  ./test-repo b834638e 10 months ago Initial commit
+cafe  ./café  b834638e 10 months ago Initial commit
+naive  ./naïve  b834638e 10 months ago Initial commit
+resume ./résumé  b834638e 10 months ago Initial commit
Showing 4 worktrees