Fix stale Monaco diff prefetch results#273
Open
cursor[bot] wants to merge 3 commits into
Open
Conversation
Contributor
📋 PR Overview
🔬 Coverage
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in the widget’s Monaco diff view where overlapping git_file_diff_contents prefetches could allow stale results to overwrite newer diff contents, and ensures failures surface as an error state instead of an infinite loading spinner.
Changes:
- Adds request “generation” tracking to ignore superseded
fileDiffContentsresponses and clears stale diff contents at request start. - Introduces a per-file failure sentinel (
null) and renders an explicit “Unable to load diff contents” message. - Adds unit tests covering stale clearing, superseded-response ignoring, and failure behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/native/src/stores/widget-store.impl.ts | Updates fileDiffContents and setter types to allow a failure sentinel (null) (and should model missing keys as “loading”). |
| apps/native/src/hooks/use-git-operations.ts | Implements request-id gating to prevent stale prefetch results from overwriting newer state; sets per-file nulls on failure. |
| apps/native/src/hooks/use-git-operations.test.ts | Adds unit tests for stale clearing, out-of-order resolution, and failure-to-null behavior. |
| apps/native/src/components/widget/summaries/full-file-diff-editor.tsx | Renders an explicit error state when diff contents are null. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
96
to
99
| // Git (from backend) | ||
| gitStatus: GitStatus | null; | ||
| fileDiffContents: Record<string, FileDiffContents>; | ||
| fileDiffContents: Record<string, FileDiffContentEntry>; | ||
| // Evolution |
Comment on lines
193
to
197
| setEvolveState: (state: EvolveState | null) => void; | ||
| setExternalBuildDetected: (detected: boolean) => void; | ||
| setGitStatus: (status: GitStatus | null) => void; | ||
| setFileDiffContents: (contents: Record<string, FileDiffContents>) => void; | ||
| setFileDiffContents: (contents: Record<string, FileDiffContentEntry>) => void; | ||
| setEvolvePrompt: (prompt: string) => void; |
6 tasks
Contributor
🎨 Storybook previewUpdated for 5e5239b |
Co-authored-by: cooper <czxtm@users.noreply.github.com>
5e5239b to
5eb137c
Compare
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
Fixes a Monaco diff review regression where overlapping
git_file_diff_contentsrequests could let an older response overwrite newer diff contents. The prefetch now clears stale content at request start, ignores superseded responses, and records per-file load failures so expanded diffs show an error instead of loading forever.Test Plan
bun run test:unit src/hooks/use-git-operations.test.tsbun run buildbun run lintDocs
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.