Skip to content

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

feat: Consolidate user status into status grid

Maximilian Roos5d9980bfa334
diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rs
index f94e2063d..51c8e2fdf 100644
--- a/src/commands/list/layout.rs
+++ b/src/commands/list/layout.rs
@@ -2,77 +2,59 @@
//!
//! # Status Column Structure
//!
-//! The Status column combines two subcolumns without a 2-space column gap:
+//! The Status column uses a unified position-based grid system for all status
+//! indicators including user-defined status:
//!
//! ```text
-//! Status Column = [Git Status Symbols] + [User Status]
-//! ↑ ↑
-//! Variable width Aligned subcolumn
-//! (position mask) (fixed position)
+//! Status Column = Dynamic Grid [Position 0a...Position 4]
//! ```
//!
-//! ## Git Status Symbols (Variable Width)
+//! ## Unified Position Grid
//!
-//! Git status symbols use position-based alignment with selective rendering:
-//! - Only positions used by at least one row are included (position mask)
+//! All status indicators use position-based alignment with selective rendering:
+//! - Position 0a: Conflicts (=)
+//! - Position 0b: Branch state (≡, ∅)
+//! - Position 0c: Git operation (↻, ⋈)
+//! - Position 0d: Worktree attributes (◇, ⊠, ⚠)
+//! - Position 1: Main divergence (↑, ↓, ↕)
+//! - Position 2: Upstream divergence (⇡, ⇣, ⇅)
+//! - Position 3: Working tree (?, !, +, », ✘)
+//! - Position 4: User status (custom labels, emoji)
+//!
+//! Only positions used by at least one row are included (position mask):
//! - Within those positions, symbols align vertically for scannability
-//! - Empty positions between symbols get spacing for alignment
+//! - Empty positions render as single space for grid alignment
//! - No leading spaces before the first symbol
//!
-//! Example with positions 0b (≡) and 3 (?!) used:
-//! ```text
-//! Row 1: "≡ " (position 0b filled, position 3 empty → space)
-//! Row 2: "≡?" (position 0b filled, position 3 filled)
-//! ```
-//!
-//! ## User Status Subcolumn (Aligned)
-//!
-//! User-defined status aligns at a fixed position within the Status column:
-//! - Starts immediately after max git symbols width (no extra gap)
-//! - All user statuses align vertically regardless of git symbols
-//! - Creates visual separation between git state and user labels
-//!
-//! Example:
+//! Example with positions 0b, 3, and 4 used:
//! ```text
-//! Git Symbols User Status
-//! ≡ ⏸ (git symbols padded to max width)
-//! ≡? 🤖 (user status aligns at fixed position)
-//! ↓!+ (no user status)
+//! Row 1: "≡ 🤖" (0b=≡, 3=space, 4=🤖)
+//! Row 2: "≡?! " (0b=≡, 3=?!, 4=space)
+//! Row 3: " 💬" (0b=space, 3=space, 4=💬)
//! ```
//!
//! ## Width Calculation
//!
//! ```text
-//! status_width = max_git_symbols_width + max_user_status_width
+//! status_width = max(rendered_width_across_all_items)
//! ```
//!
-//! Where:
-//! - `max_git_symbols_width` = maximum rendered width using position mask
-//! - `max_user_status_width` = maximum width of user-defined status strings
+//! The width is calculated by rendering each item's status with the position
+//! mask and taking the maximum width.
//!
//! ## Why This Design?
//!
+//! **Single canonical system:**
+//! - One alignment mechanism for all status indicators
+//! - User status treated consistently with git symbols
+//!
//! **Eliminates wasted space:**
//! - Position mask removes columns for symbols that appear in zero rows
-//! - No 2-space column gap between git and user status
+//! - User status only takes space when present
//!
//! **Maintains alignment:**
-//! - Git symbols align at their positions (vertical scannability)
-//! - User status aligns in its own subcolumn (visual consistency)
-//!
-//! **Example comparison:**
-//!
-//! BAD (no alignment):
-//! ```text
-//! ≡⏸
-//! ≡?🤖
-//! ```
-//!
-//! GOOD (aligned subcolumns):
-//! ```text
-//! ≡ ⏸
-//! ≡?🤖
-//! ```
+//! - All symbols align vertically at their positions (vertical scannability)
+//! - Grid adapts to minimize width based on active positions
//!
//! # Priority System Design
//!
@@ -319,8 +301,6 @@ pub struct LayoutMetadata {
pub widths: ColumnWidths,
pub data_flags: ColumnDataFlags,
pub status_position_mask: super::model::PositionMask,
- /// Maximum width of git status symbols (for padding before user status subcolumn)
- pub max_git_symbols_width: usize,
}
const EMPTY_PENALTY: u8 = 10;
@@ -418,8 +398,6 @@ pub struct LayoutConfig {
pub max_message_len: usize,
pub hidden_nonempty_count: usize,
pub status_position_mask: super::model::PositionMask,
- /// Maximum width of git status symbols (for padding before user status subcolumn)
- pub max_git_symbols_width: usize,
}
#[derive(Clone, Copy, Debug)]
@@ -592,27 +570,30 @@ pub fn calculate_column_widths(items: &[ListItem], fetch_ci: bool) -> LayoutMeta
max_upstream_behind_digits,
);
- // Calculate Status column width: git symbols + user status (as aligned subcolumns)
- // Git symbols width: maximum rendered width using position mask (variable per row)
- let max_git_symbols = items
- .iter()
- .filter_map(|item| item.worktree_info())
- .map(|info| {
- info.status_symbols
- .render_with_mask(&status_position_mask)
- .width()
- })
- .max()
- .unwrap_or(0);
-
- // User status width: maximum user-defined status width (for alignment subcolumn)
- let max_user_status = items
+ // Calculate Status column width: maximum rendered width across all items
+ // Now that user_status is Position 4 in the grid, render_with_mask() includes it
+ let status_data_width = items
.iter()
.filter_map(|item| {
if let Some(info) = item.worktree_info() {
- info.user_status.as_ref().map(|s| s.width())
+ // Worktrees: render all symbols including user_status
+ Some(
+ info.status_symbols
+ .render_with_mask(&status_position_mask)
+ .width(),
+ )
} else if let ListItem::Branch(branch_info) = item {
- branch_info.user_status.as_ref().map(|s| s.width())
+ // Branches: create minimal StatusSymbols with just user_status
+ branch_info.user_status.as_ref().map(|user_status| {
+ use crate::commands::list::model::StatusSymbols;
+ let branch_symbols = StatusSymbols {
+ user_status: Some(user_status.clone()),
+ ..Default::default()
+ };
+ branch_symbols
+ .render_with_mask(&status_position_mask)
+ .width()
+ })
} else {
None
}
@@ -620,9 +601,6 @@ pub fn calculate_column_widths(items: &[ListItem], fetch_ci: bool) -> LayoutMeta
.max()
.unwrap_or(0);
- // Total Status width = git symbols + user status (no extra gap between them)
- let status_data_width = max_git_symbols + max_user_status;
-
// For Status column: always fit header to prevent header overflow
// Even though we want narrow columns, we can't make them narrower than the header
let has_status_data = status_data_width > 0;
@@ -658,7 +636,6 @@ pub fn calculate_column_widths(items: &[ListItem], fetch_ci: bool) -> LayoutMeta
widths,
data_flags,
status_position_mask,
- max_git_symbols_width: max_git_symbols,
}
}
@@ -680,7 +657,6 @@ pub fn calculate_responsive_layout(
let ideal_widths = metadata.widths;
let data_flags = metadata.data_flags;
let status_position_mask = metadata.status_position_mask;
- let max_git_symbols_width = metadata.max_git_symbols_width;
// Calculate actual maximum path width (after common prefix removal)
let path_data_width = items
@@ -825,7 +801,6 @@ pub fn calculate_responsive_layout(
max_message_len,
hidden_nonempty_count,
status_position_mask,
- max_git_symbols_width,
}
}
@@ -870,7 +845,6 @@ mod tests {
pr_status: None,
has_conflicts: false,
status_symbols: StatusSymbols::default(),
- user_status: None,
display: DisplayFields::default(),
working_diff_display: None,
};
@@ -946,7 +920,6 @@ mod tests {
pr_status: None,
has_conflicts: false,
status_symbols: StatusSymbols::default(),
- user_status: None,
display: DisplayFields::default(),
working_diff_display: None,
};
@@ -1021,7 +994,6 @@ mod tests {
pr_status: None,
has_conflicts: false,
status_symbols: StatusSymbols::default(),
- user_status: None,
display: DisplayFields::default(),
working_diff_display: None,
};
@@ -1087,7 +1059,6 @@ mod tests {
pr_status: None,
has_conflicts: false,
status_symbols: StatusSymbols::default(),
- user_status: None,
display: DisplayFields::default(),
working_diff_display: None,
};
diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs
index 87e006c17..c4f084644 100644
--- a/src/commands/list/model.rs
+++ b/src/commands/list/model.rs
@@ -94,11 +94,8 @@ pub struct WorktreeInfo {
// Status
pub pr_status: Option<PrStatus>,
- /// Git status symbols (=, ↑, ↓, ⇡, ⇣, ?, !, +, », ✘) indicating working tree state
+ /// Git status symbols (=, ↑, ↓, ⇡, ⇣, ?, !, +, », ✘) including user-defined status
pub status_symbols: StatusSymbols,
- /// User-defined status from worktrunk.status git config
- #[serde(skip_serializing_if = "Option::is_none")]
- pub user_status: Option<String>,
// Display fields for json-pretty format (with ANSI colors)
#[serde(flatten)]
@@ -541,11 +538,11 @@ impl serde::Serialize for GitOperation {
/// This allows the Status column to only allocate space for positions that
/// have data, rather than reserving space for all possible positions.
///
-/// Uses a bit array for compact representation (7 positions = 7 bits).
+/// Uses a bit array for compact representation (8 positions = 8 bits).
#[derive(Debug, Clone, Copy, Default)]
pub struct PositionMask {
- /// Bit array: [0a, 0b, 0c, 0d, 1, 2, 3]
- positions: [bool; 7],
+ /// Bit array: [0a, 0b, 0c, 0d, 1, 2, 3, 4]
+ positions: [bool; 8],
}
impl PositionMask {
@@ -556,10 +553,11 @@ impl PositionMask {
const POS_1_MAIN_DIVERGENCE: usize = 4;
const POS_2_UPSTREAM_DIVERGENCE: usize = 5;
const POS_3_WORKING_TREE: usize = 6;
+ const POS_4_USER_STATUS: usize = 7;
/// Full mask with all positions enabled (for JSON output)
pub const FULL: Self = Self {
- positions: [true; 7],
+ positions: [true; 8],
};
/// Merge this mask with another, keeping positions that are used in either
@@ -584,7 +582,8 @@ impl PositionMask {
/// - Position 0d: Worktree attributes (◇, ⊠, ⚠)
/// - Position 1: Main branch divergence (↑, ↓, ↕)
/// - Position 2: Remote/upstream divergence (⇡, ⇣, ⇅)
-/// - Position 3+: Working tree symbols (?, !, +, », ✘)
+/// - Position 3: Working tree symbols (?, !, +, », ✘)
+/// - Position 4: User status (custom labels, emoji)
///
/// ## Mutual Exclusivity
///
@@ -627,6 +626,10 @@ pub struct StatusSymbols {
/// Working tree changes: ?, !, +, », ✘
/// Position 3+ - NOT mutually exclusive (can have "?!+" etc.)
pub(crate) working_tree: String,
+
+ /// User-defined status annotation
+ /// Position 4 - Custom labels (e.g., 💬, 🤖)
+ pub(crate) user_status: Option<String>,
}
impl StatusSymbols {
@@ -648,7 +651,8 @@ impl StatusSymbols {
/// - Position 0d: Worktree attributes (◇⊠⚠ or space)
/// - Position 1: Main divergence (↑, ↓, ↕, or space)
/// - Position 2: Upstream divergence (⇡, ⇣, ⇅, or space)
- /// - Position 3+: Working tree symbols (?, !, +, », ✘)
+ /// - Position 3: Working tree symbols (?, !, +, », ✘)
+ /// - Position 4: User status (custom labels, emoji)
///
/// This ensures vertical scannability - each symbol type appears at the same
/// column position across all rows, while minimizing wasted space.
@@ -696,6 +700,11 @@ impl StatusSymbols {
&self.working_tree,
!self.working_tree.is_empty(),
),
+ (
+ PositionMask::POS_4_USER_STATUS,
+ self.user_status.as_deref().unwrap_or(""),
+ self.user_status.is_some(),
+ ),
];
// Grid-based rendering: each position in mask gets exactly one column
@@ -719,7 +728,7 @@ impl StatusSymbols {
/// Derive a position mask that tracks which symbol slots contain data.
pub fn position_mask(&self) -> PositionMask {
- let mut positions = [false; 7];
+ let mut positions = [false; 8];
positions[PositionMask::POS_0A_CONFLICTS] = self.has_conflicts;
positions[PositionMask::POS_0B_BRANCH_STATE] = self.branch_state != BranchState::None;
positions[PositionMask::POS_0C_GIT_OPERATION] = self.git_operation != GitOperation::None;
@@ -729,6 +738,7 @@ impl StatusSymbols {
positions[PositionMask::POS_2_UPSTREAM_DIVERGENCE] =
self.upstream_divergence != UpstreamDivergence::None;
positions[PositionMask::POS_3_WORKING_TREE] = !self.working_tree.is_empty();
+ positions[PositionMask::POS_4_USER_STATUS] = self.user_status.is_some();
PositionMask { positions }
}
@@ -741,6 +751,7 @@ impl StatusSymbols {
&& self.main_divergence == MainDivergence::None
&& self.upstream_divergence == UpstreamDivergence::None
&& self.working_tree.is_empty()
+ && self.user_status.is_none()
}
}
@@ -962,16 +973,12 @@ impl WorktreeInfo {
symbols.worktree_attrs.push('⚠');
}
- // Read user-defined status from git config (worktree-specific or branch-keyed)
- let user_status = wt_repo.user_status(wt.branch.as_deref());
+ // Add user-defined status from git config to symbols (Position 4)
+ symbols.user_status = wt_repo.user_status(wt.branch.as_deref());
// Create display fields with rendered status
- let status_display = if !symbols.is_empty() || user_status.is_some() {
- let mut rendered = symbols.render();
- if let Some(ref user) = user_status {
- rendered.push_str(user);
- }
- Some(rendered)
+ let status_display = if !symbols.is_empty() {
+ Some(symbols.render())
} else {
None
};
@@ -1002,7 +1009,6 @@ impl WorktreeInfo {
upstream,
pr_status,
status_symbols: symbols,
- user_status,
display,
working_diff_display: None,
})
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index 0643eb2ed..e4fbd9692 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -235,7 +235,6 @@ impl LayoutConfig {
column.render_cell(
&ctx,
&self.status_position_mask,
- self.max_git_symbols_width,
&self.common_prefix,
self.max_message_len,
)
@@ -322,7 +321,6 @@ impl ColumnLayout {
&self,
ctx: &ListRowContext,
status_mask: &PositionMask,
- max_git_symbols_width: usize,
common_prefix: &Path,
max_message_len: usize,
) -> StyledLine {
@@ -341,19 +339,18 @@ impl ColumnLayout {
let mut cell = StyledLine::new();
if let Some(info) = ctx.worktree_info {
- let git_symbols_start = cell.width();
+ // Render all status symbols including user status (Position 4)
cell.push_raw(info.status_symbols.render_with_mask(status_mask));
-
- if let Some(ref user_status) = info.user_status {
- cell.pad_to(git_symbols_start + max_git_symbols_width);
- cell.push_raw(user_status.clone());
- }
} else if let ListItem::Branch(branch_info) = ctx.item
&& let Some(ref user_status) = branch_info.user_status
{
- let git_symbols_start = cell.width();
- cell.pad_to(git_symbols_start + max_git_symbols_width);
- cell.push_raw(user_status.clone());
+ // For branches, create a minimal StatusSymbols with just user_status
+ use crate::commands::list::model::StatusSymbols;
+ let branch_symbols = StatusSymbols {
+ user_status: Some(user_status.clone()),
+ ..Default::default()
+ };
+ cell.push_raw(branch_symbols.render_with_mask(status_mask));
}
cell
diff --git a/src/commands/list/status_column_tests.rs b/src/commands/list/status_column_tests.rs
index 3f258e10c..6f6d8fcb2 100644
--- a/src/commands/list/status_column_tests.rs
+++ b/src/commands/list/status_column_tests.rs
@@ -4,22 +4,20 @@
//!
//! ## Grid-Based Rendering Model
//!
-//! - Each symbol type has a fixed position (0a, 0b, 0c, 0d, 1, 2, 3)
+//! - Each symbol type has a fixed position (0a, 0b, 0c, 0d, 1, 2, 3, 4)
+//! - Position 4 is user-defined status (custom labels, emoji)
//! - Only positions used by at least one row are included (position mask)
//! - Rendering creates a grid: first position in mask = column 0
//! - Each position maps to exactly one column
//! - **Multiple symbols from the same position** appear together in that column (e.g., "?!+" all at position 3)
//! - Symbols fill their position's column, empty positions get spaces
-//! - Example: mask [0b, 3] creates 2-column grid:
-//! - Row with ≡ at 0b: "≡ " (≡ at col 0, space at col 1)
-//! - Row with ! at 3: " !" (space at col 0, ! at col 1)
-//! - Row with ≡!+ at 0b and 3: "≡!+" (≡ at col 0, !+ at col 1)
+//! - Example: mask [0b, 3, 4] creates 3-column grid:
+//! - Row with ≡ at 0b: "≡ " (≡ at col 0, space at col 1 and 2)
+//! - Row with ! at 3: " ! " (space at col 0, ! at col 1, space at col 2)
+//! - Row with 🤖 at 4: " 🤖" (space at col 0 and 1, 🤖 at col 2)
//!
-//! ## User Status Alignment
-//!
-//! User status rendering happens in the rendering layer (`render.rs`), not in `StatusSymbols`.
-//! User status aligns at column position `max_git_symbols_width` for both worktrees and branches.
-//! Integration tests verify user status behavior (see `with_user_status.snap`).
+//! User status is now part of the unified grid system (Position 4) and aligns vertically
+//! with all other status indicators. Integration tests verify user status behavior.
//!
//! Each test specifies the exact expected output to make the target behavior explicit.
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap b/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
index 68ea0cabb..4601d2c01 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_display_fields.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLFo230/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpsNHhir/test-config.toml
---
success: true
exit_code: 0
@@ -61,7 +61,8 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
}
},
{
@@ -99,11 +100,12 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "↕",
"upstream_divergence": "",
- "working_tree": "?!"
+ "working_tree": "?!",
+ "user_status": null
},
"commits_display": "/u001b[32m↑2/u001b[0m /u001b[2m/u001b[31m↓2/u001b[0m",
"branch_diff_display": "/u001b[32m+1/u001b[0m",
- "status_display": " ↕ ?!",
+ "status_display": " ↕ ?! ",
"working_diff_display": "/u001b[32m+1/u001b[0m /u001b[31m-1/u001b[0m"
},
{
@@ -141,10 +143,11 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "↓",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
},
"commits_display": "/u001b[2m/u001b[31m↓2/u001b[0m",
- "status_display": " ∅ ↓ "
+ "status_display": " ∅ ↓ "
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
index 7dc403092..acb814bd0 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_metadata.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyW6sML/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmphzLoxx/test-config.toml
---
success: true
exit_code: 0
@@ -61,7 +61,8 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
}
},
{
@@ -103,9 +104,10 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
},
- "status_display": " ≡ "
+ "status_display": " ≡ "
},
{
"type": "worktree",
@@ -146,9 +148,10 @@ exit_code: 0
"worktree_attrs": "⊠",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
},
- "status_display": " ≡ ⊠ "
+ "status_display": " ≡ ⊠ "
}
]
diff --git a/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap b/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
index c6048aafb..26633e2f7 100644
--- a/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
+++ b/tests/snapshots/integration__integration_tests__list__json_with_user_status.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpMrJiag/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpBMysvY/test-config.toml
---
success: true
exit_code: 0
@@ -61,7 +61,8 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
}
},
{
@@ -103,9 +104,9 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": "🔧"
},
- "user_status": "🔧",
"status_display": " ≡ 🔧"
},
{
@@ -147,9 +148,10 @@ exit_code: 0
"worktree_attrs": "",
"main_divergence": "",
"upstream_divergence": "",
- "working_tree": ""
+ "working_tree": "",
+ "user_status": null
},
- "status_display": " ≡ "
+ "status_display": " ≡ "
}
]