Skip to content

fix(editor): refresh Publish affordance after bridge-driven save#188

Open
RemiAsselin42 wants to merge 1 commit into
CoreBunch:mainfrom
RemiAsselin42:fix/editor-publish-button-bridge-save
Open

fix(editor): refresh Publish affordance after bridge-driven save#188
RemiAsselin42 wants to merge 1 commit into
CoreBunch:mainfrom
RemiAsselin42:fix/editor-publish-button-bridge-save

Conversation

@RemiAsselin42

@RemiAsselin42 RemiAsselin42 commented Jul 5, 2026

Copy link
Copy Markdown

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), so hasUnsavedChanges flips 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 lastSavedAt that 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 build
  • bun test (no unit test added; see checklist note)
  • bun run lint
  • Docker/deployment check, if relevant (not applicable)

Checklist

  • Tests cover behavior changes. (No automated test added: the fix is a toolbar effect that depends on the live editor bridge and the save pipeline. Verified by build, lint, and a manual bridge-save exercise. Happy to add a test if you prefer.)
  • Docs were updated when behavior, config, deployment, or public surfaces changed. (No user-facing surface or public API changed.)
  • No compatibility shim was added for old pre-release behavior.
  • No secrets, local databases, uploads, or generated artifacts are included.

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.
@RemiAsselin42 RemiAsselin42 marked this pull request as ready for review July 6, 2026 08:59
Copilot AI review requested due to automatic review settings July 6, 2026 08:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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-queries getCmsPublishStatus() 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants