Repository navigation
feat(switch): run the interactive picker on Windows - #3217
Conversation
Switch the preview-tab keybindings (alt-1..7 jump; tab/shift-tab cycle) from skim execute-silent shell commands (echo/tr/mv through a per-process state file) to native Action::Custom callbacks inserted into skim's keymap. The active tab is now a process-wide in-memory AtomicU8; each callback sets it and returns Event::RunPreview. skim runs keybind commands through the platform shell (cmd.exe on Windows, no tr/mv), so those bindings were the blocker to running the picker on Windows. skim 4.x (the ratatui/crossterm rewrite already in use) supports Windows, so drop the cfg(unix) gate on the picker and the transitive unix gates on its deps (GitHubPrInfo, open_pr_status, the column grid, ShowConfig, PickerProgressHandler, format_aligned, generate_summary). Removes the ModeWatcher file-poller, the state file, shell_escape::unix, and print_windows_picker_unavailable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
This won't compile on Windows yet — the picker module is now built on every platform, but its dependency stack isn't.
skim, ratatui, ansi-to-tui, and tokio are still declared under [target.'cfg(unix)'.dependencies] in Cargo.toml (which this PR doesn't touch). With mod picker no longer #[cfg(unix)], src/commands/picker/mod.rs's unconditional use skim::prelude::*; (plus the ratatui / ansi_to_tui / tokio imports in items.rs / prs.rs) resolve against crates that aren't in the Windows graph, so the test (windows) build will fail with unresolved-import errors.
Confirmed against the merged tree without compiling — the four crates resolve for unix but not for the Windows target:
Verification
$ cargo metadata --filter-platform x86_64-pc-windows-msvc --features cli \
| jq -r '[.packages[].name] | map(select(. == "skim" or . == "ratatui" or . == "ansi-to-tui" or . == "tokio")) | unique | join(", ")'
# (empty)
$ cargo metadata --filter-platform x86_64-unknown-linux-gnu --features cli \
| jq -r '[.packages[].name] | map(select(. == "skim" or . == "ratatui" or . == "ansi-to-tui" or . == "tokio")) | unique | join(", ")'
ansi-to-tui, ratatui, skim, tokioThe fix is to move those four optional = true deps out of [target.'cfg(unix)'.dependencies] and into the main [dependencies] table — they're already pulled in only via the cli feature's dep: entries, so nothing else changes. nix and signal-hook stay unix-only (the picker doesn't use them; they're for signal handling elsewhere).
That move is the necessary prerequisite; whether skim 4.8 + frizbee then build cleanly on the MSVC target is what the Windows CI leg will confirm. The Cargo.toml change is outside this PR's diff — want me to push a commit moving the four deps?
Everything else reads well: the AtomicU8 PREVIEW_MODE replacing the per-pid state file, the native Action::Custom keybindings replacing the echo/tr/mv shell binds, and the ModeWatcher removal all hang together, and PreviewMode's 1..=7 discriminants line up with from_u8 / next / prev.
# Conflicts: # src/commands/picker/mod.rs # src/commands/picker/preview.rs
The picker's skim/ratatui/ansi-to-tui/tokio dependencies were declared under [target.'cfg(unix)'.dependencies], so they were absent from the Windows dependency graph and the now-ungated picker failed to compile there (74+ "cannot find crate `skim`" errors). They're platform-neutral (skim 4.x is the ratatui/crossterm rewrite), so move them to the main [dependencies] table; nix and signal-hook stay unix-only. Also ungate the SwitchPipeline re-export (commands/worktree/mod.rs), which the picker imports on every platform. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
PR #3217 made `wt switch`'s interactive picker run on Windows, but its tests stayed `#[cfg(unix)]` — so the Windows CI leg proved the picker *compiled* without ever exercising its runtime. This ungates them so Windows CI drives the real thing. **What's ungated** (the test infra — `mock_commands`, the ConPTY handling in `tests/common/pty.rs` — was already cross-platform, so this is largely a gate flip): - `switch_picker_dry_run.rs` — the headless dry-run pipeline (collect → render → preview cache → summary spawn → warning drain). - The `--prs` dry-run tests in `switch.rs` — forge fetch + row render via the cross-platform mock `gh`/`glab`. - The two requires-tty snapshots — the no-TTY bail is uniform across platforms. - `switch_picker.rs` — the PTY/vt100 TUI snapshot tests. **Test-quality fix folded in:** the four `--prs` dry-run tests asserted only `output.status.success()`, but the fetch path is fail-soft (any error → stashed warning → exit 0). On a platform where the mock didn't resolve they would pass vacuously. They now assert the fetched row actually rendered (a `pr:42`/`mr:7` preview-cache entry, or the empty-list warning). **Also:** `/bin/cat` → `cat` in the summary test (resolves via the platform shell on Unix and Git Bash alike); removed the stale "picker is Unix-only" line that #3217 left in the `wt switch` docs (and regenerated the help snapshot). **Windows results (first full run):** of the ~50 ungated tests, 46 passed on Windows on the first run — including every PTY/vt100 snapshot test (skim renders byte-identically under ConPTY), the accept-path drain tests, and the `cat`-via-Git-Bash summary test. Two issues surfaced and are handled here: - The three interactive `--prs` picker tests failed because the test helper `mock_forge_env` joined mock-bin onto `PATH` with a hardcoded `:` separator — malformed on Windows (`;`), so the mock `gh.exe`/`glab.exe` was never found. Fixed to use `std::env::join_paths` (OS-aware), matching the dry-run path's helper. - `test_switch_picker_pre_switch_hook_requires_approval` exits 1 instead of 0 on Windows: declining the hook returns `Ok` on both platforms, so the failure is in the interactive approval prompt's stdin handoff after skim releases the ConPTY. Not reproducible locally — `#[cfg_attr(windows, ignore)]` with a TODO until a Windows box can debug it (still compiles on Windows, runs on Unix). This is a genuine picker-on-Windows gap surfaced by this work, tracked for follow-up. > _This was written by Claude Code on behalf of max_ --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Release v0.62.0 — minor bump (`cargo semver-checks` reports a breaking library-API change — `ListConfig.columns` added a public field, which requires at least a minor pre-1.0 — plus many new features). ### Highlights - **`wt switch --prs`** — browse open PRs/MRs in the interactive picker, with a live CI/review column and `pr` / `comments` / `log` preview tabs ([#3128](#3128)). [Docs](https://worktrunk.dev/switch/) - **Interactive picker now runs on Windows** ([#3217](#3217)). - **`main…±` diff column shows by default** in `wt list`; `--full` now adds only the off-machine columns (CI status, LLM summaries) ([#3236](#3236)). - **`[list] columns`** selects and orders the columns `wt list` renders ([#3141](#3141)). - **`wt config state logs profile`** performance profiler ([#3184](#3184)). - Picker keyboard shortcuts (copy / open / refresh) and the `Alt-x` removal rework, fish completion-recursion fixes, `CLAUDE_CONFIG_DIR` support, and more. **Breaking:** in the picker, remove moved from `Alt-r` to `Alt-x` (`Alt-r` now refreshes). Two "Still waiting" entries ([#3178](#3178), [#3183](#3183)) were moved here from 0.61.0 — they landed after the v0.61.0 tag, so they ship in 0.62.0. The changelog also documents the `Alt-x` removal rework ([#3262](#3262)); the tag will be placed on the `main` tip that includes both this release commit and #3262. Full notes in the `CHANGELOG.md` diff. Data-loss surface review of the cumulative diff in progress; the keyword pass came back clean (the new `Alt-x` removal uses safe variants — `SafeDelete`, no force, approval-gated). > _This was written by Claude Code on behalf of max_
worktrunk 0.62.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## Release Notes ### Improved - **Browse open PRs/MRs in the `wt switch` picker, with live CI**: The picker now streams a live CI/review-status column per row — priming from the local cache, then fetching live (it previously showed only cached numbers with no network). A new `--prs` flag adds the repository's open PRs (GitHub) / MRs (GitLab) as rows alongside your worktrees, each with `pr` / `comments` / `log` preview tabs loaded from the forge in the background; selecting one fetches its branch and switches. Rows whose branch is already shown aren't duplicated, so `--prs` differs from plain `wt switch` only by the extra rows. [Docs](https://worktrunk.dev/switch/) ([#3128](max-sixty/worktrunk#3128), [#3169](max-sixty/worktrunk#3169), [#3189](max-sixty/worktrunk#3189), [#3252](max-sixty/worktrunk#3252)) - **`main…±` diff column shows by default in `wt list`**: The `main…±` column (lines changed since the merge-base with the default branch) now renders in the default `wt list` and picker, served from a persistent cache rather than a history walk. `--full` now adds only the columns that reach off-machine — CI status and LLM branch summaries — and `wt list --format=json` populates `main.diff` for every item, not just under `--full`. ([#3236](max-sixty/worktrunk#3236)) - **`[list] columns` selects and orders the columns `wt list` shows**: A new `[list] columns` user-config key (also settable via `--config-set`) takes an ordered array of column names — built-in (`branch`, `status`, `ci`, `path`, …) and `[list.custom-columns]` headers alike — and renders exactly those, in that order. Where v0.61.0's custom columns *add* columns, this *selects and reorders* the whole set; omit the key for the default layout. (`WORKTRUNK__LIST__COLUMNS` isn't supported yet and warns if set.) ([#3141](max-sixty/worktrunk#3141)) - **Picker PR preview shows full PR/MR detail**: The `pr` tab now renders the PR/MR title, markdown description, author, draft state, comment count, bold branch name, and underlined URL for any row whose branch has an open PR — not just `--prs` rows — and the `comments` tab fetches the real thread. The title and description ride the CI fetch the picker already makes; the comment thread is fetched lazily in the background, once per row. ([#3167](max-sixty/worktrunk#3167), [#3197](max-sixty/worktrunk#3197), [#3223](max-sixty/worktrunk#3223), [#3195](max-sixty/worktrunk#3195), [#3231](max-sixty/worktrunk#3231)) - **Interactive picker runs on Windows**: The `wt switch` picker was Unix-only because its preview-tab keys shelled out through a per-process state file `cmd.exe` lacks; tab state moved to an in-memory atomic with native skim callbacks, lifting the platform gate. ([#3217](max-sixty/worktrunk#3217)) - **Picker keyboard shortcuts**: `Alt-y` copies the selected branch name, `Alt-o` opens the row's PR/MR in the browser, and `Alt-r` refreshes the list (picking up worktrees created or removed elsewhere). (Breaking: in the picker, remove moved from `Alt-r` to `Alt-x`) ([#3233](max-sixty/worktrunk#3233)) - **Picker uses the full terminal**: List height scales with the terminal (a roughly even split with the preview, minimum 3 rows) instead of a fixed 12-row cap, the table lays out at full width so toggling the preview off with `Alt-p` reveals the freed columns with no reflow, and a scrollbar appears when the list overflows. ([#3205](max-sixty/worktrunk#3205), [#3214](max-sixty/worktrunk#3214), [#3198](max-sixty/worktrunk#3198)) - **Picker filters on more of each row**: Typing a gutter sigil filters by row kind (`+` for linked worktrees, `@` for the current one), the fuzzy matcher ranks on the distinguishing path segment rather than the shared parent prefix, and rows with a PR/MR also match on its number, title, and author. ([#3143](max-sixty/worktrunk#3143), [#3208](max-sixty/worktrunk#3208), [#3252](max-sixty/worktrunk#3252)) - **Picker visual polish**: The legend recolored to dim-cyan and reordered so navigation leads, and preview loading placeholders moved to the dim-hint style (`↳` transient, `○` settled, `▲` failed). ([#3237](max-sixty/worktrunk#3237), [#3253](max-sixty/worktrunk#3253)) - **"Still waiting" status for slow commit-message generation**: A configured `commit.generation` command captures stdout, so a slow or hung LLM previously showed nothing while `wt step commit`/`squash` waited. After a 2s delay worktrunk now shows a dim, in-place `○ Waiting for the commit message (Ns)` status, escalating at 10s to reveal the exact shell-escaped invocation in a gutter beneath it; the block clears on completion, mirroring `wt list`'s stall footer. ([#3178](max-sixty/worktrunk#3178)) - **"Still waiting" status extended to more slow commands**: The same waiting status now covers three more foreground commands that were silent while a captured subprocess ran — the `wt config show --full` commit-generation self-test, the `wt switch pr:`/`mr:` host lookup, and the `wt config show --full` version check. The version check no longer caps its fetch at an aggressive 5s, instead showing the status while a slow-but-working request completes (with a generous ceiling so a non-interactive run can't hang). ([#3183](max-sixty/worktrunk#3183)) - **`wt config state logs profile` performance profiler**: A new subcommand turns a `-vv` `[wt-trace]` capture (a path argument, `-` for stdin, or the default `trace.log`) into a performance profile: subprocess time by command shape, the slowest calls, parallelism and peak concurrency, redundant cache-miss re-runs, and — for `wt list`/picker captures — derived latencies and a collect timeline. `--format=json` emits the same data, and every `-vv` bug-report bundle now inlines a rendered profile. ([#3184](max-sixty/worktrunk#3184), [#3186](max-sixty/worktrunk#3186)) - **`WORKTRUNK_VERBOSE` env var**: `WORKTRUNK_VERBOSE=0|1|2` mirrors `-v`/`-vv`, combined with any flag via `max` (the env sets a floor the flag can raise). Unlike the flags it's honored on the shell-completion path, which returns before flag parsing — so a slow tab-completion can be profiled for the first time. ([#3166](max-sixty/worktrunk#3166)) - **Aliases inherit the wrapped command's completion**: An alias that forwards `{{ args }}` to a single `wt` command (`co = "wt switch {{ args }}"`) now completes that command's arguments and flags — `wt co <Tab>` completes branches like `wt switch <Tab>` — instead of a generic stub. Bare dispatchers and multi-`{{ args }}` aliases keep the stub. ([#3172](max-sixty/worktrunk#3172), thanks @yzx9) - **`wt step copy-ignored --require-include`**: A new `--require-include` flag makes the copy a no-op unless a `.worktreeinclude` file exists in the source worktree (matching Claude Code desktop, where that file is required), reporting why it skipped as a hint in text mode and a `reason` field in `--format=json`. ([#3196](max-sixty/worktrunk#3196), thanks @yzx9) - **`wt step tether` honors `-C`**: The global `-C <path>` flag now sets the tethered command's working directory (`wt step tether -C frontend -- npm run dev`); teardown still watches the worktree root, so the command is reaped when the worktree is removed. ([#3207](max-sixty/worktrunk#3207)) - **Statusline rate-limit pace color grades by severity**: The pace segment's color now deepens (dim → dim-yellow → yellow) with the projected throttling severity, so an early-window burst stays muted while a costly projected lockout stands out. The displayed pace number is unchanged. ([#3229](max-sixty/worktrunk#3229)) ### Fixed - **Picker `Alt-x` removal updates the row in place**: Removing a worktree no longer re-collects the whole list (a flicker that reset the cursor to the top): an unmerged worktree's row morphs into a branch-only row while the worktree is removed in the background, and a merged worktree's row drops with the cursor landing on the row that slid up. A removal that can't safely happen — the current or main worktree, or a dirty or locked one — is declined with the same diagnostic `wt remove` prints, rather than a dead keypress or a disruptive `cd` home. The post-removal cursor lands by row identity, so it stays correct even under an active filter. ([#3262](max-sixty/worktrunk#3262), [#3199](max-sixty/worktrunk#3199), [#3211](max-sixty/worktrunk#3211), [#3225](max-sixty/worktrunk#3225)) - **Picker preview refreshes when its background fetch lands**: A diff/log/PR-view fetch that completed after its triggering keystroke used to sit unshown until the next keypress; the pane now updates on its own when the fetch lands. ([#3247](max-sixty/worktrunk#3247)) - **Picker rows stay aligned while filtering**: Typing a filter no longer slides the matched row left and drops its leading sigil, and `Alt-l`/`Alt-h` no longer scroll the list off its gutter. ([#3213](max-sixty/worktrunk#3213), [#3226](max-sixty/worktrunk#3226)) - **fish completions no longer recurse to the call-stack limit**: With worktrunk's fish lazy-load wrapper installed, co See merge request: Harmonybrew/homebrew-core!12862
Run the
wt switchinteractive picker on WindowsThe picker was gated
#[cfg(unix)]because its preview-tab switching (alt-1…7 jump to a tab; tab/shift-tab cycle) was implemented as skimexecute-silentkeybindings that shelled out toecho/tr/mvthrough a per-process state file. skim runs keybind commands through the platform shell —cmd.exeon Windows, which has neithertrnormv— so that was the hard blocker. skim 4.x (the ratatui/crossterm rewrite worktrunk already depends on) supports Windows.This replaces the shell keybindings with native handling: the active tab is now a process-wide in-memory
AtomicU8(PreviewStateData), and the keys are bound toAction::Customcallbacks inserted directly into skim'soptions.keymap(resolved with skim's ownparse_key, so they match its event-loop lookup exactly). Each callback sets the mode and returnsEvent::RunPreview. This drops the state file, theModeWatcherbackground poller, andshell_escape::unix— a net simplification on every platform, not just a Windows shim.With the shell dependency gone, the
#[cfg(unix)]gate comes off the whole picker, along with the now-stale gates on its dependencies — both in source (GitHubPrInfo,open_pr_status,SwitchPipeline, the column-grid types,ShowConfig,PickerProgressHandler,format_aligned,generate_summary) and inCargo.toml, where the picker's TUI stack (skim/ratatui/ansi-to-tui/tokio) moved out of[target.'cfg(unix)'.dependencies]into the main table so it's present in the Windows dependency graph. The FAQ is updated accordingly.Where to look
src/commands/picker/preview.rs—PreviewStateDatais now in-memory;PreviewMode::next/prevrotation.src/commands/picker/mod.rs—install_preview_tab_keybindings(the native bindings) and aModeWatcher-freerun_skim.Cargo.toml— TUI deps relocated out of the unix-only target table.src/commands/{mod,worktree/mod,worktree/switch}.rs,src/main.rs— picker /SwitchPipelinegate removal.src/commands/list/{ci_status,layout,collect,render}.rs,src/summary.rs— transitive gate / dead-code-suppression removal.Testing
Unit tests cover the rotation logic (
PreviewMode::next/prev) and the keymap wiring; the existing PTY integration tests intests/integration_tests/switch_picker.rsdrive the real picker and assert tab switching end-to-end (alt-N jump, tab/shift-tab cycle + wrap). CI is green on all three platforms —test (windows)confirms skim 4.8 + frizbee and their transitive deps compile and the suite passes on Windows MSVC, which is the question this PR set out to answer.🤖 Generated with Claude Code