Skip to content

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

Output: Show detailed stats only in progress messages

Maximilian Roosf1f9f1680bb9
diff --git a/CLAUDE.md b/CLAUDE.md
index 3ebd3c49f..5792531c9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -98,6 +98,39 @@ Removed worktree for bugfix
**Why this matters:** Immediate feedback builds confidence, failed operations are obvious, Ctrl+C interrupts don't leave uncertainty, matches how users think about sequential operations.
+### Information Display: Show Once, Not Twice
+
+**Core Principle: Display detailed information in progress messages, not in success messages.**
+
+When operations have both progress and success messages:
+- **Progress message**: Include detailed stats/context (what's about to happen)
+- **Success message**: Minimal confirmation with reference info (hash, path)
+
+This prevents redundant noise while giving users information when they need it most (before the operation runs).
+
+**Good pattern:**
+```rust
+// Progress: detailed stats upfront
+output::progress("πŸ”„ Committing changes... (3 files, +45, -12)")?;
+perform_commit()?;
+// Success: minimal confirmation with reference
+output::success("βœ… Committed changes @ a1b2c3d")?;
+```
+
+**Bad pattern:**
+```rust
+// Redundant - same stats shown twice
+output::progress("πŸ”„ Committing changes... (3 files, +45, -12)")?;
+perform_commit()?;
+output::success("βœ… Committed changes (3 files, +45, -12) @ a1b2c3d")?; // ❌ Too noisy
+```
+
+**Rationale:**
+- Users read progress messages to understand what's happening
+- Success messages just confirm completion - stats already seen
+- Commit hashes/paths in success messages enable easy reference
+- Reduces visual noise and line count in output
+
### Semantic Style Constants
**Style constants defined in `src/styling.rs`:**
diff --git a/src/commands/merge.rs b/src/commands/merge.rs
index b481ad923..5f19c6bd8 100644
--- a/src/commands/merge.rs
+++ b/src/commands/merge.rs
@@ -244,14 +244,9 @@ fn commit_with_generated_message(
.to_string();
use worktrunk::styling::{GREEN, SUCCESS_EMOJI};
- let success_msg = match stats_parts.is_empty() {
- true => format!("{SUCCESS_EMOJI} {GREEN}Committed changes @ {commit_hash}{GREEN:#}"),
- false => format!(
- "{SUCCESS_EMOJI} {GREEN}Committed changes ({}) @ {commit_hash}{GREEN:#}",
- stats_parts.join(", ")
- ),
- };
- crate::output::success(success_msg)?;
+ crate::output::success(format!(
+ "{SUCCESS_EMOJI} {GREEN}Committed changes @ {commit_hash}{GREEN:#}"
+ ))?;
Ok(())
}
@@ -266,10 +261,7 @@ fn handle_commit_changes(
repo.run_command(&["add", "-A"])
.git_context("Failed to stage changes")?;
- commit_with_generated_message(
- "Committing uncommitted changes...",
- commit_generation_config,
- )
+ commit_with_generated_message("Committing changes...", commit_generation_config)
}
fn handle_squash(
@@ -299,7 +291,7 @@ fn handle_squash(
if commit_count == 0 && has_staged {
// Just staged changes, no commits - commit them directly (no squashing needed)
- commit_with_generated_message("Committing staged changes...", commit_generation_config)?;
+ commit_with_generated_message("Committing changes...", commit_generation_config)?;
return Ok(None);
}
@@ -315,7 +307,7 @@ fn handle_squash(
// Get diff stats early for display in progress message
let range = format!("{}..HEAD", merge_base);
let diff_shortstat = repo
- .run_command(&["diff", "--shortstat", &format!("{}..HEAD", merge_base)])
+ .run_command(&["diff", "--shortstat", &range])
.unwrap_or_default();
let stats = parse_diff_shortstat(&diff_shortstat);
let stats_parts = stats.format_summary();
@@ -374,16 +366,9 @@ fn handle_squash(
// Show success immediately after completing the squash
use worktrunk::styling::{GREEN, SUCCESS_EMOJI};
- let success_msg = match stats_parts.is_empty() {
- true => format!(
- "{SUCCESS_EMOJI} {GREEN}Squashed {commit_count} commits into 1 @ {commit_hash}{GREEN:#}"
- ),
- false => format!(
- "{SUCCESS_EMOJI} {GREEN}Squashed {commit_count} commits into 1 ({}) @ {commit_hash}{GREEN:#}",
- stats_parts.join(", ")
- ),
- };
- crate::output::success(success_msg)?;
+ crate::output::success(format!(
+ "{SUCCESS_EMOJI} {GREEN}Squashed {commit_count} commits into 1 @ {commit_hash}{GREEN:#}"
+ ))?;
Ok(Some(commit_count))
}
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
index 57dd647fa..1c6094623 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_and_squash.snap
@@ -19,7 +19,7 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: update file 1 content"
WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpo6rpX4/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpisDYxs/test-config.toml
---
success: true
exit_code: 0
@@ -32,7 +32,7 @@ exit_code: 0
  - feat: add file 1
  - feat: add file 2
-βœ… Squashed 2 commits into 1 (2 files, +2) @ [SHA]
+βœ… Squashed 2 commits into 1 @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
index 795b64b22..011a76076 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_deterministic.snap
@@ -16,16 +16,16 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJYa7yM/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLuX5t1/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Committing uncommitted changes... (1 file, +1, -1)
+πŸ”„ Committing changes... (1 file, +1, -1)
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
-βœ… Committed changes (1 file, +1, -1) @ [SHA]
+βœ… Committed changes @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 2 commits to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
index 8a26a36c1..7b952dac9 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_auto_commit_with_llm.snap
@@ -18,16 +18,16 @@ info:
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__ARGS: "fix: improve auth validation logic"
WORKTRUNK_COMMIT_GENERATION__COMMAND: echo
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwSE8M5/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp2sHvTX/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Committing uncommitted changes... (1 file, +1, -1)
+πŸ”„ Committing changes... (1 file, +1, -1)
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
-βœ… Committed changes (1 file, +1, -1) @ [SHA]
+βœ… Committed changes @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 2 commits to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
index 9fc6906f6..c903acfda 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_dirty_working_tree.snap
@@ -16,16 +16,16 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpulyUF2/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpKeOZyO/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
-πŸ”„ Committing uncommitted changes... (1 file, +1)
+πŸ”„ Committing changes... (1 file, +1)
πŸ”„ Generating commit message...
  WIP: Auto-commit before merge
-βœ… Committed changes (1 file, +1) @ [SHA]
+βœ… Committed changes @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
index 2f3e31235..60626ed11 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_deterministic.snap
@@ -17,7 +17,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpkxZNqZ/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpBQQvyf/test-config.toml
---
success: true
exit_code: 0
@@ -31,7 +31,7 @@ exit_code: 0
  - fix: update logic
  - docs: update readme
-βœ… Squashed 3 commits into 1 (3 files, +3) @ [SHA]
+βœ… Squashed 3 commits into 1 @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
index 721282430..d26a5ba7c 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_llm_fallback.snap
@@ -18,7 +18,7 @@ info:
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
WORKTRUNK_COMMIT_GENERATION__COMMAND: nonexistent-llm-command
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpDTLZlD/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpk6VxVV/test-config.toml
---
success: true
exit_code: 0
@@ -31,7 +31,7 @@ exit_code: 0
  - feat: new feature
  - fix: bug fix
-βœ… Squashed 2 commits into 1 (2 files, +2) @ [SHA]
+βœ… Squashed 2 commits into 1 @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 1 commit to main @ [SHA]
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
index 518b878dc..e399e5b20 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_squash_with_llm.snap
@@ -20,7 +20,7 @@ info:
WORKTRUNK_COMMIT_GENERATION__ARGS__0: "-c"
WORKTRUNK_COMMIT_GENERATION__ARGS__1: "cat >/dev/null && echo 'feat: implement user authentication system'"
WORKTRUNK_COMMIT_GENERATION__COMMAND: sh
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpT3OwtL/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpr4HNo8/test-config.toml
---
success: true
exit_code: 0
@@ -33,7 +33,7 @@ exit_code: 0
  - feat: add authentication
  - fix: handle edge case
-βœ… Squashed 2 commits into 1 (1 file, +1) @ [SHA]
+βœ… Squashed 2 commits into 1 @ [SHA]
πŸ”„ Rebasing onto main...
πŸ”„ Merging 1 commit to main @ [SHA]