Skip to content

feat(publish): one before/after publish dialog for Fast Preview and sandbox - #7792

Merged
guitavano merged 6 commits into
mainfrom
guitavano/modal-fast-preview-difference
Oct 8, 2026
Merged

guitavano merged 6 commits into
mainfrom
guitavano/modal-fast-preview-difference

Conversation

@guitavano

@guitavano guitavano commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

Publishing looked different depending on the session runtime. Fast Preview opened the content-first popover, with change cards, a version note and an optional before/after review. Coding sessions with a sandbox opened a separate dialog with a commit-message form, Description/Changes tabs and a raw file diff. Both ran the same publish sequence (publish-flow.ts), but they showed it differently.

This PR gives both runtimes one publish surface: the fullscreen before/after review.

  • Sandbox sessions use the shared dialog. HeaderActions mounts PublishDialog, the former CmsPublishPopover, in place of the legacy dialog. "Review & Publish" opens it in publish mode and "Submit for review" opens it in review mode. A blocked gate switches it to review mode through "Request approval".

  • Sandbox changes come from the daemon. The daemon has no changed-file manifest, so useCmsPublishState builds the cards from the publish diff instead. fetchPublishDiff combines base…head with the working-tree diff, because a sandbox publish commits the working tree too.

    • The base diff is also fetched for unpushed commits and for daemons that omit aheadOfBase.
    • Bodies are keyed by the working tree's file list and never reused across openings.
    • A failed first read shows a load error instead of "everything is live". A failed background refetch keeps the loaded dialog.
    • Re-provisioning an unreachable sandbox runs at most once per opening, shared by every read that hits it.
  • Sandbox publishes are checked against what was shown. The agent can edit the working tree without moving HEAD. So a sandbox publish re-reads the diff and refuses with "branch changed" if its reviewDiffSignature no longer matches the confirmed one, before anything is pushed.

  • Discard is offered only where it works. The daemon's /git/discard restores working-tree paths only. In a sandbox, Discard and "Discard all" are hidden for committed changes instead of reporting a false success.

  • The "after" frame renders on the sandbox preview. CompareDraft is either Fast Preview's ?__draft= pointer or the sandbox preview URL. compareDraftUrl renders the same path and query on the sandbox dev server, for pages and for isolated global sections. "Before" is still the live site. In a sandbox, code changes (the "Other" group) get the same comparison, starting on the home page with an editable path. Fast Preview never changes code, so there those cards keep only the Code tab.

  • The visual review is the only mode. The publishVisualReview project setting, its settings toggle, the compact 420px popover, the narrow-viewport modal and the inline expand-diff card mode are removed. On narrow screens the review pane, including its Code tab, is stacked above the change list.

  • Labels and retry.

    • "In production" titles appear only for main and master bases; other bases get plain "Publish N changes".
    • The error boundary is wrapped in QueryErrorResetBoundary, so "Retry" refetches failed queries instead of rethrowing the cached error.
  • Removed as unused:

    • The legacy PublishDialog, publish-label.ts, shouldUseBaseDiff and the publishVisualReview schema field (tool contracts regenerated), plus their i18n keys.
    • The whole AI commit-message suggestion: the web fetchSuggestCommitMessage, the API /git/suggest-commit route and suggest-commit-message.ts, and the native suggest-commit intercept. Judge-review's shared context builder moved to apps/api/src/lib/git-change-context.ts.
  • Native clippy on Rust 1.99. Stable 1.99 deprecates Atomic::fetch_update and flags async-trait's generated #[must_use], which failed rust-checks for any PR touching apps/native. The three call sites now use try_update, and async-trait is bumped to 0.1.92, whose release fixes the lint.

Behavior changes for sandbox sessions:

  • The AI commit-message suggestion and its "Regenerate" button are gone. The version note is derived from the change cards; its first line is the PR and commit title.
  • The branch → main · squash-merge line is no longer shown.
  • Generated artifacts (blocks.gen.json, tailwind.css, meta.gen.json) are not listed as cards. They still publish and are reverted by "Discard all".
  • Committed changes cannot be discarded from the dialog. They could not before either; the old dialog reported success.

Known gaps:

  • The daemon's base diff reads the remote branch tip. Local commits that are not yet pushed onto an existing remote branch are pushed on publish but not listed. This predates the PR and needs daemon support.
  • Projects without a production URL get only the code diff, because there is no "before" to render.

How did you verify your code works?

  • apps/native: cargo clippy --workspace --exclude deco --all-targets -- -D warnings and cargo fmt --check pass on Rust 1.99. The Tauri crate needs CI-fetched binaries, so it is left to CI.
  • bun run verify passes: fmt, oxlint and knip are clean, and 10353 tests pass with 0 failures.
  • tsc --noEmit passes in apps/web, apps/api and packages/shared.
  • New tests:
    • publish-flow.test.ts: a sandbox publish stops before pushing when the working tree changed under the same head, and pushes when it still matches what was shown.
    • sandbox-git-api.test.ts → fetchPublishDiff:
      • Fast Preview reads base…head alone, with the routing header.
      • A sandbox combines both diffs, and the working tree wins on overlaps.
      • A dirty-only tree skips the base diff.
      • A clean tree with commits ahead reads base…head and forwards headSha.
    • sandbox-git-api.test.ts → mayHaveCommitsToPublish: commits ahead, unpushed commits, and a daemon that omits aheadOfBase.
    • cms-publish-compare-path.test.ts → canRenderCompare: content renders in both runtimes, code only on a sandbox, and nothing renders without a live site.
    • cms-publish-compare-path.test.ts → compareDraftUrl:
      • No draft renders nothing.
      • The pointer keeps the live origin and adds __draft.
      • A sandbox maps path and query, and keeps a global section's props, on the sandbox origin.
    • apps/api/src/lib/git-change-context.test.ts keeps the coverage of the moved judge-review helpers.
  • The native Rust change (removing the suggest-commit intercept) was not compiled locally because no Rust toolchain was available. native.yml runs clippy and cargo test on it.
  • Not verified in a running app. The sandbox path needs a live sandbox, and none was available while this was written.

Screenshots/Demonstration

Pending: screenshots of the dialog in a Fast Preview session and in a sandbox session will be attached before merge.

How to Test

  1. Open a project in a Fast Preview session, edit a page and click "Review & Publish". The fullscreen dialog shows the page before and after, side by side.
  2. Open the same project in a coding session with a sandbox, change a page (content or code) and click "Review & Publish". You get the same dialog. Content changes render on the live site ("before") and the sandbox preview ("after"). Code files appear under "Other": selecting one compares the home page on the live site and the sandbox (type another path to compare it), with the diff in the "Code" tab.
  3. In the sandbox session, discard an uncommitted card. It disappears and the list refreshes. Changes that are already committed show no Discard button.
  4. With the dialog open, let the agent edit a listed file, then publish. The dialog refuses with "This branch changed since these changes were shown" and re-reads the list.
  5. Use "Submit for review" from the menu. The dialog opens in review mode and opens or updates the PR.
  6. Narrow the window below 768px. The review pane sits above the list.
  7. In project settings, the "Visual publish review" toggle is gone.

Migration Notes

None. Virtual MCP metadata schemas are .loose(), so rows that still store publishVisualReview keep validating and the key is ignored.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working (not yet verified in a running app; screenshots pending)
  • Documentation is updated (if needed)
  • No breaking changes (the setting and the AI commit suggestion are removed, and sandbox publishing UX changes, see above)

🤖 Generated with Claude Code

…andbox

Coding sessions now publish through the same dialog as Fast Preview: change
cards, a version note and a before/after review pane. The sandbox side reads
its changes from the daemon (base…head plus the working tree) and renders the
"after" frame on the sandbox preview. The visual review is no longer a
project setting — it is the only publish surface, so the compact popover,
the publishVisualReview metadata field and the legacy commit-message dialog
are removed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@github-actions github-actions Bot added the claude PR authored by a coding agent label Oct 7, 2026
guitavano and others added 5 commits October 7, 2026 19:13
- Sandbox: only offer Discard for working-tree paths; committed changes
  cannot be reverted by the daemon and showed a false success.
- Sandbox: publish re-reads the diff and refuses when it no longer matches
  what was shown (the agent can edit the working tree without moving HEAD).
- A failed background refetch no longer replaces a loaded dialog with the
  load error; re-provisioning runs at most once per opening.
- Fetch the base diff for legacy daemons without aheadOfBase and for
  unpushed commits.
- Narrow screens stack the review pane above the list instead of hiding it.
- "In production" labels only for main/master bases.
- Read the last previewed page when the dialog opens, not on every header
  render; drop the unused orgId prop and stale "popover" docs.
- Remove the now-unused /git/suggest-commit route, its library and the
  native intercept; judge-review keeps its shared context builder.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Stable 1.99 deprecates `Atomic::fetch_update` (renamed `try_update`) and
flags the `#[must_use]` that async-trait <0.1.92 emits as double_must_use,
so `cargo clippy -D warnings` fails for any PR touching apps/native.
Rename the three call sites and bump async-trait to 0.1.92, which drops the
redundant attribute.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Code files (the "Other" group) only offered the Code tab, which made sense
for Fast Preview, where code never changes. A sandbox already runs the
changed code, so render those cards too: live site against the sandbox
preview, starting on the home page with an editable path. A new or removed
code file no longer shows the "didn't exist" placeholders, since the page
itself still exists on both sides.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Opened before the editor's decofile loaded, a page card has no path until
its body lands. The compare pane froze that empty path in state, and once
the path arrived the page was no longer editable, leaving "Type a page
address" with no field to type in. The path and view now follow the change
until the reviewer types a path or picks a tab.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Every card switch remounted the compare pane, and every tab switch
unmounted a frame, so each one reloaded a full storefront page. Panes now
stay mounted and hidden: the selected card, the recently visited ones and
the next in the list (up to four, so at most eight frames) load once, and
switching cards or tabs is instant. Each pane also keeps its own path, tab
and device.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@guitavano
guitavano merged commit f83981b into main Oct 8, 2026
37 checks passed
@guitavano
guitavano deleted the guitavano/modal-fast-preview-difference branch October 8, 2026 11:12
decocms Bot pushed a commit that referenced this pull request Oct 8, 2026
PR: #7792 feat(publish): one before/after publish dialog for Fast Preview and sandbox
Bump type: minor

- decocms (apps/api/package.json): 4.453.1 -> 4.454.0
- @decocms/native (apps/native/package.json): 4.453.1 -> 4.454.0
- @decocms/shared (packages/shared/package.json): 0.139.0 -> 0.140.0

Deploy-Scope: both
tlgimenes added a commit that referenced this pull request Oct 8, 2026
…ship follows the org_sites link

Brings in #7796 (org_sites.project_id link, immutable site slugs) and main.

Hosted switch:
- ownedProjectSite(orgSites, projectId, orgId) reads the project's org_sites
  link (getByProject) instead of metadata.siteSlug. hosted routes,
  decofile scope and the sandbox-less draft status use it.
- claim-site.ts: a project's site is linked once (linkProjectSite): a slug no
  org owns is claimed first (still refused for deco.cx sites and slugs another
  org's project names), then linked. Tombstoned (reserved) slugs, another
  org's, another project's, or a second slug for a linked project are refused.
- Admin backfill links v8 projects (report: linked / alreadyLinked / refused /
  ambiguous); several projects of one org naming one slug are ambiguous.
- e2e: a slug change is refused and hosted keys stay on the linked site.

Conflicts:
- publish UI: main (#7792) replaced cms-publish-popover.tsx with
  publish-dialog.tsx; the hosted changes (no review mode, no Request approval,
  hosted publish action) moved into publish-dialog.tsx.
- main removed the project "git" tab; kept hosted's "releases" tab only.
- sandbox-proxy.ts: main dropped /git/suggest-commit; judge-review keeps the
  hosted-aware fastPreviewStatus/fastPreviewDiff backfill.
- create.ts: project creation goes through claimProjectSite (claim + link).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WNwbSEePYNcY5YCgqZURig
tlgimenes added a commit that referenced this pull request Oct 15, 2026
…uction build

Run against the production web build (vite preview, as CI does), four
deco serve tests failed and others timed out at random. None is a product
bug:

- Changes: the change card names its status in the icon's title since
  #7792 ("Edited" is not visible text). Assert it with getByTitle.
- Outdated 8.1.x server: the protocol handler gzips larger answers, and
  the stub's 1.0 rewrite read the gzip bytes as text and resent them with
  Content-Encoding: gzip, so Chromium failed with
  ERR_CONTENT_DECODING_FAILED and the page said "Another program is
  using localhost". The stub now decodes the answer and sends it plain.
- Localhost: picking it closes the drafts menu (edd6986), so
  "Connected" was only seen when the connection beat the close
  animation. The test waits for the menu to close and reopens it.
- Stub close: server.close() waits for idle keep-alive connections,
  which a polling editor never leaves, so a test hung in `finally` until
  its 120 s timeout. Close every connection first.
- Off-machine link: the guide's warning is checked with the 30 s timeout
  the other page loads use, not the 5 s default.

deco serve spec, production build, --repeat-each=4: 40/40.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016ZsmzpZ2zahRBoATBb2tBu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR authored by a coding agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant