fix(admin): preview-aware banner + relabelled posts links + Check-for-Preview fix - #1170
Merged
Conversation
…-Preview fix Posts list (admin/posts-list-enhance.js): - rename "preview-pr<N> ↗" → "preview draft ↗" (URL unchanged) - rename "PR #<N>" → "view draft changes", point at the PR /files diff - add "view published changes" → the merged PR's /files diff, derived from the last main commit's associatedPullRequests (one batched GraphQL query). Shown only when the post is actually live on main (an unpublished draft has no merged PR); rendered before "preview draft" when both are present. Edit screen banner (admin/live-url-banner.js): - when the open entry is an unmerged editorial-workflow draft, swap the host to its per-PR preview env (preview-pr<N>.adamdaniel.ai) instead of linking the prod URL that 404s for the whole draft lifecycle. Reuses posts-list-enhance's PR cache / operator token; degrades to the current origin with no token or on API error. "Check for Preview" stuck forever (root cause): - decap-cms 3.12.2's github backend reads GET /commits/<sha>/status and matches backend.preview_context — it never reads the GitHub Deployment we register. deploy-preview.yml now also publishes a deploy/preview commit status (state=success, target_url=preview root) and admin/config*.yml pin backend.preview_context to it, so the editor resolves to "View Preview" → the post's preview URL. Tests: e2e/cms-posts-list-enhance.spec.js gains a pure-fs lock for all of the above; e2e/select-specs.js runs it on deploy-preview.yml too. Local-only branch per request — not pushed. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
🗑️ Preview environment cleaned up. |
Contributor
Visual Regression Video
Video regenerates automatically on every push to this PR. |
Contributor
E2E tests passing on
|
Adam-S-Daniel
enabled auto-merge (squash)
May 19, 2026 23:20
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.
Problem
On
https://adamdaniel.ai/admin/#/collections/postsand the edit-post screen, three things were wrong for unpublished-draft posts (exemplified by “Safely Keep Your Agent Iterating Autonomously With Gitleaks and PR Comments”, PR #941):preview-pr941,PR #941.https://adamdaniel.ai/blog/<slug>/) even though the post isn’t merged → 404 for the whole draft lifecycle.Root cause of (3)
decap-cms 3.12.2’s github backend implements
getDeployPreviewasGET /repos/.../commits/<pr-head-sha>/statusand surfaces the first commit status whosecontextmatchesbackend.preview_context. The repo only ever registered a GitHub Deployment (environment: preview-pr-<N>) — whichadmin/deploy-status-pill.jsreads, but Decap’s editor never does. (The decapcms.org “polls/deployments?ref=” docs describe the Netlify backend, not github.) No matching commit status ⇒ permanent “Check for Preview”.Changes
admin/posts-list-enhance.jspreview-pr<N> ↗→ “preview draft ↗” (URL unchanged:https://preview-pr<N>.adamdaniel.ai/blog/<slug>/)PR #<N>→ “view draft changes”, now pointing at the PR’s GitHub Files-changed diff (…/pull/<N>/files)/filesdiff, derived from the lastmaincommit’sassociatedPullRequests(added to the existing batched GraphQL query — still three calls total). Visibility exactly per spec: unpublished draft → no (no merged PR onmain); published → yes; published + draft changes → yes, rendered before “preview draft”.admin/live-url-banner.js— when the open entry has an open editorial-workflow PR, the banner swaps the host to that PR’s preview env (preview-pr<N>.adamdaniel.ai), exactly the URL the list surfaces; no open PR → current origin (genuinely live). Reuses the list’s shared PR cache / operator Decap token; no token / API error → degrades to the prior behaviour. Thepublished: falseplaceholder is untouched (socms-link-crawler’s known-bug allowlist still holds)..github/workflows/deploy-preview.yml— addsstatuses: writeand a step that publishes adeploy/previewcommit status (state: success,target_url= preview root) on the PR head SHA. Decap runs thattarget_urlthrough itspreview_pathbuilder, so the editor’s button resolves to “View Preview” →https://preview-pr<N>.adamdaniel.ai/blog/<slug>/.admin/config.yml/config-local.yml/config-test.yml— pinbackend.preview_context: deploy/preview(explicit, auditable; survivespatch-preview-config.sh, which only rewritessite_url/display_url/branch).Docs/tests —
AGENTS.mdbrought in sync (banner preview-origin, posts-list links, the two-signals contract);e2e/cms-posts-list-enhance.spec.jsgains a pure-fs lock for all of the above;e2e/select-specs.jsruns that spec ondeploy-preview.ymlchanges too.Verification
node --checkclean on modified JS; all YAML valid.cms-posts-list-enhance.spec.js17/17; pluscms-config,cms-permalink-contract,deploy-preview-cms-slug,preview-bot-comment,deploy-commit-metadata,cms-native-view-live,sitemap,select-specs.test.js— no existing static contract regressed.deploy-preview.yml’s trigger/paths-ignoreis unchanged and still correct — the new step consumes no new repo path (pure github-script on context+env, same dependency surface as the adjacent Deployment-registration step);deploy-previewis intentionally not a required check, so workflow-levelpaths-ignoreremains the right pattern (no always-run+early-skip refactor needed).Rollout note
The “Check for Preview” fix takes effect on future preview deploys — the commit status is set per deploy and is not backfilled, so an already-open PR only gets it on its next push.
🤖 Generated with Claude Code