Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat: Add interactive worktree selection and snapshot updates

Maximilian Roos2cb603c39f8c
diff --git a/Cargo.lock b/Cargo.lock
index 71e5bbc78..3ac575b6c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -88,6 +88,12 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
+[[package]]
+name = "arrayvec"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
+
[[package]]
name = "askama"
version = "0.14.0"
@@ -163,6 +169,12 @@ version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
+[[package]]
+name = "beef"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
+
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -228,6 +240,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "char_index"
version = "0.1.4"
@@ -311,8 +329,10 @@ version = "4.5.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
dependencies = [
+ "anstyle",
"heck",
"proc-macro2",
+ "pulldown-cmark",
"quote",
"syn",
]
@@ -438,6 +458,28 @@ dependencies = [
"itertools",
]
+[[package]]
+name = "crossbeam"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
+dependencies = [
+ "crossbeam-channel",
+ "crossbeam-deque",
+ "crossbeam-epoch",
+ "crossbeam-queue",
+ "crossbeam-utils",
+]
+
+[[package]]
+name = "crossbeam-channel"
+version = "0.5.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
+dependencies = [
+ "crossbeam-utils",
+]
+
[[package]]
name = "crossbeam-deque"
version = "0.8.6"
@@ -457,6 +499,15 @@ dependencies = [
"crossbeam-utils",
]
+[[package]]
+name = "crossbeam-queue"
+version = "0.3.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
+dependencies = [
+ "crossbeam-utils",
+]
+
[[package]]
name = "crossbeam-utils"
version = "0.8.21"
@@ -514,6 +565,16 @@ dependencies = [
"syn",
]
+[[package]]
+name = "defer-drop"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f613ec9fa66a6b28cdb1842b27f9adf24f39f9afc4dcdd9fdecee4aca7945c57"
+dependencies = [
+ "crossbeam-channel",
+ "once_cell",
+]
+
[[package]]
name = "deranged"
version = "0.5.5"
@@ -588,6 +649,16 @@ dependencies = [
"dirs-sys",
]
+[[package]]
+name = "dirs-next"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
+dependencies = [
+ "cfg-if",
+ "dirs-sys-next",
+]
+
[[package]]
name = "dirs-sys"
version = "0.5.0"
@@ -596,10 +667,21 @@ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
dependencies = [
"libc",
"option-ext",
- "redox_users",
+ "redox_users 0.5.2",
"windows-sys 0.61.2",
]
+[[package]]
+name = "dirs-sys-next"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
+dependencies = [
+ "libc",
+ "redox_users 0.4.6",
+ "winapi",
+]
+
[[package]]
name = "dlv-list"
version = "0.5.2"
@@ -646,6 +728,12 @@ dependencies = [
"regex",
]
+[[package]]
+name = "env_home"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
+
[[package]]
name = "env_logger"
version = "0.11.8"
@@ -768,6 +856,15 @@ dependencies = [
"slab",
]
+[[package]]
+name = "fuzzy-matcher"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94"
+dependencies = [
+ "thread_local",
+]
+
[[package]]
name = "generic-array"
version = "0.14.9"
@@ -1051,7 +1148,19 @@ checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.10.0",
"cfg-if",
- "cfg_aliases",
+ "cfg_aliases 0.1.1",
+ "libc",
+]
+
+[[package]]
+name = "nix"
+version = "0.29.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
+dependencies = [
+ "bitflags 2.10.0",
+ "cfg-if",
+ "cfg_aliases 0.2.1",
"libc",
]
@@ -1242,7 +1351,7 @@ dependencies = [
"lazy_static",
"libc",
"log",
- "nix",
+ "nix 0.28.0",
"serial2",
"shared_library",
"shell-words",
@@ -1256,6 +1365,15 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+[[package]]
+name = "ppv-lite86"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
+dependencies = [
+ "zerocopy",
+]
+
[[package]]
name = "predicates"
version = "3.1.3"
@@ -1301,6 +1419,17 @@ dependencies = [
"unicode-ident",
]
+[[package]]
+name = "pulldown-cmark"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e8bbe1a966bd2f362681a44f6edce3c2310ac21e4d5067a6e7ec396297a6ea0"
+dependencies = [
+ "bitflags 2.10.0",
+ "memchr",
+ "unicase",
+]
+
[[package]]
name = "quote"
version = "1.0.41"
@@ -1316,6 +1445,35 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
+[[package]]
+name = "rand"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
+dependencies = [
+ "rand_chacha",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_chacha"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
+dependencies = [
+ "ppv-lite86",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.9.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
+dependencies = [
+ "getrandom 0.3.4",
+]
+
[[package]]
name = "rayon"
version = "1.11.0"
@@ -1336,6 +1494,17 @@ dependencies = [
"crossbeam-utils",
]
+[[package]]
+name = "redox_users"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
+dependencies = [
+ "getrandom 0.2.16",
+ "libredox",
+ "thiserror 1.0.69",
+]
+
[[package]]
name = "redox_users"
version = "0.5.2"
@@ -1590,6 +1759,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f"
+[[package]]
+name = "shell-quote"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb502615975ae2365825521fa1529ca7648fd03ce0b0746604e0683856ecd7e4"
+dependencies = [
+ "bstr",
+]
+
[[package]]
name = "shell-words"
version = "1.1.0"
@@ -1605,12 +1783,72 @@ dependencies = [
"dirs",
]
+[[package]]
+name = "shlex"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+
[[package]]
name = "similar"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa"
+[[package]]
+name = "skim"
+version = "0.20.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "60e10a7f70e8e532d8780d88210055e15e12d0df431bf5dab7bb1ed22b6fb4f2"
+dependencies = [
+ "beef",
+ "bitflags 1.3.2",
+ "chrono",
+ "clap",
+ "clap_complete",
+ "crossbeam",
+ "defer-drop",
+ "derive_builder",
+ "env_logger",
+ "fuzzy-matcher",
+ "indexmap",
+ "log",
+ "nix 0.29.0",
+ "rand",
+ "rayon",
+ "regex",
+ "shell-quote",
+ "shlex",
+ "skim-common",
+ "skim-tuikit",
+ "time",
+ "timer",
+ "unicode-width",
+ "vte",
+ "which",
+]
+
+[[package]]
+name = "skim-common"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d8312ae7ca1a5883e68042b9c6bce05bfc12f06b814ecfda06c34abfb6c88175"
+
+[[package]]
+name = "skim-tuikit"
+version = "0.6.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb54242783b4234134359fea4d11f26879c49ace6c00c5d402fd04a5ab2ad7bd"
+dependencies = [
+ "bitflags 1.3.2",
+ "lazy_static",
+ "log",
+ "nix 0.29.0",
+ "skim-common",
+ "term",
+ "unicode-width",
+]
+
[[package]]
name = "slab"
version = "0.4.11"
@@ -1681,6 +1919,17 @@ dependencies = [
"windows-sys 0.61.2",
]
+[[package]]
+name = "term"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f"
+dependencies = [
+ "dirs-next",
+ "rustversion",
+ "winapi",
+]
+
[[package]]
name = "terminal_size"
version = "0.4.3"
@@ -1737,6 +1986,15 @@ dependencies = [
"syn",
]
+[[package]]
+name = "thread_local"
+version = "1.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185"
+dependencies = [
+ "cfg-if",
+]
+
[[package]]
name = "time"
version = "0.3.44"
@@ -1770,6 +2028,15 @@ dependencies = [
"time-core",
]
+[[package]]
+name = "timer"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "31d42176308937165701f50638db1c31586f183f1aab416268216577aec7306b"
+dependencies = [
+ "chrono",
+]
+
[[package]]
name = "tiny-keccak"
version = "2.0.2"
@@ -1889,6 +2156,12 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
+[[package]]
+name = "unicase"
+version = "2.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
+
[[package]]
name = "unicode-ident"
version = "1.0.22"
@@ -1957,6 +2230,16 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+[[package]]
+name = "vte"
+version = "0.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"
+dependencies = [
+ "arrayvec",
+ "memchr",
+]
+
[[package]]
name = "wait-timeout"
version = "0.2.1"
@@ -2046,6 +2329,18 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "which"
+version = "7.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762"
+dependencies = [
+ "either",
+ "env_home",
+ "rustix",
+ "winsafe",
+]
+
[[package]]
name = "winapi"
version = "0.3.9"
@@ -2310,6 +2605,12 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "winsafe"
+version = "0.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"
+
[[package]]
name = "wit-bindgen"
version = "0.46.0"
@@ -2345,6 +2646,7 @@ dependencies = [
"serde_json",
"shell-escape",
"shellexpand",
+ "skim",
"strum",
"synoptic",
"tempfile",
diff --git a/Cargo.toml b/Cargo.toml
index ae9386645..886b9bda1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -47,6 +47,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shell-escape = "0.1"
shellexpand = "3.1"
+skim = "0.20"
strum = { version = "0.27", features = ["derive"] }
synoptic = "2"
terminal_size = "0.4"
diff --git a/ISSUE.md b/ISSUE.md
new file mode 100644
index 000000000..a415193f6
--- /dev/null
+++ b/ISSUE.md
@@ -0,0 +1,654 @@
+# Improving `wt select`: Interactive Worktree Selector Interface
+
+## Executive Summary
+
+We have implemented a basic interactive worktree selector (`wt select`) using the skim fuzzy finder library. The command works functionally - users can fuzzy search through worktrees and switch to them - but we want to explore how to make this interface significantly more useful and powerful. This report documents the current implementation, available data, and open questions about how to design the best possible interface.
+
+## Project Context
+
+**Worktrunk** is a git worktree management tool written in Rust. Git worktrees allow multiple working directories for a single repository, enabling developers to work on multiple branches simultaneously without stashing changes or maintaining multiple clones.
+
+The tool already has a `wt list` command that displays rich information about worktrees in a table format. The new `wt select` command provides an interactive fuzzy-finder interface for switching between worktrees.
+
+## Goals
+
+1. **Primary Goal**: Create an interactive interface that makes it faster and easier to navigate between worktrees compared to `wt list` + `wt switch <name>`
+2. **Design Goal**: Surface the most relevant information to help users make switching decisions quickly
+3. **UX Goal**: Support power users who may have dozens of worktrees and need efficient filtering/sorting
+4. **Extensibility Goal**: Design an interface that could later support additional actions beyond just switching (e.g., remove, merge, create)
+
+## Current Implementation
+
+### Technology Stack
+
+- **skim** (v0.20): Rust-based fuzzy finder library, similar to fzf
+- **Bundled**: skim is compiled into the binary (~500KB increase), no external dependencies
+- **Features Used**:
+ - Basic fuzzy matching on display text
+ - Preview pane (right 50% of screen)
+ - Custom header with keyboard shortcuts
+ - Single selection mode
+
+### Current Interface Design
+
+**Main Display (Left Pane)**:
+Each line shows:
+```
+<branch_name> <status_symbols> <commit_message>
+```
+
+Example output:
+```
+main Initial commit
+skim !+ Add skim-based selector
+refactor ! Refactor list rendering
+switch- ?! WIP: switch improvements
+demo-fix ↓ Fix demo crash
+```
+
+**Status Symbols** (8 characters wide, centered):
+- `·` - Branch without worktree
+- `=` - Merge conflicts in working tree
+- `↑` - Ahead of main branch
+- `↓` - Behind main branch
+- `⇡` - Ahead of remote tracking branch
+- `⇣` - Behind remote tracking branch
+- `?` - Untracked files present
+- `!` - Modified files (unstaged changes)
+- `+` - Staged files
+- `»` - Renamed files
+- `✘` - Deleted files
+
+**Preview Pane (Right 50%)**:
+Shell script that shows:
+1. Branch name header
+2. Working tree status (`git status --short`)
+3. Ahead/behind counts vs main
+4. Recent 5 commits (`git log --oneline`)
+5. Diff stats vs main (`git diff --stat`)
+6. Diff preview (first 30 lines of `git diff`)
+
+**Keyboard Shortcuts** (shown in header):
+- `Enter` - Switch to selected worktree
+- `Ctrl-/` - Toggle preview pane
+- `Esc` - Cancel
+
+### Code Structure
+
+The implementation is in `src/commands/select.rs` (208 lines):
+
+```rust
+pub fn handle_select() -> Result<(), GitError> {
+ let repo = Repository::current();
+
+ // Gather data using existing list infrastructure
+ let Some(list_data) = gather_list_data(&repo, false, false, false)? else {
+ return Ok(());
+ };
+
+ // Calculate max branch name length for column alignment
+ let max_branch_len = list_data.items.iter()
+ .map(|item| item.branch_name().len())
+ .max()
+ .unwrap_or(20);
+
+ // Convert to skim items with formatted display text
+ let items: Vec<Arc<dyn SkimItem>> = list_data.items
+ .into_iter()
+ .map(|item| {
+ let branch_name = item.branch_name().to_string();
+ let commit_msg = item.commit_details()
+ .commit_message
+ .lines()
+ .next()
+ .unwrap_or("");
+
+ // Aligned columns: branch + status + commit message
+ let mut display_text = format!("{:<width$}", branch_name, width = max_branch_len);
+ let status = if let Some(wt_info) = item.worktree_info() {
+ format!("{:^8}", wt_info.status_symbols)
+ } else {
+ " ".to_string()
+ };
+ display_text.push_str(&status);
+ display_text.push_str(" ");
+ display_text.push_str(commit_msg);
+
+ Arc::new(WorktreeSkimItem { display_text, branch_name }) as Arc<dyn SkimItem>
+ })
+ .collect();
+
+ // Configure skim with preview script
+ let preview_cmd = r#"sh -c '
+ BRANCH="$1"
+ echo "━━━ Branch: $BRANCH ━━━"
+ echo ""
+ echo "Working tree:"
+ git -c color.status=always status --short 2>/dev/null || echo " Clean"
+ # ... more preview commands
+ ' -- {}"#.to_string();
+
+ let options = SkimOptionsBuilder::default()
+ .height("50%".to_string())
+ .multi(false)
+ .preview(Some(preview_cmd))
+ .preview_window("right:50%".to_string())
+ .header(Some("Enter: switch | Ctrl-/: toggle preview | Esc: cancel".to_string()))
+ .build()?;
+
+ // Run skim and handle selection
+ let output = Skim::run_with(&options, Some(rx));
+ if let Some(out) = output && !out.is_abort {
+ if let Some(selected) = out.selected_items.first() {
+ let identifier = selected.output().to_string();
+ let config = WorktrunkConfig::load()?;
+ let (result, resolved_branch) = handle_switch(&identifier, false, None, false, false, &config)?;
+ handle_switch_output(&result, &resolved_branch, false)?;
+ }
+ }
+ Ok(())
+}
+```
+
+The `WorktreeSkimItem` implements skim's `SkimItem` trait:
+- `text()` returns the formatted display string (what users see)
+- `output()` returns the branch name (what gets selected)
+
+### Available Data
+
+The `gather_list_data()` function provides rich metadata for each worktree through the `ListItem` enum. Here's what's available:
+
+```rust
+pub enum ListItem {
+ Worktree(WorktreeInfo),
+ Branch(BranchInfo), // Only when --branches flag is used
+}
+
+pub struct WorktreeInfo {
+ // Core info
+ pub worktree: worktrunk::git::Worktree, // path, head, branch, locked, prunable
+ pub is_primary: bool,
+
+ // Commit info
+ pub commit: CommitDetails {
+ timestamp: i64,
+ commit_message: String,
+ },
+
+ // Counts vs main branch
+ pub counts: AheadBehind {
+ ahead: usize, // Commits ahead of main
+ behind: usize, // Commits behind main
+ },
+
+ // Working tree changes
+ pub working_tree_diff: (usize, usize), // (lines_added, lines_deleted) vs HEAD
+ pub working_tree_diff_with_main: Option<(usize, usize)>, // vs main branch
+
+ // Branch diff stats
+ pub branch_diff: BranchDiffTotals {
+ diff: (usize, usize), // (lines_added, lines_deleted) in commits ahead of main
+ },
+
+ // Remote tracking
+ pub upstream: UpstreamStatus {
+ remote: Option<String>, // e.g. "origin"
+ ahead: usize, // Commits ahead of remote
+ behind: usize, // Commits behind remote
+ },
+
+ // State info
+ pub worktree_state: Option<String>, // e.g. "MERGING", "REBASING", "(matches main)"
+ pub status_symbols: String, // e.g. "!+↑⇡"
+ pub has_conflicts: bool,
+
+ // CI/PR info (requires --full flag)
+ pub pr_status: Option<PrStatus> {
+ state: String, // "passed", "running", "failed", "conflicts", "no-ci"
+ is_stale: bool, // PR head differs from local
+ pr_number: Option<i32>,
+ pr_url: Option<String>,
+ },
+
+ // Display fields (for JSON output)
+ pub display: DisplayFields,
+ pub working_diff_display: Option<String>,
+}
+```
+
+**Important Note**: Currently `gather_list_data(&repo, false, false, false)` is called with all flags set to `false`:
+- First `false`: Don't include branches without worktrees
+- Second `false`: Don't fetch CI status (expensive network requests)
+- Third `false`: Don't check for merge conflicts (expensive git operations)
+
+This means `pr_status` and `has_conflicts` are always `None`/`false` in the current implementation.
+
+## What We Have Tried
+
+### Iteration 1: Basic Implementation
+- Used skim's default display
+- No preview pane
+- Result: Too minimal, users couldn't see enough context
+
+### Iteration 2: Added Status Symbols
+- Added the status symbols column (8 chars wide)
+- Result: Better, but symbols are cryptic without reference
+
+### Iteration 3: Added Commit Message
+- Show first line of commit message after status symbols
+- Result: Much better context for identifying branches
+
+### Iteration 4: Added Preview Pane
+- Implemented shell-based preview with git commands
+- Shows working tree status, commits, diffs
+- Result: Very helpful but preview is slow (runs git commands for each cursor movement)
+
+### Iteration 5: Column Alignment
+- Calculate max branch name length
+- Use format strings for aligned columns
+- Result: Professional appearance, easier to scan
+
+### What Has Worked Well
+1. **Fuzzy matching** - Users can type partial branch names and find worktrees quickly
+2. **Status symbols** - Compact visual indicators (once users learn them)
+3. **Commit message** - Essential for identifying what each branch is about
+4. **Preview pane** - Very useful but has performance issues
+
+### What Hasn't Worked Well
+1. **Preview performance** - Preview runs git commands for every cursor movement, causing lag with many worktrees
+2. **Limited information density** - Only showing branch name, status symbols, and commit message
+3. **No sorting/filtering** - All worktrees shown in timestamp order (newest commit first)
+4. **Static display** - Can't customize what columns are shown
+5. **No color coding** - Main display is monochrome (preview uses git's colors)
+
+## Current User Experience
+
+**Positive Aspects**:
+- Fast to launch
+- Fuzzy search works well
+- Preview provides detailed context
+- Keyboard-driven workflow
+
+**Pain Points**:
+- Preview lag when rapidly moving through items
+- Can't quickly identify which worktrees are "important" (e.g., have uncommitted work, are behind main)
+- No visual distinction between clean branches and dirty branches
+- Can't filter to "only show worktrees with changes"
+- Branch names can be long, pushing commit messages off screen
+
+## Open Questions & Research Opportunities
+
+### 1. Display Design & Information Architecture
+
+**Question**: What information is most valuable for making switching decisions?
+
+**Current approach**: Branch name + status symbols + commit message
+
+**Alternatives to research**:
+- Should we show ahead/behind counts as numbers? (e.g., `↑3 ↓1` instead of just `↑↓`)
+- Should we show working tree changes as numbers? (e.g., `+52 -12`)
+- Should we use colors in the main display? (e.g., red for branches behind main, yellow for uncommitted changes)
+- Should we show the worktree path? (currently only in preview)
+- Should we show commit age? (e.g., "2d ago")
+- Should we show PR status? (requires network calls)
+
+**Research needed**:
+- How do other fuzzy finders (fzf, telescope.nvim, etc.) handle information density?
+- What do GitHub CLI (`gh`), GitLab CLI (`glab`) show in their interactive pickers?
+- Are there UX studies on optimal information density in terminal interfaces?
+- How do users prioritize information when choosing which branch to work on?
+
+### 2. Preview Pane Performance
+
+**Question**: How can we make the preview pane faster without sacrificing information?
+
+**Current approach**: Shell script that runs 5-6 git commands per preview
+
+**Problems**:
+- Runs every time cursor moves to a new item
+- Each git command has overhead (process spawn, repo traversal)
+- With 20+ worktrees, moving through the list feels sluggish
+
+**Alternatives to research**:
+- **Pre-compute previews**: Generate all previews upfront, cache them
+ - Trade-off: Slower startup, faster navigation
+ - Question: How to keep cache fresh if user has multiple `wt` sessions?
+- **Debounce previews**: Only update preview after cursor stops moving for N milliseconds
+ - Trade-off: Faster navigation, delayed preview
+ - Question: What's the optimal debounce delay?
+- **Async previews**: Start preview computation in background, show "Loading..." placeholder
+ - Trade-off: Complex implementation, better perceived performance
+ - Question: Does skim support async preview updates?
+- **Simplified previews**: Show less information (e.g., skip diff, just show status)
+ - Trade-off: Faster but less useful
+ - Question: What's the minimum viable preview?
+- **Rust-based previews**: Instead of shell script, implement preview in Rust
+ - Trade-off: More complex, potentially faster (no shell overhead)
+ - Question: Can skim previews call back into Rust code?
+
+**Research needed**:
+- How does fzf handle preview performance with expensive commands?
+- Do other fuzzy finders (telescope.nvim, peco, etc.) have solutions for this?
+- What's the performance bottleneck: process spawning or git operations?
+- Can we use libgit2 (via git2-rs) instead of shelling out to git?
+- Does skim have built-in caching or preview optimization features?
+
+### 3. Sorting & Filtering
+
+**Question**: How should worktrees be sorted by default? Should users be able to filter?
+
+**Current approach**: Sorted by commit timestamp (newest first)
+
+**Sorting options to consider**:
+- **By commit timestamp** (current) - Most recently updated branches at top
+- **By creation time** - Order branches by when worktree was created
+- **By name** - Alphabetical
+- **By "importance"** - Custom heuristic (uncommitted changes > ahead of main > recently updated)
+- **By ahead/behind counts** - Branches furthest from main first
+- **By working tree diff** - Branches with most uncommitted changes first
+- **User-configurable** - Let users choose in config file
+
+**Filtering options to consider**:
+- **Show only dirty** - Worktrees with uncommitted changes
+- **Show only ahead** - Worktrees with commits not in main
+- **Show only behind** - Worktrees behind main (need to sync)
+- **Show only with conflicts** - Worktrees that would conflict with main
+- **Smart filter** - Exclude "boring" worktrees (clean, no commits, matches main)
+- **Keyboard toggle** - Press a key to toggle filter on/off
+
+**Research needed**:
+- How do other git tools (magit, lazygit, GitKraken) prioritize branches?
+- What do users typically look for when choosing a branch to work on?
+- Should filtering be done via skim's query syntax or dedicated keyboard shortcuts?
+- Can we implement fuzzy filtering on metadata (e.g., `:dirty` to filter dirty worktrees)?
+
+### 4. Color & Visual Hierarchy
+
+**Question**: Should the main display use colors? How should visual hierarchy work?
+
+**Current approach**: Monochrome display (no colors in main list)
+
+**Alternatives**:
+- **Color by state**: Red for conflicts, yellow for uncommitted, green for clean, blue for ahead
+- **Color by age**: Dim old branches, bright for recent
+- **Color by priority**: Custom heuristic (uncommitted > ahead > behind > clean)
+- **Minimal color**: Only color status symbols, keep text monochrome
+- **Full color**: Color branch names, symbols, and commit messages
+
+**Visual hierarchy questions**:
+- Should current worktree be highlighted? (bold, different color, marker character)
+- Should primary worktree be visually distinct?
+- Should "boring" branches be dimmed? (Like `wt list` does)
+- Should we use icons/emoji beyond status symbols? (e.g., 🏠 for primary, ⭐ for current)
+
+**Research needed**:
+- What color schemes do other terminal UIs use? (lazygit, tig, delta)
+- How do fuzzy finders handle colors? (fzf --ansi, telescope themes)
+- What's the accessibility impact? (color blindness, low contrast terminals)
+- Does skim support ANSI color codes in display text?
+
+### 5. Multi-Action Support
+
+**Question**: Should `wt select` support actions beyond switching?
+
+**Current approach**: Single action (switch on Enter)
+
+**Potential actions**:
+- **Switch** (Enter) - Navigate to worktree
+- **Remove** (Ctrl-X?) - Delete worktree and branch
+- **Merge** (Ctrl-M?) - Merge worktree into main
+- **Create** (Ctrl-C?) - Create new worktree from selected branch
+- **Execute** (Ctrl-E?) - Run command in worktree
+- **Preview toggle** (Ctrl-/) - Already implemented
+- **Multi-select** (Tab?) - Select multiple worktrees for batch operations
+- **Quick actions** - Show action menu for selected item
+
+**Design questions**:
+- Should actions be shown in the header?
+- Should there be a "command palette" mode (press `:` to show actions)?
+- Should multi-select be enabled? What batch operations make sense?
+- Should we show different previews for different actions? (e.g., preview merge conflicts when Merge is selected)
+
+**Research needed**:
+- How do other fuzzy finders handle multi-action interfaces? (telescope.nvim actions, fzf --bind)
+- What's the mental model for keyboard shortcuts? (vim-style, emacs-style, custom?)
+- How to avoid overwhelming users with too many shortcuts?
+- Should actions be discoverable (shown in UI) or documented (in help text)?
+
+### 6. Skim-Specific Capabilities
+
+**Question**: What skim features are we not using that could improve the interface?
+
+**Skim features we're NOT using**:
+- **Multi-select mode** - Allow selecting multiple worktrees
+- **Custom scoring** - Override fuzzy match scoring
+- **Preview position** - top/bottom/left/right
+- **Preview window size** - Currently hardcoded to 50%
+- **Colors** - Skim supports ANSI colors
+- **Custom bindings** - Map keys to custom actions
+- **Query history** - Remember previous searches
+- **Default query** - Pre-populate search
+- **Match highlighting** - Show which parts matched query
+
+**Research needed**:
+- What's the full skim API? (Check skim documentation/examples)
+- What have fzf users found useful that we could port to skim?
+- Are there skim-specific features that fzf doesn't have?
+- How do skim's colors work with ANSI codes?
+- Can we customize skim's UI beyond what we're using?
+
+### 7. Performance & Scalability
+
+**Question**: How does the interface scale to hundreds of worktrees?
+
+**Current state**: Untested with large numbers of worktrees
+
+**Concerns**:
+- Preview performance degrades linearly with item count
+- Display may become unwieldy with 50+ worktrees
+- Fuzzy search performance with large item counts
+- Memory usage with pre-computed data
+
+**Research needed**:
+- What's the performance of skim with 100+ items?
+- Do we need pagination or lazy loading?
+- Should we limit the number of worktrees shown by default?
+- Can we profile where time is spent (data gathering vs display vs preview)?
+- What's a realistic maximum number of worktrees users might have?
+
+### 8. Integration with `wt list`
+
+**Question**: Should `wt select` and `wt list` share more functionality?
+
+**Current state**: `wt select` uses `gather_list_data()` but doesn't expose the same flags
+
+**Possibilities**:
+- Add `--full` flag to `wt select` for CI status / conflict detection
+- Add `--branches` flag to include branches without worktrees
+- Add `--format` flag for different display styles
+- Share sorting/filtering logic between commands
+- Make `wt list` interactive (arrow keys to select, press Enter to switch)
+
+**Design questions**:
+- Should `wt select` be a distinct tool or an interactive mode of `wt list`?
+- What's the mental model: "list then select" or "select from list"?
+- Should flags be consistent across commands or specialized per command?
+
+**Research needed**:
+- How do other CLIs handle the list vs interactive-select pattern?
+- What's the user expectation when switching from `wt list` to `wt select`?
+- Should there be a `wt list --interactive` flag instead of separate command?
+
+## Assumptions We're Making
+
+### Unproven Assumptions (High Risk)
+
+1. **Preview performance is acceptable** - We haven't tested with 20+ worktrees
+ - Load bearing: If preview is too slow, the whole interface feels sluggish
+ - How to validate: Benchmark with varying numbers of worktrees
+
+2. **Status symbols are learnable** - Users will learn what `!+↑⇡` means
+ - Load bearing: If symbols are too cryptic, users won't understand worktree state
+ - How to validate: User testing with developers unfamiliar with the tool
+
+3. **Fuzzy matching on display text is sufficient** - Users don't need to search by status, age, etc.
+ - Load bearing: If users want to filter by metadata, they can't
+ - How to validate: Observe how users try to filter/search
+
+4. **Single selection is the right default** - Multi-select isn't needed
+ - Load bearing: If users want to batch-remove worktrees, they can't
+ - How to validate: Ask users what batch operations they'd want
+
+5. **50% preview size is optimal** - Not too big, not too small
+ - Load bearing: If preview is too small, diffs are unreadable; too large, list is cramped
+ - How to validate: User preference testing, check other tools' defaults
+
+### Validated Assumptions (Low Risk)
+
+1. **Fuzzy matching is valuable** - Users can find worktrees by typing partial names ✓
+2. **Commit message helps identify branches** - Better than just branch name ✓
+3. **Preview pane is useful** - Provides essential context for switching decisions ✓
+4. **Keyboard-driven is preferred** - Faster than mouse-based selection ✓
+
+## What We Need to Decide
+
+### Critical Decisions
+
+1. **Preview performance strategy**: Pre-compute vs debounce vs simplify vs Rust implementation
+2. **Information density**: How much to show in main display vs preview
+3. **Color usage**: Monochrome vs minimal color vs full color
+4. **Sorting default**: Timestamp vs importance vs user-configurable
+
+### Nice-to-Have Decisions
+
+1. **Multi-action support**: Single-purpose vs multi-action interface
+2. **Advanced filtering**: Built-in filters vs query syntax vs none
+3. **Multi-select**: Enable or keep single-select
+4. **Integration strategy**: Keep `wt select` separate vs merge with `wt list`
+
+## Specific Research Questions
+
+We need external research to help answer:
+
+1. **UX Best Practices**:
+ - How do popular fuzzy finders (fzf, telescope.nvim, CtrlP) handle information density?
+ - What visual patterns work best for terminal UIs? (colors, alignment, symbols)
+ - How do users scan long lists of items in terminal interfaces?
+
+2. **Git Tool Patterns**:
+ - How do GitHub CLI (`gh pr list`, `gh repo view`) and GitLab CLI structure their interactive pickers?
+ - What does magit (Emacs) show when selecting branches?
+ - How does lazygit organize its branch list interface?
+ - What information does GitKraken show in its branch list?
+
+3. **Performance Patterns**:
+ - How does fzf optimize preview performance with expensive commands?
+ - Do any fuzzy finders use caching strategies for previews?
+ - What's the standard approach to debouncing in terminal UIs?
+ - Are there benchmarks comparing shell-based vs native preview implementations?
+
+4. **Skim-Specific**:
+ - What's the complete skim API and feature set?
+ - Are there skim-based projects we can learn from? (What do they do well?)
+ - What are skim's performance characteristics with large item counts?
+ - Can skim previews be implemented in Rust code instead of shell scripts?
+
+5. **User Behavior**:
+ - What do developers prioritize when choosing which branch to work on?
+ - How often do developers batch-operate on worktrees vs one-at-a-time?
+ - What's the typical number of concurrent worktrees developers maintain?
+ - Do developers prefer seeing everything at once or filtered views?
+
+## Example Output for Context
+
+Current `wt list` output:
+```
+Branch Status Working ± Main ↕ State Path
+main ./worktrunk
+skim !+ +528 -12 ./worktrunk.skim
+refactor ! +57 -108 ./worktrunk.refactor
+switch- ?! +75 -8 ./worktrunk.switch-
+demo-fix ↓ ↓3 (no commits) ./worktrunk.demo-fix
+
+⚪ Showing 5 worktrees, 3 with changes, 1 behind
+```
+
+Current `wt select` main display:
+```
+main Initial commit
+skim !+ Add skim-based selector
+refactor ! Refactor list rendering
+switch- ?! WIP: switch improvements
+demo-fix ↓ Fix demo crash
+```
+
+Preview pane shows:
+```
+━━━ Branch: skim ━━━
+
+Working tree:
+ M src/commands/select.rs
+A src/commands/select.rs
+
+vs main: ↑2 ↓0
+
+Recent commits:
+a1b2c3d Add skim-based selector
+d4e5f6g Initial implementation
+
+Changes vs main:
+ src/commands/select.rs | 208 +++++++++++++++++++++++
+ 1 file changed, 208 insertions(+)
+
+Diff preview:
++++ b/src/commands/select.rs
+@@ -0,0 +1,208 @@
++use skim::prelude::*;
+...
+```
+
+## Success Criteria
+
+How will we know we've made `wt select` significantly more useful?
+
+1. **Performance**: Preview feels responsive even with 20+ worktrees (subjective: no perceived lag)
+2. **Efficiency**: Users can find and switch to target worktree faster than `wt list` + `wt switch`
+3. **Clarity**: Users understand worktree state without reading documentation
+4. **Flexibility**: Power users can customize sorting/filtering to match their workflow
+5. **Discoverability**: Keyboard shortcuts and capabilities are obvious or easily learned
+
+## Constraints
+
+1. **No external dependencies**: Must use skim (already bundled), can't require fzf or other external tools
+2. **Cross-shell compatibility**: Preview scripts must work in bash, zsh, fish, etc. (use `sh -c`)
+3. **Terminal compatibility**: Must work in various terminal emulators, respect NO_COLOR, etc.
+4. **Performance budget**: Should remain fast even with dozens of worktrees
+5. **Maintain consistency**: Should feel like part of the worktrunk ecosystem (similar to `wt list`, `wt switch`)
+
+## Next Steps
+
+We're looking for **IDEAS and RESEARCH** to help us decide:
+
+1. What information should be in the main display vs preview?
+2. How to optimize preview performance without sacrificing utility?
+3. Should we use colors in the main display? What color scheme?
+4. What sorting/filtering options would be most valuable?
+5. Should we support multi-action workflows or keep it single-purpose?
+6. What can we learn from other fuzzy finders and git tools?
+
+**We are NOT looking for**:
+- Implementation details or code (we'll handle that)
+- PRs or patches
+- Opinions without research backing
+
+**We ARE looking for**:
+- Patterns from other tools that work well (with examples)
+- UX research on terminal interfaces and information density
+- Performance optimization strategies with trade-off analysis
+- User behavior insights from git workflows
+- Comparative analysis of similar tools (fzf, telescope, lazygit, gh, glab)
+- Skim-specific capabilities we're not aware of
+
+---
+
+**Maintainer Note**: This report was generated to seek research assistance. The researcher will only see this document and won't have access to the codebase, so all relevant context has been included above.
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 2d9cc5f96..124afa9b1 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -1,7 +1,7 @@
mod ci_status;
mod columns;
mod layout;
-mod model;
+pub mod model;
mod render;
#[cfg(test)]
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 993b50e6b..f6c1c3f1b 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -8,6 +8,7 @@ pub mod init;
pub mod list;
pub mod merge;
pub mod process;
+pub mod select;
pub mod worktree;
pub use completion::{handle_complete, handle_completion};
@@ -22,6 +23,7 @@ pub use dev::{
pub use init::handle_init;
pub use list::handle_list;
pub use merge::handle_merge;
+pub use select::handle_select;
pub use worktree::{handle_remove, handle_switch};
// Re-export Shell from the canonical location
diff --git a/src/commands/select.rs b/src/commands/select.rs
new file mode 100644
index 000000000..e43dddf36
--- /dev/null
+++ b/src/commands/select.rs
@@ -0,0 +1,377 @@
+use skim::prelude::*;
+use std::borrow::Cow;
+use std::fs;
+use std::path::PathBuf;
+use std::sync::Arc;
+use worktrunk::config::WorktrunkConfig;
+use worktrunk::git::{GitError, GitResultExt, Repository};
+
+use super::list::model::{ListItem, gather_list_data};
+use super::worktree::handle_switch;
+use crate::output::handle_switch_output;
+
+/// Preview modes for the interactive selector
+///
+/// Each mode shows a different aspect of the worktree:
+/// 1. WorkingTree: Uncommitted changes (git diff HEAD --stat)
+/// 2. History: Commit history since diverging from main (git log with merge-base)
+/// 3. BranchDiff: Line diffs in commits ahead of main (git diff --stat main...)
+///
+/// Loosely aligned with `wt list` columns, though not a perfect match:
+/// - Mode 1 corresponds to "Working ±" column
+/// - Mode 2 shows commits (related to "Main ↕" counts)
+/// - Mode 3 corresponds to "Main ± (--full)" column
+///
+/// Note: Order of modes 2 & 3 could potentially be swapped
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum PreviewMode {
+ WorkingTree = 1,
+ History = 2,
+ BranchDiff = 3,
+}
+
+impl PreviewMode {
+ fn from_u8(n: u8) -> Self {
+ match n {
+ 2 => Self::History,
+ 3 => Self::BranchDiff,
+ _ => Self::WorkingTree,
+ }
+ }
+
+ fn read_from_state() -> Self {
+ let state_path = Self::state_path();
+ fs::read_to_string(&state_path)
+ .ok()
+ .and_then(|s| s.trim().parse::<u8>().ok())
+ .map(Self::from_u8)
+ .unwrap_or(Self::WorkingTree)
+ }
+
+ 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-mode-{}", std::process::id()))
+ }
+}
+
+/// Wrapper to implement SkimItem for ListItem
+struct WorktreeSkimItem {
+ display_text: String,
+ branch_name: String,
+ item: Arc<ListItem>,
+}
+
+impl SkimItem for WorktreeSkimItem {
+ fn text(&self) -> Cow<'_, str> {
+ Cow::Borrowed(&self.display_text)
+ }
+
+ fn output(&self) -> Cow<'_, str> {
+ Cow::Borrowed(&self.branch_name)
+ }
+
+ fn preview(&self, _context: PreviewContext<'_>) -> ItemPreview {
+ let mode = PreviewMode::read_from_state();
+ let preview_text = match mode {
+ PreviewMode::WorkingTree => self.render_working_tree_preview(),
+ PreviewMode::History => self.render_history_preview(),
+ PreviewMode::BranchDiff => self.render_branch_diff_preview(),
+ };
+
+ ItemPreview::AnsiText(preview_text)
+ }
+}
+
+impl WorktreeSkimItem {
+ /// Render Mode 1: Working tree preview (uncommitted changes vs HEAD)
+ /// Matches `wt list` "Working ±" column
+ fn render_working_tree_preview(&self) -> String {
+ let mut output = String::new();
+ let repo = Repository::current();
+
+ let Some(wt_info) = self.item.worktree_info() else {
+ output.push_str("No worktree (branch only)\n");
+ return output;
+ };
+
+ let path_str = wt_info.worktree.path.display().to_string();
+
+ // Show working tree changes as --stat (uncommitted changes)
+ if let Ok(diff_stat) =
+ repo.run_command(&["-C", &path_str, "diff", "HEAD", "--stat", "--color=always"])
+ && !diff_stat.trim().is_empty()
+ {
+ output.push_str(&diff_stat);
+ } else {
+ output.push_str("No uncommitted changes\n");
+ }
+
+ output
+ }
+
+ /// Render Mode 3: Branch diff preview (line diffs in commits ahead of main)
+ /// Matches `wt list` "Main ± (--full)" column
+ fn render_branch_diff_preview(&self) -> String {
+ let mut output = String::new();
+ let repo = Repository::current();
+ let counts = self.item.counts();
+
+ if counts.ahead > 0 {
+ let head = self.item.head();
+ let merge_base = format!("main...{}", head);
+ if let Ok(diff_stat) =
+ repo.run_command(&["diff", "--stat", "--color=always", &merge_base])
+ {
+ output.push_str(&diff_stat);
+ } else {
+ output.push_str("No changes vs main\n");
+ }
+ } else {
+ output.push_str("No commits ahead of main\n");
+ }
+
+ output
+ }
+
+ /// Render Mode 2: History preview
+ fn render_history_preview(&self) -> String {
+ const HISTORY_LIMIT: &str = "40";
+
+ let mut output = String::new();
+ let repo = Repository::current();
+
+ let counts = self.item.counts();
+
+ // Show commits since diverging from main, with merge-base boundary
+ if counts.ahead > 0 {
+ // Use --boundary to show the merge-base commit where we diverged
+ let head = self.item.head();
+ let range = format!("main..{}", head);
+ if let Ok(log_output) = repo.run_command(&[
+ "log",
+ "--graph",
+ "--boundary",
+ "--decorate",
+ "--oneline",
+ "--color=always",
+ &range,
+ ]) {
+ output.push_str(&log_output);
+ } else {
+ output.push_str("No commits\n");
+ }
+ } else {
+ // Not ahead of main - just show recent history
+ if let Ok(log_output) = repo.run_command(&[
+ "log",
+ "--graph",
+ "--decorate",
+ "--oneline",
+ "--color=always",
+ "-n",
+ HISTORY_LIMIT,
+ self.item.head(),
+ ]) {
+ output.push_str(&log_output);
+ } else {
+ output.push_str("No commits\n");
+ }
+ }
+
+ output
+ }
+}
+
+pub fn handle_select() -> Result<(), GitError> {
+ let repo = Repository::current();
+
+ // Initialize preview mode state file (default to WorkingTree)
+ let state_path = PreviewMode::state_path();
+ if !state_path.exists() {
+ let _ = fs::write(&state_path, "1");
+ }
+
+ // Gather list data using existing logic
+ let Some(list_data) = gather_list_data(&repo, false, false, false)? else {
+ return Ok(());
+ };
+
+ // Calculate max branch name length for alignment
+ let max_branch_len = list_data
+ .items
+ .iter()
+ .map(|item| item.branch_name().len())
+ .max()
+ .unwrap_or(20);
+
+ // Convert to skim items - store full ListItem for preview rendering
+ let items: Vec<Arc<dyn SkimItem>> = list_data
+ .items
+ .into_iter()
+ .map(|item| {
+ let branch_name = item.branch_name().to_string();
+ let commit_msg = item
+ .commit_details()
+ .commit_message
+ .lines()
+ .next()
+ .unwrap_or("");
+
+ // Build display text with aligned columns
+ let mut display_text = format!("{:<width$}", branch_name, width = max_branch_len);
+
+ // Add status symbols for worktrees (fixed width)
+ let status = if let Some(wt_info) = item.worktree_info() {
+ format!("{:^8}", wt_info.status_symbols)
+ } else {
+ " ".to_string()
+ };
+ display_text.push_str(&status);
+
+ // Add commit message
+ display_text.push_str(" ");
+ display_text.push_str(commit_msg);
+
+ Arc::new(WorktreeSkimItem {
+ display_text,
+ branch_name,
+ item: Arc::new(item),
+ }) as Arc<dyn SkimItem>
+ })
+ .collect();
+
+ // Get state path for key bindings
+ let state_path_str = state_path.display().to_string();
+
+ // Configure skim options with Rust-based preview and mode switching keybindings
+ let options = SkimOptionsBuilder::default()
+ .height("50%".to_string())
+ .multi(false)
+ .preview(Some("".to_string())) // Enable preview (empty string means use SkimItem::preview())
+ .preview_window("right:50%".to_string())
+ .color(Some(
+ "fg:-1,bg:-1,matched:108,current:-1,current_bg:254,current_match:108".to_string(),
+ ))
+ .bind(vec![
+ // Mode switching
+ format!(
+ "1:execute-silent(echo 1 > {})+refresh-preview",
+ state_path_str
+ ),
+ format!(
+ "2:execute-silent(echo 2 > {})+refresh-preview",
+ state_path_str
+ ),
+ format!(
+ "3:execute-silent(echo 3 > {})+refresh-preview",
+ state_path_str
+ ),
+ // Preview scrolling
+ "ctrl-u:preview-page-up".to_string(),
+ "ctrl-d:preview-page-down".to_string(),
+ ])
+ .header(Some(
+ "1: working | 2: commits | 3: diff | ctrl-u/d: scroll | ctrl-/: toggle".to_string(),
+ ))
+ .build()
+ .map_err(|e| GitError::CommandFailed(format!("Failed to build skim options: {}", e)))?;
+
+ // Create item receiver
+ let (tx, rx): (SkimItemSender, SkimItemReceiver) = unbounded();
+ for item in items {
+ tx.send(item)
+ .map_err(|e| GitError::CommandFailed(format!("Failed to send item to skim: {}", e)))?;
+ }
+ drop(tx);
+
+ // Run skim
+ let output = Skim::run_with(&options, Some(rx));
+
+ // Clean up state file
+ let _ = fs::remove_file(&state_path);
+
+ // Handle selection
+ if let Some(out) = output
+ && !out.is_abort
+ && let Some(selected) = out.selected_items.first()
+ {
+ // Get branch name or worktree path from selected item
+ // (output() returns the worktree path for existing worktrees, branch name otherwise)
+ let identifier = selected.output().to_string();
+
+ // Load config
+ let config = WorktrunkConfig::load().git_context("Failed to load config")?;
+
+ // Switch to the selected worktree
+ // handle_switch can handle both branch names and worktree paths
+ let (result, resolved_branch) =
+ handle_switch(&identifier, false, None, false, false, &config)?;
+
+ // Show success message (show shell integration hint if not configured)
+ handle_switch_output(&result, &resolved_branch, false)?;
+ }
+
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_preview_mode_from_u8() {
+ assert_eq!(PreviewMode::from_u8(1), PreviewMode::WorkingTree);
+ assert_eq!(PreviewMode::from_u8(2), PreviewMode::History);
+ assert_eq!(PreviewMode::from_u8(3), PreviewMode::BranchDiff);
+ // Invalid values default to WorkingTree
+ assert_eq!(PreviewMode::from_u8(0), PreviewMode::WorkingTree);
+ assert_eq!(PreviewMode::from_u8(99), PreviewMode::WorkingTree);
+ }
+
+ #[test]
+ fn test_preview_mode_state_file_read_default() {
+ // When state file doesn't exist or is invalid, default to WorkingTree
+ let state_path = PreviewMode::state_path();
+ // Clean up any existing state
+ let _ = fs::remove_file(&state_path);
+
+ assert_eq!(PreviewMode::read_from_state(), PreviewMode::WorkingTree);
+ }
+
+ #[test]
+ fn test_preview_mode_state_file_roundtrip() {
+ // Use a unique test file to avoid conflicts with concurrent tests
+ let test_state_path =
+ std::env::temp_dir().join(format!("wt-select-mode-test-{}", std::process::id()));
+
+ // Write mode 1 (WorkingTree)
+ fs::write(&test_state_path, "1").unwrap();
+ let mode = fs::read_to_string(&test_state_path)
+ .ok()
+ .and_then(|s| s.trim().parse::<u8>().ok())
+ .map(PreviewMode::from_u8)
+ .unwrap_or(PreviewMode::WorkingTree);
+ assert_eq!(mode, PreviewMode::WorkingTree);
+
+ // Write mode 2 (History)
+ fs::write(&test_state_path, "2").unwrap();
+ let mode = fs::read_to_string(&test_state_path)
+ .ok()
+ .and_then(|s| s.trim().parse::<u8>().ok())
+ .map(PreviewMode::from_u8)
+ .unwrap_or(PreviewMode::WorkingTree);
+ assert_eq!(mode, PreviewMode::History);
+
+ // Write mode 3 (BranchDiff)
+ fs::write(&test_state_path, "3").unwrap();
+ let mode = fs::read_to_string(&test_state_path)
+ .ok()
+ .and_then(|s| s.trim().parse::<u8>().ok())
+ .map(PreviewMode::from_u8)
+ .unwrap_or(PreviewMode::WorkingTree);
+ assert_eq!(mode, PreviewMode::BranchDiff);
+
+ // Cleanup
+ let _ = fs::remove_file(&test_state_path);
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index 0251ee1d0..ad8354085 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -34,7 +34,7 @@ use commands::{
handle_config_init, handle_config_list, handle_config_refresh_cache, handle_configure_shell,
handle_dev_ask_approvals, handle_dev_commit, handle_dev_push, handle_dev_rebase,
handle_dev_run_hook, handle_dev_squash, handle_init, handle_list, handle_merge, handle_remove,
- handle_switch,
+ handle_select, handle_switch,
};
use output::{execute_user_command, handle_remove_output, handle_switch_output};
@@ -149,6 +149,9 @@ enum DevCommand {
#[arg(long)]
all: bool,
},
+
+ /// Interactive worktree selector
+ Select,
}
#[derive(Subcommand)]
@@ -604,6 +607,7 @@ fn main() {
} => handle_dev_push(target.as_deref(), allow_merge_commits),
DevCommand::Rebase { target } => handle_dev_rebase(target.as_deref()).map(|_| ()),
DevCommand::AskApprovals { force, all } => handle_dev_ask_approvals(force, all),
+ DevCommand::Select => handle_select(),
},
Commands::List {
format,
diff --git a/templates/bash.sh b/templates/bash.sh
index 4b0104054..0e7858ea9 100644
--- a/templates/bash.sh
+++ b/templates/bash.sh
@@ -86,6 +86,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then
# Commands that need --internal for directory change support
_wt_exec --internal "${args[@]}"
;;
+ dev)
+ # Check if dev subcommand is select
+ if [[ ${{ '{' }}#args[@]} -gt 1 ]] && [[ "${args[1]}" == "select" ]]; then
+ _wt_exec --internal "${args[@]}"
+ else
+ command "$_WORKTRUNK_CMD" "${args[@]}"
+ fi
+ ;;
*)
# All other commands pass through directly
command "$_WORKTRUNK_CMD" "${args[@]}"
diff --git a/templates/elvish.elv b/templates/elvish.elv
index d182949bf..177124b36 100644
--- a/templates/elvish.elv
+++ b/templates/elvish.elv
@@ -92,6 +92,13 @@ if (or (has-external wt) (has-env WORKTRUNK_BIN)) {
# Commands that need --internal for directory change support
var rest-args = $filtered-args[1..]
_wt_exec --internal $subcommand $@rest-args
+ } elif (eq $subcommand "dev") {
+ # Check if dev subcommand is select
+ if (and (> (count $filtered-args) 1) (eq $filtered-args[1] "select")) {
+ _wt_exec --internal $@filtered-args
+ } else {
+ e:$_WORKTRUNK_CMD $@filtered-args
+ }
} else {
# All other commands pass through directly
e:$_WORKTRUNK_CMD $@filtered-args
diff --git a/templates/fish.fish b/templates/fish.fish
index da0607cac..c1001e86d 100644
--- a/templates/fish.fish
+++ b/templates/fish.fish
@@ -121,6 +121,13 @@ if type -q {{ cmd_prefix }}; or set -q WORKTRUNK_BIN
case switch remove merge
# Commands that need --internal for directory change support
_wt_exec --internal $args
+ case dev
+ # Check if dev subcommand is select
+ if test (count $args) -gt 1; and test "$args[2]" = "select"
+ _wt_exec --internal $args
+ else
+ command $_WORKTRUNK_CMD $args
+ end
case '*'
# All other commands pass through directly
command $_WORKTRUNK_CMD $args
diff --git a/templates/nushell.nu b/templates/nushell.nu
index 21c7657b9..0a8f7a717 100644
--- a/templates/nushell.nu
+++ b/templates/nushell.nu
@@ -76,6 +76,16 @@ if (which wt | is-not-empty) or ($env.WORKTRUNK_BIN? | is-not-empty) {
let exit_code = (_wt_exec $cmd ...$internal_args)
return $exit_code
}
+ "dev" => {
+ # Check if dev subcommand is select
+ let dev_subcommand = ($filtered_args | get 1? | default "")
+ if $dev_subcommand == "select" {
+ let exit_code = (_wt_exec $cmd --internal ...$filtered_args)
+ return $exit_code
+ } else {
+ ^$cmd ...$filtered_args
+ }
+ }
_ => {
# All other commands pass through directly
^$cmd ...$filtered_args
diff --git a/templates/powershell.ps1 b/templates/powershell.ps1
index 49eda222c..efdd2d0e2 100644
--- a/templates/powershell.ps1
+++ b/templates/powershell.ps1
@@ -95,6 +95,16 @@ if ((Get-Command wt -ErrorAction SilentlyContinue) -or $env:WORKTRUNK_BIN) {
$exitCode = _wt_exec -Command $cmd --internal $subcommand @restArgs
return $exitCode
}
+ "dev" {
+ # Check if dev subcommand is select
+ if ($filteredArgs.Count -gt 1 -and $filteredArgs[1] -eq "select") {
+ $exitCode = _wt_exec -Command $cmd --internal @filteredArgs
+ return $exitCode
+ } else {
+ & $cmd @filteredArgs
+ return $LASTEXITCODE
+ }
+ }
default {
# All other commands pass through directly
& $cmd @filteredArgs
diff --git a/templates/xonsh.xsh b/templates/xonsh.xsh
index a2f2e34ff..d46104e77 100644
--- a/templates/xonsh.xsh
+++ b/templates/xonsh.xsh
@@ -76,6 +76,13 @@ if shutil.which("wt") is not None or os.environ.get('WORKTRUNK_BIN'):
# Commands that need --internal for directory change support
rest_args = filtered_args[1:]
return _wt_exec(["--internal", subcommand] + rest_args, cmd=cmd)
+ elif subcommand == "dev":
+ # Check if dev subcommand is select
+ if len(filtered_args) > 1 and filtered_args[1] == "select":
+ return _wt_exec(["--internal"] + filtered_args, cmd=cmd)
+ else:
+ result = ![@(cmd) @(filtered_args)]
+ return result.returncode
else:
# All other commands pass through directly
result = ![@(cmd) @(filtered_args)]
diff --git a/templates/zsh.zsh b/templates/zsh.zsh
index bed88e1c4..35e1e13a4 100644
--- a/templates/zsh.zsh
+++ b/templates/zsh.zsh
@@ -67,6 +67,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then
shift
_wt_exec --internal "$subcommand" "$@"
;;
+ dev)
+ # Check if dev subcommand is select
+ if [[ "$2" == "select" ]]; then
+ _wt_exec --internal "$@"
+ else
+ command "$_WORKTRUNK_CMD" "$@"
+ fi
+ ;;
*)
# All other commands pass through directly
command "$_WORKTRUNK_CMD" "$@"
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index ee30c0696..99c6e1bff 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/.tmp4TfyPE/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpwN6n08/test-config.toml
---
success: true
exit_code: 0
@@ -109,6 +109,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then
# Commands that need --internal for directory change support
_wt_exec --internal "${args[@]}"
;;
+ dev)
+ # Check if dev subcommand is select
+ if [[ ${#args[@]} -gt 1 ]] && [[ "${args[1]}" == "select" ]]; then
+ _wt_exec --internal "${args[@]}"
+ else
+ command "$_WORKTRUNK_CMD" "${args[@]}"
+ fi
+ ;;
*)
# All other commands pass through directly
command "$_WORKTRUNK_CMD" "${args[@]}"
@@ -214,6 +222,9 @@ _wt() {
wt__dev,run-hook)
cmd="wt__dev__run__hook"
;;
+ wt__dev,select)
+ cmd="wt__dev__select"
+ ;;
wt__dev,squash)
cmd="wt__dev__squash"
;;
@@ -354,7 +365,7 @@ _wt() {
return 0
;;
wt__dev)
- opts="-v -h --verbose --help run-hook commit squash push rebase ask-approvals"
+ opts="-v -h --verbose --help run-hook commit squash push rebase ask-approvals select"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -437,6 +448,20 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
+ wt__dev__select)
+ opts="-v -h --verbose --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
wt__dev__squash)
opts="-f -v -h --force --no-verify --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index b4ce27ed3..bfaefa54b 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -16,7 +16,7 @@ info:
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpdie7vF/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmplxtrjb/test-config.toml
---
success: true
exit_code: 0
@@ -144,6 +144,13 @@ if type -q wt; or set -q WORKTRUNK_BIN
case switch remove merge
# Commands that need --internal for directory change support
_wt_exec --internal $args
+ case dev
+ # Check if dev subcommand is select
+ if test (count $args) -gt 1; and test "$args[2]" = "select"
+ _wt_exec --internal $args
+ else
+ command $_WORKTRUNK_CMD $args
+ end
case '*'
# All other commands pass through directly
command $_WORKTRUNK_CMD $args
@@ -244,14 +251,15 @@ zsh\t''"
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -s f -l force -d 'Skip confirmation prompt'
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "run-hook" -d 'Run a project hook for testing'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "commit" -d 'Commit changes with LLM-generated message'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "squash" -d 'Squash commits with LLM-generated message'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "push" -d 'Push changes to target branch'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "rebase" -d 'Rebase current branch onto target branch'
-complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals" -f -a "ask-approvals" -d 'Approve commands in the project config (shows unapproved by default)'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "run-hook" -d 'Run a project hook for testing'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "commit" -d 'Commit changes with LLM-generated message'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "squash" -d 'Squash commits with LLM-generated message'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "push" -d 'Push changes to target branch'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "rebase" -d 'Rebase current branch onto target branch'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "ask-approvals" -d 'Approve commands in the project config (shows unapproved by default)'
+complete -c wt -n "__fish_wt_using_subcommand dev; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals select" -f -a "select" -d 'Interactive worktree selector'
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from run-hook" -s f -l force -d 'Skip command approval prompts'
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from run-hook" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from run-hook" -s h -l help -d 'Print help'
@@ -272,6 +280,8 @@ complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_fr
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from ask-approvals" -l all -d 'Show all commands including already-approved ones'
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from ask-approvals" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from ask-approvals" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from select" -s v -l verbose -d 'Enable verbose output (show git commands and debug info)'
+complete -c wt -n "__fish_wt_using_subcommand dev; and __fish_seen_subcommand_from select" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand list" -l format -d 'Output format' -r -f -a "table\t'Human-readable table format'
json\t'Machine-readable JSON with display fields (includes styled unicode for rendering)'"
complete -c wt -n "__fish_wt_using_subcommand list" -l branches -d 'Include branches without worktrees'
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 25f09aebe..29368b2e3 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/.tmpF1Pxjb/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmptrPwrW/test-config.toml
---
success: true
exit_code: 0
@@ -90,6 +90,14 @@ if command -v wt >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; then
shift
_wt_exec --internal "$subcommand" "$@"
;;
+ dev)
+ # Check if dev subcommand is select
+ if [[ "$2" == "select" ]]; then
+ _wt_exec --internal "$@"
+ else
+ command "$_WORKTRUNK_CMD" "$@"
+ fi
+ ;;
*)
# All other commands pass through directly
command "$_WORKTRUNK_CMD" "$@"
@@ -303,6 +311,14 @@ _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
+;;
+(select)
+_arguments "${_arguments_options[@]}" : \
+'-v[Enable verbose output (show git commands and debug info)]' \
+'--verbose[Enable verbose output (show git commands and debug info)]' \
+'-h[Print help]' \
+'--help[Print help]' \
+&& ret=0
;;
esac
;;
@@ -457,6 +473,7 @@ _wt__dev_commands() {
'push:Push changes to target branch' \
'rebase:Rebase current branch onto target branch' \
'ask-approvals:Approve commands in the project config (shows unapproved by default)' \
+'select:Interactive worktree selector' \
)
_describe -t commands 'wt dev commands' commands "$@"
}
@@ -485,6 +502,11 @@ _wt__dev__run-hook_commands() {
local commands; commands=()
_describe -t commands 'wt dev run-hook commands' commands "$@"
}
+(( $+functions[_wt__dev__select_commands] )) ||
+_wt__dev__select_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt dev select commands' commands "$@"
+}
(( $+functions[_wt__dev__squash_commands] )) ||
_wt__dev__squash_commands() {
local commands; commands=()