Skip to content

Suggest mode 6: Bump payload schema to v2 (foundations)#77967

Open
adamsilverstein wants to merge 8 commits into
suggest-mode-autosavefrom
suggest-mode-6-foundations
Open

Suggest mode 6: Bump payload schema to v2 (foundations)#77967
adamsilverstein wants to merge 8 commits into
suggest-mode-autosavefrom
suggest-mode-6-foundations

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented May 5, 2026

Copy link
Copy Markdown
Member

What

Bumps the suggestion payload schemaVersion from 1 to 2 and tightens parseSuggestionPayload to:

  • Refuse payloads written by a newer editor (schemaVersion > SCHEMA_VERSION) — surfaces an explicit "newer editor" notice instead of silently dropping unknown op types.
  • Migrate older payloads forward (schemaVersion < SCHEMA_VERSION) — pure version-field stamp; v1 payloads only ever carried attribute-set ops and remain valid as v2 payloads.
  • Treat a missing schemaVersion field as v1 (only the v1 implementation could have emitted it).

This is plumbing for the structural-suggestion stack tracked in #77434. No user-visible change.

Why

Without the bump, a v1 reader receiving a v2 payload with block-insert-after / block-remove / block-move ops would silently apply only the attribute-set ops and drop the rest — a confusing partial-apply. Refusing the payload outright hands the user a clear "this suggestion was made by a newer editor" notice and only the Reject affordance.

The shape is otherwise unchanged: v1 payloads carry only attribute-set ops, which are still valid in v2. The migration step in parseSuggestionPayload is a no-op rewrite — it just stamps the version field forward.

Testing the complete feature

To exercise the complete Suggest-mode feature (structural suggestions + inline preview marks) end-to-end, check out the combined integration branch try/suggest-mode-combined, which merges this stack (#77967#77979) with the inline-preview stack (#77869) on top of add-suggestion-mode:

git fetch origin try/suggest-mode-combined && git checkout try/suggest-mode-combined
npm install && npm run build
npm run wp-env start

The combined branch is testing-only — review still happens on the individual PRs.

Testing instructions

Then in wp-admin:

  1. Open a post for editing.
  2. Open the editor's "Options" kebab → switch the editor intent to Suggest.
  3. block-remove suggestion: click "Remove block" on a paragraph from the toolbar.
    • The block stays in place with strikethrough + 50% opacity.
    • The Notes sidebar shows a "Remove block: paragraph" thread with Apply / Reject buttons.
    • Apply → block removes for real, marker clears, comment marked applied.
    • Reject → marker clears, block stays.
  4. block-insert-after suggestion: insert a new block via the inserter while in Suggest mode.
    • The block lands at the chosen position with reduced opacity + dashed green outline.
    • Sidebar shows an "Insert block: " thread with Apply / Reject.
    • Apply → marker clears, block stays as a normal part of the post.
    • Reject → block removes.
  5. block-move suggestion: drag a paragraph to a new position (or use "Move up" / "Move down").
    • The block sits at its new position with reduced opacity + dotted green outline.
    • Sidebar shows a "Move block: " thread with Apply / Reject and a from→to descriptor.
    • Apply → marker clears, block stays at the new position.
    • Reject → block moves back to its original position.

For the multi-peer scenario, open the same post in a second browser tab as a different user. Suggestions auto-saved on tab A appear in tab B's sidebar; Apply/Reject on tab B propagates back through the sync layer without the originating tab's interceptor reverting the apply (covered by isAcceptedSuggestionChange for attribute-set today; structural multi-peer accept hardening tracked as a follow-up).

Stack

  1. This PR (#77967) — Schema v2 bump (foundations)
  2. #77968 — Capture block-remove (mechanism)
  3. #77970 — Render block-remove preview (UI)
  4. #77971 — Capture block-insert-after (mechanism)
  5. #77973 — Render block-insert-after preview (UI)
  6. #77978 — Capture block-move (mechanism)
  7. #77979 — Render block-move preview (UI)

Refs #77434, #73411.

@github-actions

github-actions Bot commented May 5, 2026

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 May 5, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

Size Change: +134 B (0%)

Total Size: 7.51 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 482 kB +134 B (+0.03%)

compressed-size-action

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

Flaky tests detected in f6c4e6f.
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/25390203164
📝 Reported issues:

@github-actions github-actions Bot added [Package] Core data /packages/core-data [Package] API fetch /packages/api-fetch [Package] DOM /packages/dom [Package] Components /packages/components [Package] Blocks /packages/blocks [Package] Editor /packages/editor [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor [Package] Edit Post /packages/edit-post [Package] Data Controls /packages/data-controls [Package] Edit Widgets /packages/edit-widgets [Package] E2E Tests /packages/e2e-tests [Package] Edit Site /packages/edit-site [Package] Base styles /packages/base-styles [Package] Commands /packages/commands [Package] Core commands [Package] DataViews /packages/dataviews labels Jun 17, 2026
@adamsilverstein adamsilverstein force-pushed the suggest-mode-autosave branch from 54bc0e5 to b6a0a74 Compare June 17, 2026 20:18
@adamsilverstein adamsilverstein force-pushed the suggest-mode-6-foundations branch from b9092d0 to 7259d48 Compare June 17, 2026 20:18
@github-actions github-actions Bot removed [Package] Date /packages/date [Package] Data /packages/data labels Jun 17, 2026
Per-block debounced background save for Suggest mode. After a 1.5 s idle
window, pending overlay edits persist as a note comment; subsequent
edits on the same block update the existing note's meta rather than
creating a new one, and a fully reverted overlay trashes the note.
Saves on the same clientId run sequentially via a per-block promise
queue, while different blocks run concurrently. Replaces the explicit
SuggestionCommitBar toolbar button.
Move the auto-save subsystem's ref syncing out of render and into an
effect, matching the store-interceptor fix, so the react-hooks rule
against accessing refs during render passes. Prune the now-unused
auto-save.js suppression along with the stale bulk-suppressions the
stack carried before trunk's ESLint dependency bump. lint:js passes.
v1 readers silently dropped operation types they didn't know about,
which would cause a v2 payload with structural ops (block-insert-after,
block-remove, block-move under #77434) to apply only its attribute-set
operations. Refusing the payload outright instead surfaces an explicit
"newer editor" notice and offers only Reject.

The shape is unchanged: v1 payloads only ever carried attribute-set ops
and remain valid as v2 payloads. The migration step in
parseSuggestionPayload stamps the version field forward; no rewriting
needed. Pre-versioned payloads are treated as v1.

Refs #77434.
…ations

Bring the payload-schema-v2 foundations branch up to date with its base after
autosave was cascaded onto latest trunk and reconciled onto phase-5b's REST
architecture.

Take the auto-save subsystem from the base (auto-save.js and its test): the
base carries the dup-note concurrency fixes (synchronous commentId/syncedOps ref
maps and the peer-resolution fresh-read via the note collection endpoint) that
this branch's older copy predated. The v2 payload work is unaffected — it lives
in provider.js (`schemaVersion: 2`) and the architecture doc, both of which
merge cleanly on top. Keep the base's trunk-derived CHANGELOG version heading.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Package] Editor /packages/editor [Status] In Progress Tracking issues with work in progress [Type] Feature New feature to highlight in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant