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.rsindex 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 namediff --git a/src/output/handlers.rs b/src/output/handlers.rsindex 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>) -> Resuchanged_directory,} = result{- use worktrunk::styling::CYAN;-// 1. Emit cd directive if needed - shell will execute this immediatelyif *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.rsindex 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: trueexit_code: 0----- stdout -----+ π [36mRemoving worktree...[0mβ [32mAlready on default branch [1m[32mmain[0m[0m----- 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.snapindex 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: CLC_ALL: CSOURCE_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: trueexit_code: 0----- stdout -----+π [36mRemoving worktree...[0mβ [32mAlready on default branch [1m[32mmain[0m[0m----- 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.snapindex 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: CLC_ALL: CSOURCE_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: falseexit_code: 1----- stdout -----+π [36mRemoving worktree for [1m[36mfeature-dirty[0m...[0m----- stderr -----β [31mWorking tree has uncommitted changes[0mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snap b/tests/snapshots/integration__integration_tests__remove__remove_dirty_working_tree.snapindex 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: CLC_ALL: CSOURCE_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: falseexit_code: 1----- stdout -----+π [36mRemoving worktree...[0m----- stderr -----β [31mWorking tree has uncommitted changes[0mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap b/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snapindex 81eb4cf86..01780bdca 100644Binary files a/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap and b/tests/snapshots/integration__integration_tests__remove__remove_internal_mode.snap differdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snap b/tests/snapshots/integration__integration_tests__remove__remove_nonexistent_worktree.snapindex 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: CLC_ALL: CSOURCE_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: falseexit_code: 1----- stdout -----+π [36mRemoving worktree for [1m[36mnonexistent[0m...[0m----- stderr -----β [31mNo worktree found for branch [1m[31mnonexistent[0m[0mdiff --git a/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snap b/tests/snapshots/integration__integration_tests__remove__remove_switch_to_default.snapindex 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: CLC_ALL: CSOURCE_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: trueexit_code: 0----- stdout -----+π [36mRemoving worktree...[0mβ [32mSwitched to default branch [1m[32mmain[0m[0m----- stderr -----