fix(ai-moderation): style the category dialog with Kumo tokens - #3014
fix(ai-moderation): style the category dialog with Kumo tokens#3014DavidPivert wants to merge 2 commits into
Conversation
The admin stylesheet is precompiled from the admin package and the Kumo design system; classes used by plugin admin modules are not scanned. The shadcn-style utilities the settings page relied on (bg-background, bg-primary, text-primary-foreground, bg-muted, text-muted-foreground, resize-none) therefore produced no CSS: the "Edit Category" dialog had no background and was drawn over the category list, unreadable. Switch the dialog panel, fields and secondary controls to Kumo utilities (bg-kumo-elevated, bg-kumo-base, bg-kumo-fill, bg-kumo-tint, text-kumo-subtle) and the primary/secondary action buttons to the Kumo Button component, which also gives them a proper loading state. Add a source-level test that fails when admin.tsx uses one of those absent utilities, so the regression cannot come back silently. Closes emdash-cms#3013
🦋 Changeset detectedLatest commit: bc36721 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
There was a problem hiding this comment.
This PR takes the right approach for the reported bug: the admin stylesheet is built from the admin package and Kumo sources, so plugin JSX that relies on shadcn semantic utilities can end up unstyled. Replacing those utilities with Kumo tokens is consistent with AGENTS.md's styling rules, and converting the primary/async actions to the Kumo Button matches the sibling forms plugin.
The fix is mostly clean, but I found one concrete oversight: the StatusWidget link still uses text-primary, the same class family the PR is removing because it is not guaranteed to ship. That leaves a visible element that can render with the wrong color in light/dark mode. I also noted that the new style-guard test lists text-muted-foreground twice, and I left a suggestion about finishing the Kumo migration for the hand-rolled dialog, inputs, and icon buttons since this file is already being touched.
Findings
-
[needs fixing]
packages/plugins/ai-moderation/src/admin.tsx:90The
text-primaryclass is part of the shadcn semantic-utility family this PR is removing because it is not guaranteed to exist in the precompiled admin stylesheet. Leaving it on the "Configure moderation" link means that link can render with the wrong color (or no usable color) in light/dark mode, which is the same kind of visual defect the PR fixes elsewhere.Remove
text-primary(or replace it with a verified Kumo token such astext-kumo-brand) and addtext-primaryto the test's disallowed-utility list so the regression test catches it.<a href="/_emdash/admin/plugins/ai-moderation/settings" className="text-xs hover:underline" > -
[suggestion]
packages/plugins/ai-moderation/tests/admin-styles.test.ts:21"text-muted-foreground"is listed twice inSHADCN_UTILITIES, so the same assertion runs redundantly. Remove the duplicate entry."text-muted-foreground", "bg-secondary", -
[suggestion]
packages/plugins/ai-moderation/src/admin.tsx:117-119The dialog is still a hand-rolled
fixedoverlay with raw<input>,<select>,<textarea>, and plain<button>elements. AGENTS.md says to use Kumo components (Dialog,Input,Select,InputArea,Button) instead of rolling custom markup so the admin gets focus trapping, ARIA roles, and consistent styling for free. Since this PR is already restyling the dialog, consider migrating the dialog and its icon-action buttons to Kumo as a follow-up.
Review follow-up: the "Configure moderation" link in the dashboard widget still used text-primary, from the same family of utilities the admin stylesheet does not ship. Use text-kumo-brand instead, add text-primary to the style-guard test, and remove a duplicated entry from that list.
|
Thanks for the review. Addressed in bc36721:
On the full Kumo migration ( Plugin suite: 4 files, 50 tests green; Before/after screenshots will be added to the description shortly. |
|
CI note: after bc36721 everything is green except Test Shard (1/4) (and the aggregate Tests). The failures are in The same shard failed on two unrelated branches yesterday ( |
What does this PR do?
Fixes the "Edit Category" / "Add Category" dialog on the AI Moderation settings page rendering with no background, drawn on top of the category list and unreadable.
The admin stylesheet (
@emdash-cms/admin/dist/styles.css) is precompiled from the admin package and Kumo only; classes used by plugin admin modules are not scanned. The settings page relied on shadcn-style utilities (bg-background,bg-primary,text-primary-foreground,bg-muted,text-muted-foreground,resize-none) that produce no CSS at all, so only thebg-black/50overlay was visible.Changes in
packages/plugins/ai-moderation/src/admin.tsx:bg-kumo-elevated border-kumo-line; inputs →bg-kumo-base; hover/badge/test-result backgrounds →bg-kumo-fill/bg-kumo-tint; muted copy →text-kumo-subtle;resize-none→ inlinestyle={{ resize: "none" }}Buttoncomponent (primary / secondary, withloadingfor the async ones) instead of hand-rolled classes — same asplugin-formsNew test
tests/admin-styles.test.tsscansadmin.tsxfor those absent utilities; it fails onmain(6 cases) and passes with this change.Closes #3013
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runmessages.pochanges except in translation PRs — a workflow extracts catalogs on merge tomain. — not applicable: no string added or changed; the plugin's existing strings are not wrapped either.AI-generated code disclosure
Screenshots / test output
Before (0.37.0,
@emdash-cms/plugin-ai-moderation0.2.0): the overlay dims the page but the dialog has no panel — title, ID / Name / Description / Action fields and Cancel / Save are painted over the category rows.After: the dialog sits on an opaque elevated panel with Kumo-styled fields, a primary Save and a secondary Cancel (captured on a production admin rendering the same Kumo utilities as this branch).
Test output:
Same test file against
main:Tests 6 failed | 44 passed (50).