Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: disable clap text wrapping to preserve markdown tables (#436)
Maximilian Roos87ba49a907bd
diff --git a/src/cli.rs b/src/cli.rsindex 86c862ea4..5be5a8df3 100644--- a/src/cli.rs+++ b/src/cli.rs@@ -134,6 +134,9 @@ pub enum OutputFormat {#[command(disable_help_subcommand = true)]#[command(styles = help_styles())]#[command(arg_required_else_help = true)]+// Disable clap's text wrapping - we handle wrapping in the markdown renderer.+// This prevents clap from breaking markdown tables by wrapping their rows.+#[command(term_width = 0)]#[command(after_long_help = "\Getting starteddiff --git a/src/main.rs b/src/main.rsindex c567681d3..d6bbd0d92 100644--- a/src/main.rs+++ b/src/main.rs@@ -214,12 +214,13 @@ fn maybe_handle_help_with_pager() -> bool {ErrorKind::DisplayHelp | ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand => {// err.render() returns a StyledStr containing ANSI codes.// Use .ansi() to preserve them; .to_string() strips ANSI codes.- let mut help = err.render().ansi().to_string();+ let clap_output = err.render().ansi().to_string();- // Render markdown sections to ANSI, wrapping prose to terminal width- // (tables stay unwrapped to preserve column alignment)+ // Render markdown sections (tables, code blocks, prose) with proper wrapping.+ // Since we disabled clap's wrapping above, our renderer controls all line breaks.let width = worktrunk::styling::get_terminal_width();- help = md_help::render_markdown_in_help_with_width(&help, Some(width));+ let help =+ md_help::render_markdown_in_help_with_width(&clap_output, Some(width));// show_help_in_pager checks if stdout or stderr is a TTY.// If neither is a TTY (e.g., `wt --help &>file`), it skips the pager.diff --git a/src/md_help.rs b/src/md_help.rsindex 3f4760343..ce8ce536d 100644--- a/src/md_help.rs+++ b/src/md_help.rs@@ -105,6 +105,7 @@ pub fn render_markdown_in_help_with_width(help: &str, width: Option<usize>) -> S// Prose text - wrap if width is specifiedlet formatted = render_inline_formatting(line);if let Some(w) = width {+ // wrap_styled_text preserves leading indentation on continuation linesfor wrapped_line in wrap_styled_text(&formatted, w) {result.push_str(&wrapped_line);result.push('\n');@@ -711,4 +712,34 @@ mod tests {// Should NOT have separator lineassert!(!result.contains('─'));}++ #[test]+ fn test_render_markdown_in_help_table_wrapping() {+ // Test the full render_markdown_in_help_with_width function+ // which is what actually runs on the help text+ let help = r#"### Other environment variables++| Variable | Purpose |+|----------|---------|+| `WORKTRUNK_BIN` | Override binary path for shell wrappers (useful for testing dev builds) |+| WORKTRUNK_CONFIG_PATH | Override user config file location |+| `WORKTRUNK_MAX_CONCURRENT_COMMANDS` | Max parallel git commands (default: 32). Lower if hitting resource limits. |+| NO_COLOR | Disable colored output (standard) |+"#;+ let rendered = render_markdown_in_help_with_width(help, Some(80));++ // Check for pipe characters+ for line in rendered.lines() {+ assert!(+ !line.trim_start().starts_with("| "),+ "Line should not start with '| ': {:?}",+ line+ );+ assert!(+ !line.trim_end().ends_with(" |"),+ "Line should not end with ' |': {:?}",+ line+ );+ }+ }}diff --git a/src/styling/format.rs b/src/styling/format.rsindex 6aa90d972..d5f19b413 100644--- a/src/styling/format.rs+++ b/src/styling/format.rs@@ -146,18 +146,37 @@ pub fn format_with_gutter(content: &str, max_width: Option<usize>) -> String {/// IMPORTANT: wrap_ansi only restores foreground colors on continuation lines,/// not text attributes like dim. We detect this and prepend dim (\x1b[2m) to/// continuation lines that start with a color code, ensuring consistent dimming.+///+/// Leading indentation is preserved: if the input starts with spaces, continuation+/// lines will have the same indentation (wrapping happens within the remaining width).pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {if max_width == 0 {return vec![styled.to_string()];}+ // Detect leading indentation (spaces before any content or ANSI codes)+ let leading_spaces = styled.chars().take_while(|c| *c == ' ').count();+ let indent = " ".repeat(leading_spaces);+ let content = &styled[leading_spaces..];++ // Handle whitespace-only or empty content+ if content.is_empty() {+ return vec![styled.to_string()];+ }++ // Calculate width for content (excluding indent)+ let content_width = max_width.saturating_sub(leading_spaces);+ if content_width < 10 {+ // Width too narrow for meaningful wrapping+ return vec![styled.to_string()];+ }++ // wrap_ansi returns a string with '\n' at wrap points, preserving ANSI styles// Preserve leading whitespace (wrap_ansi's default trims it)let options = wrap_ansi::WrapOptions::builder().trim_whitespace(false).build();-- // wrap_ansi returns a string with '\n' at wrap points, preserving ANSI styles- let wrapped = wrap_ansi::wrap_ansi(styled, max_width, Some(options));+ let wrapped = wrap_ansi::wrap_ansi(content, content_width, Some(options));if wrapped.is_empty() {return vec![String::new()];@@ -189,12 +208,14 @@ pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {// We restore dim for lines that start with a color code. This is safe// because format_bash_with_gutter_impl always starts lines with dim,// so any wrapped continuation should also be dimmed.- if i > 0 && trimmed.starts_with("\x1b[3") {- // Prepend dim before the color code- result.push(format!("\x1b[2m{trimmed}"));+ let with_dim = if i > 0 && trimmed.starts_with("\x1b[3") {+ format!("\x1b[2m{trimmed}")} else {- result.push(trimmed.to_owned());- }+ trimmed.to_owned()+ };++ // Add the original indentation to all lines+ result.push(format!("{indent}{with_dim}"));}result@@ -425,6 +446,24 @@ mod tests {assert_eq!(result, vec![" "]);}+ #[test]+ fn test_wrap_styled_text_preserves_indent_on_wrap() {+ // Force wrapping by using a narrow width - text should wrap and preserve indent+ let result = wrap_styled_text(+ " This is a longer text that should wrap across multiple lines",+ 40,+ );+ assert!(result.len() > 1, "Should have wrapped");+ // All lines should have the 10-space indent+ for line in &result {+ assert!(+ line.starts_with(" "),+ "Line should start with 10 spaces: {:?}",+ line+ );+ }+ }+#[test]fn test_format_with_gutter_basic() {let result = format_with_gutter("hello", Some(80));diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snapindex ac8631caf..f57acb25f 100644--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap@@ -146,7 +146,7 @@ When project hooks run for the first time, Worktrunk prompts for approval. Appro[2m[projects."my-project"][2mapproved-commands = ["npm ci", "npm test"]-Manage approvals with [2mwt hook approvals add[0m to review and pre-approve commands, and [2mwt hook approvals clear[0m to reset (add [2m--global[0m to clear all+Manage approvals with [2mwt hook approvals add[0m to review and pre-approve commands, and [2mwt hook approvals clear[0m to reset (add [2m--global[0m to clear allprojects).[1mUser hooks@@ -185,7 +185,7 @@ The [2m[list][0m section adds a URL column to [2mwt list[0m:[2m[list][2murl = "http://localhost:{{ branch | hash_port }}"-URLs are dimmed when the port isn't listening. The template supports [2m{{ branch }}[0m with filters [2mhash_port[0m (port 10000-19999) and [2msanitize+URLs are dimmed when the port isn't listening. The template supports [2m{{ branch }}[0m with filters [2mhash_port[0m (port 10000-19999) and [2msanitize[0m(filesystem-safe).[32mShell integration@@ -213,8 +213,7 @@ All user config options can be overridden with environment variables using the[1mNaming convention-Config keys use kebab-case ([2mworktree-path[0m), while env vars use SCREAMING_SNAKE_CASE ([2mWORKTRUNK_WORKTREE_PATH[0m). The conversion happens-automatically.+Config keys use kebab-case ([2mworktree-path[0m), while env vars use SCREAMING_SNAKE_CASE ([2mWORKTRUNK_WORKTREE_PATH[0m). The conversion happens automatically.For nested config sections, use double underscores to separate levels:diff --git a/tests/snapshots/integration__integration_tests__help__help_list_long.snap b/tests/snapshots/integration__integration_tests__help__help_list_long.snapindex 3bba67680..9e4de8d05 100644--- a/tests/snapshots/integration__integration_tests__help__help_list_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_list_long.snap@@ -11,6 +11,7 @@ info:GIT_EDITOR: ""RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ TERM: alacrittyWORKTRUNK_CONFIG_PATH: /nonexistent/test/config.tomlWORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"---@@ -62,9 +63,8 @@ Usage: [1m[36mwt list[0m [36m[OPTIONS]Show all worktrees with their status. The table includes uncommitted changes, divergence from the default branch and remote, and optional CI status.-The table renders progressively: branch names, paths, and commit hashes appear immediately, then status, divergence, and other columns fill in as-background git operations complete. With [2m--full[0m, CI status fetches from the network — the table displays instantly and CI fills in as results-arrive.+The table renders progressively: branch names, paths, and commit hashes appear immediately, then status, divergence, and other columns fill in as+background git operations complete. With [2m--full[0m, CI status fetches from the network — the table displays instantly and CI fills in as results arrive.[32mExamples@@ -117,8 +117,8 @@ The CI column shows GitHub/GitLab pipeline status:⚠ yellow Fetch error (rate limit, network)(blank) No upstream or no PR/MR-CI indicators are clickable links to the PR or pipeline page. Any CI dot appears dimmed when there are unpushed local changes (stale status). PRs/MRs-are checked first, then branch workflows/pipelines for branches with an upstream. Local-only branches show blank. Results are cached for 30-60+CI indicators are clickable links to the PR or pipeline page. Any CI dot appears dimmed when there are unpushed local changes (stale status). PRs/MRs+are checked first, then branch workflows/pipelines for branches with an upstream. Local-only branches show blank. Results are cached for 30-60seconds; use [2mwt config state[0m to view or clear.[32mStatus symbolsdiff --git a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snapindex 7b7090b9b..e9d558772 100644--- a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap+++ b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap@@ -11,6 +11,7 @@ info:GIT_EDITOR: ""RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ TERM: alacrittyWORKTRUNK_CONFIG_PATH: /nonexistent/test/config.tomlWORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"---@@ -46,7 +47,7 @@ Usage: [1m[36mwt list[0m [36m[OPTIONS]Show fast info immediately, update with slow infoDisplays local data (branches, paths, status) first, then updates with- remote data (CI, upstream) as it arrives. Auto-enabled for TTY.+ remote data (CI, upstream) as it arrives. Auto-enabled for TTY.[1m[36m-h[0m, [1m[36m--helpPrint help (see a summary with '-h')@@ -61,12 +62,12 @@ Usage: [1m[36mwt list[0m [36m[OPTIONS][1m[36m-v[0m, [1m[36m--verboseShow commands and debug info-Show all worktrees with their status. The table includes uncommitted changes,+Show all worktrees with their status. The table includes uncommitted changes,divergence from the default branch and remote, and optional CI status.-The table renders progressively: branch names, paths, and commit hashes appear-immediately, then status, divergence, and other columns fill in as background-git operations complete. With [2m--full[0m, CI status fetches from the network — the+The table renders progressively: branch names, paths, and commit hashes appear+immediately, then status, divergence, and other columns fill in as background+git operations complete. With [2m--full[0m, CI status fetches from the network — thetable displays instantly and CI fills in as results arrive.[32mExamples@@ -104,8 +105,8 @@ Output as JSON for scripting:Age Time since last commitMessage Last commit message (truncated)-Note: [2mmain↕[0m and [2mmain…±[0m refer to the default branch (header label stays-[2mmain[0m for compactness). [2mmain…±[0m uses a merge-base (three-dot) diff.+Note: [2mmain↕[0m and [2mmain…±[0m refer to the default branch (header label stays [2mmain[0m for+compactness). [2mmain…±[0m uses a merge-base (three-dot) diff.[1mCI status@@ -122,14 +123,14 @@ The CI column shows GitHub/GitLab pipeline status:(blank) No upstream or no PR/MRCI indicators are clickable links to the PR or pipeline page. Any CI dot appears-dimmed when there are unpushed local changes (stale status). PRs/MRs are checked-first, then branch workflows/pipelines for branches with an upstream. Local-only-branches show blank. Results are cached for 30-60 seconds; use [2mwt config state-to view or clear.+ dimmed when there are unpushed local changes (stale status). PRs/MRs are+checked first, then branch workflows/pipelines for branches with an upstream.+Local-only branches show blank. Results are cached for 30-60 seconds; use [2mwt+[2mconfig state[0m to view or clear.[32mStatus symbols-The Status column has multiple subcolumns. Within each, only the first matching+The Status column has multiple subcolumns. Within each, only the first matchingsymbol is shown (listed in priority order):Subcolumn Symbol Meaning@@ -146,22 +147,22 @@ symbol is shown (listed in priority order):⊟ Prunable (directory missing)⊞ Locked worktreeDefault branch ^ Is the default branch-| | [33m✗[0m | Would conflict if merged to the default branch (with [2m--full[0m,-includes uncommitted changes) |- _ Same commit as the default branch, clean- – Same commit as the default branch, uncommitted changes-| | [2m⊂[0m | Content integrated into the default-branch or target |- ↕ Diverged from the default branch- ↑ Ahead of the default branch- ↓ Behind the default branch- Remote | In sync with remote- ⇅ Diverged from remote- ⇡ Ahead of remote- ⇣ Behind remote--Rows are dimmed when safe to delete ([2m_[0m same-commit with clean working tree or [2m⊂[0m content integrated).+ ✗ Would conflict if merged to the default branch (with+ --full, includes uncommitted changes)+ _ Same commit as the default branch, clean+ – Same commit as the default branch, uncommitted+ changes+ ⊂ Content integrated into the default branch or target+ ↕ Diverged from the default branch+ ↑ Ahead of the default branch+ ↓ Behind the default branch+ Remote | In sync with remote+ ⇅ Diverged from remote+ ⇡ Ahead of remote+ ⇣ Behind remote++Rows are dimmed when safe to delete ([2m_[0m same commit with clean working tree or [2m⊂[0m+content integrated).[32mJSON output@@ -180,8 +181,7 @@ Query structured data with [2m--format=json[0m:[2mwt list --format=json | jq '.[] | select(.main.ahead > 0)'[2m[2m# Integrated branches (ready to clean up)- [2mwt list --format=json | jq '.[] | select(.main_state == "integrated" or- [2m.main_state == "empty")'+ [2mwt list --format=json | jq '.[] | select(.main_state == "integrated" or .main_state == "empty")'[1mFields:@@ -195,23 +195,24 @@ Query structured data with [2m--format=json[0m:working_tree object Working tree state (see below)main_state string Relation to the default branch (see below)integration_reason string Why branch is integrated (see below)-| [2moperation_state[0m | string | [2m"conflicts"[0m, [2m"rebase"[0m, or [2m"merge"[0m (absent-when clean) |-| [2mmain[0m | object | Relationship to the default branch (see below, absent when-is_main) |-| [2mremote[0m | object | Tracking branch info (see below, absent when no tracking)- ─────────── ─────── ────────────────────────────────────────- worktree object Worktree metadata (see below)- is_main boolean Is the main worktree- is_current boolean Is the current worktree- is_previous boolean Previous worktree from wt switch- ci object CI status (see below, absent when no CI)-| [2murl[0m | string | Dev server URL from project config (absent when not-configured) |-| [2murl_active[0m | boolean | Whether the URL's port is listening (absent when not-configured) |- statusline string Pre-formatted status with ANSI colors- symbols string Raw status symbols without colors (e.g., "!?↓")+ operation_state string "conflicts", "rebase", or "merge" (absent+ when clean)+ main object Relationship to the default branch (see+ below, absent when is_main)+ remote object Tracking branch info (see below, absent when+ no tracking)+ worktree object Worktree metadata (see below)+ is_main boolean Is the main worktree+ is_current boolean Is the current worktree+ is_previous boolean Previous worktree from wt switch+ ci object CI status (see below, absent when no CI)+ url string Dev server URL from project config (absent+ when not configured)+ url_active boolean Whether the URL's port is listening (absent+ when not configured)+ statusline string Pre-formatted status with ANSI colors+ symbols string Raw status symbols without colors (e.g.,+ "!?↓")[1mcommit object@@ -224,16 +225,15 @@ configured) |[1mworking_tree object- Field Type Description- ───────── ─────── ───────────────────────────────────────- staged boolean Has staged files- modified boolean Has modified files (unstaged)- untracked boolean Has untracked files- renamed boolean Has renamed files- deleted boolean Has deleted files- diff object Lines changed vs HEAD: {added, deleted}-| [2mdiff_vs_main[0m | object | Lines changed vs the default branch: [2m{added,-deleted}[2m |+ Field Type Description+ ──────────── ─────── ─────────────────────────────────────────────────────+ staged boolean Has staged files+ modified boolean Has modified files (unstaged)+ untracked boolean Has untracked files+ renamed boolean Has renamed files+ deleted boolean Has deleted files+ diff object Lines changed vs HEAD: {added, deleted}+ diff_vs_main object Lines changed vs the default branch: {added, deleted}[1mmain object@@ -254,12 +254,12 @@ deleted}[2m |[1mworktree object- Field Type Description- ───── ──── ───────────-| [2mstate[0m | string | [2m"branch_worktree_mismatch"[0m, [2m"prunable"[0m, [2m"locked"-(absent when normal) |- reason string Reason for locked/prunable state- detached boolean HEAD is detached+ Field Type Description+ ──────── ─────── ───────────────────────────────────────────────────────────+ state string "branch_worktree_mismatch", "prunable", "locked" (absent+ when normal)+ reason string Reason for locked/prunable state+ detached boolean HEAD is detached[1mci object@@ -274,19 +274,19 @@ deleted}[2m |These values describe relation to the default branch.-[2m"is_main"[0m [2m"would_conflict"[0m [2m"empty"[0m [2m"same_commit"[0m [2m"integrated"-[2m"diverged"[0m [2m"ahead"[0m [2m"behind"+[2m"is_main"[0m [2m"would_conflict"[0m [2m"empty"[0m [2m"same_commit"[0m [2m"integrated"[0m [2m"diverged"[0m [2m"ahead"+ [2m"behind"[1mintegration_reason values-When [2mmain_state == "integrated"[0m: [2m"ancestor"[0m [2m"trees_match"-[2m"no_added_changes"[0m [2m"merge_adds_nothing"+When [2mmain_state == "integrated"[0m: [2m"ancestor"[0m [2m"trees_match"[0m [2m"no_added_changes"[0m+[2m"merge_adds_nothing"[1mci.status values[2m"passed"[0m [2m"running"[0m [2m"failed"[0m [2m"conflicts"[0m [2m"no-ci"[0m [2m"error"-Missing a field that would be generally useful? Open an issue at+Missing a field that would be generally useful? Open an issue athttps://github.com/max-sixty/worktrunk.[32mSee alsodiff --git a/tests/snapshots/integration__integration_tests__help__help_md_merge.snap b/tests/snapshots/integration__integration_tests__help__help_md_merge.snapindex f87f6a40e..56901e0cf 100644--- a/tests/snapshots/integration__integration_tests__help__help_md_merge.snap+++ b/tests/snapshots/integration__integration_tests__help__help_md_merge.snap@@ -109,30 +109,23 @@ wt merge --no-commit`wt merge` runs these steps:-1. **Squash** — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use `--stage` to-control what gets staged: `all` (default), `tracked`, or `none`. A backup ref is saved to `refs/wt-backup/<branch>`. With `--no-squash`, uncommitted-changes become a separate commit and individual commits are preserved.+1. **Squash** — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use `--stage` to control what gets staged: `all` (default), `tracked`, or `none`. A backup ref is saved to `refs/wt-backup/<branch>`. With `--no-squash`, uncommitted changes become a separate commit and individual commits are preserved.2. **Rebase** — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.3. **Pre-merge hooks** — Hooks run after rebase, before merge. Failures abort. See [wt hook](@/hook.md).4. **Merge** — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.5. **Pre-remove hooks** — Hooks run before removing worktree. Failures abort.-6. **Cleanup** — Removes the worktree and branch. Use `--no-remove` to keep the worktree. When already on the target branch or in the main worktree,-the worktree is preserved.+6. **Cleanup** — Removes the worktree and branch. Use `--no-remove` to keep the worktree. When already on the target branch or in the main worktree, the worktree is preserved.7. **Post-merge hooks** — Hooks run after cleanup. Failures are logged but don't abort.-Use `--no-commit` to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless `--no-rebase` is-passed. Useful after preparing commits manually with `wt step`. Requires a clean working tree.+Use `--no-commit` to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless `--no-rebase` is passed. Useful after preparing commits manually with `wt step`. Requires a clean working tree.## Local CI-For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes-instead of fewer large ones.+For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes instead of fewer large ones.-Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it-guaranteed validation happened. `wt merge` brings that guarantee local.+Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it guaranteed validation happened. `wt merge` brings that guarantee local.-The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run `wt merge`, move on. Pre-merge-hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.+The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run `wt merge`, move on. Pre-merge hooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.```toml[pre-merge]diff --git a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap b/tests/snapshots/integration__integration_tests__help__help_merge_long.snapindex 69e9cb5eb..85d7037cf 100644--- a/tests/snapshots/integration__integration_tests__help__help_merge_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_merge_long.snap@@ -100,29 +100,29 @@ Skip committing/squashing (rebase still runs unless --no-rebase):[2mwt merge[0m runs these steps:-1. [1mSquash[0m — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use [2m--stage[0m to-control what gets staged: [2mall[0m (default), [2mtracked[0m, or [2mnone[0m. A backup ref is saved to [2mrefs/wt-backup/<branch>[0m. With [2m--no-squash[0m, uncommitted-changes become a separate commit and individual commits are preserved.+1. [1mSquash[0m — Stages uncommitted changes, then combines all commits since target into one (like GitHub's "Squash and merge"). Use [2m--stage[0m to control+what gets staged: [2mall[0m (default), [2mtracked[0m, or [2mnone[0m. A backup ref is saved to [2mrefs/wt-backup/<branch>[0m. With [2m--no-squash[0m, uncommitted changes become a+separate commit and individual commits are preserved.2. [1mRebase[0m — Rebases onto target if behind. Skipped if already up-to-date. Conflicts abort immediately.3. [1mPre-merge hooks[0m — Hooks run after rebase, before merge. Failures abort. See wt hook.4. [1mMerge[0m — Fast-forward merge to the target branch. Non-fast-forward merges are rejected.5. [1mPre-remove hooks[0m — Hooks run before removing worktree. Failures abort.-6. [1mCleanup[0m — Removes the worktree and branch. Use [2m--no-remove[0m to keep the worktree. When already on the target branch or in the main worktree,-the worktree is preserved.+6. [1mCleanup[0m — Removes the worktree and branch. Use [2m--no-remove[0m to keep the worktree. When already on the target branch or in the main worktree, the+worktree is preserved.7. [1mPost-merge hooks[0m — Hooks run after cleanup. Failures are logged but don't abort.-Use [2m--no-commit[0m to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless [2m--no-rebase[0m is+Use [2m--no-commit[0m to skip committing uncommitted changes and squashing; rebase still runs by default and can rewrite commits unless [2m--no-rebase[0m ispassed. Useful after preparing commits manually with [2mwt step[0m. Requires a clean working tree.[32mLocal CI-For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changes+For personal projects, pre-merge hooks open up the possibility of a workflow with much faster iteration — an order of magnitude more small changesinstead of fewer large ones.-Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: it+Historically, ensuring tests ran before merging was difficult to enforce locally. Remote CI was valuable for the process as much as the checks: itguaranteed validation happened. [2mwt merge[0m brings that guarantee local.-The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run [2mwt merge[0m, move on. Pre-merge+The full workflow: start an agent (one of many) on a task, work elsewhere, return when it's ready. Review the diff, run [2mwt merge[0m, move on. Pre-mergehooks validate before merging — if they pass, the branch goes to the default branch and the worktree cleans up.[2m[pre-merge]diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snapindex f811bf010..478847051 100644--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap@@ -85,7 +85,7 @@ Force-delete an unmerged branch:[32mBranch cleanup-By default, branches are deleted when merging them would add nothing. This works with squash-merge and rebase workflows where commit history differs+By default, branches are deleted when merging them would add nothing. This works with squash-merge and rebase workflows where commit history differsbut file changes match.Worktrunk checks five conditions (in order of cost):@@ -96,8 +96,8 @@ Worktrunk checks five conditions (in order of cost):4. [1mTrees match[0m — Branch tree SHA equals target tree SHA. Shows [2m⊂[0m.5. [1mMerge adds nothing[0m — Simulated merge produces the same tree as target. Handles squash-merged branches where target has advanced. Shows [2m⊂[0m.-The "same commit" check uses the local default branch; for other checks, [1mtarget[0m means the default branch, or its upstream (e.g., [2morigin/main[0m)-when strictly ahead.+The "same commit" check uses the local default branch; for other checks, [1mtarget[0m means the default branch, or its upstream (e.g., [2morigin/main[0m) when+strictly ahead.Branches showing [2m_[0m or [2m⊂[0m are dimmed as safe to delete.@@ -105,8 +105,8 @@ Use [2m-D[0m to force-delete branches with unmerged changes. Use [2m--no-dele[32mBackground removal-Removal runs in the background by default (returns immediately). Logs are written to [2m.git/wt-logs/{branch}-remove.log[0m. Use [2m--no-background[0m to run-in the foreground.+Removal runs in the background by default (returns immediately). Logs are written to [2m.git/wt-logs/{branch}-remove.log[0m. Use [2m--no-background[0m to run in+the foreground.[32mShortcutsdiff --git a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap b/tests/snapshots/integration__integration_tests__help__help_switch_long.snapindex cddaee85f..327fdd1c6 100644--- a/tests/snapshots/integration__integration_tests__help__help_switch_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_switch_long.snap@@ -11,6 +11,7 @@ info:GIT_EDITOR: ""RUST_LOG: warnSOURCE_DATE_EPOCH: "1735776000"+ TERM: alacrittyWORKTRUNK_CONFIG_PATH: /nonexistent/test/config.tomlWORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"---@@ -47,15 +48,15 @@ Usage: [1m[36mwt switch[0m [36m[OPTIONS][0m [36m<BRANCH>[0m [1m[36m[--Command to run after switchReplaces the wt process with the command after switching, giving it full terminal control. Useful for launching editors, AI agents, or other- interactive tools.+ interactive tools.Especially useful with shell aliases:[1m[1malias wsc='wt switch --create -x claude'[1mwsc feature-branch -- 'Fix GH #322'- [0m- Then [1mwsc feature-branch[0m creates the worktree and launches Claude Code. Arguments after [1m--[0m are passed to the command, so [1mwsc feature -- 'Fix- GH #322'[0m runs [1mclaude 'Fix GH #322'[0m, starting Claude with a prompt.++ Then [1mwsc feature-branch[0m creates the worktree and launches Claude Code. Arguments after [1m--[0m are passed to the command, so [1mwsc feature -- 'Fix+ [1mGH #322'[0m runs [1mclaude 'Fix GH #322'[0m, starting Claude with a prompt.[1m[36m-y[0m, [1m[36m--yesSkip approval prompts@@ -81,7 +82,7 @@ Usage: [1m[36mwt switch[0m [36m[OPTIONS][0m [36m<BRANCH>[0m [1m[36m[--Change directory to a worktree, creating one if needed.-Worktrees are addressed by branch name; paths are computed from a template. Unlike [2mgit switch[0m, this navigates between worktrees rather than changing+Worktrees are addressed by branch name; paths are computed from a template. Unlike [2mgit switch[0m, this navigates between worktrees rather than changingbranches in place.[32mExamples