Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: Only show progress for slow operations (>400ms)
Maximilian Roosed732e79133a
diff --git a/CLAUDE.md b/CLAUDE.mdindex ffb35f3c3..253d52272 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -94,6 +94,42 @@ Command::new("sh")Users experience commands as temporal sequences. Output that appears far from its triggering operation creates confusion and breaks the mental model of what's happening.+**When to Show Progress Messages:**++Progress messages (`π Doing something...`) are only appropriate for operations that take perceptible time (>400ms). For fast operations like file checks or simple file writes, show only the result.++- **Show progress for**: Operations that take noticeable time (>400ms)+ - Git operations (rebase, push, commit, worktree operations)+ - Network requests+ - Building/compiling+ - Operations on large files+ - Batch operations that iterate multiple slow steps++- **Don't show progress for**: Fast operations (<400ms)+ - Checking if a line exists in a file+ - Writing a single line to a config file+ - Reading small files+ - Simple validations++**Examples:**++```rust+// β Bad - progress for fast operation+output::progress("π Checking config file...")?;+let exists = config_file.exists(); // <1ms - way too fast for progress+output::success("Config file checked")?;++// β Good - just show the result for fast operations+if config_file.exists() {+ println!("Config file found at {}", path);+}++// β Good - progress for slow operation+output::progress("π Removing worktree...")?;+repo.remove_worktree(&path)?; // Takes >400ms - worth showing progress+output::success("Removed worktree")?;+```+**The Two Patterns:**1. **Progress β Operation β Success** (for sequential operations)diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex b8cc6ea31..d22d0b2fa 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -119,33 +119,9 @@ fn scan_shell_configs(if should_configure {let path = target_path.or_else(|| paths.first());if let Some(path) = path {- // Show progress before configuring (only in real mode, not dry run)- if !dry_run {- use anstyle::Style;- use worktrunk::styling::CYAN;- let bold = Style::new().bold();- crate::output::progress(format!(- "π {CYAN}Configuring {bold}{shell}{bold:#}...{CYAN:#}"- )).ok();- }-match configure_shell_file(shell, path, cmd_prefix, dry_run, shell_filter.is_some()){- Ok(Some(result)) => {- // Show success immediately after configuring (only in real mode)- if !dry_run && result.action != ConfigAction::AlreadyExists {- use anstyle::Style;- let bold = Style::new().bold();- crate::output::success(format!(- "{} {bold}{}{bold:#} at {}",- result.action.description(),- result.shell,- result.path.display()- )).ok();- crate::output::progress(worktrunk::styling::format_with_gutter(&result.config_line, "", None)).ok();- }- results.push(result);- }+ Ok(Some(result)) => results.push(result),Ok(None) => {} // No action neededErr(e) => {// For non-critical errors, we could continue with other shellsdiff --git a/src/main.rs b/src/main.rsindex eab367b1a..ef1155758 100644--- a/src/main.rs+++ b/src/main.rs@@ -317,8 +317,21 @@ fn main() {return;}- // Individual progress/success messages were already shown during configuration- // Just show the final summary+ // Show what was done (instant operations, no progress needed)+ for result in &results {+ use worktrunk::styling::format_with_gutter;+ let bold = Style::new().bold();+ let shell = result.shell;+ let path = result.path.display();+ println!(+ "{} {bold}{shell}{bold:#} {path}",+ result.action.description(),+ );+ // Show config line with gutter+ print!("{}", format_with_gutter(&result.config_line, "", None));+ }++ // Success summaryprintln!();let green = Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green)));let plural = if changes_count == 1 { "" } else { "s" };diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_remove_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_remove_no_directive_leak.snapindex 89858f611..b2334366a 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_remove_no_directive_leak.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_remove_no_directive_leak.snap@@ -2,4 +2,5 @@source: tests/integration_tests/shell_wrapper.rsexpression: normalized.as_ref()---+π [36mRemoving worktree for [1mfish-to-remove[0m...[0mRemoved worktree for [1mfish-to-remove[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__remove_through_wrapper_no_directive_leak.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__remove_through_wrapper_no_directive_leak.snapindex 7367ff4c8..5b3d52781 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__remove_through_wrapper_no_directive_leak.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__remove_through_wrapper_no_directive_leak.snap@@ -2,4 +2,5 @@source: tests/integration_tests/shell_wrapper.rsexpression: normalized.as_ref()---+π [36mRemoving worktree for [1mto-remove[0m...[0mRemoved worktree for [1mto-remove[0m