Repository navigation
perf(picker): share default-branch SHA across BranchDiff preview tasks - #2658
Merged
Merged
Conversation
`compute_branch_diff_preview` was forking `git rev-parse <default_branch>` once per item to key the preview disk cache. With N worktrees, the orchestrator's rayon fan-out produced N redundant subprocesses for the same ref name. Add `Repository::default_branch_sha()` that sources the SHA from the already-cached `local_branches` inventory — same `for-each-ref` scan the picker is going to run anyway. The accessor's docstring spells out the snapshot-at-first-scan staleness contract and directs ref-mutating callers (e.g. `wt merge`) to capture a fresh `RefSnapshot` instead. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
worktrunk-bot
approved these changes
May 9, 2026
max-sixty
added a commit
that referenced
this pull request
May 10, 2026
…iew (#2659) The Log preview's `git merge-base` call (around `items.rs:510`) looks like a candidate for switching to a cached method, but it isn't always safe — `Repository::default_branch_sha` (the inventory-snapshot accessor added in #2658) would freeze the dim/bright styling at the SHA main pointed at when the picker started. Adds a comment block at the call site spelling out which substitution is unsafe and why, and a brief note that `Repository::merge_base` (the broader cached method) would be correctness-safe — just slower than the current direct subprocess. No behavior change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
max-sixty
added a commit
that referenced
this pull request
May 10, 2026
Bump worktrunk to **0.49.0** — minor bump (semver-checks reports a
breaking change in `GitError::UncommittedChanges`, which gained a
`dirty_files: Vec<String>` field).
## Highlights
**Improved**
- New `codename(n)` template filter — deterministic friendly worktree
names from a ~1.26M-combo pool (`{{ branch | codename(2) }}` →
`malleable-opah`).
[#2641](#2641), thanks
@endigma
- Picker preview disk cache for Log / BranchDiff / UpstreamDiff, with
background refresh for stale Log decorations.
[#2628](#2628),
[#2646](#2646)
- Picker shares one `default_branch_sha` lookup across BranchDiff items
instead of forking N rev-parse subprocesses.
[#2658](#2658)
- "X has uncommitted changes" errors now list the dirty files inline.
[#2653](#2653)
**Fixed**
- `wt switch` integrates with `cd` aliases like zoxide (uses `builtin
cd`). [#2644](#2644), thanks
@xkumiyu for reporting
- Empty hook tables no longer panic during `wt switch --create`.
[#2635](#2635), thanks @topit
for reporting
- `Repository::current_worktree()` and five sibling helpers no longer
silently leak the process CWD when called via `Repository::at(p)`.
[#2652](#2652)
- `WorkingTree::is_linked` tolerates non-git CWDs (e.g. Nix sandbox).
[#2625](#2625), thanks
@DArtagan for reporting
- Picker no longer overlays `collect` warnings on the active TUI; clears
its frame on exit in inline mode.
[#2627](#2627),
[#2626](#2626)
- Failed `git log` no longer poisons the picker's preview disk cache.
[#2651](#2651)
- `wt step prune` says "removing branch" for branch-only candidates.
[#2619](#2619)
- Claude Code Windows integration uses a `wt.sh` wrapper to avoid
colliding with Windows Terminal's `wt.exe`.
[#1754](#1754), thanks
@lucaspimentel
**Documentation**
- cmux workspace integration recipe.
[#1907](#1907), thanks
@alvistar
See
[CHANGELOG.md](https://github.com/max-sixty/worktrunk/blob/release/CHANGELOG.md)
for the full list including internal CI / test-isolation changes.
## Test plan
- [x] `cargo run -- hook pre-merge --yes` (tests + lints clean)
- [x] `cargo semver-checks check-release -p worktrunk` (one breaking
change confirmed → minor bump)
- [x] CHANGELOG entries verified by subagent against actual diffs
🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compute_branch_diff_previewwas forkinggit rev-parse <default_branch>once per item to key the preview disk cache. With N worktrees, the orchestrator's rayon fan-out produced N redundant subprocesses for the same ref name.Add
Repository::default_branch_sha()that sources the SHA from the already-cachedlocal_branchesinventory — samefor-each-refscan the picker is going to run anyway. The accessor's docstring spells out the snapshot-at-first-scan staleness contract and directs ref-mutating callers (e.g.wt merge) to capture a freshRefSnapshotinstead.The picker session is read-only, so the snapshot is correct for the orchestrator's lifetime. Three new tests cover the happy path, the missing-from-inventory fall-through, and the staleness contract; existing picker tests now use the accessor too.
🤖 Generated with Claude Code