Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Refactor colorize_status_symbols to use helper function and remove unused hint style
Maximilian Roosdd0e82e0321a
diff --git a/src/md_help.rs b/src/md_help.rsindex b9ec6cd9b..37c5c074c 100644--- a/src/md_help.rs+++ b/src/md_help.rs@@ -273,10 +273,9 @@ fn render_inline_formatting(line: &str) -> String {fn colorize_status_symbols(text: &str) -> String {use anstyle::{AnsiColor, Color as AnsiStyleColor, Style};- // Define semantic styles matching src/commands/list/model.rs StatusSymbols::render_with_mask+ // Define semantic styles matching src/commands/list/model.rs StatusSymbols::styled_symbolslet error = Style::new().fg_color(Some(AnsiStyleColor::Ansi(AnsiColor::Red)));let warning = Style::new().fg_color(Some(AnsiStyleColor::Ansi(AnsiColor::Yellow)));- let hint = Style::new().dimmed();let success = Style::new().fg_color(Some(AnsiStyleColor::Ansi(AnsiColor::Green)));let progress = Style::new().fg_color(Some(AnsiStyleColor::Ansi(AnsiColor::Blue)));let disabled = Style::new().fg_color(Some(AnsiStyleColor::Ansi(AnsiColor::BrightBlack)));@@ -284,12 +283,38 @@ fn colorize_status_symbols(text: &str) -> String {// Pattern for dimmed text (from inline `code` rendering)// render_inline_formatting wraps backticked text in dimmed style- let code_style = Style::new().dimmed();- let dimmed_bullet = format!("{code_style}●{code_style:#}");-- text- // CI status circles in table format: `●` green → colored ● green- // The backticks are converted to dimmed styling by render_inline_formatting first+ let dim = Style::new().dimmed();++ // Helper to create dimmed symbol pattern and its colored replacement+ let replace_dim = |text: String, sym: &str, style: Style| -> String {+ let dimmed = format!("{dim}{sym}{dim:#}");+ let colored = format!("{style}{sym}{style:#}");+ text.replace(&dimmed, &colored)+ };++ let mut result = text.to_string();++ // Working tree symbols: CYAN+ result = replace_dim(result, "+", working_tree);+ result = replace_dim(result, "!", working_tree);+ result = replace_dim(result, "?", working_tree);++ // Conflicts: ERROR (red)+ result = replace_dim(result, "✖", error);++ // Git operations, MergeTreeConflicts: WARNING (yellow)+ result = replace_dim(result, "↻", warning);+ result = replace_dim(result, "⋈", warning);+ result = replace_dim(result, "⊘", warning);++ // Worktree state: PathMismatch (red), Prunable/Locked (yellow)+ result = replace_dim(result, "⚑", error);+ result = replace_dim(result, "⌫", warning);+ result = replace_dim(result, "⊠", warning);++ // CI status circles: replace dimmed ● followed by color name+ let dimmed_bullet = format!("{dim}●{dim:#}");+ result = result.replace(&format!("{dimmed_bullet} green"),&format!("{success}●{success:#} green"),@@ -309,61 +334,23 @@ fn colorize_status_symbols(text: &str) -> String {.replace(&format!("{dimmed_bullet} gray"),&format!("{disabled}●{disabled:#} gray"),- )- // Legacy CI status circles (for statusline format)+ );++ // Legacy CI status circles (for statusline format)+ result = result.replace("● passed", &format!("{success}●{success:#} passed")).replace("● running", &format!("{progress}●{progress:#} running")).replace("● failed", &format!("{error}●{error:#} failed")).replace("● conflicts", &format!("{warning}●{warning:#} conflicts"))- .replace("● no-ci", &format!("{disabled}●{disabled:#} no-ci"))- // Conflicts: ✖ is ERROR (red), ⊘ is WARNING (yellow)- .replace(- "✖ Merge conflicts",- &format!("{error}✖{error:#} Merge conflicts"),- )- .replace(- "⊘ Would conflict",- &format!("{warning}⊘{warning:#} Would conflict"),- )- // Git operations: WARNING (yellow)- .replace("↻ Rebase", &format!("{warning}↻{warning:#} Rebase"))- .replace("⋈ Merge", &format!("{warning}⋈{warning:#} Merge"))- // Worktree attributes: WARNING (yellow)- .replace("⊠ Locked", &format!("{warning}⊠{warning:#} Locked"))- .replace("⚠ Prunable", &format!("{warning}⚠{warning:#} Prunable"))- // Branch state: HINT (dimmed)- .replace(- "≡ Working tree matches",- &format!("{hint}≡{hint:#} Working tree matches"),- )- .replace("_ No commits", &format!("{hint}_{hint:#} No commits"))- .replace(- "· Branch without",- &format!("{hint}·{hint:#} Branch without"),- )- // Main/upstream divergence: NO COLOR (plain text in actual output)- // ↑, ↓, ↕, ⇡, ⇣, ⇅ remain uncolored- // Working tree changes: CYAN- .replace(- "? Untracked",- &format!("{working_tree}?{working_tree:#} Untracked"),- )- .replace(- "! Modified",- &format!("{working_tree}!{working_tree:#} Modified"),- )- .replace(- "+ Staged",- &format!("{working_tree}+{working_tree:#} Staged"),- )- .replace(- "» Renamed",- &format!("{working_tree}»{working_tree:#} Renamed"),- )- .replace(- "✘ Deleted",- &format!("{working_tree}✘{working_tree:#} Deleted"),- )+ .replace("● no-ci", &format!("{disabled}●{disabled:#} no-ci"));++ // Symbols that should remain dimmed are already dimmed from backtick rendering:+ // - Branch state: ≡ (matches main), _ (no commits)+ // - Main divergence: ^, ↑, ↓, ↕+ // - Upstream divergence: |, ⇡, ⇣, ⇅+ // - Worktree state: / (branch without worktree)++ result}#[cfg(test)]diff --git a/tests/snapshots/integration__integration_tests__help__help_list_long.snap b/tests/snapshots/integration__integration_tests__help__help_list_long.snapindex 37f7042bc..7b296a72e 100644--- a/tests/snapshots/integration__integration_tests__help__help_list_long.snap+++ b/tests/snapshots/integration__integration_tests__help__help_list_long.snap@@ -114,13 +114,13 @@ Symbols appear in the Status column in this order:Category Symbol Meaning───────────────── ────── ──────────────────────────────────────────────- Working tree [2m+[0m Staged files- [2m![0m Modified files (unstaged)- [2m?[0m Untracked files- [2m✖[0m Merge conflicts- [2m↻[0m Rebase in progress- [2m⋈[0m Merge in progress- Branch state [2m⊘[0m Would conflict if merged to main ([2m--full[0m only)+ Working tree [36m+[0m Staged files+ [36m![0m Modified files (unstaged)+ [36m?[0m Untracked files+ [31m✖[0m Merge conflicts+ [33m↻[0m Rebase in progress+ [33m⋈[0m Merge in progress+ Branch state [33m⊘[0m Would conflict if merged to main ([2m--full[0m only)[2m≡[0m Matches main (identical contents)[2m_[0m No commits ahead, clean working treeMain divergence [2m^[0m Is the main branch@@ -132,9 +132,9 @@ Symbols appear in the Status column in this order:[2m⇣[0m Behind remote[2m⇅[0m Diverged from remoteWorktree state [2m/[0m Branch without worktree- [2m⚑[0m Path doesn't match template- [2m⌫[0m Prunable (directory missing)- [2m⊠[0m Locked worktree+ [31m⚑[0m Path doesn't match template+ [33m⌫[0m Prunable (directory missing)+ [33m⊠[0m Locked worktreeRows are dimmed when the branch content is already in main ([2m≡[0m matches main or [2m_[0m no commits ahead).