Fix[Editorial Notes]: Persist block metadata on generation to link back notes on reload#682
Conversation
6ceac22 to
bb546ce
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
dkotter
left a comment
There was a problem hiding this comment.
Overall this looks good to me but probably worth pausing for a discussion on this.
Up to this point, we've more or less taken the approach that saving content should be a user initiated behavior. For instance, if I trigger Excerpt Generation, I still have to manually click the save button otherwise that excerpt is lost with a page refresh.
This PR changes that for Editorial Notes where we automatically trigger a save when a Note is added. While this ensures that Note and it's association aren't lost, this does mean the post is saved even though a user didn't intentionally click save. If they had made other changes to the post that they weren't ready to publish yet, this makes those changes live.
We may be fine with that though as mentioned, we've tried to stay away from that so far cc @jeffpaul
|
Thanks for looking into this. I agree this is the main tradeoff here. From the issue side, the problem I wanted to report was that after reload the UI can still offer “Apply Editorial Updates”, but the existing Notes can no longer be matched back to the block. I was not assuming that automatically saving the whole post is necessarily the right fix. Your point about user-initiated saving makes sense to me. If generating Editorial Notes triggers a full post save, that could also persist unrelated content changes the user was not ready to save yet. So I think the safer direction may need a product/maintainer decision first. A few possible directions could be:
The important part for me is avoiding the broken state where pending Notes exist, the action is shown, but applying updates only results in “No blocks found matching the existing Notes.” |
What?
Closes #678
Why?
Editorial Notes store the root Note ID in block metadata so later review and refinement passes can associate a block with its Note thread. Without saving after a new
noteIdis linked, that metadata exists only in editor state and is lost after reload.Ref:
ai/src/experiments/editorial-notes/hooks/useEditorialNotes.ts
Lines 463 to 468 in 6ceac22
How?
createNote()now reports whether it created a new root Note thread and linked its ID to block metadata. Full-post review accumulates that signal across batches and saves post once at the end, only when a new noteId was linked. Single-block review also saves only when its review links a new noteId.Use of AI Tools
AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5.5
Used for: Initial code skeleton; final implementation was reviewed and edited by me.
Testing Instructions
Screencast
fix.mov
Changelog Entry