fix(picker): keep branch names out of shared diff-preview cache entries#3481
Open
max-sixty wants to merge 1 commit into
Open
fix(picker): keep branch names out of shared diff-preview cache entries#3481max-sixty wants to merge 1 commit into
max-sixty wants to merge 1 commit into
Conversation
The branch-diff and upstream-diff disk caches are keyed by SHAs only, so
branches parked at the same commit (common after wt landed resets merged
branches to main's tip) share one entry — but the cached value was the
finished pane with the row's branch name baked into the empty-diff
headline, so every same-SHA row showed the first writer's name ("main has
no file changes vs main" under another branch's row).
Follow the Log cache's split: cache only the name-free diff body (plus
ahead/behind counts for the upstream mode) and render the branch-named
headline on read. Old bare-string entries fail to deserialize, read as a
miss, and are overwritten in place.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
worktrunk-bot
approved these changes
Jul 15, 2026
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.
The picker's branch-diff (tab 3) and upstream-diff (tab 4) disk caches are keyed by SHAs only, so branches parked at the same commit — common after
wt landedresets merged branches to main's tip — share one entry. The cached value was the finished pane with the row's branch name baked into the empty-diff headline, so every same-SHA row showed the first writer's name:main has no file changes vs mainunder another branch's row (surfaced as the "preview shows another row's content" oddity while A/B-testing #3439; skim was exonerated — it requests the correct row).The fix follows the Log cache's existing split: cache only the branch-agnostic data (
BranchDiffCacheEntry { body },UpstreamDiffCacheEntry { ahead, behind, body }— the name-free rendered diff,Nonewhen empty) and render the branch-named headline on read, on the hit and miss paths alike.compute_diff_previewnow returnsOption<String>instead of taking ano_changes_msg, so a branch name can't leak into a cached value again. No key/version bump: old bare-string entries fail struct deserialization, read as a miss (cache::read's documented corrupt-entry semantics), and are recomputed and overwritten in place.Rendered output is byte-identical in every state, so no snapshot changes.
Testing: regression tests pin the collision for both modes (second same-SHA branch asserted to hit the first's entry and render its own name), a migration test pins old-format-reads-as-miss, and the previously untested empty-diff headlines (clean working tree; upstream ahead/diverged/behind via
--allow-emptycommits) now have coverage since they're lazily evaluated. Also verified end-to-end by driving the picker in the wt-perf test repo: a poisoned old-format entry self-healed and same-SHA rows render their own names.