Repository navigation
Fix stale README after cached repo tree refresh (RepoCodePage race) - #109
Merged
Merged
Conversation
When the code page opens from a stale cached tree, it queues a README preview and a background tree refresh at the same time. The refresh snapshots the visible file, then applies the new tree and decides whether to reload it. If the cached README finished loading between the snapshot and the apply, the refresh saw "no file shown", skipped the reload, and queued a README preview that then saw a file already showing and did nothing. The stale README stayed over the new tree. Wait for the in-flight default preview to settle before applying the refreshed tree so the snapshot reflects what is actually visible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zhuowcui
approved these changes
Oct 28, 2026
This was referenced Oct 28, 2026
Merged
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.
Summary
RepoCodePageViewModelTests.Initialize_CachedTreeRefreshReloadsReadmeWhenShaChangesfailed in about 1 of 10 full-suite runs (Expected "readme-new", Actual "readme-old"). The test wasn't asserting too early: it already waits onTreeRefreshTaskandDefaultPreviewTask, and the refresh waits on both the reconciliation and the default preview before it completes. The view model had a race. The fix is inJitHub.WinUI, and the test is unchanged.Cause
When the code page opens from a stale cached tree, two background jobs start at once:
readme-old), andNetworkOnly).ApplyTreeAsynctakes a snapshot of the visible file in one UI step. In a later UI step it applies the new tree and decides from that snapshot whether to reload the visible file. If the cached README finished loading between those two steps:Preview.CurrentFile is not null) and did nothing;readme-oldstayed visible over a tree that listsreadme-new.This can happen in the app too, because the two UI steps are separate dispatcher posts. Tests have no dispatcher, so the window is wider there. When the README load landed while the new tree was being applied, a second outcome was an empty preview.
Fix
RefreshTreeInBackgroundAsyncnow waits for the in-flight default README preview to finish (the existingAwaitDefaultPreviewSettledAsync) before callingApplyTreeAsync. The snapshot then reflects what is actually visible:Notes:
Verification
readme-old, 21 showed nothing).RepoCode*tests pass.dotnet test JitHub.WinUI.Tests/JitHub.WinUI.Tests.csproj -c Debug -p:Platform=x64: the target test passed in all 20.Phase0RequestTransportTests.RequestQueue_LastPrefetchSubscriberCancellationStopsActiveWork, timing out at line 207. That is the losttoken.Registersignal fixed by Make Phase0 service tests deterministic under parallel load #107, which isn't merged yet.Not changed (possible follow-up)
A file the user selects can hit the same snapshot gap if it finishes loading between the two UI steps of a tree refresh. One fix is to re-read
Preview.CurrentFileinside the apply step. This PR doesn't change that, to keep it to the README path that the flaky test covers.🤖 Generated with Claude Code