[diff/editor] Add stale async editor-sync guards#932
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30a51dd0a5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| () => ({ | ||
| ...cloneFileDiffMetadata(pristineFileDiff), | ||
| cacheKey: pristineFileDiff.name + resetKey, | ||
| }), | ||
| [pristineFileDiff, resetKey] |
There was a problem hiding this comment.
Recreate the live diff on surface remounts
When someone edits the diff surface, then switches to the File surface and back, handleSurfaceChange only clears hasEdits; it does not bump resetKey. FileDiff.applyDocumentChange mutates the supplied fileDiff, so this memo keeps returning the same edited liveFileDiff object across that conditional unmount/remount because its deps are only pristineFileDiff and resetKey. The UI then shows a disabled Reset button while the previous diff edit is still present, instead of rebuilding from the pristine diff as the comment describes.
Useful? React with 👍 / 👎.
/edit: keeps a pristine clonedFileDiffMetadata baseline and passes a fresh clone toFileDiffon reset/remount, so prior edits cannot leak back in.