Skip to content

Suggestion mode 5/9: inline suggestion operations - #80431

Open
adamsilverstein wants to merge 117 commits into
suggest/inline-markersfrom
suggest/inline-ops
Open

adamsilverstein wants to merge 117 commits into
suggest/inline-markersfrom
suggest/inline-ops

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

Part of #73411

What's in this PR

Adds the suggestion-specific layer on top of the marker primitive. Still pure modules, nothing is wired into the live editor yet:

  • one rich-text format per kind of suggestion, core/suggestion-add, -del and -format, and their canonical nesting order (format.ts)
  • create, accept and reject for inline text and formatting suggestions (operations.ts)
  • the reconcilers that turn a text edit or a format toggle into marker actions (reconcile-edit.ts, reconcile-format.ts)
  • which gestures may land on text that already carries a marker (overlap.ts), what a decision does to the other suggestions (resolution.ts), and how a suggestion sits among the others for the sidebar (relations.ts)
  • the per-suggestion formatting deltas that let formatting suggestions stack on the same text (format-delta.ts)
  • the shared overlap fixtures, with the oracle and fuzz that check every accept / reject order (test/fixtures/)
  • the guard that keeps content synced over real-time collaboration from re-attributing a marker (marker-integrity.ts)
  • word and line delete-range resolution, marker stripping for clean attribute snapshots, and the annotate-suggestions hook

The keyboards and reconcilers that call these from the live editor land in #80433. The rules for overlapping suggestions used to be a layer of their own (#86206, now closed) and are part of this one.

Diagram

Pure transforms over a rich-text value: write a marker, resolve it on accept or reject, strip it for output.

Inline suggestion operations grouped into write, resolve and strip, with a worked type-over example

Testing

This is one layer of the stack. To exercise the whole feature, #78994 bundles every layer into one branch and builds it in Playground:

Test in WordPress Playground

👉 https://playground.wordpress.net/gutenberg.html?pr=78994

Enable Gutenberg > Experiments > Collaboration > Suggestion Mode, then follow the walkthrough in #73411, which also explains how to review the stack layer by layer.


Suggestion mode stack

This rebuilds the manually-stacked Suggestion mode work (#73411) as a GitHub Stack of 9 small, independently reviewable PRs, each building on the one below it:

  1. #80427 - editor intent (edit/suggest) + experiment gate
  2. #80428 - suggestion storage, REST controller, provider
  3. #80429 - block-level capture (attribute + structural)
  4. #80430 - inline marker primitive
  5. #80431 - inline suggestion operations
  6. #80432 - review UI (Apply/Reject sidebar + summary)
  7. #80433 - inline live wiring
  8. #82047 - architecture documentation
  9. #82048 - end-to-end test suite

Each follow up fix now sits in the layer that owns the code it changes, rather than piling onto the top of the stack. Overlapping suggestions were briefly their own layer (#86206, now closed); that code sits in the layers that own it, mainly #80431 and #80433. The whole feature can be exercised end-to-end via the combined testing branch #78994 (Playground). Behind the "Suggestion Mode" experiment (Gutenberg > Experiments).


AI Use

Code and description both written with 🤖 Claude Code. I will review and test.

Adds the suggestion-specific layer on top of the marker primitive: create,
accept, and reject inline text (add/del) and formatting suggestions
(operations.js); the pure reconcilers that turn a text edit or a format
toggle into marker actions (reconcile-edit.js, reconcile-format.js); word/
line delete-range resolution; strip-markers for clean attribute snapshots;
findSuggestionText/findMarkerText helpers; and the annotate-suggestions hook.
Still pure modules - the keyboards and reconcilers that call them into the
live editor land in the final step.
@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 7.93 MB

compressed-size-action

@adamsilverstein
adamsilverstein marked this pull request as ready for review August 5, 2026 22:24
@github-actions

github-actions Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Flaky tests detected in d690668.
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/33117688052
📝 Reported tests:

refuses the drop and uploads nothing in /test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js, passed after 1 failed attempt.
Error: expect(received).toHaveLength(expected)

Expected length: 0
Received length: 2
Received array:  [{"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "curies": [{"href": "https://api.w.org/{rel}", "name": "wp", "templated": true}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=106"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/106", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}], "wp:attached-to": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/posts/104", "id": 104, "post_type": "post"}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-106", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-08-27T21:35:42", "date_gmt": "2026-08-27T21:35:42", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK-1.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK-1.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "10x10_e2e_test_image_z9T8jK-1.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK-1.png"}, "id": 106, "link": "http://localhost:8889/?attachment_id=106", "media_details": {"file": "2026/08/10x10_e2e_test_image_z9T8jK-1.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-08-27T21:35:42", "modified_gmt": "2026-08-27T21:35:42", "ping_status": "closed", "post": 104, "slug": "10x10_e2e_test_image_z9t8jk-2", "source_url": "http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK-1.png", "status": "inherit", "template": "", "title": {"rendered": "10x10_e2e_test_image_z9T8jK"}, "type": "attachment"}, {"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "curies": [{"href": "https://api.w.org/{rel}", "name": "wp", "templated": true}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=105"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/105", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}], "wp:attached-to": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/posts/104", "id": 104, "post_type": "post"}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-105", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-08-27T21:35:42", "date_gmt": "2026-08-27T21:35:42", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "10x10_e2e_test_image_z9T8jK.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK.png"}, "id": 105, "link": "http://localhost:8889/?attachment_id=105", "media_details": {"file": "2026/08/10x10_e2e_test_image_z9T8jK.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-08-27T21:35:42", "modified_gmt": "2026-08-27T21:35:42", "ping_status": "closed", "post": 104, "slug": "10x10_e2e_test_image_z9t8jk", "source_url": "http://localhost:8889/wp-content/uploads/2026/08/10x10_e2e_test_image_z9T8jK.png", "status": "inherit", "template": "", "title": {"rendered": "10x10_e2e_test_image_z9T8jK"}, "type": "attachment"}]
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js:71:45

…ayer

The operations layer refused most gestures over another author's
inline suggestion, and a later layer replaced the refusals with
stacked markers that let suggestions nest and overlap, each resolving
on its own in any order. Plan and resolve overlapping suggestions here
instead, with the format deltas and the overlap fixtures that prove
accept and reject in any order reach the same text.

Claude-Session: https://claude.ai/code/session_018vwYjS1afuMwCEzNKqAxg6
Another author writes a formatting suggestion's delta, and a reviewer's
decision applies its formats to the content. A stored descriptor could
name a suggestion marker or an unregistered type, which serializes as
an element of that name, carry a `javascript:` value in any attribute a
format maps to `href`, and claim offsets large enough that expanding or
rebasing the delta allocated and looped without bound.

Validate a delta's runs and formats before any of them are applied,
check every attribute value's protocol, and rebase run by run instead
of expanding every offset a run claims.

Claude-Session: https://claude.ai/code/session_018vwYjS1afuMwCEzNKqAxg6
…riment

An emptied marker only survives a rich-text round trip while its format is registered, and that is the form the editor loads with the experiment off.
…utes

Format deltas carried their own copy of the allowed protocols and the
scheme test. Proposed block attributes are now checked the same way on
accept, so the delta sanitizer uses that module and the two cannot
drift.
Formatting applied to text you suggested adding is folded into that
addition, so nothing recorded that the run was bold. Compare the run's
formats with those of the text next to it, so a card can name them.

Claude-Session: https://claude.ai/code/session_018vwYjV5xvNjZT3oL9uthV9
Formatting text you had suggested adding was folded into that addition,
so a reviewer could not take the text without the formatting. Testers
expect one card each, as Google Docs gives. The planner now nests a
format suggestion in the author's own addition, as it does in anyone
else's, and a second format on those words still revises that one
suggestion.

Claude-Session: https://claude.ai/code/session_018vwYjV5xvNjZT3oL9uthV9
…d it

An addition typed into bold text carries its own bold format object, so
once the marker was unwrapped the run serialized as three adjacent
<strong> elements. Normalize the formats when a marker is unwrapped so
equal formats on neighboring text share one identity again.

Claude-Session: https://claude.ai/code/session_018vwYjV5xvNjZT3oL9uthV9
@adamsilverstein adamsilverstein changed the title Suggestion mode 5/10: inline suggestion operations Suggestion mode 5/9: inline suggestion operations Nov 28, 2026

This branch has not been deployed

No deployments
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 [Type] Feature New feature to highlight in changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants