Skip to content

fix(picker): keep branch names out of shared diff-preview cache entries#3481

Open
max-sixty wants to merge 1 commit into
mainfrom
tab3-preview-latency
Open

fix(picker): keep branch names out of shared diff-preview cache entries#3481
max-sixty wants to merge 1 commit into
mainfrom
tab3-preview-latency

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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 landed resets 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 main under 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, None when empty) and render the branch-named headline on read, on the hit and miss paths alike. compute_diff_preview now returns Option<String> instead of taking a no_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-empty commits) 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.

This was written by Claude Code on behalf of max

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants