Skip to content

Removed admin-x-framework's dependency on admin-x-design-system#29331

Open
9larsons wants to merge 2 commits into
mainfrom
slars/framework-ds-decouple
Open

Removed admin-x-framework's dependency on admin-x-design-system#29331
9larsons wants to merge 2 commits into
mainfrom
slars/framework-ds-decouple

Conversation

@9larsons

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/PLA-190/decouple-admin-x-framework-from-admin-x-design-system

admin-x-framework is the long-lived foundation library; admin-x-design-system is the legacy DS being replaced by shade. The framework depending on the DS dragged the legacy package into every consumer's graph and would block deleting the DS later. The DS has no reverse dependency, so the decouple is one-directional. All five coupling sites are resolved:

  • showToast (runtime) — moved a self-contained copy of the DS error toast into src/utils/toast.tsx (markup, classes, data-testid, icons copied verbatim; react-hot-toast was already a direct framework dep). Error toasts render identically inside the DS <Toaster> in admin-x-settings — the only surface that mounts one today. Provider injection was rejected as an unnecessary configuration seam.
  • usePagination (runtime) — copied into src/hooks/use-pagination.ts with its PaginationMeta/PaginationData types. The DS keeps its copy for its own Table/Pagination components (a DS→framework dep must not exist); structural typing keeps the framework's pagination result assignable to DS props. Note createPaginatedQuery has no production consumer today — only framework tests.
  • ButtonColor (type) — inlined the literal union in use-form.ts.
  • KoenigInstance (type) — inlined in focus-koenig-editor-on-bottom-click.ts, including the index signature so DS-typed editor refs stay compatible.
  • DesignSystemAppProps (type)test/render.tsx (the standalone-dev renderer used by settings/activitypub main.tsx) now declares the minimal {darkMode, fetchKoenigLexical} shape it actually passes.

Because the toast markup now lives outside the DS, admin-x-framework/src was added to the Tailwind @source lists (central admin pipeline + admin-x-settings' standalone build) so its classes are scanned in their own right.

Reviewer callouts

  • The one visual surface to eyeball: trigger any API error in admin-x-settings and confirm the bottom-left error toast looks unchanged (byte-identical markup, but it's a copy now, not shared code). The built settings bundle was confirmed to contain the toast classes (animate-toaster-in, shadow-md-heavy).
  • Pre-existing gap, unchanged by this PR: a react-hot-toast <Toaster/> is mounted only by the DS provider, so framework error toasts were already invisible in apps/admin outside settings and in activitypub — worth closing later via shade.

Verification

  • admin-x-framework: tsc, lint, and the nx build all succeed without the DS in the graph; 31 files / 440 tests green; grep + package.json confirm zero remaining @tryghost/admin-x-design-system references
  • apps/admin: unit 88 files / 848 tests; acceptance (browser mode) 12 files / 79 tests; tsc clean
  • admin-x-settings: 19 files / 203 tests; tsc && vite build clean
  • activitypub: 10 files / 116 tests; tsc clean

9larsons added 2 commits July 14, 2026 14:43
ref https://linear.app/ghost/issue/PLA-189/react-query-v4-v5-decide-execute

The shared query/mutation factories in admin-x-framework multiply into
every screen migrated out of Ember, so moving off the deprecated v4
major now avoids rewriting more call sites later in the migration.

Mechanical changes for the v5 API:
- cacheTime renamed to gcTime; removed logger and suspense QueryClient
  options from test clients
- invalidateQueries/setQueriesData/getQueriesData now take filter
  objects instead of bare query keys
- keepPreviousData option replaced with placeholderData: keepPreviousData;
  isPreviousData replaced by isPlaceholderData
- useInfiniteQuery requires initialPageParam; passing undefined keeps
  first-page requests identical to v4
- mutation results renamed isLoading to isPending
- the framework factories no longer override isLoading because v5's
  definition (isPending && isFetching) matches the old workaround
- hook-testing-utils mocks updated to the v5 result shape (status
  'pending', fetchStatus, isPending)
- removed the react-query v4 fallback in gh-billing-iframe per its TODO
ref https://linear.app/ghost/issue/PLA-190/decouple-admin-x-framework-from-admin-x-design-system

admin-x-framework is the long-lived foundation library, while
admin-x-design-system is a legacy design system being replaced by shade.
The framework depending on the design system meant every framework
consumer dragged the legacy package into its dependency graph, and would
block deleting the design system later. The design system has no reverse
dependency on the framework, so the decouple is one-directional.

Per coupling site:

- use-handle-error.ts (showToast, runtime): moved a self-contained copy
  of the design system's error toast into src/utils/toast.tsx. The
  framework already depended on react-hot-toast directly, and the design
  system's showToast is only a styled react-hot-toast custom render, so
  the markup, classes, testid and the two icons were copied verbatim.
  Error toasts still render identically inside the design system's
  <Toaster> in admin-x-settings (the only surface that mounts a
  react-hot-toast Toaster today). Injecting a toast handler through
  FrameworkProvider was rejected as an unnecessary configuration seam.

- utils/api/hooks.ts (usePagination, runtime): copied the hook (plus
  PaginationMeta/PaginationData) into src/hooks/use-pagination.ts. The
  framework's createPaginatedQuery is its own pagination contract; the
  design system keeps its copy because its Table/Pagination components
  use the PaginationData type, and a design-system->framework dependency
  must not be introduced. TypeScript's structural typing keeps the
  framework's pagination result assignable to design system props.

- use-form.ts (ButtonColor, type): inlined the literal union. okProps
  stays structurally assignable to the design system's Button color.

- focus-koenig-editor-on-bottom-click.ts (KoenigInstance, type): inlined
  the type. Consumers that type editor refs against the design system's
  KoenigInstance stay compatible structurally.

- test/render.tsx (DesignSystemAppProps, type): inlined the minimal
  {darkMode, fetchKoenigLexical} shape the standalone renderer actually
  passes; it stays assignable to admin-x-settings' designSystem prop.

The framework's toast markup now lives outside the design system, so its
Tailwind classes must be scanned explicitly: added admin-x-framework/src
to the @source lists of the central admin pipeline and admin-x-settings'
standalone build instead of relying on the identical classes in the
design system's own Toast staying scanned.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: de24487a-85a0-4749-9ad2-696c60f7e481

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/framework-ds-decouple

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 14, 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 6009485

Command Status Duration Result
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 9m 57s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-f... ✅ Succeeded 8m 22s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 51s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 16s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 7s View ↗
nx run-many -t lint -p @tryghost/admin-x-framew... ✅ Succeeded 3m 43s View ↗
nx run @tryghost/koenig-lexical:test:acceptance ✅ Succeeded 2m 41s View ↗
Additional runs (12) ✅ Succeeded ... View ↗

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


☁️ Nx Cloud last updated this comment at 2026-07-14 20:21:40 UTC

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.00%. Comparing base (6e1abec) to head (6009485).

Additional details and impacted files
@@                   Coverage Diff                    @@
##           slars/react-query-v5   #29331      +/-   ##
========================================================
- Coverage                 74.03%   74.00%   -0.04%     
========================================================
  Files                      1577     1577              
  Lines                    136818   136818              
  Branches                  16577    16566      -11     
========================================================
- Hits                     101298   101253      -45     
- Misses                    34478    34556      +78     
+ Partials                   1042     1009      -33     
Flag Coverage Δ
admin-tests 55.32% <ø> (ø)
e2e-tests 76.10% <ø> (-0.04%) ⬇️

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.

Base automatically changed from slars/react-query-v5 to main July 14, 2026 20:50
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