Skip to content

Don't save the page draft when the builder opens - #276

Merged
s3rot0n1n merged 1 commit into
mainfrom
t3/builder-no-save-on-open
Nov 29, 2026
Merged

s3rot0n1n merged 1 commit into
mainfrom
t3/builder-no-save-on-open

Conversation

@s3rot0n1n

Copy link
Copy Markdown
Contributor

Fixes #274.

The builder's change effect also ran on mount, so just opening a page saved the draft: once in production, twice in development because of StrictMode. Each open raised draftVersion and updatedAt without any edit. As a result, update_page callers passing expectedDraftVersion got spurious STALE_DRAFT, other open tabs saw a false "changed elsewhere", and page lists showed viewed pages as recently edited.

The builder now remembers the state it opened with and skips onChange until the layout, theme, SEO or custom themes change.

A draft saved before the page text profile used to be cleaned by that open-time save. Now it's cleaned by the next real save. Nothing depended on the open-time save: the renderer and the status check already handle such drafts, and MCP update_page repairs them.

There's a changeset for @frontlit/page-builder (patch), since CourseLit uses the package.

Testing

  • page-builder: typecheck passes, 83 tests pass. The lint warning (an unused disable directive) was already on main. The package has no DOM test setup, so the fix is checked in the browser instead.
  • Local browser smoke on the "Launch copy" page:
    • Opened it in the builder: draftVersion stayed at 8. Before the fix it went to 10.
    • Moved a block: one save, version 9, order saved.
    • Reloaded: still 9.
    • Moved the block back: version 10, original order restored.

🤖 Generated with Claude Code

The builder's change effect ran on mount, so opening a page saved it
(twice in development under StrictMode), raising draftVersion and
updatedAt with no edit. Skip the state the builder opened with.

Fixes #274

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T05:49:13.177099Z 6546b34 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@s3rot0n1n
s3rot0n1n merged commit 09be592 into main Nov 29, 2026
4 checks passed
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.

Builder saves the draft on open, bumping draftVersion with no changes

1 participant