Skip to content

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

feat: Improve filter functionality, update styling, and enhance worktree messages

Maximilian Roos030219763601
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index b9f9fa3ca..9aabec873 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -237,6 +237,15 @@ pub fn handle_switch(
}
pub fn handle_remove(worktree_name: Option<&str>) -> Result<RemoveResult, GitError> {
+ // Show progress immediately, before slow validation
+ let cyan_bold = CYAN.bold();
+ let progress_msg = if let Some(b) = worktree_name {
+ format!("πŸ”„ {CYAN}Removing worktree for {cyan_bold}{b}{cyan_bold:#}...{CYAN:#}")
+ } else {
+ format!("πŸ”„ {CYAN}Removing worktree...{CYAN:#}")
+ };
+ crate::output::progress(progress_msg)?;
+
let repo = Repository::current();
// Two modes: remove current worktree vs. remove by name
diff --git a/src/output/handlers.rs b/src/output/handlers.rs
index 55e9c235a..a14604a67 100644
--- a/src/output/handlers.rs
+++ b/src/output/handlers.rs
@@ -108,24 +108,14 @@ pub fn handle_remove_output(result: &RemoveResult, branch: Option<&str>) -> Resu
changed_directory,
} = result
{
- use worktrunk::styling::CYAN;
-
// 1. Emit cd directive if needed - shell will execute this immediately
if *changed_directory {
super::change_directory(primary_path)?;
super::flush()?; // Force flush to ensure shell processes the cd
}
- // 2. Show progress message with branch name
- let cyan_bold = CYAN.bold();
- let progress_msg = if let Some(b) = branch {
- format!("πŸ”„ {CYAN}Removing worktree for {cyan_bold}{b}{cyan_bold:#}...{CYAN:#}")
- } else {
- format!("πŸ”„ {CYAN}Removing worktree...{CYAN:#}")
- };
- super::progress(progress_msg)?;
-
- // 3. Do the deletion (shell already changed directory if needed)
+ // 2. Do the deletion (shell already changed directory if needed)
+ // Progress message already shown at start of handle_remove()
let repo = worktrunk::git::Repository::current();
repo.remove_worktree(worktree_path)
.git_context("Failed to remove worktree")?;
diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rs
index 1626ce9b2..834248a18 100644
--- a/tests/integration_tests/directives.rs
+++ b/tests/integration_tests/directives.rs
@@ -80,7 +80,7 @@ fn test_remove_internal_directive() {
.arg("remove")
.current_dir(repo.root_path());
- assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\nβœ… \u{1b}[32mAlready on default branch \u{1b}[1m\u{1b}[32mmain\u{1b}[0m\u{1b}[0m\0\n----- stderr -----");
+ assert_cmd_snapshot!(cmd, @"success: true\nexit_code: 0\n----- stdout -----\nπŸ”„ \u{1b}[36mRemoving worktree...\u{1b}[0m\0βœ… \u{1b}[32mAlready on default branch \u{1b}[1m\u{1b}[32mmain\u{1b}[0m\u{1b}[0m\0\n----- stderr -----");
});
}
@@ -102,6 +102,7 @@ fn test_remove_without_internal() {
success: true
exit_code: 0
----- stdout -----
+ πŸ”„ Removing worktree...
βœ… Already on default branch main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap b/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
index a4796929d..13951eb82 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_already_on_default.snap
@@ -15,11 +15,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpVGZnEV/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUGNVDx/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
+πŸ”„ Removing worktree...
βœ… Already on default branch main
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap b/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap
index 52a54fb34..0f077816b 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_by_name_dirty_target.snap
@@ -16,11 +16,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpyXEZSS/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpYBQ7Tb/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
+πŸ”„ Removing worktree for feature-dirty...
----- stderr -----
❌ Working tree has uncommitted changes
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
index e897c9b64..fc7830fa6 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap
@@ -15,11 +15,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpUeasps/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp1eKvXS/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
+πŸ”„ Removing worktree...
----- stderr -----
❌ Working tree has uncommitted changes
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap b/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap
index 81eb4cf86..01780bdca 100644
Binary files a/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap and b/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap differ
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap b/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
index 86fbcc8e6..1eebb8f7c 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap
@@ -16,11 +16,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpOe0qpE/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpag8zin/test-config.toml
---
success: false
exit_code: 1
----- stdout -----
+πŸ”„ Removing worktree for nonexistent...
----- stderr -----
❌ No worktree found for branch nonexistent
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap b/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
index c373ea694..05b8be4a9 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap
@@ -15,11 +15,12 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpzNBMTY/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmkWgHe/test-config.toml
---
success: true
exit_code: 0
----- stdout -----
+πŸ”„ Removing worktree...
βœ… Switched to default branch main
----- stderr -----