Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Show progress messages during batch worktree removal
Maximilian Roos04385e775aaa
diff --git a/CLAUDE.md b/CLAUDE.mdindex 6259c8a01..ffb35f3c3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -88,57 +88,99 @@ Command::new("sh").status()?;```-### Temporal Locality: Show Success When Actions Complete+### Temporal Locality: Output Should Be Close to Operations-**Principle: Emit success messages immediately when operations complete, not just in summaries.**+**Core Principle: Output should appear immediately adjacent to the operations they describe.**-Users need instant feedback that an operation succeeded. Summaries at the end are useful for context, but immediate feedback at the point of completion is critical for good UX.+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.-**Good pattern:**-```-π Squashing 3 commits into one...-π Generating squash commit message...- [commit message display]-β Squashed 3 commits into one β Immediate feedback-π Rebasing onto main...-...-β Merged feature β main β Final summary-Squashed 3 commits β Context in summary-```+**The Two Patterns:**++1. **Progress β Operation β Success** (for sequential operations)+ ```+ π Removing worktree for feature...+ β Removed worktree for feature+ π Removing worktree for bugfix...+ β Removed worktree for bugfix+ ```-**Bad pattern:**+2. **Progress β Operation β Success β Summary** (for complex multi-step operations)+ ```+ π Squashing 3 commits into one...+ π Generating commit message...+ [commit message display]+ β Squashed 3 commits into one β Immediate feedback+ π Rebasing onto main...+ ...+ β Merged feature β main β Final summary+ Squashed 3 commits β Context in summary+ ```++**Bad pattern - output decoupled from operations:**```-π Squashing 3 commits into one...-π Generating squash commit message...- [commit message display]- β No immediate feedback!-π Rebasing onto main...-...-β Merged feature β main-Squashed 3 commits β Only mentioned in summary+π Removing worktree for feature...+π Removing worktree for bugfix...+π Removing worktree for hotfix...+ β Long delay, no feedback+Removed worktree for feature β All output at the end+Removed worktree for bugfix+Removed worktree for hotfix```**Why this matters:**-- **Temporal locality**: Feedback should appear when the action completes, not minutes later-- **User confidence**: Immediate success messages confirm the operation worked-- **Debugging**: If something fails later, users know which steps succeeded++- **Temporal locality**: Feedback appears when the action completes, not seconds/minutes later+- **User confidence**: Immediate success messages confirm each operation worked+- **Debugging**: If something fails, users know exactly which operation failed- **Progress visibility**: Users can see what's done vs. what's still in progress+- **Interrupt recovery**: If user hits Ctrl+C, they know what completed+- **Natural mental model**: Matches how users think about sequential operations++**Implementation patterns:**-**Implementation:**```rust-// After completing a significant operation, emit success immediately-crate::output::success("Squashed 3 commits into one")?;+// Pattern 1: Simple sequential operations (like batch remove)+for item in items {+ // Show what we're about to do+ output::progress(format!("π {CYAN}Removing {item}...{CYAN:#}"))?;++ // Do the operation+ let result = perform_operation(item)?;++ // Show immediate success+ output::success(format!("Removed {item}"))?;+}++// Pattern 2: Complex operation with substeps+output::progress("π Starting complex operation...")?;-// The summary can still include this info for context-let summary = format!("Merged {from} β {to}\nSquashed {count} commits\n...");-crate::output::success(summary)?;+// Substep 1+output::progress("π Validating...")?;+validate()?;+output::success("Validated")?;++// Substep 2+output::progress("π Processing...")?;+process()?;+output::success("Processed")?;++// Final summary (optional, for context)+output::success("Completed complex operation")?;```+**Red flags - violations of temporal locality:**++1. **Collecting messages in a buffer**: `let mut messages = Vec::new(); messages.push(...)` β emit immediately instead+2. **Single success message for batch operations**: Loop that shows all successes at the end+3. **No progress before slow operations**: User sees nothing, then suddenly output appears+4. **Progress without matching success**: Progress messages that aren't followed by success/failure+5. **Success before operation**: Showing success message before operation completes (async timing bugs)+**Apply this to:**-- Squashing commits: Show "β Squashed N commits" immediately after squashing-- Pushing changes: Show "β Pushed to branch" immediately after pushing-- Committing changes: Show "β Committed changes" immediately after committing-- Any multi-step operation: Show success after each major step completes+- Batch operations: Show progress + success for each item in the loop+- Multi-step operations: Show success after each major step completes+- Slow operations: Show progress immediately before starting+- Error handling: Show failure immediately when detected, not collected for later### Semantic Style Constantsdiff --git a/src/main.rs b/src/main.rsindex 438c29ea3..660747b6e 100644--- a/src/main.rs+++ b/src/main.rs@@ -397,12 +397,28 @@ fn main() {// Remove others firstfor worktree in others.iter() {+ // Show progress before starting removal+ use anstyle::Style;+ use worktrunk::styling::CYAN;+ let bold = Style::new().bold();+ output::progress(format!(+ "π {CYAN}Removing worktree for {bold}{worktree}{bold:#}...{CYAN:#}"+ ))?;+let result = handle_remove(Some(worktree.as_str()))?;handle_remove_output(&result)?;}// Remove current worktree last (if it was in the list)if let Some(current_name) = current {+ // Show progress before starting removal+ use anstyle::Style;+ use worktrunk::styling::CYAN;+ let bold = Style::new().bold();+ output::progress(format!(+ "π {CYAN}Removing worktree for {bold}{current_name}{bold:#}...{CYAN:#}"+ ))?;+let result = handle_remove(Some(current_name.as_str()))?;handle_remove_output(&result)?;}