Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: rename `select` module to `picker` (#1650)
Maximilian Roos40fec3872df9
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex f87d45cb3..c691e7fe8 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -56,8 +56,8 @@ repos:types: ["rust"]entry: '\\x1b\['# format.rs strips ANSI codes injected by wrap_ansi crate- # select.rs tests verify ANSI dimming behavior- exclude: '^(tests/|.*_test\.rs$|src/styling/(mod|format)\.rs$|src/commands/select/)'+ # picker tests verify ANSI dimming behavior+ exclude: '^(tests/|.*_test\.rs$|src/styling/(mod|format)\.rs$|src/commands/picker/)'- id: no-std-canonicalize-in-testsname: no-std-canonicalize-in-testsdescription: Use dunce::canonicalize in tests to avoid Windows \\?\ prefix issues@@ -71,12 +71,12 @@ repos:types: ["rust"]entry: '\.output\(\)'# shell_exec.rs: defines Cmd which legitimately calls .output()- # select.rs: skim API's selected.output() is not Command::output()+ # picker: skim API's selected.output() is not Command::output()# tests/benches: test utilities run commands directly# src/config/{test,expansion,mod}.rs: TestRepo test fixtures use git init directly# src/config/user/tests.rs: TestRepo test fixtures use git init directly# src/styling/mod.rs: terminal width detection probes should be silent/quick- exclude: '^(src/shell_exec\.rs|src/commands/select/|src/config/(test|expansion|mod)\.rs|src/config/user/tests\.rs|src/styling/mod\.rs|tests/|benches/)'+ exclude: '^(src/shell_exec\.rs|src/commands/picker/|src/config/(test|expansion|mod)\.rs|src/config/user/tests\.rs|src/styling/mod\.rs|tests/|benches/)'ci:# pre-commit.ci doesn't have Rust toolchain, so skip Rust-specific hooks.diff --git a/CLAUDE.md b/CLAUDE.mdindex 2790c76c9..f04759a93 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -88,7 +88,7 @@ The permission tests (`test_permission_error_prevents_save`, `test_approval_prom### Shell/PTY Integration Tests-PTY-based tests (approval prompts, TUI select, progressive rendering, shell wrappers) are behind the `shell-integration-tests` feature.+PTY-based tests (approval prompts, TUI picker, progressive rendering, shell wrappers) are behind the `shell-integration-tests` feature.**IMPORTANT:** Tests that spawn interactive shells (`zsh -ic`, `bash -ic`) cause nextest's InputHandler to receive SIGTTOU when restoring terminal settings. This suspends the test process mid-run with `zsh: suspended (tty output)` or similar. See [nextest#2878](https://github.com/nextest-rs/nextest/issues/2878) for details.@@ -276,6 +276,8 @@ cargo llvm-cov report --show-missing-lines | grep <file> # find uncovered lineFor each uncovered function/method, either write a test or document why it's intentionally untested. Integration tests (via `assert_cmd_snapshot!`) do capture subprocess coverage.+**Renames and moves:** File renames (`git mv`) can trigger codecov/patch failures on pre-existing uncovered lines — codecov treats changed lines in renamed files as part of the patch. If the uncovered lines are unchanged and existed before the rename, this is a false positive. Verify by checking coverage on `main` for the same lines under the old path.+## BenchmarksBenchmarks measure `wt list` performance across worktree counts and repository sizes.diff --git a/src/commands/context.rs b/src/commands/context.rsindex fb13bb309..b90b70d92 100644--- a/src/commands/context.rs+++ b/src/commands/context.rs@@ -12,7 +12,7 @@ use super::command_executor::CommandContext;////// This helper is used for commands that explicitly act on "where the user is standing"/// (e.g., `beta` and `merge`) and therefore need all of these pieces together. Commands that-/// inspect multiple worktrees or run without a config/branch requirement (`list`, `select`,+/// inspect multiple worktrees or run without a config/branch requirement (`list`, the picker,/// some `worktree` helpers) still call `Repository::current()` directly so they can operate in/// broader contexts without forcing config loads or branch resolution.pub struct CommandEnv {diff --git a/src/commands/list/collect/mod.rs b/src/commands/list/collect/mod.rsindex 62b78ae79..b5a7aea8a 100644--- a/src/commands/list/collect/mod.rs+++ b/src/commands/list/collect/mod.rs@@ -202,7 +202,7 @@ fn worktree_branch_set(worktrees: &[WorktreeInfo]) -> HashSet<&str> {/// Controls how show flags (branches/remotes/full) are determined in [`collect`].#[cfg_attr(not(unix), allow(dead_code))]pub enum ShowConfig {- /// Flags already resolved by the caller (used by `wt select`).+ /// Flags already resolved by the caller (used by the picker).Resolved {show_branches: bool,show_remotes: bool,diff --git a/src/commands/list/layout.rs b/src/commands/list/layout.rsindex 981ca0534..56fb9e91a 100644--- a/src/commands/list/layout.rs+++ b/src/commands/list/layout.rs@@ -197,7 +197,7 @@ use crate::display::{shorten_path, terminal_width};use super::collect::{TaskKind, parse_port_from_url};use super::columns::{COLUMN_SPECS, ColumnKind, ColumnSpec, column_display_index};-// Re-export DiffVariant for external use (e.g., select command)+// Re-export DiffVariant for external use (e.g., picker module)pub use super::columns::DiffVariant;/// Width of short commit hash display (first 8 hex characters)@@ -312,7 +312,7 @@ impl DiffDisplayConfig {////// Numbers are right-aligned within a 3-digit column width./// Returns empty spaces if both values are zero (unless `always_show_zeros` is set).- #[cfg(unix)] // Only used by select command which is unix-only+ #[cfg(unix)] // Only used by picker module which is unix-onlypub fn format_aligned(&self, positive: usize, negative: usize) -> String {const DIGITS: usize = 3;let positive_width = 1 + DIGITS; // symbol + digitsdiff --git a/src/commands/list/model/item.rs b/src/commands/list/model/item.rsindex 551692caa..073b52480 100644--- a/src/commands/list/model/item.rs+++ b/src/commands/list/model/item.rs@@ -222,12 +222,12 @@ pub struct ListItem {pub struct ListData {pub items: Vec<ListItem>,/// Path to the main worktree, used for computing relative paths in display.- #[cfg_attr(windows, allow(dead_code))] // Used only by select module (unix-only)+ #[cfg_attr(windows, allow(dead_code))] // Used only by picker module (unix-only)pub main_worktree_path: std::path::PathBuf,/// Tasks that were skipped during collection (includes runtime gating like/// SummaryGenerate disabled when no LLM configured). Callers that recalculate/// layout (e.g., the picker at a different width) should use this set.- #[cfg_attr(windows, allow(dead_code))] // Used only by select module (unix-only)+ #[cfg_attr(windows, allow(dead_code))] // Used only by picker module (unix-only)pub skip_tasks: std::collections::HashSet<super::super::collect::TaskKind>,}diff --git a/src/commands/list/render.rs b/src/commands/list/render.rsindex bbadb2b3a..7ad03ae52 100644--- a/src/commands/list/render.rs+++ b/src/commands/list/render.rs@@ -242,7 +242,7 @@ impl LayoutConfig {/// Render with stale placeholders for items where data collection was truncated./// Uses `·` instead of `⋯` to indicate data won't arrive.- #[cfg_attr(windows, allow(dead_code))] // Used only by select module (unix-only)+ #[cfg_attr(windows, allow(dead_code))] // Used only by picker module (unix-only)pub fn render_list_item_stale(&self, item: &ListItem) -> StyledLine {self.render_item_with_placeholder(item, "·")}diff --git a/src/commands/mod.rs b/src/commands/mod.rsindex 1e7f16692..853d0c179 100644--- a/src/commands/mod.rs+++ b/src/commands/mod.rs@@ -15,12 +15,12 @@ pub(crate) mod hooks;pub(crate) mod init;pub(crate) mod list;pub(crate) mod merge;+#[cfg(unix)]+pub(crate) mod picker;pub(crate) mod process;pub(crate) mod project_config;mod relocate;pub(crate) mod repository_ext;-#[cfg(unix)]-pub(crate) mod select;pub(crate) mod statusline;pub(crate) mod step_commands;pub(crate) mod worktree;@@ -42,7 +42,7 @@ pub(crate) use init::{handle_completions, handle_init};pub(crate) use list::handle_list;pub(crate) use merge::{MergeOptions, handle_merge};#[cfg(unix)]-pub(crate) use select::handle_select;+pub(crate) use picker::handle_picker;pub(crate) use step_commands::{PromoteResult, RebaseResult, SquashResult, handle_promote, handle_rebase, handle_squash,step_commit, step_copy_ignored, step_diff, step_prune, step_relocate, step_show_squash_prompt,diff --git a/src/commands/select/items.rs b/src/commands/picker/items.rssimilarity index 100%rename from src/commands/select/items.rsrename to src/commands/picker/items.rsdiff --git a/src/commands/select/log_formatter.rs b/src/commands/picker/log_formatter.rssimilarity index 100%rename from src/commands/select/log_formatter.rsrename to src/commands/picker/log_formatter.rsdiff --git a/src/commands/select/mod.rs b/src/commands/picker/mod.rssimilarity index 99%rename from src/commands/select/mod.rsrename to src/commands/picker/mod.rsindex 178947d94..8b791d19a 100644--- a/src/commands/select/mod.rs+++ b/src/commands/picker/mod.rs@@ -39,7 +39,7 @@ enum PickerAction {Remove,}-pub fn handle_select(+pub fn handle_picker(cli_branches: bool,cli_remotes: bool,change_dir_flag: Option<bool>,@@ -61,7 +61,7 @@ pub fn handle_select(let state = PreviewState::new();// Gather list data using simplified collection (buffered mode)- // Skip expensive operations not needed for select UI+ // Skip expensive operations not needed for picker UIlet skip_tasks: std::collections::HashSet<collect::TaskKind> = [collect::TaskKind::BranchDiff,collect::TaskKind::CiStatus,@@ -86,7 +86,7 @@ pub fn handle_select(collect_deadline,},false, // show_progress (no progress bars)- false, // render_table (select renders its own UI)+ false, // render_table (picker renders its own UI)true, // skip_expensive_for_stale (faster for repos with many stale branches))?else {@@ -107,7 +107,7 @@ pub fn handle_select(&list_data.skip_tasks,skim_list_width,&list_data.main_worktree_path,- None, // URL column not shown in select+ None, // URL column not shown in picker);// Render header using layout system (need both plain and styled text for skim)diff --git a/src/commands/select/pager.rs b/src/commands/picker/pager.rssimilarity index 100%rename from src/commands/select/pager.rsrename to src/commands/picker/pager.rsdiff --git a/src/commands/select/preview.rs b/src/commands/picker/preview.rssimilarity index 99%rename from src/commands/select/preview.rsrename to src/commands/picker/preview.rsindex c8a8c257f..957172e0e 100644--- a/src/commands/select/preview.rs+++ b/src/commands/picker/preview.rs@@ -163,7 +163,7 @@ pub(super) struct PreviewStateData;impl PreviewStateData {pub(super) fn state_path() -> PathBuf {// Use per-process temp file to avoid race conditions when running multiple instances- std::env::temp_dir().join(format!("wt-select-state-{}", std::process::id()))+ std::env::temp_dir().join(format!("wt-picker-state-{}", std::process::id()))}/// Read current preview mode from state filediff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__branch_diff.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__branch_diff.snapsimilarity index 89%rename from src/commands/select/snapshots/wt__commands__select__items__tests__branch_diff.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__branch_diff.snapindex 4c0ca15fc..2efee5351 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__branch_diff.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__branch_diff.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::render_preview_tabs(mode)"---[2m1: HEAD±[22m[0m | [2m2: log[22m[0m | [1m3: main…±[22m[0m | [2m4: remote⇅[22m[0m | [2m5: summary[22m[0mdiff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__cache_hit.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_hit.snapsimilarity index 79%rename from src/commands/select/snapshots/wt__commands__select__items__tests__cache_hit.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_hit.snapindex 6d057825d..ae14f2088 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__cache_hit.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_hit.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "cache_hit.preview_for_mode(PreviewMode::Summary, 80, 40)"---[1mAdd auth module[0mdiff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__cache_miss.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_miss.snapsimilarity index 81%rename from src/commands/select/snapshots/wt__commands__select__items__tests__cache_miss.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_miss.snapindex 95571e5c6..f75be4676 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__cache_miss.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__cache_miss.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "cache_miss.preview_for_mode(PreviewMode::Summary, 80, 40)"---[2m○[22m Generating summary...diff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__direct.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__direct.snapsimilarity index 81%rename from src/commands/select/snapshots/wt__commands__select__items__tests__direct.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__direct.snapindex 37a8ca104..8dea121a3 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__direct.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__direct.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::compute_summary_preview(&main_item)"---[2m○[22m Generating summary...diff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__log.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__log.snapsimilarity index 89%rename from src/commands/select/snapshots/wt__commands__select__items__tests__log.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__log.snapindex ef283bd7f..fa7d5c91c 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__log.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__log.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::render_preview_tabs(mode)"---[2m1: HEAD±[22m[0m | [1m2: log[22m[0m | [2m3: main…±[22m[0m | [2m4: remote⇅[22m[0m | [2m5: summary[22m[0mdiff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__summary.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__summary.snapsimilarity index 89%rename from src/commands/select/snapshots/wt__commands__select__items__tests__summary.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__summary.snapindex 453233466..d3ff91ef6 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__summary.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__summary.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::render_preview_tabs(mode)"---[2m1: HEAD±[22m[0m | [2m2: log[22m[0m | [2m3: main…±[22m[0m | [2m4: remote⇅[22m[0m | [1m5: summary[22m[0mdiff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__upstream_diff.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__upstream_diff.snapsimilarity index 89%rename from src/commands/select/snapshots/wt__commands__select__items__tests__upstream_diff.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__upstream_diff.snapindex e1e1bab9b..1663500df 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__upstream_diff.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__upstream_diff.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::render_preview_tabs(mode)"---[2m1: HEAD±[22m[0m | [2m2: log[22m[0m | [2m3: main…±[22m[0m | [1m4: remote⇅[22m[0m | [2m5: summary[22m[0mdiff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__via_compute_preview.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__via_compute_preview.snapsimilarity index 83%rename from src/commands/select/snapshots/wt__commands__select__items__tests__via_compute_preview.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__via_compute_preview.snapindex c75da5d0d..015d5bbf1 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__via_compute_preview.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__via_compute_preview.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::compute_preview(&feature_item, PreviewMode::Summary, 80, 40)"---[2m○[22m Generating summary...diff --git a/src/commands/select/snapshots/wt__commands__select__items__tests__working_tree.snap b/src/commands/picker/snapshots/wt__commands__picker__items__tests__working_tree.snapsimilarity index 89%rename from src/commands/select/snapshots/wt__commands__select__items__tests__working_tree.snaprename to src/commands/picker/snapshots/wt__commands__picker__items__tests__working_tree.snapindex a3ff33c0e..9f10a7053 100644--- a/src/commands/select/snapshots/wt__commands__select__items__tests__working_tree.snap+++ b/src/commands/picker/snapshots/wt__commands__picker__items__tests__working_tree.snap@@ -1,5 +1,5 @@----source: src/commands/select/items.rs+source: src/commands/picker/items.rsexpression: "WorktreeSkimItem::render_preview_tabs(mode)"---[1m1: HEAD±[22m[0m | [2m2: log[22m[0m | [2m3: main…±[22m[0m | [2m4: remote⇅[22m[0m | [2m5: summary[22m[0mdiff --git a/src/commands/select/summary.rs b/src/commands/picker/summary.rssimilarity index 100%rename from src/commands/select/summary.rsrename to src/commands/picker/summary.rsdiff --git a/src/commands/worktree/resolve.rs b/src/commands/worktree/resolve.rsindex 66561bd2d..a8aa2a33d 100644--- a/src/commands/worktree/resolve.rs+++ b/src/commands/worktree/resolve.rs@@ -187,7 +187,7 @@ pub(crate) fn paths_match(a: &std::path::Path, b: &std::path::Path) -> bool {/// Returns the expected path if `actual_path` differs from the template-computed path.////// Returns `Some(expected_path)` when there's a mismatch, `None` when paths match.-/// Used to show path mismatch warnings in switch, select, remove, and merge.+/// Used to show path mismatch warnings in switch, picker, remove, and merge.pub fn path_mismatch(repo: &Repository,branch: &str,diff --git a/src/completion.rs b/src/completion.rsindex 92ccbd2ea..e450f6af3 100644--- a/src/completion.rs+++ b/src/completion.rs@@ -164,7 +164,7 @@ pub(crate) fn branch_value_completer() -> ArgValueCompleter {})}-/// Branch completion for positional arguments (switch, select).+/// Branch completion for positional arguments (switch)./// Suppresses completions when --create flag is present.pub(crate) fn worktree_branch_completer() -> ArgValueCompleter {ArgValueCompleter::new(BranchCompleter {diff --git a/src/main.rs b/src/main.rsindex 9b206d973..3b2f03f31 100644--- a/src/main.rs+++ b/src/main.rs@@ -42,7 +42,7 @@ pub(crate) use invocation::{pub(crate) use crate::cli::OutputFormat;#[cfg(unix)]-use commands::handle_select;+use commands::handle_picker;use commands::worktree::{handle_no_ff_merge, handle_push};use commands::{MergeOptions, OperationMode, RebaseResult, SquashResult, SwitchOptions, add_approvals,@@ -469,9 +469,9 @@ fn handle_list_command(#[cfg(unix)]fn handle_select_command(branches: bool, remotes: bool) -> anyhow::Result<()> {- // Deprecated: show warning and delegate to handle_select+ // Deprecated: show warning and delegate to handle_pickerwarn_select_deprecated();- handle_select(branches, remotes, None)+ handle_picker(branches, remotes, None)}#[cfg(not(unix))]@@ -507,7 +507,7 @@ fn handle_switch_command(spec: SwitchCommandArgs) -> anyhow::Result<()> {let Some(branch) = spec.branch else {#[cfg(unix)]{- return handle_select(spec.branches, spec.remotes, change_dir_flag);+ return handle_picker(spec.branches, spec.remotes, change_dir_flag);}#[cfg(not(unix))]diff --git a/src/summary.rs b/src/summary.rsindex ef776844e..59d5c8b37 100644--- a/src/summary.rs+++ b/src/summary.rs@@ -236,7 +236,7 @@ pub(crate) fn generate_summary_core(////// This is the TUI-friendly wrapper that returns a formatted string for all cases,/// including errors and "no changes" — suitable for `wt switch` preview pane.-#[cfg_attr(windows, allow(dead_code))] // Called from select module (unix-only)+#[cfg_attr(windows, allow(dead_code))] // Called from picker module (unix-only)pub(crate) fn generate_summary(branch: &str,head: &str,diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 73ea8cde2..9939d3221 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -589,7 +589,7 @@ const STATIC_TEST_ENV_VARS: &[(&str, &str)] = &[// NOTE: TERM is intentionally NOT in STATIC_TEST_ENV_VARS because:// - configure_cli_command() sets TERM=alacritty for hyperlink detection testing-// - PTY tests (especially skim-based select tests) need a TERM with valid terminfo+// - PTY tests (especially skim-based picker tests) need a TERM with valid terminfo// - macOS CI doesn't have alacritty terminfo, causing skim to fail/// Null device path, platform-appropriate.@@ -2924,7 +2924,7 @@ pub fn setup_temp_snapshot_settings(temp_path: &std::path::Path) -> insta::Setti// PTY Test Filters// =============================================================================//-// PTY-based tests (shell wrappers, approval prompts, TUI select) capture output+// PTY-based tests (shell wrappers, approval prompts, TUI picker) capture output// from pseudo-terminals. This output has platform-specific artifacts that need// normalization for stable snapshots.//diff --git a/tests/integration_tests/output_system_guard.rs b/tests/integration_tests/output_system_guard.rsindex 6d475db47..a44e67b2a 100644--- a/tests/integration_tests/output_system_guard.rs+++ b/tests/integration_tests/output_system_guard.rs@@ -39,7 +39,7 @@ const STDOUT_ALLOWED_PATHS: &[&str] = &[// LLM prompt output for wt step commit --show-prompt"step_commands.rs",// --no-cd flag: branch name output for scripting- "select/mod.rs",+ "picker/mod.rs",];/// Substrings that indicate the line is a special case (e.g., in a comment or test reference)