Repository navigation
Conversation
WordPress has one inline reply form that moves between comments. A suggestion that was still being generated when the form moved was written into the other comment's reply form, and that form stayed disabled until the request finished. The result is now used only while the form is still open for the comment it was generated for. The form is handed back as soon as it is closed or moved, and an earlier generation no longer touches a form that a newer one has taken over. See WordPress#1157.
|
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1158 +/- ##
==========================================
Coverage 82.11% 82.11%
Complexity 3396 3396
==========================================
Files 136 136
Lines 13179 13179
==========================================
Hits 10822 10822
Misses 2357 2357
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Replace the interval and the generation counter with a set of comment IDs that have a request running, and a MutationObserver on the comment list that locks or unlocks the inline form whenever it is opened, moved or closed. The result is only inserted when the form is open in Reply mode for the comment it was generated for, so it is not written into the Quick Edit form of the same comment. Returning to a comment whose request is still running locks the form again and inserts the suggestion when it arrives, instead of dropping it.
What?
Closes #1157
Stops Suggest Reply from inserting a suggestion into the reply form of a different comment than the one it was generated for.
Why?
WordPress has a single inline reply form (
#replyrow) that moves between comments. While a suggestion was being generated, the Reply, Quick Edit and "Suggest reply" row actions of the other comments still worked, so the form could move before the result arrived.runGeneration()then wrote the result into whatever form was open, and clicking Reply posted it under the wrong comment. The form that had moved also stayed disabled, with the "Generating AI reply…" placeholder, until the first request finished. Steps are in #1157.How?
All changes are in
runGeneration()insrc/experiments/suggest-reply/components/SuggestReply.ts:isInlineReplyOpenForComment()already existed and is reused.The request for the first comment is not cancelled, only ignored.
runAbility()passes an abort signal on its REST fallback path only, so I did not rely on it here.Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus
Used for: Investigation, implementation, tests, manual testing, and PR wording. I reviewed the changes and the test results, and I take responsibility for the contribution.
Testing Instructions
developit stays disabled.developit contains the suggestion generated for Alice's comment.I ran these steps in Chrome on WordPress 7.1.3 (wp-env, PHP 8.3). To make the timing easy to hit and the result unambiguous, the provider response was answered locally with a 6 second delay and named the comment author it was generated for. Before the fix, Bob's form contained "Thank you Alice! …". After it, Bob's form stayed empty in step 5 and contained "Thank you Bob! …" in step 6.
Automated:
suggest-reply.spec.js. It holds the ability request, moves the reply form to a second comment, and expects that form to be enabled and still empty after the request finishes. It fails ondevelop.npm run typecheckandnpm run lint:jspass.Screenshots or screencast
Changelog Entry