Skip to content

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

feat: Use ║ symbol to indicate "in sync" with remote

Maximilian Roos85a7b2a32ae4
diff --git a/README.md b/README.md
index f2cc9b98d..a0138d04c 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ merge, cleanup.
```console
$ wt list
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
-@ main ^ ./repo ⇡0 ⇣0 b834638e 1d Initial commit
+@ main ^║ ./repo ║ b834638e 1d Initial commit
+ feature-x + ↑ +5 ↑3 ./repo.feature-x 6bba16d6 1h Add file 3
+ bugfix-y ↑ ↑1 ./repo.bugfix-y bafa4cbd 2h Fix bug
diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rs
index 87aee0e99..174d4bcb2 100644
--- a/src/commands/list/layout.rs
+++ b/src/commands/list/layout.rs
@@ -299,7 +299,7 @@ impl ColumnKind {
variant: DiffVariant::UpstreamArrows,
positive_style: ADDITION,
negative_style: DELETION.dimmed(),
- always_show_zeros: true,
+ always_show_zeros: false, // 0/0 case handled specially with ║ symbol
}),
_ => None,
}
diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs
index fbe8a69d0..93d48a2db 100644
--- a/src/commands/list/model.rs
+++ b/src/commands/list/model.rs
@@ -155,9 +155,10 @@ impl AheadBehind {
upstream: &UpstreamStatus,
) -> (MainDivergence, UpstreamDivergence) {
let main_divergence = MainDivergence::from_counts(self.ahead, self.behind);
- let (upstream_ahead, upstream_behind) =
- upstream.active().map(|(_, a, b)| (a, b)).unwrap_or((0, 0));
- let upstream_divergence = UpstreamDivergence::from_counts(upstream_ahead, upstream_behind);
+ let upstream_divergence = match upstream.active() {
+ None => UpstreamDivergence::None,
+ Some((_, ahead, behind)) => UpstreamDivergence::from_counts_with_remote(ahead, behind),
+ };
(main_divergence, upstream_divergence)
}
@@ -643,9 +644,11 @@ impl MainDivergence {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, strum::IntoStaticStr)]
pub enum UpstreamDivergence {
#[strum(serialize = "")]
- /// Up to date with remote
+ /// No remote tracking branch configured
#[default]
None,
+ /// In sync with remote (has remote, 0 ahead, 0 behind)
+ InSync,
/// Ahead of remote (has commits remote doesn't have)
Ahead,
/// Behind remote (missing commits from remote)
@@ -658,6 +661,7 @@ impl std::fmt::Display for UpstreamDivergence {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::None => Ok(()),
+ Self::InSync => write!(f, "║"),
Self::Ahead => write!(f, "⇡"),
Self::Behind => write!(f, "⇣"),
Self::Diverged => write!(f, "⇅"),
@@ -676,10 +680,13 @@ impl serde::Serialize for UpstreamDivergence {
}
impl UpstreamDivergence {
- /// Compute divergence state from ahead/behind counts.
- pub fn from_counts(ahead: usize, behind: usize) -> Self {
+ /// Compute divergence state from ahead/behind counts when a remote exists.
+ ///
+ /// Returns `InSync` for 0/0 since we know a remote tracking branch exists.
+ /// For cases where there's no remote, use `UpstreamDivergence::None` directly.
+ pub fn from_counts_with_remote(ahead: usize, behind: usize) -> Self {
match (ahead, behind) {
- (0, 0) => Self::None,
+ (0, 0) => Self::InSync,
(_, 0) => Self::Ahead,
(0, _) => Self::Behind,
_ => Self::Diverged,
diff --git a/src/commands/list/render.rs b/src/commands/list/render.rs
index 5c90d6194..53247fc8d 100644
--- a/src/commands/list/render.rs
+++ b/src/commands/list/render.rs
@@ -609,6 +609,17 @@ impl ColumnLayout {
let Some((_, ahead, behind)) = ctx.upstream.active() else {
return StyledLine::new();
};
+ // Show centered ║ when in sync instead of ⇡0 ⇣0
+ // Note: This duplicates the InSync check from UpstreamDivergence, but
+ // checking counts directly is simpler than threading the enum through.
+ if ahead == 0 && behind == 0 {
+ let mut cell = StyledLine::new();
+ // Center the symbol in the column width
+ let padding_left = (self.width.saturating_sub(1)) / 2;
+ cell.push_raw(" ".repeat(padding_left));
+ cell.push_styled("║", Style::new().dimmed());
+ return cell;
+ }
self.render_diff_cell(ahead, behind)
}
ColumnKind::Time => {
diff --git a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
index 80b187272..bbfcc2549 100644
--- a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
+++ b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap
@@ -25,7 +25,7 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
-@ main ^⇡ ./repo ⇡1 ⇣0 85ed6d3d 1d Main advances
+@ main ^⇡ ./repo ⇡1 85ed6d3d 1d Main advances
+ feature +!?⊘↕⇅⊠🤖 +2 -2 ↑2 ↓1 +3 -1 ./repo.feature ⇡1 ⇣1 4afb2b9e 1d Local commit
⚪ Showing 2 worktrees, 1 with changes, 1 ahead
diff --git a/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap b/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
index 1d2d930ac..b299b4bb2 100644
--- a/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
+++ b/tests/snapshots/integration__integration_tests__list__readme_example_simple_list.snap
@@ -24,7 +24,7 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
-@ main ^ ./repo ⇡0 ⇣0 b834638e 1d Initial commit
+@ main ^║ ./repo ║ b834638e 1d Initial commit
+ feature-x + ↑ +5 ↑3 ./repo.feature-x 6bba16d6 1h Add file 3
+ bugfix-y ↑ ↑1 ./repo.bugfix-y bafa4cbd 2h Fix bug
diff --git a/tests/snapshots/integration__integration_tests__list__task_dag_with_upstream.snap b/tests/snapshots/integration__integration_tests__list__task_dag_with_upstream.snap
index 0d2155cde..33de62c38 100644
--- a/tests/snapshots/integration__integration_tests__list__task_dag_with_upstream.snap
+++ b/tests/snapshots/integration__integration_tests__list__task_dag_with_upstream.snap
@@ -26,8 +26,8 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
-@ main ^ ./repo ⇡0 ⇣0 6c3da842 1d Initial commit on main
-+ ahead ↑⇡ ↑1 +1 ./repo.ahead ⇡1 ⇣0 2fff52c2 1d Ahead commit
-+ in-sync _ ./repo.in-sync ⇡0 ⇣0 6c3da842 1d Initial commit on main
+@ main ^║ ./repo ║ 6c3da842 1d Initial commit on main
++ ahead ↑⇡ ↑1 +1 ./repo.ahead ⇡1 2fff52c2 1d Ahead commit
++ in-sync _ ║ ./repo.in-sync ║ 6c3da842 1d Initial commit on main
⚪ Showing 3 worktrees, 1 ahead
diff --git a/tests/snapshots/integration__integration_tests__list__with_remotes_and_branches.snap b/tests/snapshots/integration__integration_tests__list__with_remotes_and_branches.snap
index 971299a0a..cc352a7e4 100644
--- a/tests/snapshots/integration__integration_tests__list__with_remotes_and_branches.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_remotes_and_branches.snap
@@ -26,7 +26,7 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
-@ main ^ . ⇡0 ⇣0 b834638e 1d Initial commit
+@ main ^║ . ║ b834638e 1d Initial commit
local-only-1 _ ⎇ b834638e 1d Initial commit
local-only-2 _ ⎇ b834638e 1d Initial commit
origin/remote-only-1 _ ⎇ b834638e 1d Initial commit
diff --git a/tests/snapshots/integration__integration_tests__list__with_remotes_filters_worktrees.snap b/tests/snapshots/integration__integration_tests__list__with_remotes_filters_worktrees.snap
index ba91c1847..ce410ef77 100644
--- a/tests/snapshots/integration__integration_tests__list__with_remotes_filters_worktrees.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_remotes_filters_worktrees.snap
@@ -25,7 +25,7 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
-@ main ^ ./repo ⇡0 ⇣0 b834638e 1d Initial commit
+@ main ^║ ./repo ║ b834638e 1d Initial commit
+ feature-with-worktree _ ./repo.feature-with-worktree b834638e 1d Initial commit
origin/remote-only _ ⎇ b834638e 1d Initial commit
diff --git a/tests/snapshots/integration__integration_tests__list__with_remotes_flag.snap b/tests/snapshots/integration__integration_tests__list__with_remotes_flag.snap
index b4d2a06f5..5eef1a59e 100644
--- a/tests/snapshots/integration__integration_tests__list__with_remotes_flag.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_remotes_flag.snap
@@ -25,7 +25,7 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ Path Remote⇅ Commit Age Message
-@ main ^ . ⇡0 ⇣0 b834638e 1d Initial commit
+@ main ^║ . ║ b834638e 1d Initial commit
origin/remote-feature-1 _ ⎇ b834638e 1d Initial commit
origin/remote-feature-2 _ ⎇ b834638e 1d Initial commit
diff --git a/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap b/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
index 1e23e173f..48524e78a 100644
--- a/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
+++ b/tests/snapshots/integration__integration_tests__list__with_upstream_tracking.snap
@@ -27,11 +27,11 @@ exit_code: 0
----- stderr -----
Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
-@ main ^ ./repo ⇡0 ⇣0 6c3da842 1d Initial commit on main
-+ ahead ↑⇡ ↑2 +2 ./repo.ahead ⇡2 ⇣0 8d8f4673 1d Ahead commit 2
-+ behind _ ⇣ ./repo.behind ⇡0 ⇣1 6c3da842 1d Initial commit on main
+@ main ^║ ./repo ║ 6c3da842 1d Initial commit on main
++ ahead ↑⇡ ↑2 +2 ./repo.ahead ⇡2 8d8f4673 1d Ahead commit 2
++ behind _ ⇣ ./repo.behind ⇣1 6c3da842 1d Initial commit on main
+ diverged ↑⇅ ↑1 +1 ./repo.diverged ⇡1 ⇣1 ca7cb696 1d Diverged local commit
-+ in-sync _ ./repo.in-sync ⇡0 ⇣0 6c3da842 1d Initial commit on main
++ in-sync _ ║ ./repo.in-sync ║ 6c3da842 1d Initial commit on main
+ no-upstream _ ./repo.no-upstream 6c3da842 1d Initial commit on main
⚪ Showing 6 worktrees, 2 ahead