Skip to content

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.rs
index 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.sh
index 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 output
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
index 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.snap
index 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.rs
expression: normalized
---
y
+
🟑 test-repo needs approval to execute 1 command:
πŸ”„ post-create:
  echo 'test command'
πŸ’‘ Allow and remember? [y/N]
-
πŸ”„ Running post-create:
  echo 'test command'
test command
diff --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.snap
index 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.rs
expression: normalized
---
n
+
🟑 test-repo needs approval to execute 1 command:
πŸ”„ post-create:
  echo 'test command'
πŸ’‘ Allow and remember? [y/N]
-
βšͺ Commands declined, continuing worktree creation
βœ… Created new worktree for test-decline from main at [REPO]/test-repo.test-decline
πŸ’‘ To enable automatic cd, run: wt config shell
diff --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.snap
index 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.rs
expression: normalized
---
y
+
🟑 test-repo needs approval to execute 2 commands:
πŸ”„ post-create:
@@ -12,7 +13,6 @@ y
  echo 'Third command'
πŸ’‘ Allow and remember? [y/N]
-
πŸ”„ Running post-create:
  echo 'First command'
First command
diff --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.snap
index 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.rs
expression: normalized
---
n
+
🟑 test-repo needs approval to execute 2 commands:
πŸ”„ post-create:
@@ -12,7 +13,6 @@ n
  echo 'Third command'
πŸ’‘ Allow and remember? [y/N]
-
βšͺ Commands declined, continuing worktree creation
βœ… Created new worktree for test-mixed-decline from main at [REPO]/test-repo.test-mixed-decline
πŸ’‘ To enable automatic cd, run: wt config shell
diff --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.snap
index 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.rs
expression: normalized
---
y
+
🟑 test-repo needs approval to execute 3 commands:
πŸ”„ post-create:
@@ -15,7 +16,6 @@ y
  echo 'Third command'
πŸ’‘ Allow and remember? [y/N]
-
πŸ”„ Running post-create:
  echo 'First command'
First command
diff --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.snap
index 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.rs
expression: normalized
---
y
+
🟑 test-repo needs approval to execute 3 commands:
πŸ”„ post-create install:
@@ -15,7 +16,6 @@ y
  echo 'Running tests...'
πŸ’‘ Allow and remember? [y/N]
-
πŸ”„ Running post-create install:
  echo 'Installing dependencies...'
Installing dependencies...
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 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: C
LC_ALL: C
SOURCE_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: true
exit_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 output
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 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: C
LC_ALL: C
SOURCE_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: true
exit_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 output
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
index 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/null
GIT_CONFIG_SYSTEM: /dev/null
- GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /tmp/.tmpYJPBXb/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpuWtNMC/test-config.toml
---
success: false
exit_code: 1
@@ -29,7 +28,8 @@ exit_code: 1
  hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
  hint: You can instead skip this commit: run "git rebase --skip".
  hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
-  Could not apply [SHA]... Update shared.txt in feature
+  hint: Disable this message with "git config set advice.mergeConflict false"
+  Could not apply [SHA]... # Update shared.txt in feature
----- stderr -----