Repository navigation
fix(picker): stop first-keystroke freeze - #3087
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Design and implementation look right — the diagnosis (skim's matcher starving on the same global pool the collect+preview flood blocks) and fix (route the git-heavy work through a dedicated pool, mirroring COPY_POOL/REMOVE_POOL) are clean, and the docstring sweep across collect, picker/mod, preview_cache, preview_orchestrator, and progressive_handler is thorough. Nice catch on rayon::spawn_fifo inheriting the calling worker's pool — that's exactly the wart that would have re-leaked the Log refresh task to the global pool.
One blocker before this can land: codecov/patch is failing on the new COLLECT_POOL initializer. The only uncovered added line is src/commands/list/collect/mod.rs:334 — the 0 branch when RAYON_NUM_THREADS is set. Per the repo's CLAUDE.md, codecov/patch is a merge gate even though GitHub marks it non-required.
The cleanest fix is to factor the env-var-vs-default logic out of the LazyLock closure into a small pure helper that takes the env var as a parameter, then add a one-line test. That also de-duplicates the identical pattern in main::init_rayon_thread_pool (currently uncovered there too for the same reason).
Want me to push that as a fixup commit?
|
nice! thanks a lot @bendrucker ! |
Release v0.59.0 (minor). The bump is minor because two backward-incompatible behavior changes ship: in the `wt switch` picker, `1`–`5` no longer switch preview tabs (digits now filter; tabs move to `Alt-1`–`Alt-5` / `Tab`); and `wt step eval --dry-run` is removed in favor of `-v`. `cargo semver-checks` reports no library API breakage. ### Highlights - **Improved**: picker frees digit keys for filtering (preview tabs to `Alt`); squash templates use `commit_details` instead of the deprecated `commits`; `wt step eval -v` lists template variables. - **Fixed**: picker no longer freezes on the first keystroke with many worktrees (#3087, thanks @bendrucker; fixes #2926, thanks @mahume for reporting); tab-completion covers all hook types; Ctrl-C on a concurrent alias reports the right exit code. See `CHANGELOG.md` for the full set. ### Bundled test fix This PR also carries one non-release commit: `test(ci_status): cover '?' worker-thread label in snapshot filter`. The `test_list_full_with_invalid_configured_platform` snapshot filter only normalized `[a-zA-Z]` worker-thread labels, but `label_for_thread_index` emits `?` for thread IDs above 52. On high-core machines the rayon pools span enough threads to hit that, so the gate failed locally (CI's low core count never triggers it). The filter now covers the full label alphabet. Test-only; not in the changelog. > _This was written by Claude Code on behalf of max_ --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk 0.59.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 - **Picker frees digit keys for filtering; preview tabs move to `Alt`**: In the `wt switch` picker, plain digits now go to the filter, so a branch name with a number in it can be typed directly. Preview tabs jump with `Alt-1`–`Alt-5` or cycle with `Tab`/`Shift-Tab`. (Breaking: `1`–`5` no longer switch preview tabs) ([#3079](max-sixty/worktrunk#3079)) - **Squash templates use `commit_details` instead of `commits`**: The squash commit-message template's `{{ commits }}` variable (commit subjects) is deprecated in favor of `{{ commit_details }}`, which renders as the bare subject when printed directly and also exposes `.subject` and `.body`. `wt config update` migrates `commits` to `commit_details` as a plain rename. ([#2985](max-sixty/worktrunk#2985)) - **`wt step eval -v` lists template variables**: `wt step eval -v` now prints the available template variables on stderr in the gutter style, above the template-expansion view. That expansion (also shown by `wt switch -v`, hooks, aliases, and `wt -v list`) renders the template and its result as separate labeled `source` / `result` blocks rather than a shared gutter. The result still goes to stdout, so `$(wt step eval …)` is unchanged. Since `eval` mutates nothing and is experimental, its `--dry-run` flag (which dumped the raw variable context) is removed rather than deprecated. ([#3078](max-sixty/worktrunk#3078), [#3099](max-sixty/worktrunk#3099)) ### Fixed - **Picker no longer freezes on the first keystroke**: With many worktrees, typing the first character in the `wt switch` picker locked the UI for several seconds. The fuzzy matcher shares rayon's global thread pool with worktrunk's git collection, which floods it with blocking subprocess calls, so the matcher queued behind them. Collection and preview work now run on a dedicated pool, keeping the matcher responsive. ([#3087](max-sixty/worktrunk#3087), thanks @bendrucker; fixes [#2926](max-sixty/worktrunk#2926), thanks @mahume for reporting) - **Tab-completion covers all hook types**: `wt hook <type> <Tab>` completed configured command names for only seven of the ten hook types; `pre-switch`, `post-switch`, and `post-remove` returned nothing. Completion now derives the type from the canonical hook list, so every type completes its command names. ([#3070](max-sixty/worktrunk#3070)) - **Ctrl-C on a concurrent alias reports the right exit code**: Interrupting `wt step <concurrent-alias>` could report exit 143 (SIGTERM) instead of 130 (SIGINT), because a per-child SIGINT → SIGTERM → SIGKILL escalation could land a SIGTERM on a child during the grace window; the escalation also serialized across process groups, so repeated Ctrl-C could wait. wt now forwards the user's signal once per process group, so a cooperative child dies from the signal actually sent (130 on Ctrl-C); a second signal kills any survivor immediately. ([#3075](max-sixty/worktrunk#3075)) ### Documentation - **Per-worktree env vars**: A Tips & Patterns section shows how to give each worktree its own environment variables with direnv or mise. ([#3074](max-sixty/worktrunk#3074)) ### Internal - The commit-generation command is not rewritten to disk when its value is unchanged. ([#3084](max-sixty/worktrunk#3084)) ## Install worktrunk 0.59.0 ### Install prebuilt binaries via shell script ```sh curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-installer.sh | sh && wt config shell install ``` ### Install prebuilt binaries via powershell script ```sh powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-installer.ps1 | iex"; git-wt config shell install ``` ### Install prebuilt binaries via Homebrew ```sh brew install worktrunk && wt config shell install ``` ## Download worktrunk 0.59.0 | File | Platform | Checksum | |--------|----------|----------| | [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) | | [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) | | [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) | | [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.59.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) | ### Install via Cargo ```sh cargo install worktrunk && wt config shell install ``` ### Install via Winget (Windows) ```sh winget install max-sixty.worktrunk && git-wt config shell install ``` ### Install via AUR (Arch Linux) ```sh paru worktrunk-bin && wt config shell install ``` </pre> <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.59.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.59.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!11836
Fixes a multi-second freeze in the
wt switchpicker: with many accumulated worktrees, typing the first character locks the UI for seconds, then it recovers. The freeze scales with worktree count.The picker (skim) runs its per-keystroke fuzzy matcher and result sort on rayon's global thread pool. Worktrunk's collection floods that same global pool with blocking git subprocess tasks (status, diff, rev-list, merge-base, plus the preview orchestrator's per-mode
git diff/git log), one batch per worktree. The global pool has only2× CPUworkers, and each git call blocks its worker for the subprocess lifetime. When the user types, skim's matcher queues behind that flood and can't run until workers drain.wt listnever froze because nothing else contends for the pool there.The fix moves the git-heavy collection and preview work onto a dedicated
COLLECT_POOL, leaving the global pool free for skim. This is the same isolation pattern already used bycopy::COPY_POOLandremove_dir::REMOVE_POOL. The new pool is sized like the global pool (2× CPU, honoringRAYON_NUM_THREADS), so collection throughput is unchanged. Its only job is to keep the git work off the pool skim's matcher uses.Decisions
rayon::scopecalls stay on the global pool. They are O(1) in worktree count (~7 spawns), so they are not the scaling flood.populate_item) routes throughCOLLECT_POOLtoo, purely for consistency. A single item never floods the pool, so this path was never the problem.rayon::spawn_fifoneeds no change. The freerayon::spawn_fiforesolves its target via the current worker's registry, so when called from inside aCOLLECT_POOLworker it inheritsCOLLECT_POOLrather than falling back to the global pool. Confirmed against the rayon-core source.Testing
Ran locally, before and after below, depicting the freeze/fix
Before
before.mov
After
after.mov