Skip to content

Started confirming automation re-publish#28113

Merged
troyciesco merged 1 commit into
mainfrom
evanhahn-ny-1299-before-publishing-an-active-automation-confirm-with-user
May 25, 2026
Merged

Started confirming automation re-publish#28113
troyciesco merged 1 commit into
mainfrom
evanhahn-ny-1299-before-publishing-an-active-automation-confirm-with-user

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

closes https://linear.app/ghost/issue/NY-1299

Screencast.mp4

If an automation is active and you go to update it, we now show a confirmation dialog.

This change has no effect for inactive automations.

closes https://linear.app/ghost/issue/NY-1299

If an automation is active and you go to update it, we now show a
confirmation dialog.

This change has no effect for inactive automations.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ce53627b-a6ef-4028-bdd2-0228ae145995

📥 Commits

Reviewing files that changed from the base of the PR and between 87b6c6e and b4d876c.

📒 Files selected for processing (3)
  • apps/posts/src/views/Automations/editor.tsx
  • apps/posts/src/views/Automations/types.ts
  • apps/posts/test/unit/views/automations/automation-editor.test.tsx

Walkthrough

This PR extends the automation editor's state machine to support republishing active automations through a user confirmation flow. A new AutomationEditState type is introduced with 're-publishing', 'confirming re-publish', and 'failed to re-publish' states. The save() function is refactored to compute state transitions from old-to-new status values, enabling explicit republish paths. When publishing an active draft, the UI now routes to a confirmation modal ("Update automation?") instead of immediately saving; inactive drafts proceed directly to save. The edit state switch is extended with handlers for the new republish states that control dialog visibility, button state, and retry styling. Test coverage is updated to verify the confirmation modal appears, prevents immediate mutation, and supports retrying after failures.

Possibly related PRs

  • TryGhost/Ghost#27852: Updates AutomationHeader publish button state and label when automation is active, directly related to the header wiring changes in this PR.
  • TryGhost/Ghost#28055: Refactors automation editor save() UI state-machine and AutomationHeader prop wiring for the same useEditAutomation mutation flow, including inactive save/retry patterns.
  • TryGhost/Ghost#27857: Modifies automation editor publish/turn-on/off state machine and useEditAutomation wiring, which this PR extends with republish confirmation and failure states.

Suggested labels

ok to merge for me

Suggested reviewers

  • troyciesco
  • cmraible
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a confirmation dialog when re-publishing (updating) an active automation, which is the core feature introduced in this PR.
Description check ✅ Passed The description is directly related to the changeset, explaining that a confirmation dialog now appears when updating an active automation, with no effect for inactive ones.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch evanhahn-ny-1299-before-publishing-an-active-automation-confirm-with-user

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud

This comment was marked as low quality.

@nx-cloud

This comment was marked as low quality.

@@ -173,27 +233,49 @@ const AutomationEditor: React.FC = () => {
const onConfirmUnpublishOpenChange = (open: boolean): void => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not strictly in scope, but I simplified this alert open change callback because I was adding a new similar one.

<AlertDialogHeader>
<AlertDialogTitle>Update automation?</AlertDialogTitle>
<AlertDialogDescription>
This will update the automation for new runs of the automation, as well as any actively-running ones.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure on this copy, but we can tweak it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This diff is a little hard to read because I started adding newlines. Here's the effective change:

 export type AutomationEditState =
   | 'idle'
   | 'saving'
   | 'publishing'
+  | 're-publishing'
   | 'unpublishing'
   | 'confirming unpublish'
+  | 'confirming re-publish'
   | 'failed to save'
   | 'failed to publish'
+  | 'failed to re-publish'
   | 'failed to unpublish';

@EvanHahn EvanHahn requested a review from troyciesco May 25, 2026 17:19
@EvanHahn EvanHahn added the ok to merge for me You can merge this on my behalf if you want. label May 25, 2026

const oldStatus = draft.status;
const newStatus = statusToSave ?? oldStatus;
const statusTransition: `${AutomationStatus} -> ${AutomationStatus}` = `${oldStatus} -> ${newStatus}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ooooo trickyyyy

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Couldn't tell if this was too clever, but it succinctly described what I wanted...

Comment on lines +250 to +251
case 'confirming re-publish':
case 'failed to re-publish':
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not something for this PR, but i'm wondering if we should clean up these states into something other than strings as they continue to grow.

For example, there's sort of a relationship here between these two states, or any two states that're like confirming <whatever> and failed <whatever>.

In all of these functions we don't really have to worry about typos or anything since TypeScript is doing the heavy-lifting, but it kinda feels like the AutomationEditState bucket might be too general now. I'm also finding this harder to read as it grows.

Maybe syntax like state.republish.confirming or something like that? Not urgent, might be a fun one for 2-3 of us to pair on when we're in a QA window just as a chance to talk shop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea. Made a cleanup ticket.

@troyciesco troyciesco merged commit e830217 into main May 25, 2026
47 checks passed
@troyciesco troyciesco deleted the evanhahn-ny-1299-before-publishing-an-active-automation-confirm-with-user branch May 25, 2026 20:32
9larsons added a commit that referenced this pull request May 25, 2026
…28121)

ref #28113 

The `updates a wait step as the wait editor value changes` test in
`apps/posts` has been failing on `main` since #28113 merged. This PR
adds the two lines needed to click through the new "Update automation?"
confirmation dialog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok to merge for me You can merge this on my behalf if you want.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants