Skip to content

Chore: Warn when updating a Spaces page with an active editor draft#377

Open
rafaeljusto wants to merge 1 commit into
mainfrom
chore/spaces-warn
Open

Chore: Warn when updating a Spaces page with an active editor draft#377
rafaeljusto wants to merge 1 commit into
mainfrom
chore/spaces-warn

Conversation

@rafaeljusto

Copy link
Copy Markdown
Contributor

Description

Publishing page content through the REST API updates only the published content, not the collaborative OT editor draft ("Edit version"). When a page already has an active draft, that draft goes stale, and a subsequent edit-and-publish from the Spaces web editor can silently overwrite the API-published content. This is a Spaces backend limitation with no REST surface to update the draft, so the MCP cannot fix the data itself.

As an interim mitigation, twspaces-update_page now detects the dangerous case and warns without blocking: when a write changes published content (content set, or isPublish present) and the page's draftVersion > 1, the tool result is prefixed with a draft-sync warning that points the user to "Revert to last published version" in the web editor to resync. The draftVersion is read from the request argument first, falling back to a best-effort get only when absent/<=1, so the common path adds no extra call. Pages with draftVersion <= 1 (no real draft yet; the editor self-heals on first edit) produce no warning. The update_page tool description also states the limitation.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

  • Tests pass locally (go test -v ./...)
  • Added/updated tests for new functionality

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added necessary documentation
  • No new warnings or errors

Publishing page content through the REST API updates only the published
content, not the collaborative OT editor draft ("Edit version"). When a
page already has an active draft, that draft goes stale and a subsequent
edit-and-publish from the Spaces web editor can silently overwrite the
API-published content. This is a Spaces backend limitation with no REST
surface to update the draft, so the MCP cannot fix the data itself.

As an interim mitigation, twspaces-update_page now detects the dangerous
case and warns without blocking: when a write changes published content
(content set, or isPublish present) and the page's draftVersion > 1, the
tool result is prefixed with a draft-sync warning that points the user to
"Revert to last published version" in the web editor to resync. The
draftVersion is read from the request argument first, falling back to a
best-effort get only when absent/<=1, so the common path adds no extra
call. Pages with draftVersion <= 1 (no real draft yet; the editor
self-heals on first edit) produce no warning. The update_page tool
description also states the limitation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rafaeljusto rafaeljusto requested a review from a team as a code owner July 8, 2026 14:10
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.

1 participant