Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
chore(deps): upgrade tree-sitter to 0.26, add show-theme wrapping examples (#906)
Maximilian Roosee54aa6102c9
diff --git a/Cargo.lock b/Cargo.lockindex 04d76b6cc..2975c582a 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2533,9 +2533,9 @@ checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607"[[package]]name = "tree-sitter"-version = "0.25.10"+version = "0.26.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "78f873475d258561b06f1c595d93308a7ed124d9977cb26b148c2084a4a3cc87"+checksum = "974d205cc395652cfa8b37daa053fe56eebd429acf8dc055503fee648dae981e"dependencies = ["cc","regex",@@ -2557,9 +2557,9 @@ dependencies = [[[package]]name = "tree-sitter-highlight"-version = "0.25.10"+version = "0.26.3"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "adc5f880ad8d8f94e88cb81c3557024cf1a8b75e3b504c50481ed4f5a6006ff3"+checksum = "bb0636662a03005d9289649e0b4a89ff37b75df5033e8d4a16398740ae6496d2"dependencies = ["regex","streaming-iterator",diff --git a/Cargo.toml b/Cargo.tomlindex 36adae8c5..611ae7016 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -92,12 +92,13 @@ synoptic = "2"terminal_size = "0.4"toml = { version = "0.9", features = ["preserve_order"] }toml_edit = { version = "0.24", features = ["serde"] }-# All three crates must use the same version series to avoid native library conflicts+# tree-sitter and tree-sitter-highlight should use matching versions.+# tree-sitter-bash may lag behind (0.25.x works with tree-sitter 0.26.x).# These are optional dependencies controlled by the "syntax-highlighting" feature.# To build without C compilation requirements, use: cargo install worktrunk --no-default-features-tree-sitter = { version = "0.25", optional = true }-tree-sitter-bash = { version = "0.25", optional = true }-tree-sitter-highlight = { version = "0.25", optional = true }+tree-sitter = { version = "0.26", optional = true }+tree-sitter-bash = { version = "0.25.1", optional = true }+tree-sitter-highlight = { version = "0.26", optional = true }unicode-width = "0.2"wrap-ansi = "0.1"osc8 = "0.1.0"diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex a95583f35..24a95ca13 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -1264,11 +1264,13 @@ pub fn handle_show_theme() {eprintln!();- // Gutter - bash code (syntax highlighted)+ // Gutter - bash code (short, long wrapping, multi-line string, multi-line command, and template)eprintln!("{}", info_message("Gutter formatting (shell code):"));eprintln!("{}",- format_bash_with_gutter("eval \"$(wt config shell init bash)\"",)+ format_bash_with_gutter(+ "eval \"$(wt config shell init bash)\"\necho 'This is a long command that will wrap to the next line when the terminal is narrow enough to require wrapping.'\necho 'hello\nworld'\ncargo build --release &&\ncargo test\ncp {{ repo_root }}/target {{ worktree }}/target"+ ));eprintln!();diff --git a/src/styling/format.rs b/src/styling/format.rsindex 046e5aaf4..24db0cef6 100644--- a/src/styling/format.rs+++ b/src/styling/format.rs@@ -225,6 +225,22 @@ pub fn wrap_styled_text(styled: &str, max_width: usize) -> Vec<String> {#[cfg(feature = "syntax-highlighting")]fn format_bash_with_gutter_impl(content: &str, width_override: Option<usize>) -> String {+ // Normalize line endings: CRLF to LF, and trim trailing newlines.+ // Trailing newlines would create spurious blank gutter lines because+ // style restoration after newlines produces `\n[DIM]` which becomes+ // its own line when split.+ let content = content.replace("\r\n", "\n");+ let content = content.trim_end_matches('\n');++ // Replace Jinja template delimiters with quoted string placeholders before parsing.+ // Tree-sitter can't parse `{{` and `}}` (especially when split across lines),+ // so we swap them out and restore after highlighting. Using quoted strings+ // ensures consistent "string" styling regardless of position in the line.+ const TPL_OPEN: &str = "\"WTO\"";+ const TPL_CLOSE: &str = "\"WTC\"";+ let normalized = content.replace("{{", TPL_OPEN).replace("}}", TPL_CLOSE);+ let content = normalized.as_str();+let gutter = super::GUTTER;let reset = anstyle::Reset;let dim = anstyle::Style::new().dimmed();@@ -248,109 +264,81 @@ fn format_bash_with_gutter_impl(content: &str, width_override: Option<usize>) ->let bash_language = tree_sitter_bash::LANGUAGE.into();let bash_highlights = tree_sitter_bash::HIGHLIGHT_QUERY;- let mut config = match HighlightConfiguration::new(+ let mut config = HighlightConfiguration::new(bash_language,- "bash", // language name+ "bash",bash_highlights,"", // injections query"", // locals query- ) {- Ok(config) => config,- Err(_) => {- // Fallback: if tree-sitter fails, use plain gutter formatting- HighlightConfiguration::new(- tree_sitter_bash::LANGUAGE.into(),- "bash", // language name- "", // empty query- "",- "",- )- .unwrap()- }- };-+ )+ .expect("tree-sitter-bash HIGHLIGHT_QUERY should be valid");config.configure(&highlight_names);let mut highlighter = Highlighter::new();-- // Build lines without trailing newline - caller is responsible for element separation- let mut output_lines: Vec<String> = Vec::new();-- // Process each line separately - this is required because tree-sitter's bash- // grammar fails to highlight multi-line commands when `&&` appears at line ends.- // Per-line processing gives proper highlighting for each line's content.- for line in content.lines() {- let mut styled_line = format!("{dim}");-- let Ok(highlights) = highlighter.highlight(&config, line.as_bytes(), None, |_| None) else {- // Fallback: if highlighting fails, use plain dim- styled_line.push_str(line);- for wrapped in wrap_styled_text(&styled_line, available_width) {- output_lines.push(format!("{gutter} {gutter:#} {wrapped}{reset}"));- }- continue;- };-- let line_bytes = line.as_bytes();-- // Track the current highlight type so we can decide styling when we see the actual text- let mut pending_highlight: Option<usize> = None;-- for event in highlights {- match event.unwrap() {- HighlightEvent::Source { start, end } => {- // Output the text for this source region- if let Ok(text) = std::str::from_utf8(&line_bytes[start..end]) {- // Apply pending highlight style, but skip command styling for template syntax- // (tree-sitter misinterprets `}}` at line start as a command)- if let Some(idx) = pending_highlight.take() {- let is_template_syntax =- text.starts_with("}}") || text.starts_with("{{");- let is_function = highlight_names- .get(idx)- .is_some_and(|name| *name == "function");-- // Skip command styling for template syntax, apply normal styling otherwise- if !(is_function && is_template_syntax)- && let Some(name) = highlight_names.get(idx)- && let Some(style) = bash_token_style(name)- {- // Reset before applying style to clear the base dim, then apply token style.- // Token styles use dim+color (not bold) because bold (SGR 1) and dim (SGR 2)- // are mutually exclusive in some terminals like Alacritty.- styled_line.push_str(&format!("{reset}{style}"));- }- }-- styled_line.push_str(text);+ let highlights = highlighter+ .highlight(&config, content.as_bytes(), None, |_| None)+ .expect("highlighting valid UTF-8 should not fail");++ let content_bytes = content.as_bytes();++ // Phase 1: Build styled content with ANSI codes, restoring style after newlines+ let mut styled = format!("{dim}");+ let mut pending_highlight: Option<usize> = None;+ let mut active_style: Option<anstyle::Style> = None;++ for event in highlights {+ match event.unwrap() {+ HighlightEvent::Source { start, end } => {+ if let Ok(text) = std::str::from_utf8(&content_bytes[start..end]) {+ // Apply pending highlight style+ if let Some(idx) = pending_highlight.take()+ && let Some(name) = highlight_names.get(idx)+ && let Some(style) = bash_token_style(name)+ {+ styled.push_str(&format!("{reset}{style}"));+ active_style = Some(style);}- }- HighlightEvent::HighlightStart(idx) => {- // Remember the highlight type - we'll decide on styling when we see the text- pending_highlight = Some(idx.0);- }- HighlightEvent::HighlightEnd => {- // End of highlighted region - reset and restore dim for unhighlighted text- pending_highlight = None;- styled_line.push_str(&format!("{reset}{dim}"));++ // Insert style restore after each newline so lines are self-contained+ let style_restore = match active_style {+ Some(style) => format!("{dim}{reset}{style}"),+ None => format!("{dim}"),+ };+ styled.push_str(&text.replace('\n', &format!("\n{style_restore}")));}}- }-- // Wrap and collect gutter lines- for wrapped in wrap_styled_text(&styled_line, available_width) {- output_lines.push(format!("{gutter} {gutter:#} {wrapped}{reset}"));+ HighlightEvent::HighlightStart(idx) => {+ pending_highlight = Some(idx.0);+ }+ HighlightEvent::HighlightEnd => {+ pending_highlight = None;+ active_style = None;+ styled.push_str(&format!("{reset}{dim}"));+ }}}- output_lines.join("\n")+ // Phase 2: Restore original template delimiters before wrapping.+ // This ensures line width calculations use the actual 2-char `{{`/`}}`+ // instead of the longer placeholders.+ let styled = styled.replace(TPL_OPEN, "{{").replace(TPL_CLOSE, "}}");++ // Phase 3: Split into lines, wrap each, add gutters+ styled+ .lines()+ .flat_map(|line| wrap_styled_text(line, available_width))+ .map(|wrapped| format!("{gutter} {gutter:#} {wrapped}{reset}"))+ .collect::<Vec<_>>()+ .join("\n")}/// Formats bash/shell commands with syntax highlighting and gutter///-/// Processes each line separately for highlighting (required for multi-line commands-/// with `&&` at line ends), then applies template syntax detection to avoid-/// misinterpreting `}}` as a command when it appears at line start.+/// Uses unified highlighting (entire command at once) to preserve context across+/// line breaks. Multi-line strings are correctly highlighted.+///+/// Template syntax (`{{ }}`) is detected to avoid misinterpreting Jinja variables+/// as shell commands.////// # Example/// ```@@ -594,4 +582,117 @@ mod tests {assert!(result.contains("cargo"));assert!(result.contains("--release"));}++ /// Regression test: tree-sitter 0.26 properly highlights multi-line commands.+ ///+ /// With tree-sitter-bash 0.25.1+, unified highlighting (processing the entire+ /// command at once) correctly identifies `&&` as operators even when they appear+ /// at line ends. This enables switching from line-by-line to unified highlighting.+ #[test]+ #[cfg(feature = "syntax-highlighting")]+ fn test_unified_multiline_highlighting() {+ use tree_sitter_highlight::{HighlightConfiguration, HighlightEvent, Highlighter};++ let cmd = "echo 'line1' &&\necho 'line2' &&\necho 'line3'";++ let highlight_names = vec![+ "function", "keyword", "string", "operator", "comment", "number", "variable",+ "constant",+ ];++ let bash_language = tree_sitter_bash::LANGUAGE.into();+ let bash_highlights = tree_sitter_bash::HIGHLIGHT_QUERY;++ let mut config =+ HighlightConfiguration::new(bash_language, "bash", bash_highlights, "", "").unwrap();+ config.configure(&highlight_names);++ let mut highlighter = Highlighter::new();++ // Collect highlight events as tagged text for verification+ let mut output = String::new();+ let highlights = highlighter+ .highlight(&config, cmd.as_bytes(), None, |_| None)+ .unwrap();+ for event in highlights {+ match event.unwrap() {+ HighlightEvent::Source { start, end } => {+ output.push_str(&cmd[start..end]);+ }+ HighlightEvent::HighlightStart(idx) => {+ output.push_str(&format!("[{}:", highlight_names[idx.0]));+ }+ HighlightEvent::HighlightEnd => {+ output.push(']');+ }+ }+ }++ // Unified highlighting should identify && as operators+ assert!(+ output.contains("[operator:&&]"),+ "Should identify && as operator in multi-line command"+ );++ // Should identify echo as function on each line+ assert_eq!(+ output.matches("[function:echo]").count(),+ 3,+ "Should identify all three echo commands"+ );+ }++ /// Regression test: template syntax ({{ }}) doesn't break highlighting.+ ///+ /// Tree-sitter parses around template variables, still identifying commands.+ #[test]+ #[cfg(feature = "syntax-highlighting")]+ fn test_highlighting_with_template_syntax() {+ use tree_sitter_highlight::{HighlightConfiguration, HighlightEvent, Highlighter};++ let cmd = "echo {{ branch }} && mkdir {{ path }}";++ let highlight_names = vec!["function", "keyword", "string", "operator", "constant"];++ let bash_language = tree_sitter_bash::LANGUAGE.into();+ let bash_highlights = tree_sitter_bash::HIGHLIGHT_QUERY;++ let mut config =+ HighlightConfiguration::new(bash_language, "bash", bash_highlights, "", "").unwrap();+ config.configure(&highlight_names);++ let mut highlighter = Highlighter::new();++ let mut output = String::new();+ let highlights = highlighter+ .highlight(&config, cmd.as_bytes(), None, |_| None)+ .unwrap();+ for event in highlights {+ match event.unwrap() {+ HighlightEvent::Source { start, end } => {+ output.push_str(&cmd[start..end]);+ }+ HighlightEvent::HighlightStart(idx) => {+ output.push_str(&format!("[{}:", highlight_names[idx.0]));+ }+ HighlightEvent::HighlightEnd => {+ output.push(']');+ }+ }+ }++ // Commands should still be identified despite template syntax+ assert!(+ output.contains("[function:echo]"),+ "Should identify echo despite template syntax"+ );+ assert!(+ output.contains("[function:mkdir]"),+ "Should identify mkdir despite template syntax"+ );+ assert!(+ output.contains("[operator:&&]"),+ "Should identify && operator"+ );+ }}diff --git a/src/styling/snapshots/worktrunk__styling__tests__format_bash_multiline_command_consistent_styling.snap b/src/styling/snapshots/worktrunk__styling__tests__format_bash_multiline_command_consistent_styling.snapindex 50476007b..84903debc 100644--- a/src/styling/snapshots/worktrunk__styling__tests__format_bash_multiline_command_consistent_styling.snap+++ b/src/styling/snapshots/worktrunk__styling__tests__format_bash_multiline_command_consistent_styling.snap@@ -2,11 +2,11 @@source: src/styling/mod.rsexpression: result----[107m [0m [2m[ -d {{ repo_root }}/target/debug/deps ] && [ ! -e {{ worktree }}/target ] [0m[2m[36m&&[0m[2m[0m[2m[0m-[107m [0m [2m[0m[2m[34mmkdir[0m[2m [0m[2m[36m-p[0m[2m {{ worktree }}/target/debug/deps [0m[2m[36m&&[0m[2m[0m[2m[0m-[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-c[0m[2m {{ repo_root }}/target/debug/deps/*.rlib {{ repo_root [0m-[107m [0m [2m}}/target/debug/deps/*.rmeta {{ worktree[0m-[107m [0m [2m}}/target/debug/deps/[0m[2m [0m[2m[36m&&[0m[2m[0m[2m[0m-[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-cR[0m[2m {{ repo_root }}/target/debug/.fingerprint {{ repo_root [0m-[107m [0m [2m}}/target/debug/build {{ worktree[0m-[107m [0m [2m}}/target/debug/[0m[2m[0m+[107m [0m [2m[ -d [0m[2m[32m{{[0m[2m repo_root [0m[2m[32m}}[0m[2m/target/debug/deps ] [0m[2m[36m&&[0m[2m [ ! -e [0m[2m[32m{{[0m[2m worktree [0m[2m[32m}}[0m[2m/target ] [0m[2m[36m&&[0m[2m[0m+[107m [0m [2m[0m[2m[34mmkdir[0m[2m [0m[2m[36m-p[0m[2m [0m[2m[32m{{[0m[2m worktree [0m[2m[32m}}[0m[2m/target/debug/deps [0m[2m[36m&&[0m[2m[0m+[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-c[0m[2m [0m[2m[32m{{[0m[2m repo_root [0m[2m[32m}}[0m[2m/target/debug/deps/*.rlib [0m[2m[32m{{[0m[2m repo_root [0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/target/debug/deps/*.rmeta [0m[2m[32m{{[0m[2m worktree[0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/target/debug/deps/[0m[2m [0m[2m[36m&&[0m[2m[0m+[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-cR[0m[2m [0m[2m[32m{{[0m[2m repo_root [0m[2m[32m}}[0m[2m/target/debug/.fingerprint [0m[2m[32m{{[0m[2m repo_root [0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/target/debug/build [0m[2m[32m{{[0m[2m worktree[0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/target/debug/[0m[2m[0mdiff --git a/src/styling/snapshots/worktrunk__styling__tests__format_bash_with_gutter_template_command.snap b/src/styling/snapshots/worktrunk__styling__tests__format_bash_with_gutter_template_command.snapindex ca678923a..aeb6f9536 100644--- a/src/styling/snapshots/worktrunk__styling__tests__format_bash_with_gutter_template_command.snap+++ b/src/styling/snapshots/worktrunk__styling__tests__format_bash_with_gutter_template_command.snap@@ -2,5 +2,5 @@source: src/styling/mod.rsexpression: result----[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-cR[0m[2m {{ repo_root }}/target/debug/.fingerprint {{ repo_root [0m-[107m [0m [2m}}/target/debug/build {{ worktree }}/target/debug/[0m+[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[36m-cR[0m[2m [0m[2m[32m{{[0m[2m repo_root [0m[2m[32m}}[0m[2m/target/debug/.fingerprint [0m[2m[32m{{[0m[2m repo_root [0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/target/debug/build [0m[2m[32m{{[0m[2m worktree [0m[2m[32m}}[0m[2m/target/debug/[0mdiff --git a/src/styling/snapshots/worktrunk__styling__tests__unhighlighted_text_has_consistent_dim_across_lines.snap b/src/styling/snapshots/worktrunk__styling__tests__unhighlighted_text_has_consistent_dim_across_lines.snapindex e8df30407..253360204 100644--- a/src/styling/snapshots/worktrunk__styling__tests__unhighlighted_text_has_consistent_dim_across_lines.snap+++ b/src/styling/snapshots/worktrunk__styling__tests__unhighlighted_text_has_consistent_dim_across_lines.snap@@ -2,5 +2,5 @@source: src/styling/mod.rsexpression: result----[107m [0m [2m[0m[2m[34mecho[0m[2m {{ worktree[0m-[107m [0m [2m}}/path[0m[2m[0m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m{{[0m[2m worktree[0m+[107m [0m [2m[0m[2m[32m}}[0m[2m/path[0m[2m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__config_show_theme__show_theme.snap b/tests/integration_tests/snapshots/integration__integration_tests__config_show_theme__show_theme.snapindex a368adf03..7c24d1aab 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__config_show_theme__show_theme.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__config_show_theme__show_theme.snap@@ -9,6 +9,7 @@ info:env:CLICOLOR_FORCE: "1"COLUMNS: "500"+ GIT_EDITOR: ""LANG: CLC_ALL: CPSModulePath: ""@@ -43,6 +44,12 @@ exit_code: 0[2m○[22m Gutter formatting (shell code):[107m [0m [2m[0m[2m[34meval[0m[2m [0m[2m[32m"$([0m[2m[34mwt[0m[2m config shell init bash)"[0m[2m[0m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'This is a long command that will wrap to the next line when the terminal is narrow enough to require wrapping.'[0m[2m[0m+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'hello[0m+[107m [0m [2m[0m[2m[32mworld'[0m[2m[0m+[107m [0m [2m[0m[2m[34mcargo[0m[2m build [0m[2m[36m--release[0m[2m [0m[2m[36m&&[0m[2m[0m+[107m [0m [2m[0m[2m[34mcargo[0m[2m test[0m+[107m [0m [2m[0m[2m[34mcp[0m[2m [0m[2m[32m{{[0m[2m repo_root [0m[2m[32m}}[0m[2m/target [0m[2m[32m{{[0m[2m worktree [0m[2m[32m}}[0m[2m/target[0m[2m○[22m Prompt formatting:[36m❯[39m [36mProceed? [y/N][39mdiff --git a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snapindex 6c388280d..6eaebc5eb 100644--- a/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap+++ b/tests/snapshots/integration__integration_tests__approval_ui__approval_multiple_commands.snap@@ -14,6 +14,6 @@ exit_code: 1[2m○[22m post-create [1mrepo[22m:[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'Repo: {{ repo }}'[0m[2m[2m○[22m post-create [1mpwd[22m:-[107m [0m [2m[0m[2m[34mcd[0m[2m {{ worktree_path }} [0m[2m[36m&&[0m[2m [0m[2m[34mpwd[0m[2m+[107m [0m [2m[0m[2m[34mcd[0m[2m [0m[2m[32m{{[0m[2m worktree_path [0m[2m[32m}}[0m[2m [0m[2m[36m&&[0m[2m [0m[2m[34mpwd[0m[2m[31m✗[39m [31mCannot prompt for approval in non-interactive environment[39m[2m↳[22m [2mTo skip prompts in CI/CD, add [90m--yes[39m; to pre-approve commands, run [90mwt hook approvals add[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__configure_shell__configure_shell_fish_dry_run.snap b/tests/snapshots/integration__integration_tests__configure_shell__configure_shell_fish_dry_run.snapindex d6ec1b0f0..7311c0101 100644--- a/tests/snapshots/integration__integration_tests__configure_shell__configure_shell_fish_dry_run.snap+++ b/tests/snapshots/integration__integration_tests__configure_shell__configure_shell_fish_dry_run.snap@@ -16,6 +16,7 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -47,10 +48,10 @@ exit_code: 0[107m [0m [2m# Check: wt config show | Uninstall: wt config shell uninstall[0m[2m[107m [0m [2m[107m [0m [2m[0m[2m[35mfunction[0m[2m wt-[107m [0m [2m [0m[2m[34mcommand[0m[2m wt config shell init fish [0m[2m[36m|[0m[2m [0m[2m[34msource[0m[2m+[107m [0m [2m command wt config shell init fish [0m[2m[36m|[0m[2m source[107m [0m [2m # Check both command exit code ($pipestatus[1]) and source exit code ($pipestatus[2])[0m[2m[107m [0m [2m # If source fails, the function isn't replaced and we'd infinite-loop calling ourselves[0m[2m-[107m [0m [2m [0m[2m[34mset[0m[2m [0m[2m[36m-l[0m[2m wt_status [0m[2m[36m$[0m[2mpipestatus[1]+[107m [0m [2m set -l wt_status [0m[2m[36m$[0m[2mpipestatus[1][0m[2m[107m [0m [2m [0m[2m[34mset[0m[2m [0m[2m[36m-l[0m[2m source_status [0m[2m[36m$[0m[2mpipestatus[2][107m [0m [2m [0m[2m[34mtest[0m[2m [0m[2m[36m$[0m[2mwt_status [0m[2m[36m-eq[0m[2m 0; [0m[2m[34mor[0m[2m return [0m[2m[36m$[0m[2mwt_status[107m [0m [2m [0m[2m[34mtest[0m[2m [0m[2m[36m$[0m[2msource_status [0m[2m[36m-eq[0m[2m 0; [0m[2m[34mor[0m[2m return [0m[2m[36m$[0m[2msource_statusdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_syntax_error.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_syntax_error.snapindex 24e0ed6ea..59f24f6c1 100644--- a/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_syntax_error.snap+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_syntax_error.snap@@ -15,6 +15,7 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -45,4 +46,4 @@ exit_code: 0[36mPROJECT HOOKS[39m _REPO_/.config/wt.toml[36m❯[39m pre-commit [1mbroken[22m: [2m(requires approval)[22m[107m [0m [2m# Template error: Template syntax error: syntax error: unexpected end of input, expected end of variable block (in hook preview:1)[0m[2m-[107m [0m [2m[0m[2m[34mecho[0m[2m {{ branch+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m{{[0m[2m branchdiff --git a/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_undefined_var.snap b/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_undefined_var.snapindex ef939b6ab..a646cd223 100644--- a/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_undefined_var.snap+++ b/tests/snapshots/integration__integration_tests__hook_show__hook_show_expanded_undefined_var.snap@@ -15,6 +15,7 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -45,4 +46,4 @@ exit_code: 0[36mPROJECT HOOKS[39m _REPO_/.config/wt.toml[36m❯[39m pre-commit [1moptional-var[22m: [2m(requires approval)[22m[107m [0m [2m# Template error: Template render error: undefined value (in hook preview:1)[0m[2m-[107m [0m [2m[0m[2m[34mecho[0m[2m {{ base }}+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m{{[0m[2m base [0m[2m[32m}}[0m[2mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snapindex 0d196ac58..d3d71364a 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_create_multiline_control_structure.snap@@ -14,6 +14,7 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C@@ -39,11 +40,11 @@ exit_code: 0----- stderr -----[36m◎[39m [36mRunning post-create project hook @ [1m_REPO_.feature[22m:[39m-[107m [0m [2m[0m[2m[35mif[0m[2m [ ! -f test.txt ]; [0m[2m[35mthen[0m[2m[0m[2m+[107m [0m [2m[0m[2m[35mif[0m[2m [ ! -f test.txt ]; [0m[2m[35mthen[0m[2m[107m [0m [2m [0m[2m[34mecho[0m[2m [0m[2m[32m'File does not exist'[0m[2m [0m[2m[36m>[0m[2m result.txt-[107m [0m [2m[0m[2m[34melse[0m[2m+[107m [0m [2m[0m[2m[35melse[0m[2m[107m [0m [2m [0m[2m[34mecho[0m[2m [0m[2m[32m'File exists'[0m[2m [0m[2m[36m>[0m[2m result.txt-[107m [0m [2m[0m[2m[34mfi[0m[2m+[107m [0m [2m[0m[2m[35mfi[0m[2m[0m[32m✓[39m [32mCreated branch [1mfeature[22m from [1mmain[22m and worktree @ [1m_REPO_.feature[22m[39m[33m▲[39m [33mCannot change directory — shell integration not installed[39m[2m↳[22m [2mTo enable automatic cd, run [90mwt config shell install[39m[22mdiff --git a/tests/snapshots/integration__integration_tests__switch__switch_execute_verbose_multiline_template.snap b/tests/snapshots/integration__integration_tests__switch__switch_execute_verbose_multiline_template.snapindex 91fb1c03e..900cc4add 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_execute_verbose_multiline_template.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_execute_verbose_multiline_template.snap@@ -17,6 +17,7 @@ info:GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/null+ GIT_EDITOR: ""GIT_TERMINAL_PROMPT: "0"HOME: "[TEST_HOME]"LANG: C