fix(editor): refresh Publish affordance after bridge-driven save#188
Open
RemiAsselin42 wants to merge 1 commit into
Open
fix(editor): refresh Publish affordance after bridge-driven save#188RemiAsselin42 wants to merge 1 commit into
RemiAsselin42 wants to merge 1 commit into
Conversation
An MCP editor-bridge edit flushes the draft save immediately (`flushEditorSave`), flipping `hasUnsavedChanges` true->false within a single tick — too fast for the reset effect to ever observe `true`. The Publish button stayed stuck on "Published" after a bridge edit, so the change could not be published without an editor reload. Re-query publish status whenever a save completes by keying an effect off the save's `lastSavedAt`. This covers manual and bridge-driven saves alike and never interrupts an in-flight publish.
There was a problem hiding this comment.
Pull request overview
Keeps the Site editor toolbar’s Publish button state accurate after saves that complete “too fast” to be observed via the existing hasUnsavedChanges-based reset (notably saves triggered via the MCP editor bridge), by re-checking server publish status after each completed save.
Changes:
- Adds a
lastSavedAt-keyed effect that re-queriesgetCmsPublishStatus()after each completed draft save. - Updates the Publish button state based on whether the saved draft matches what’s currently published, without disrupting an in-flight publish.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Keeps the Site editor toolbar's Publish button in sync after a save that comes from the MCP editor bridge.
A bridge-driven edit flushes the draft save immediately (
flushEditorSave), sohasUnsavedChangesflips from true to false within a single tick. The existing reset effect never gets a render where the flag is true, so the Publish button stayed stuck on "Published", and a bridge edit could not be published without reloading the editor.This adds an effect keyed off the save's
lastSavedAtthat re-queries publish status (getCmsPublishStatus) after every completed save, manual or bridge. It never interrupts an in-flight publish and re-enables Publish when the draft differs from what is published. Manual editing is unaffected, since the same refresh now also covers it.Verification
Run on Windows 11, Bun 1.3.14:
bun run buildbun test(no unit test added; see checklist note)bun run lintChecklist