Prevent auto-save reload from clobbering unsaved recap edits#257
Prevent auto-save reload from clobbering unsaved recap edits#257onurmatik wants to merge 7 commits into
Conversation
Restrict topic_create view to POST requests
…process Queue topic title saves during auto-save
…-recap Enable auto-saving for the recap editor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| baseline = normalizedText; | ||
| const preReloadValue = textarea ? getValue() : null; | ||
| const preReloadNormalized = textarea ? norm(preReloadValue) : ''; | ||
| const hadUnsavedDuringSave = textarea ? preReloadNormalized !== normalizedText : false; | ||
| await afterPersistedChange(); |
There was a problem hiding this comment.
Snapshot unsaved text too early during auto-save reload
preReloadValue is captured before await afterPersistedChange(). While that reload request is in flight the editor remains editable, so a user can keep typing after this snapshot. When the reload later overwrites the textarea and the code restores preReloadValue, any keystrokes typed after the snapshot but before the reload finishes are discarded. Capture the value inside the reload callback or merge the current value after the reload to avoid dropping recent edits on slow saves.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68fbb102f3d88328b44e753d5fadc961