Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
feat: Add ZSH job control opt and enhance ZSH plugin for improved output
Maximilian Roos0f5a7113b33e
diff --git a/src/commands/list/collect.rs b/src/commands/list/collect.rsindex 297032a91..18664b531 100644--- a/src/commands/list/collect.rs+++ b/src/commands/list/collect.rs@@ -564,8 +564,11 @@ pub fn collect(}).collect();- // Cache last rendered message per row to avoid redundant updates- let mut last_lines: Vec<String> = vec![String::new(); all_items.len()];+ // Cache last rendered (unclamped) message per row to avoid redundant updates.+ // Store the full string so updates that are truncated for narrow terminals+ // (e.g., CI column at the end) still trigger a refresh when the underlying+ // data changes.+ let mut last_rendered_lines: Vec<String> = vec![String::new(); all_items.len()];// Footer progress bar with loading status// Uses determinate bar (no spinner) with {wide_msg} to prevent clearing artifacts@@ -700,9 +703,10 @@ pub fn collect(layout.format_list_item_line(info, current_worktree_path.as_ref());let clamped = clamp(&rendered);- // Only update if content changed- if clamped != last_lines[item_idx] {- last_lines[item_idx] = clamped.clone();+ // Compare using the full (unclamped) line so updates that fall+ // past the clamp boundary still cause a redraw.+ if rendered != last_rendered_lines[item_idx] {+ last_rendered_lines[item_idx] = rendered;pb.set_message(clamped);}}diff --git a/templates/posix_directives.sh b/templates/posix_directives.shindex f2f754270..2662671b2 100644--- a/templates/posix_directives.sh+++ b/templates/posix_directives.sh@@ -7,6 +7,14 @@# Note: Uses ${_WORKTRUNK_CMD:-{{ cmd_prefix }}} fallback because shell snapshot# systems may capture functions but not environment variables.wt_exec() {+ # Disable job control notifications in zsh (prevents "[1] 12345" / "[1] + done" messages)+ # Zsh prints these when background jobs start/complete in interactive shells+ # Note: Bash also prints these, but `set +m` doesn't work within functions to suppress them+ # Bash notifications are less intrusive (completion message only at next prompt vs inline)+ if [[ -n "${ZSH_VERSION:-}" ]]; then+ setopt LOCAL_OPTIONS NO_MONITOR+ fi+local exec_cmd="" chunk="" exit_code=0 tmp_dir="" fifo_path="" runner_pid=""# Create temp directory with FIFO for streaming outputdiff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex ed3f302f1..7a01daa43 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -308,6 +308,9 @@ fn exec_in_pty_interactive(cmd.env("SHELL", shell);// For zsh, isolate from user rc files+ // Note: We no longer pass NO_MONITOR here - job control notifications are now+ // suppressed by the shell integration code itself (setopt LOCAL_OPTIONS NO_MONITOR+ // in wt_exec). This ensures tests match real user experience.if shell == "zsh" {cmd.env("ZDOTDIR", "/dev/null");cmd.arg("--no-rcs");@@ -315,8 +318,6 @@ fn exec_in_pty_interactive(cmd.arg("NO_GLOBAL_RCS");cmd.arg("-o");cmd.arg("NO_RCS");- cmd.arg("-o");- cmd.arg("NO_MONITOR");}cmd.arg("-c");diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snapindex 617293aa1..7a998bd94 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap@@ -3,13 +3,13 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---y+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m1[0m[33m command:[0mπ post-create:[40m [0m [1m[34mecho[0m [32m'test command'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-π [36mRunning post-create:[0m[40m [0m [1m[34mecho[0m [32m'test command'[0m[0m[0mtest commanddiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snapindex f07215dd7..8aca362b5 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap@@ -3,13 +3,13 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---n+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m1[0m[33m command:[0mπ post-create:[40m [0m [1m[34mecho[0m [32m'test command'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-βͺ Commands declined, continuing worktree creationβ [32mCreated new worktree for [1m[32mtest-decline[0m[32m from [1m[32mmain[0m[32m at [1m[32m[REPO]/test-repo.test-decline[0m[0mπ‘ [2mTo enable automatic cd, run: wt config shell[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snapindex 9e794fde2..9be8f95a0 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap@@ -3,6 +3,7 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---y+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m2[0m[33m commands:[0mπ post-create:@@ -12,7 +13,6 @@ y[40m [0m [1m[34mecho[0m [32m'Third command'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-π [36mRunning post-create:[0m[40m [0m [1m[34mecho[0m [32m'First command'[0m[0m[0mFirst commanddiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snapindex 1306251b5..3f4b7eaf4 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap@@ -3,6 +3,7 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---n+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m2[0m[33m commands:[0mπ post-create:@@ -12,7 +13,6 @@ n[40m [0m [1m[34mecho[0m [32m'Third command'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-βͺ Commands declined, continuing worktree creationβ [32mCreated new worktree for [1m[32mtest-mixed-decline[0m[32m from [1m[32mmain[0m[32m at [1m[32m[REPO]/test-repo.test-mixed-decline[0m[0mπ‘ [2mTo enable automatic cd, run: wt config shell[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snapindex 8a8154193..ad9c09961 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap@@ -3,6 +3,7 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---y+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m3[0m[33m commands:[0mπ post-create:@@ -15,7 +16,6 @@ y[40m [0m [1m[34mecho[0m [32m'Third command'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-π [36mRunning post-create:[0m[40m [0m [1m[34mecho[0m [32m'First command'[0m[0m[0mFirst commanddiff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snapindex ab262fbfa..fcf7362ca 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap@@ -3,6 +3,7 @@ source: tests/integration_tests/approval_pty.rsexpression: normalized---y+π‘ [33m[1m[33mtest-repo[0m[33m needs approval to execute [1m[33m3[0m[33m commands:[0mπ post-create [1minstall[0m:@@ -15,7 +16,6 @@ y[40m [0m [1m[34mecho[0m [32m'Running tests...'[0m[0mπ‘ Allow and remember? [1m[y/N][0m-π [36mRunning post-create [1minstall[0m:[0m[40m [0m [1m[34mecho[0m [32m'Installing dependencies...'[0m[0m[0mInstalling dependencies...diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snapindex b89d196e3..6a7290171 100644--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpnii422/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpBHTXJE/test-config.toml---success: trueexit_code: 0@@ -38,6 +38,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then# Note: Uses ${_WORKTRUNK_CMD:-wt} fallback because shell snapshot# systems may capture functions but not environment variables.wt_exec() {+ # Disable job control notifications in zsh (prevents "[1] 12345" / "[1] + done" messages)+ # Zsh prints these when background jobs start/complete in interactive shells+ # Note: Bash also prints these, but `set +m` doesn't work within functions to suppress them+ # Bash notifications are less intrusive (completion message only at next prompt vs inline)+ if [[ -n "${ZSH_VERSION:-}" ]]; then+ setopt LOCAL_OPTIONS NO_MONITOR+ fi+local exec_cmd="" chunk="" exit_code=0 tmp_dir="" fifo_path="" runner_pid=""# Create temp directory with FIFO for streaming outputdiff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snapindex a7943d925..db0f2a888 100644--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap@@ -16,7 +16,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcZNo1a/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpCB5xzm/test-config.toml---success: trueexit_code: 0@@ -38,6 +38,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then# Note: Uses ${_WORKTRUNK_CMD:-wt} fallback because shell snapshot# systems may capture functions but not environment variables.wt_exec() {+ # Disable job control notifications in zsh (prevents "[1] 12345" / "[1] + done" messages)+ # Zsh prints these when background jobs start/complete in interactive shells+ # Note: Bash also prints these, but `set +m` doesn't work within functions to suppress them+ # Bash notifications are less intrusive (completion message only at next prompt vs inline)+ if [[ -n "${ZSH_VERSION:-}" ]]; then+ setopt LOCAL_OPTIONS NO_MONITOR+ fi+local exec_cmd="" chunk="" exit_code=0 tmp_dir="" fifo_path="" runner_pid=""# Create temp directory with FIFO for streaming outputdiff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snapindex ddf84ea30..bdf78f5e1 100644--- a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap+++ b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap@@ -12,11 +12,10 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: /dev/nullGIT_CONFIG_SYSTEM: /dev/null- GIT_EDITOR: ""LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /tmp/.tmpYJPBXb/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpuWtNMC/test-config.toml---success: falseexit_code: 1@@ -29,7 +28,8 @@ exit_code: 1[40m [0m hint: "git add/rm <conflicted_files>", then run "git rebase --continue".[40m [0m hint: You can instead skip this commit: run "git rebase --skip".[40m [0m hint: To abort and get back to the state before "git rebase", run "git rebase --abort".-[40m [0m Could not apply [SHA]... Update shared.txt in feature+[40m [0m hint: Disable this message with "git config set advice.mergeConflict false"+[40m [0m Could not apply [SHA]... # Update shared.txt in feature----- stderr -----