Repository navigation
perf(switch): reuse the list collector's ref scan for the preview comparison base - #3308
Merged
Merged
Conversation
…parison base The diff/summary preview panes resolve their comparison base by capturing their own RefSnapshot, duplicating the scan the list collector already runs. Split the resolution into a snapshot-taking core and have the collector prime the memoized base from its snapshot; the panes share the same Arc<RepoCache>, so they reuse it instead of re-scanning. The lazy capture stays as the fallback for callers that preview without collecting first. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Jun 29, 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.
Follow-up to #3305. That PR routed the picker's diff/summary preview panes through the upstream-aware comparison base, which is resolved from a
RefSnapshotand memoized on the repo'sRepoCache. But the preview path captured its own snapshot — a secondgit for-each-refscan duplicating the one thewt listcollector already runs a moment earlier.This primes that memoized base from the collector's snapshot.
resolve_comparison_basesplits into a snapshot-taking core (comparison_base_from) shared by the lazy path and a newprime_comparison_base; the collector calls the latter once from the snapshot it already holds. The picker's preview panes run on a clone of the collector'sRepository(sharedArc<RepoCache>) andwt list --full's summary column runs on it directly, so both read the primed base instead of re-scanning. The lazy capture remains as the fallback for any caller that previews without collecting first.No behavior change — the base value and its staleness characteristics are identical; only the scan that resolves it is shared instead of repeated.
Testing: new
prime_comparison_base_feeds_branch_diff_specexercises the prime path and asserts it feedsbranch_diff_specthe upstream-aware base; the existing branch-diff and summary tests cover the lazy path. Feature-gated clippy and the rustdoc-Dwarningsgate are clean.