Skip to content

Moved the automations domain from the posts package into apps/admin - #29207

Merged
9larsons merged 1 commit into
mainfrom
slars/pla-221-move-automations
Jul 9, 2026
Merged

Moved the automations domain from the posts package into apps/admin#29207
9larsons merged 1 commit into
mainfrom
slars/pla-221-move-automations

Conversation

@9larsons

@9larsons 9larsons commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/PLA-221/posts-admin-move-tags-comments-automations

Second domain to leave the posts package as it dissolves into apps/admin (PLA-221), after tags. Automations is self-contained — no cross-domain or PostsAppContext dependency, its utils are internal — so it's a clean move.

What changed

  • apps/posts/src/views/Automations/apps/admin/src/automations/ (32 files).
  • The automations routes fold into the shell's own route table (apps/admin/src/routes.tsx), preserving the hideAdminSidebar handle on the /automations/:id editor route. Admin already honours that handle via layout/sidebar-visibility.ts (covered by sidebar-visibility.test.tsx). Removed the automations block from apps/posts/src/routes.tsx.
  • MainLayout → shade Box + Container, matching the tags move; rendered layout unchanged.
  • Adds a smoke e2e (e2e/tests/admin/automations/) — automations was the only admin domain with no e2e coverage.

Admin strictness

Admin's config is stricter than posts; the move surfaced 21 lint/tsc issues, all fixed at the source (no disables):

  • exhaustiveness throw sites stringify the never value (restrict-template-expressions)
  • only-throw-error: throw error instanceof Error ? error : new Error(...)
  • floating promises voided, one no-misused-promises onClick wrapped, one spurious async dropped
  • non-component canvas helpers (nodeTypes, toApiAnchor) extracted to node-helpers.ts (react-refresh/only-export-components)
  • an any router-state spread narrowed; module-mock hooks use vi.hoisted (hoist-safe)

Verification

  • tsc -b, eslint . (admin) — exit 0
  • vitest run (admin) — 449 tests pass (incl. the 4 moved automations suites)
  • @tryghost/posts build / lint / test — exit 0 (automations removed cleanly; posts import-sort re-fixed after AdminRouteHandle dropped from its imports)
  • nx build @tryghost/admin — exit 0; automations code-splits into its own lazy chunks (list + editor)

Note: I did not dev-drive the Beta (flag-gated) editor this round — the hideAdminSidebar behaviour it exercises is unit-tested and the route wiring is confirmed. Happy to boot dev and walk it if preferred.

ref https://linear.app/ghost/issue/PLA-221/posts-admin-move-tags-comments-automations

- second domain to leave the posts package as it dissolves into apps/admin; automations is self-contained (no cross-domain or PostsAppContext dependency, its utils are internal), so it moves cleanly
- the automations routes fold into the shell's own route table, preserving the hideAdminSidebar handle on the editor route (the Admin layout already honours it via sidebar-visibility)
- MainLayout is replaced with shade Box + Container, matching the tags move; the rendered layout is unchanged
- brings the migrated code up to Admin's stricter lint/tsconfig: exhaustiveness throws stringify the never value, react-query error callbacks and floating promises are voided/awaited correctly, the exhaustive-switch throw uses instanceof, non-component canvas helpers move to node-helpers.ts for react-refresh, and the module-mock hooks use vi.hoisted
- adds a smoke e2e for the automations page, which previously had no e2e coverage
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The Automations feature is relocated from apps/posts to apps/admin with new routes, dependencies (@xyflow/react, react-router, sonner, validator, dequal), and an APP_ROUTE_PREFIX export replacing the removed posts route subtree. The automations page, canvas, editor, and email modal components are refactored with stricter TypeScript typing (type-only imports, exhaustive-check error stringification), promise-handling fixes in the email modal, and extraction of nodeTypes/toApiAnchor helpers into a new node-helpers module. Test mocks are updated accordingly, and a new Playwright e2e suite with an AutomationsPage page object is added.

Suggested reviewers: EvanHahn, troyciesco

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving Automations from posts into apps/admin.
Description check ✅ Passed The description is directly related and accurately describes the Automations migration and related cleanup.
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.
✨ 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 slars/pla-221-move-automations

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.

@nx-cloud

nx-cloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 12bed8a

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 10m 30s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 40s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run-many -t test:unit -p @tryghost/admin,@tr... ✅ Succeeded 26s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 44s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 55s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 6s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 25s View ↗
Additional runs (11) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-09 17:12:41 UTC

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
apps/admin/package.json (1)

24-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move @xyflow/react to the shared catalog
Add @xyflow/react to pnpm-workspace.yaml and switch apps/admin/package.json:24 to catalog: so it follows the workspace dependency convention.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/admin/package.json` at line 24, The `@xyflow/react` dependency in the
admin package is still pinned directly instead of using the workspace catalog
convention. Add `@xyflow/react` to the shared catalog in pnpm-workspace.yaml, then
update the apps/admin package.json dependency entry to reference catalog: so it
stays aligned with the rest of the workspace.

Source: Coding guidelines

apps/admin/src/automations/utils.ts (1)

1-8: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the shared LexicalState/LexicalNode types
apps/admin/src/automations/utils.ts and apps/admin/src/automations/components/email-modal/validation.ts both define the same interfaces. Move them to a shared module so the parsing logic stays aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/admin/src/automations/utils.ts` around lines 1 - 8, The LexicalNode and
LexicalState interfaces are duplicated between the automation utils and the
email modal validation logic, so extract them into a shared module and import
them from both places. Update the parsing helpers that use these types,
including the symbols LexicalNode, LexicalState, and any related JSON parsing
functions, so both callers stay aligned on the same shape and future changes
only happen in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/admin/package.json`:
- Line 24: The `@xyflow/react` dependency in the admin package is still pinned
directly instead of using the workspace catalog convention. Add `@xyflow/react` to
the shared catalog in pnpm-workspace.yaml, then update the apps/admin
package.json dependency entry to reference catalog: so it stays aligned with the
rest of the workspace.

In `@apps/admin/src/automations/utils.ts`:
- Around line 1-8: The LexicalNode and LexicalState interfaces are duplicated
between the automation utils and the email modal validation logic, so extract
them into a shared module and import them from both places. Update the parsing
helpers that use these types, including the symbols LexicalNode, LexicalState,
and any related JSON parsing functions, so both callers stay aligned on the same
shape and future changes only happen in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb241af6-4ba8-4dfc-adb9-0217b941a345

📥 Commits

Reviewing files that changed from the base of the PR and between 7493e13 and 12bed8a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (44)
  • apps/admin/package.json
  • apps/admin/src/automations/automations.test.tsx
  • apps/admin/src/automations/automations.tsx
  • apps/admin/src/automations/components/automation-header.tsx
  • apps/admin/src/automations/components/automation-status-badge.tsx
  • apps/admin/src/automations/components/automations-help-cards.tsx
  • apps/admin/src/automations/components/automations-list.test.tsx
  • apps/admin/src/automations/components/automations-list.tsx
  • apps/admin/src/automations/components/canvas/add-step-edge.tsx
  • apps/admin/src/automations/components/canvas/automation-canvas.tsx
  • apps/admin/src/automations/components/canvas/controls.tsx
  • apps/admin/src/automations/components/canvas/format-wait.test.ts
  • apps/admin/src/automations/components/canvas/format-wait.ts
  • apps/admin/src/automations/components/canvas/node-helpers.ts
  • apps/admin/src/automations/components/canvas/nodes.tsx
  • apps/admin/src/automations/components/canvas/step-picker.tsx
  • apps/admin/src/automations/components/canvas/step-sidebar.tsx
  • apps/admin/src/automations/components/email-modal/email-content-modal.tsx
  • apps/admin/src/automations/components/email-modal/email-editor.tsx
  • apps/admin/src/automations/components/email-modal/newsletter-emails.ts
  • apps/admin/src/automations/components/email-modal/preview-frame.tsx
  • apps/admin/src/automations/components/email-modal/sender-details.ts
  • apps/admin/src/automations/components/email-modal/test-email-dropdown.tsx
  • apps/admin/src/automations/components/email-modal/use-email-preview.ts
  • apps/admin/src/automations/components/email-modal/use-link-suggestions.ts
  • apps/admin/src/automations/components/email-modal/use-sender-details.ts
  • apps/admin/src/automations/components/email-modal/validation.ts
  • apps/admin/src/automations/components/types.ts
  • apps/admin/src/automations/editor.test.tsx
  • apps/admin/src/automations/editor.tsx
  • apps/admin/src/automations/hooks/use-visible-automations.ts
  • apps/admin/src/automations/hooks/use-welcome-email-sender-details.ts
  • apps/admin/src/automations/types.ts
  • apps/admin/src/automations/utils.ts
  • apps/admin/src/automations/utils/default-welcome-email-values.ts
  • apps/admin/src/automations/utils/newsletter-emails.ts
  • apps/admin/src/automations/utils/welcome-email-sender-details.ts
  • apps/admin/src/routes.tsx
  • apps/posts/src/routes.tsx
  • apps/posts/src/views/Automations/components/email-modal/koenig-lexical.d.ts
  • e2e/helpers/pages/admin/automations/automations-page.ts
  • e2e/helpers/pages/admin/automations/index.ts
  • e2e/helpers/pages/admin/index.ts
  • e2e/tests/admin/automations/automations.test.ts
💤 Files with no reviewable changes (1)
  • apps/posts/src/views/Automations/components/email-modal/koenig-lexical.d.ts

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.07%. Comparing base (7493e13) to head (12bed8a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29207      +/-   ##
==========================================
+ Coverage   74.04%   74.07%   +0.03%     
==========================================
  Files        1570     1570              
  Lines      136624   136624              
  Branches    16520    16524       +4     
==========================================
+ Hits       101159   101202      +43     
+ Misses      34460    34417      -43     
  Partials     1005     1005              
Flag Coverage Δ
admin-tests 55.19% <ø> (ø)
e2e-tests 76.18% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@9larsons
9larsons enabled auto-merge (squash) July 9, 2026 17:12
@9larsons
9larsons merged commit 83a5b36 into main Jul 9, 2026
52 checks passed
@9larsons
9larsons deleted the slars/pla-221-move-automations branch July 9, 2026 17:13
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