Skip to content

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

feat: Include branch diff in statusline

Maximilian Roos736109bd8798
diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs
index 1f41b6368..ec5d5071e 100644
--- a/src/commands/list/model.rs
+++ b/src/commands/list/model.rs
@@ -19,7 +19,7 @@ pub struct DisplayFields {
#[serde(skip_serializing_if = "Option::is_none")]
pub status_display: Option<String>,
/// Pre-formatted single-line representation for statusline tools.
- /// Format: `branch status ±working commits upstream ci` (2-space separators)
+ /// Format: `branch status @working commits ^branch_diff upstream ci` (2-space separators)
///
/// Use via JSON: `wt list --format=json | jq '.[] | select(.is_current) | .status_line'`
#[serde(skip_serializing_if = "Option::is_none")]
@@ -334,7 +334,7 @@ impl ListItem {
/// Format this item as a single-line statusline string.
///
- /// Format: `branch status ±working commits upstream ci`
+ /// Format: `branch status @working commits ^branch_diff upstream ci`
/// Uses 2-space separators between non-empty parts.
pub fn format_statusline(&self) -> String {
let mut parts: Vec<String> = Vec::new();
@@ -351,13 +351,14 @@ impl ListItem {
}
// 3. Working diff (worktrees only)
+ // Prefix with @ ("at" current state) to distinguish from branch diff (^)
if let Some(data) = self.worktree_data()
&& let Some(ref diff) = data.working_tree_diff
&& !diff.is_empty()
&& let Some(formatted) =
ColumnKind::WorkingDiff.format_diff_plain(diff.added, diff.deleted)
{
- parts.push(format!("±{formatted}"));
+ parts.push(format!("@{formatted}"));
}
// 4. Commits ahead/behind main
@@ -367,7 +368,17 @@ impl ListItem {
parts.push(formatted);
}
- // 5. Upstream status
+ // 5. Branch diff vs main (line changes)
+ // Prefix with ^ (main) to distinguish from working diff (@)
+ let branch_diff = self.branch_diff();
+ if !branch_diff.diff.is_empty()
+ && let Some(formatted) = ColumnKind::BranchDiff
+ .format_diff_plain(branch_diff.diff.added, branch_diff.diff.deleted)
+ {
+ parts.push(format!("^{formatted}"));
+ }
+
+ // 6. Upstream status
if let Some(ref upstream) = self.upstream
&& let Some((_, ahead, behind)) = upstream.active()
&& let Some(formatted) = ColumnKind::Upstream.format_diff_plain(ahead, behind)
@@ -375,7 +386,7 @@ impl ListItem {
parts.push(formatted);
}
- // 6. CI status
+ // 7. CI status
if let Some(Some(ref pr_status)) = self.pr_status {
parts.push(pr_status.format_indicator());
}
diff --git a/tests/integration_tests/statusline.rs b/tests/integration_tests/statusline.rs
index de0179bbf..c7e5770a3 100644
--- a/tests/integration_tests/statusline.rs
+++ b/tests/integration_tests/statusline.rs
@@ -128,7 +128,7 @@ fn test_statusline_commits_ahead() {
// Run from the feature worktree to see commits ahead
let feature_path = repo.worktree_path("feature");
let output = run_statusline_from_dir(&repo, &[], None, feature_path);
- assert_snapshot!(output, @"feature ↑ ↑2");
+ assert_snapshot!(output, @"feature ↑ ↑2 ^+2");
}
// --- Claude Code Mode Tests ---
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 be671f370..291da493a 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
@@ -111,7 +111,7 @@ exit_code: 0
},
"commits_display": "/u001b[32m↑2/u001b[0m /u001b[2m/u001b[31m↓2/u001b[0m",
"branch_diff_display": "/u001b[32m+1/u001b[0m",
- "status_line": "feature-ahead /u001b[36m!/u001b[39m/u001b[36m?/u001b[39m/u001b[2m↕/u001b[22m ±/u001b[32m+1/u001b[0m /u001b[31m-1/u001b[0m /u001b[32m↑2/u001b[0m /u001b[2m/u001b[31m↓2/u001b[0m",
+ "status_line": "feature-ahead /u001b[36m!/u001b[39m/u001b[36m?/u001b[39m/u001b[2m↕/u001b[22m @/u001b[32m+1/u001b[0m /u001b[31m-1/u001b[0m /u001b[32m↑2/u001b[0m /u001b[2m/u001b[31m↓2/u001b[0m ^/u001b[32m+1/u001b[0m",
"type": "worktree",
"path": "[REPO].feature-ahead",
"bare": false,