Skip to content

[diff/editor] Add stale async editor-sync guards#932

Open
ije wants to merge 1 commit into
beta-1.3from
editor/reset-diff-cache
Open

[diff/editor] Add stale async editor-sync guards#932
ije wants to merge 1 commit into
beta-1.3from
editor/reset-diff-cache

Conversation

@ije

@ije ije commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator
  • fix live editing in /edit: keeps a pristine cloned FileDiffMetadata baseline and passes a fresh clone to FileDiff on reset/remount, so prior edits cannot leak back in.
  • add stale async editor-sync guards

@ije ije requested review from amadeus and necolas July 1, 2026 17:36
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffs Ready Ready Preview Jul 1, 2026 5:36pm
pierre-docs-diffshub Ready Ready Preview Jul 1, 2026 5:36pm
pierre-docs-trees Ready Ready Preview Jul 1, 2026 5:36pm
pierrejs-diff-demo Ready Ready Preview Jul 1, 2026 5:36pm

Request Review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +69 to +73
() => ({
...cloneFileDiffMetadata(pristineFileDiff),
cacheKey: pristineFileDiff.name + resetKey,
}),
[pristineFileDiff, resetKey]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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.

1 participant