refactor(dify-ui): finish primitive migration from web/base/ui to @langgenius/dify-ui#35349
Merged
refactor(dify-ui): finish primitive migration from web/base/ui to @langgenius/dify-ui#35349
Conversation
…ggenius/dify-ui
- Bootstrap dify-ui tooling: vitest config, test setup, peer/dev deps, storybook types
- Extend web tailwind content and storybook stories glob to scan packages/dify-ui/src
- Add dify-ui-test job in web-tests workflow
- Introduce @dify/tsconfig/react.json as a framework-neutral React base (used by dify-ui; nextjs.json now extends it; old web.json removed)
- Migrate shared overlay helpers (placement, overlay-shared) plus avatar and slider components as source subpath exports
- Codemod all consumers from @/app/components/base/ui/{avatar,slider,placement,overlay-shared} to @langgenius/dify-ui/<sub>
Made-with: Cursor
lyzno1
commented
Apr 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #35349 +/- ##
==========================================
- Coverage 85.48% 85.47% -0.01%
==========================================
Files 4428 4429 +1
Lines 206408 206407 -1
Branches 38340 38339 -1
==========================================
- Hits 176438 176431 -7
- Misses 26860 26866 +6
Partials 3110 3110
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ot a standalone subpath - Each overlay primitive (popover, tooltip, select, dropdown-menu, context-menu) now re-exports `type Placement` from its own index - The 3 external wrappers (operation-dropdown, plugin-version-picker, select-metadata-modal) import `type Placement` from the overlay component they actually use - Fix two stories that still referenced the old `../placement` path - Document the API debt in packages/dify-ui/AGENTS.md: `./placement` and `./overlay-shared` subpath exports are internal transition bridges, pending removal once overlay primitives migrate into packages/dify-ui/src/* Type-only re-exports compile away under `verbatimModuleSyntax`, so the `no-barrel-files` rule is locally suppressed with a comment explaining why. Made-with: Cursor
… and select Made-with: Cursor
…/dify-ui/switch - Copy switch to packages/dify-ui/src/switch; merge former skeleton.tsx into the same index.tsx (both Switch and SwitchSkeleton are named exports now) - Drop React.memo / displayName; declare component at its definition site as a named export per the dify-ui authoring rules - Tighten API: SwitchProps now extends base-ui's Switch.Root.Props (so ref, render, form integration are free), with size from CVA variants and a narrow onCheckedChange(checked) that matches the React setter shape. SwitchSkeletonProps extends HTMLAttributes<HTMLDivElement> - Codemod all consumers: 53 default imports -> named imports from @langgenius/dify-ui/switch, 7 vi.mock blocks updated (path swap + `default:` -> `Switch:`, drop stale __esModule:true) - Delete web/app/components/base/switch/ - Fix tsconfig leak: dify-ui had noEmit:false + outDir:dist which silently emitted dist/ on every type-check and polluted vitest runs; switch to noEmit for the source-export phase Made-with: Cursor
Made-with: Cursor
- Add @vitest/coverage-v8 to dify-ui devDeps; configure v8 provider, scope to src/ and exclude stories/tests/styles - codecov.yml: register a dify-ui flag pointing at packages/dify-ui/ - web-tests.yml dify-ui-test job now runs `--coverage` and calls codecov-action with flag=dify-ui - Add packages/dify-ui/.gitignore for coverage/ and dist/ Made-with: Cursor
The loading-state toggle added to AppCard was bundled into an unrelated CI/coverage commit; drop the app-card portion only and keep the rest. Made-with: Cursor
…ails CI Made-with: Cursor
…and refactor-friendly project status - Migrate top-level `flags:` to `flag_management:` (default_rules + individual_flags; less repetition) - Add global `ignore:` for .d.ts, stories, specs, configs, storybook, next/vite/test setup - `project` status: add 1% threshold + `removed_code_behavior: adjust_base` so migrations deleting covered code don't regress the baseline - `comment.layout` pinned to `diff, flags, files` (drop default `reach`) - Pin `precision`, `round`, `range`, `require_ci_to_pass`, `notify.wait_for_ci` explicitly Validated against https://codecov.io/validate. Made-with: Cursor
… and removed_code_behavior Made-with: Cursor
… noise Made-with: Cursor
hyoban
previously approved these changes
Apr 17, 2026
Member
|
Maybe next version? |
… toast (Wave A, independent leaves) Made-with: Cursor
Made-with: Cursor
…cement and overlay-shared exports - popover, tooltip, select, context-menu, dropdown-menu moved to packages/dify-ui/src/* - Each rewrites placement/overlay-shared imports to relative paths (../placement, ../overlay-shared) - no-barrel-files eslint-disable comments removed (rule is web-only, not needed in packages/) - package.json exports: add 5 new subpaths, remove ./placement and ./overlay-shared (no external consumers remain; they stay as internal implementation files) - web/app/components/base/ui/ now empty Made-with: Cursor
…lative vi.mock paths Made-with: Cursor
…i-to-dify-ui Made-with: Cursor # Conflicts: # web/app/components/workflow/nodes/_base/components/panel-operator/index.tsx
…y-ui Made-with: Cursor
The storybook preview was still pointing at the removed web/app/components/base/ui/toast path, causing knip to report an unresolved import. Align it with app/layout.tsx which already uses the dify-ui package. Made-with: Cursor
hyoban
approved these changes
Apr 17, 2026
lyzno1
added a commit
to lyzno1/dify
that referenced
this pull request
Apr 17, 2026
Finish the follow-up to langgenius#35349 by replacing all remaining references to the removed `app/components/base/ui/` path with `@langgenius/dify-ui` across docs, ESLint config, deprecation notices, and incidental comments and test descriptions. Also drop the now-dead `dify/base-ui-primitives` ESLint override whose glob no longer matches any file. Made-with: Cursor
4 tasks
lyzno1
added a commit
to lyzno1/dify
that referenced
this pull request
Apr 17, 2026
- New `packages/dify-ui/README.md`: documents the package scope, subpath import model, the Base UI portal behavior, the root `isolation: isolate` requirement, and the `z-1002` / `z-1003` layering — the permanent contract that should outlive the overlay migration. - `web/docs/overlay-migration.md`, `web/AGENTS.md`: add pointers to the new dify-ui README so the permanent contract is discoverable and the migration doc can shrink over time. - Replace the `base/button/index.spec.tsx` example reference (directory removed in langgenius#35349) with `base/radio/__tests__/index.spec.tsx`, which better matches the user-event / role-query patterns in `test.md`. Touches: `web/README.md`, `web/docs/test.md`, `web/scripts/analyze-component.js`, `.agents/skills/frontend-testing/SKILL.md`. - `.agents/skills/frontend-testing/references/mocking.md`: broaden the "don't mock" guidance to cover both `@/app/components/base/*` and `@langgenius/dify-ui/*`, and fix code examples that imported from the removed `base/button` path. Made-with: Cursor
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 2026
…nggenius/dify-ui (langgenius#35349) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
asukaminato0721
pushed a commit
to asukaminato0721/dify
that referenced
this pull request
Apr 24, 2026
…nggenius/dify-ui (langgenius#35349) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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.
Summary
Finishes the incremental move of every atomic UI primitive from
web/app/components/base/ui/*to@langgenius/dify-ui. After this PRweb/app/components/base/ui/no longer exists.Full component list now under dify-ui (14 primitives + shared helpers):
alert-dialog, avatar, button, context-menu, dialog, dropdown-menu, number-field, popover, scroll-area, select, slider, switch, toast, tooltip.
Package shape — source subpath exports, one subpath per component (
@langgenius/dify-ui/<comp>). No build step in this phase; future npm publishing only needs to point exports at a tsdown dist.Props pattern (consistent across all 14 components):
Native HTML attrs,
ref,aria-*,data-*, form integration come from base-ui for free; only design decisions (variants,classNamemerge, opinionated callback signatures) are owned by dify-ui.Tooling / CI bootstrapped
dify-ui-testCI job with v8 coverage uploaded to Codecov under flagdify-uistoriesglob extended to../../packages/dify-ui/src/**contentscanspackages/dify-ui/src/**@dify/tsconfig/react.jsonintroduced so dify-ui does not extend web-flavored configscodecov.ymlgainsdify-uiflag,removed_code_behavior: adjust_base, and a 1% threshold so refactor PRs are not flagged by sub-percent noiseAPI-debt resolution — overlay primitives (popover, tooltip, select, dropdown-menu, context-menu) each
export type { Placement }from their own index; no consumer imports the internalplacement.ts/overlay-shared.tsvia a standalone subpath. Those two subpath exports are removed frompackage.json#exports; the files remain as internal implementation.Codemod — ~2600 web consumer lines rewritten from
@/app/components/base/ui/<x>to@langgenius/dify-ui/<x>, including allvi.mocksites (key and path). A handful of stale relative imports (../../ui/...,./components/base/ui/...) were repaired.Non-mechanical items
scroll-area/index.stories.tsxreplaced its<AppIcon>usage with a neutral<div>placeholder sinceAppIconis a web-only business component.Verification
vp run -r type-check— 5 workspaces greenpackages/dify-ui— 14 spec files / 180 tests green; coverage emitted and uploaded to Codecov under flagdify-uiweb— 2332 spec files / 28698 tests / 2 skipped, all greeneslint --fix packages/dify-ui/src/**/*.{ts,tsx}— 0 errorsChecklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsFrom Cursor Agent