Repository navigation
Suggestion mode 3/9: block-level capture (attribute and structural) - #80429
Open
adamsilverstein wants to merge 129 commits into
Open
adamsilverstein wants to merge 129 commits into
adamsilverstein wants to merge 129 commits into
Conversation
Adds the store-level interceptor that catches block mutations dispatched straight to the block-editor store (the block-switcher variation picker, programmatic writes), routing attribute drift into the overlay and reverting the live block; captures structural edits (insert/remove/move) by tagging the live block with a metadata.suggestion marker and recording the op; and the overlay HOC that renders the pending-suggestion visual treatment (the green attribute bracket and the strikethrough/dim/move-ghost overlays). The revert guard and undo guard keep the interceptor's own writes off the undo stack and out of its own subscribe loop, and the server hides un-accepted structural insertions at render time. Inline text and formatting markers are layered on top of this HOC in a later step.
This was referenced Jul 17, 2026
This was referenced Jul 17, 2026
|
Size Change: +7.4 kB (+0.09%) Total Size: 7.93 MB 📦 View Changed
|
adamsilverstein
marked this pull request as ready for review
August 5, 2026 22:24
|
Flaky tests detected in ec6ef6b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/33450977039 user-customized templates cannot be overridden by plugins in
|
Trunk switched @wordpress/dependency-group to 'never' mode, so the import group headers in these files now fail lint.
# Conflicts: # tools/eslint/suppressions.json
… layer Merge branch 'suggest/data' into suggest/block-capture. The storage layer now carries the marker design, so the capture layer builds on it directly instead of on the in-memory overlay a later layer removed. The HOC writes attribute proposals into the block's `metadata.suggestion.after` and renders them merged over the live attributes, the store interceptor routes store-level drift to the same marker and records structural captures on the session, and the undo guard orders those captures against history-owned proposal writes. The inline marker hand-offs (format and content reconciliation, refused edits) stay with the layer that wires inline suggestions. Claude-Session: https://claude.ai/code/session_018vwYjU3KeQ4xVQPLeAzqZz
…pture layer A later layer changed how edits to another author's suggested block are captured: a move, removal or attribute change there now nests as a suggestion of its own instead of folding into theirs, and the block shows every author's proposal. Capture and show them that way from the start, so the capture layer does not ship the folding model only to rewrite it. Claude-Session: https://claude.ai/code/session_018vwYjS1afuMwCEzNKqAxg6
# Conflicts: # packages/editor/src/store/reducer.js # tools/eslint/suppressions.json
Each editor's undo guard wrapped the actions on the core-data object all editors share, so one editor's undo ran every editor's guard, and unmounting out of order left a stale wrap behind or dropped a live one. Register the guard as the interceptor of its own editor's undo and redo instead, the surface every in-editor caller already goes through.
The store interceptor diffed every block in the canvas, so an edit inside a synced pattern, a template part or a navigation menu wrote a marker into that entity, where the save pass never looks, and the blocks a controlled container loaded were proposed as insertions. With the template shown it also captured edits to the template itself. Add one ownership check, following the nearest ancestor with controlled inner blocks, and have the interceptor adopt any block the post does not own.
While suggesting, the overlay turned an edit to a synced pattern's, template part's or navigation menu's block into a proposal marker saved in that entity. Writing it through instead would be a direct edit made in Suggesting. Decline it with a notice, as an edit to a site setting already is.
Assigning refs during render can leave a ref holding a value from a render React threw away. useEvent gives the interceptor's subscribe callback and the wrapped undo the latest session callbacks without resubscribing, and drops seven react-hooks/refs suppressions.
The comment still named the overlay context, which became the suggestion session.
Proposals are stored on the block, so there is no overlay to contrast with or to retire.
The suggest intent is now refused without the experiment.
The canvas merged a block's proposal into the attributes its edit component renders, before any decision and without the checks accept runs. Any author of the post can write a marker, so a proposed element name or URL scheme reached the reviewer's canvas as written. The displayed proposal now goes through the same validation as accept. A value that fails stays at its baseline in the canvas, while the note still describes it and accepting it is still refused.
The suggest intent is refused without it, so the interceptor never started.
…llback The ref it read was replaced by useEvent, so removing a block from a controlled block threw.
The session read the user once, so one that began before the user resolved wrote every marker without an author, and those are never saved.
…n capture An authorless marker no longer belongs to the viewer, so an edit inside one is a proposal like an edit inside another author's.
A pending insertion was rendered in full and its output dropped on render_block, so its render callback and those of its inner blocks still ran and enqueued their assets on the front end. Short-circuit it on pre_render_block, after core's callbacks, which reset the value to null. The render_block filter stays for a block rendered directly.
…tions The interceptor recorded the whole block on a block-remove or block-insert-after capture, which auto-save then sent as the note's payload. A large block took the payload over the 64 KB cap, the note was refused, and the marker stayed in content with nothing to decide it by. The capture now carries the block's excerpt, like an operation derived from a marker.
The capture callbacks are read through useEvent, so nothing in this layer's interceptor holds a ref.
Deleting from the middle of one block to the middle of another left one attribute note and one removal note per block, each decided on its own, so accepting one left the post half deleted. The rewritten block and the removed ones now share a group id, as the halves of a block transform do (#87283, F-52). Claude-Session: https://claude.ai/code/session_018vwYjTYKPCN8vz5C4CntuY
A block rendered in a preview is not part of the post. The previewed Navigation block in the Template panel wrote its ref once its menu resolved, which was refused with a "saved outside this post" notice (#87283, F-68). Claude-Session: https://claude.ai/code/session_018vwYjTYKPCN8vz5C4CntuY
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #73411
What's in this PR
Adds block-level capture: in Suggesting, an edit to a block is written onto the block's
metadata.suggestionmarker instead of being applied.setAttributesHOC (with-suggestion-overlay.tsx) writes an attribute edit into the marker's proposal (after) and leaves the live attributes at the baseline. In every mode it renders the block with the proposal merged over the live attributes, so everyone sees what is proposed.store-interceptor.ts) catches changes dispatched straight to the block-editor store (the block switcher's variation picker, programmatic writes). It routes attribute drift into the same proposal and reverts the live block, and it captures structural edits (insert / remove / move, list indent and outdent) by tagging the live block with apending-insert,pending-removeorpending-movemarker and recording the operation.Inline text and formatting markers are layered on top of this HOC in #80433.
Screenshot
Structural suggestions keep the block on the canvas and tag it instead of applying the change. A suggested move lands the block at its proposed position and leaves a ghost at the origin; a suggested removal keeps the block with a struck-through treatment:
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:
👉 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:
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.