Overview
- #3505118: The status badge should indicate if there are changes to the page made the status badge way better.
- #3502902: Only auto-save content entities/PageRegion config entities when there are actual changes: simply previewing incorrectly causes them to appear in "Review x changes" made the "Review changes" way more useful.
But both are less impressive due to the ~10 s delay between making changes and seeing those UI pieces react:

That's because both depend on the ~10s polling of /xb/api/autosaves/pending.
(The status badge changes from Published
for an existing unmodified entity to Changed
after you make any modification, as you can see in the GIF. See @jessebaker's diagram at #3505118-6: The status badge should indicate if there are changes to the page.)
Proposed resolution
We already are updating XB's preview immediately, by doing POST /xb/api/layout/…. after any client-side change.
That response currently only returns
{"html": …}
We can just make that also return a list of auto-saves newly created during that request, that’d result in instantaneous updates to both the status badge and “Review changes”!
No websockets. Not even a new request 😊 We only need websockets for making those changes appear instantaneously for other users, but for those it’s fine if it only arrives every ~10s.
User interface changes
The same as in the GIF, but instantaneous!
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | glitches.gif | 248.61 KB | hooroomoo |
| #11 | XB UI instantaneous auto-save detecting.gif | 53.22 KB | wim leers |
| XB UI polling dependent.gif | 167.72 KB | wim leers |
Issue fork experience_builder-3509270
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
wim leersThere: I propose to simply make mutations to the layout (
POSTorPATCHto/xb/api/layout/…) to change:POSTPATCHhtml, but alsolayout,modelandentity_form_fields:Comment #4
larowlanAn alternate proposal
In preview.ts in previewApi.endpoints.postPreview.onQueryStarted trigger a clientside invalidation and force pendingChangesApi.endpoints.getAllPendingChanges to invalidate.
It would require adding a cache tag to getAllPendingChanges and using something like https://git.drupalcode.org/project/experience_builder/-/merge_requests/7... from onQueryStarted
Comment #5
wim leers#4: that works too, but does require an extra request. I know that the polling is still ongoing, and so this would just change the polling rhythm, if you will.
But … #4 is inevitably more concurrent requests immediately after making changes. And hence also more Drupal bootstraps.
I think in my proposal, we can even reduce the polling frequency, to say, every 30 seconds. It'll still feel instantaneous.
Comment #6
larowlanYes but it does require making use of RTK Query internals - https://redux-toolkit.js.org/rtk-query/usage/manual-cache-updates which as @balintbrews has pointed out
Comment #7
larowlanJust to be clear, I'm not against manual cache updates, PreviewEnvelope was designed for this purpose
Comment #9
wim leersSo you're saying: your MR fixes it with a
+13,0diffstat, barely more than my OpenAPI-only change 🤣Yeah, that's a no-brainer! Can't wait to test that tomorrow! 😄 (Would be happy to insta-merge after manual testing, and to move what I proposed to a new issue for a distant future.)
Comment #10
wim leersWill test @larowlan's MR after lunch 👍
Comment #11
wim leersWell … that totally works 😄🤩
Still needs approval by somebody who knows RTK queries.
Comment #13
hooroomooI may have found a regression so am looking into it. Clicking publish all changes shows the happy green smiley but then flashes back to show "Publish all changes" again
Comment #15
hooroomooAdding credit for @jessebaker for pointing me to the manualRetch that might not be necessary anymore and removing it fixed the regression i was looking at
Comment #16
longwave@hooroomoo I've manually tested this and can't find any issues.. I can reproduce the delay on 0.x but with the MR in place it's gone, the Published > Changed label updates almost instantly. Publishing then works as expected - with no issues as in #13 - then I can repeat the whole cycle.
Comment #17
larowlanI reverted @hooroomoo's changes after we tested in a zoom call and found the behaviour reported in #13 actually exists in HEAD too - #3509509: When adding single hero component Auto-save shows a change when there is not one
I've implemented the change of dispatch ordering per my review and that
a) fixes the bug from this issue
b) keeps things the same as they are in head for #3509509: When adding single hero component Auto-save shows a change when there is not one (i.e. it takes 10s for it to (wrongly) report 1 change - which is what was happening in #13 but immediately rather than after 10s
I think this is ready to go
Comment #18
wim leersSee #11 for my enthusiasm after seeing the impact 🤩
Comment #20
effulgentsia commented