Skip to content

Suggest mode: reopen an undone decision with a status the server accepts - #81963

Merged
adamsilverstein merged 2 commits into
suggest/inline-wiringfrom
fix/81962-undo-reopen-pending
Aug 23, 2026
Merged

adamsilverstein merged 2 commits into
suggest/inline-wiringfrom
fix/81962-undo-reopen-pending

Conversation

@adamsilverstein

Copy link
Copy Markdown
Member

Claude tracked this one down this morning and wrote the fix:

What?

Fixes #81962: undoing an accepted or rejected suggestion puts the marker back in the content but leaves its note resolved, so the run is marked up again with no Accept or Reject on it and no way to clear it through the UI. Follow-up to #81669 (F-18, part of #73411), based on suggest/inline-wiring (#80433) like the other Table 1 fixes.

Why?

The reopen pass from #81669 does fire - it just half lands. It writes the comment status and the lifecycle meta in one request, and it tried to clear the meta with an empty string:

saveEntityRecord(
'root',
'comment',
{
id: note.id,
status: 'hold',
meta: { _wp_suggestion_status: '' },
},

_wp_suggestion_status is registered with an enum of pending / applied / rejected, so the REST request comes back rest_not_in_enum. WP_REST_Comments_Controller::update_item() updates the comment before it updates meta, so the status change persists while the meta write fails: status lands back on hold, the meta stays applied, and the sidebar reads the meta - not the status - to decide whether a decision has been made. Because the save rejects, the note also goes back into the resolved-this-session set, so every later pass retries the same doomed write.

How?

Write pending instead - the enum's own word for a suggestion awaiting a decision. Every reader already treats pending the same as absent meta: the sidebar counts only applied and rejected as resolved (suggestion-actions.js), the replacement-pairing scan skips only those two (provider.js), and the note GC's trash gate explicitly allows pending. The unit test expectation now pins pending, so it matches a payload the server will actually take.

Two e2e tests already covered this and were failing on the branch (suggestion-mode-undo.spec.js, the two "reopens its note with the marker" tests). With the fix they pass, along with the rest of the undo spec (12/12) and the GC unit suite.

Testing Instructions

  1. Enable the gutenberg-suggestion-mode experiment.
  2. In a new post, add a paragraph reading Hello, switch to Suggesting (Options menu), and type world at the end.
  3. Switch back to Editing, open All notes, and click Accept suggestion.
  4. Press Ctrl/Cmd+Z.
  5. The marker comes back and its note reopens with Accept and Reject on it. Before the fix it stayed under Resolved with an "Applied" label.

Or run the pinned tests:

npm run test:e2e -- test/e2e/specs/editor/various/suggestion-mode-undo.spec.js -g "reopens its note"

AI Use

Claude wrote the code and this description, steered from the issue it filed earlier. I will review and test.

The reopen pass wrote _wp_suggestion_status: '' to clear the lifecycle
meta, but the registered enum only allows pending, applied and rejected,
so the REST request failed after the comment status had already been
updated. That left the note half reopened: status back to hold, meta
still applied, and the sidebar - which reads the meta - kept the note
resolved with no Accept/Reject on it. Write pending instead, which every
reader already treats the same as absent meta.

Fixes #81962
@github-actions

Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Aug 23, 2026
The undo-reopen entry from #81669 now also points at #81963, which makes
the reopen write use a value the registered meta enum accepts.
@github-actions

Copy link
Copy Markdown

Size Change: -1 B (0%)

Total Size: 7.81 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 578 kB -1 B (0%)

compressed-size-action

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 5e05deb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32645968093
📝 Reported tests:

Navigates the items list via UP/DOWN arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-330-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-330-label" aria-describedby="view-list-0-330-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:112:49
style — toggling a format back off retracts the suggestion in /test/e2e/specs/editor/various/suggestion-mode.spec.js, passed after 1 failed attempt.
Error: expect(received).not.toContain(expected) // indexOf

Expected substring: not "wp-suggestion"
Received string:        "<!-- wp:paragraph {\"metadata\":{\"noteId\":[24]}} -->
<p>Hello <mark data-suggestion-id=\"24\" data-suggestion-type=\"format\" data-author=\"1\" class=\"wp-suggestion\"><strong>w</strong>orl<strong>d</strong></mark></p>
<!-- /wp:paragraph -->"

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/suggestion-mode.spec.js:1081:9

@adamsilverstein
adamsilverstein merged commit 84e3bf2 into suggest/inline-wiring Aug 23, 2026
44 checks passed
@adamsilverstein
adamsilverstein deleted the fix/81962-undo-reopen-pending branch August 23, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant