close
Skip to content

Visual revisions: add shareable urls - #79934

Merged
priethor merged 27 commits into
trunkfrom
add/addvisual-revisions-shareable-urls
Aug 3, 2026
Merged

Visual revisions: add shareable urls#79934
priethor merged 27 commits into
trunkfrom
add/addvisual-revisions-shareable-urls

Conversation

@priethor

@priethor priethor commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Part of #79120, closes #76552.

Makes visual revisions linkable in the post editor and site editor.

Why

Reviewing or discussing a specific revision is much easier when the URL points to the exact revision being shown.

How

  • A URL with revision=<id> now opens the editor directly on that revision, and moving through revisions keeps the address bar up to date so the current view can be shared.
  • The URL is updated with history replacement, so moving through revisions does not add extra browser history entries. Rapid slider or keyboard changes are grouped to stay below Safari's limit of 100 History API calls in 30 seconds. Normal post URL updates and single revision changes remain immediate.
  • Leaving revisions mode removes the arg again.
  • Invalid revision IDs show a notice and fall back to the normal editor, while posts with active classic meta boxes still land on the classic revisions screen.

Testing Instructions

  1. Create a post and update it enough times to get at least two revisions.
  2. Open wp-admin/post.php?post=<post-id>&action=edit&revision=<old-revision-id>.
  3. Check that the post editor opens in revisions mode at that revision.
  4. Move the revision slider and check that the revision arg changes to the selected revision.
  5. Click “Exit” and check that the revision arg is removed.
  6. Open the same post with an invalid revision ID and check that the notice appears and the URL is cleaned up.
  7. Repeat the deep-link, slider, and exit checks for a page in the site editor with wp-admin/site-editor.php?p=%2Fpage%2F<page-id>&canvas=edit&revision=<old-revision-id>.
  8. For a post type with active classic meta boxes, open a revision deep link and check that it redirects to the classic revisions screen.

Screencast

Grabacion.de.pantalla.2026-07-08.a.las.12.12.25.mov

Implemented with Claude and Codex, with direction, manual testing, and review by me.

@priethor priethor self-assigned this Jul 7, 2026
@github-actions github-actions Bot added [Package] Editor /packages/editor [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site [Package] Router /packages/router labels Jul 7, 2026
@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @priethor! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

Size Change: +1.23 kB (+0.02%)

Total Size: 7.77 MB

📦 View Changed
Filename Size Change
build/scripts/core-data/index.min.js 36.4 kB -4 B (-0.01%)
build/scripts/edit-post/index.min.js 52.4 kB +488 B (+0.94%)
build/scripts/edit-site/index.min.js 306 kB +447 B (+0.15%)
build/scripts/editor/index.min.js 501 kB +284 B (+0.06%)
build/scripts/router/index.min.js 5.97 kB +12 B (+0.2%)

compressed-size-action

@im3dabasia

Copy link
Copy Markdown
Contributor

Surprised to see the "First-time contributor" label added to these PRs #79934 and #79901 😕 , Ideally should not have happened.

@priethor priethor added [Feature] History History, undo, redo, revisions, autosave. [Type] Enhancement A suggestion for improvement. and removed First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository labels Jul 7, 2026
@cbravobernal

Copy link
Copy Markdown
Contributor

Surprised to see the "First-time contributor" label added to these PRs #79934 and #79901 😕 , Ideally should not have happened.

Bots doing bots stuff :)

@priethor

priethor commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Surprised to see the "First-time contributor" label added to these PRs

Indeed, it was very annoying 😅 . Fixed it in #79987

@priethor
priethor marked this pull request as ready for review July 13, 2026 10:47
Comment thread packages/editor/src/store/private-actions.js Outdated
Comment thread packages/edit-post/src/components/browser-url/use-classic-revision-redirect.js Outdated

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some minor comments but things tested well for me.

'wp_template_part',
].includes( postType );

useEffect( () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this is an effect. Why don't we do this when the revisions button is clicked, or determine the right link to provide for the button?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button already links to revision.php when clicked, indeed, but the effect handles opening an editor URL that already contains ?revision= in it. In that case, we only know after the editor loads whether the post needs the classic revisions screen or not, and once we know, the effect redirects there. I added a comment to make that clearer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only know that when the editor loads? Why can't we redirect in PHP?

const _isPreviewingTheme = isPreviewingTheme();
const iframeProps = useEditorIframeProps();
const isEditMode = canvas === 'edit';
useRevisionsURLSync( isEditMode, editorPostType, editorPostId );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just seeing this already makes me wonder: is the URL not the source of truth? If not, why not? Why are we syncing it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the URL sets the initial revision when an entity loads. After that, the existing revisions UI keeps the selection and this hook mirrors those changes back to the URL.

Making the URL the only source would mean changing the shared revision controls so every selection goes through navigation, especially while using the slider. I’m not against that, but it felt like a bigger behavioral change and a lot of navigation for this PR. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the URL the only source would mean changing the shared revision controls so every selection goes through navigation, especially while using the slider.

Shouldn't that be the case? The URL is the state. What's the behavior change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior change is mostly in the slider: the preview updates immediately, while URL updates have to be throttled because of Safari’s History API limit. Making the URL the source of truth would be cleaner indeed, but it would also need some changes to the shared revision controls. I’d rather handle that in a polishing follow-up, would that work for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Isn't the slider already throttled?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but it might be worth considering handlding the throttle at RangeControl level. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I throttled a tiny bit because otherwise it goes through tons of diff calculations of intermediate revisions you slide through.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does, I can't see it 😅 . The slider seems to dispatch on every input event, so dragging accross 20 revisions would parse all 20, not just the one you land in.

I guess moving up the throttle a level (even if it's not at range control level) would improve the revisions performance to avoid these unnecessary diffings when sliding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess moving up the throttle a level (even if it's not at range control level) would improve the revisions performance to avoid these unnecessary diffings when sliding.

To answer my comment above: I measured it to see how impactful it could be with 30 revisions of ~100 paragraphs each and it takes under 50 ms for a full drag, so I don't think it's worth considering throttling at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think I ended up speeding up diffing and dropped the throttling maybe. 🤔 100 paragraphs is small though.

@priethor
priethor merged commit 816fdbb into trunk Aug 3, 2026
50 of 57 checks passed
@priethor
priethor deleted the add/addvisual-revisions-shareable-urls branch August 3, 2026 17:05
@github-project-automation github-project-automation Bot moved this from 🔎 Needs Review to ✅ Done in WordPress 7.1 Editor Tasks Aug 3, 2026
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 3, 2026
@t-hamano

t-hamano commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR is a blessed task, so we are considering backporting it to 7.1. Do you have any concerns about backporting this PR as is to 7.1? cc @annezazu

@priethor

priethor commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Do you have any concerns about backporting this PR as is to 7.1?

I'd like to explore a follow-up based on the feedback received to make the URL the canonical source of truth. I don't consider it a blocker to port it and start testing it, but also don't have a strong opinion on whether it should be included at this point, I'll defer to release leads.

@t-hamano

t-hamano commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

It has been agreed to backport this PR to 7.1. If a follow-up PR is submitted, let's backport it to 7.1 as well, if possible.

@t-hamano t-hamano added the Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

There was a conflict while trying to cherry-pick the commit to the wp/7.1 branch. Please resolve the conflict manually and create a PR to the wp/7.1 branch.

PRs to wp/7.1 are similar to PRs to trunk, but you should base your PR on the wp/7.1 branch instead of trunk.

# Checkout the wp/7.1 branch instead of trunk.
git checkout wp/7.1

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick 816fdbb14f353498aed164cde410274d741057ec

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.1 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

t-hamano added a commit that referenced this pull request Aug 5, 2026
Co-authored-by: priethor <priethor@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
@t-hamano

t-hamano commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Manual backport: #81205

@t-hamano t-hamano added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.1 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Aug 5, 2026
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
Co-authored-by: priethor <priethor@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] History History, undo, redo, revisions, autosave. [Package] Core data /packages/core-data [Package] Edit Post /packages/edit-post [Package] Edit Site /packages/edit-site [Package] Editor /packages/editor [Package] Router /packages/router [Type] Enhancement A suggestion for improvement.

Projects

Development

Successfully merging this pull request may close these issues.

Revisions: Ability to link to a specific revision in the editor

10 participants