Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: add ReactScan component for enhanced development scanning (#29086)

zhsama0343374d5246
diff --git a/web/app/components/react-scan.tsx b/web/app/components/react-scan.tsx
new file mode 100644
index 00000000000..03577b7d2b0
--- /dev/null
+++ b/web/app/components/react-scan.tsx
@@ -0,0 +1,22 @@
+'use client'
+
+import { scan } from 'react-scan'
+import { useEffect } from 'react'
+import { IS_DEV } from '@/config'
+
+export function ReactScan() {
+ useEffect(() => {
+ if (IS_DEV) {
+ scan({
+ enabled: true,
+ // HACK: react-scan's getIsProduction() incorrectly detects Next.js dev as production
+ // because Next.js devtools overlay uses production React build
+ // Issue: https://github.com/aidenybai/react-scan/issues/402
+ // TODO: remove this option after upstream fix
+ dangerouslyForceRunInProduction: true,
+ })
+ }
+ }, [])
+
+ return null
+}
diff --git a/web/app/layout.tsx b/web/app/layout.tsx
index 011defe4666..878f335b924 100644
--- a/web/app/layout.tsx
+++ b/web/app/layout.tsx
@@ -1,3 +1,4 @@
+import { ReactScan } from './components/react-scan'
import RoutePrefixHandle from './routePrefixHandle'
import type { Viewport } from 'next'
import I18nServer from './components/i18n-server'
@@ -86,6 +87,7 @@ const LocaleLayout = async ({
className='color-scheme h-full select-auto'
{...datasetMap}
>
+ <ReactScan />
<ThemeProvider
attribute='data-theme'
defaultTheme='system'
diff --git a/web/config/index.ts b/web/config/index.ts
index 2555a9767ec..a5b37fd9c99 100644
--- a/web/config/index.ts
+++ b/web/config/index.ts
@@ -77,6 +77,9 @@ const EDITION = getStringConfig(
export const IS_CE_EDITION = EDITION === 'SELF_HOSTED'
export const IS_CLOUD_EDITION = EDITION === 'CLOUD'
+export const IS_DEV = process.env.NODE_ENV === 'development'
+export const IS_PROD = process.env.NODE_ENV === 'production'
+
export const SUPPORT_MAIL_LOGIN = !!(
process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN
|| globalThis.document?.body?.getAttribute('data-public-support-mail-login')
diff --git a/web/package.json b/web/package.json
index 11b2165ac7c..07d1c97b3f4 100644
--- a/web/package.json
+++ b/web/package.json
@@ -201,6 +201,7 @@
"lodash": "^4.17.21",
"magicast": "^0.3.5",
"postcss": "^8.5.6",
+ "react-scan": "^0.4.3",
"sass": "^1.93.2",
"storybook": "9.1.13",
"tailwindcss": "^3.4.18",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index 2d528ecdf29..a973996284d 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -125,7 +125,7 @@ importers:
version: 3.2.5
'@tailwindcss/typography':
specifier: ^0.5.19
'@tanstack/react-form':
specifier: ^1.23.7
@@ -498,7 +498,7 @@ importers:
eslint-plugin-tailwindcss:
specifier: ^3.18.2
globals:
specifier: ^15.15.0
version: 15.15.0
@@ -523,6 +523,9 @@ importers:
postcss:
specifier: ^8.5.6
version: 8.5.6
+ react-scan:
+ specifier: ^0.4.3
sass:
specifier: ^1.93.2
version: 1.94.2
@@ -531,7 +534,7 @@ importers:
version: 9.1.13(@testing-library/[email protected])
tailwindcss:
specifier: ^3.4.18
- version: 3.4.18([email protected])
ts-node:
specifier: ^10.9.2
version: 10.9.2(@types/[email protected])([email protected])
@@ -1349,12 +1352,18 @@ packages:
peerDependencies:
storybook: ^0.0.0-0 || ^9.0.0 || ^9.1.0-0 || ^9.2.0-0 || ^10.0.0-0 || ^10.1.0-0 || ^10.2.0-0 || ^10.3.0-0
+ '@clack/[email protected]':
+ resolution: {integrity: sha512-5cfhQNH+1VQ2xLQlmzXMqUoiaH0lRBq9/CLW9lTyMbuKLC3+xEK01tHVvyut++mLOn5urSHmkm6I0Lg9MaJSTQ==}
+
resolution: {integrity: sha512-p3y0FIOwaYRUPRcMO7+dlmLh8PSRcrjuTndsiA0WAFbWES0mLZlrjVoBRZ9DzkPFJZG6KGkJmoEAY0ZcVWTkow==}
resolution: {integrity: sha512-pMN5FcrEw9hUkZA4f+zLlzivQSeQf5dRGJjSUbvVYDLvpKCdQx5OaknvKzgbtXOizhP+SJJJjqEbOe55uKKfAw==}
+ '@clack/[email protected]':
+ resolution: {integrity: sha512-6b9Ab2UiZwJYA9iMyboYyW9yJvAO9V753ZhS+DHKEjZRKAxPPOb7MXXu84lsPFG+vZt6FRFniZ8rXi+zCIw4yQ==}
+
'@code-inspector/[email protected]':
resolution: {integrity: sha512-A1w+G73HlTB6S8X6sA6tT+ziWHTAcTyH+7FZ1Sgd3ZLXF/E/jT+hgRbKposjXMwxcbodRc6hBG6UyiV+VxwE6Q==}
@@ -2591,6 +2600,12 @@ packages:
resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==}
engines: {node: '>= 10.0.0'}
+ '@pivanov/[email protected]':
+ resolution: {integrity: sha512-q9CN0bFWxWgMY5hVVYyBgez1jGiLBa6I+LkG37ycylPhFvEGOOeaADGtUSu46CaZasPnlY8fCdVJZmrgKb1EPA==}
+ peerDependencies:
+ react: '>=18'
+ react-dom: '>=18'
+
resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==}
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
@@ -2627,6 +2642,11 @@ packages:
'@preact/[email protected]':
resolution: {integrity: sha512-BwbTXpj+9QutoZLQvbttRg5x3l5468qaV2kufh+51yha1c53ep5dY4kTuZR35+3pAZxpfQerGJiQqg34ZNZ6uA==}
+ '@preact/[email protected]':
+ resolution: {integrity: sha512-naxcJgUJ6BTOROJ7C3QML7KvwKwCXQJYTc5L/b0eEsdYgPB6SxwoQ1vDGcS0Q7GVjAenVq/tXrybVdFShHYZWg==}
+ peerDependencies:
+ preact: 10.x
+
'@radix-ui/[email protected]':
resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==}
@@ -3457,6 +3477,11 @@ packages:
peerDependencies:
'@types/react': ~19.1.17
+ '@types/[email protected]':
+ resolution: {integrity: sha512-HHM3nxyUZ3zAylX8ZEyrDNd2XZOnQ0D5XfunJF5FLQnZbHHYq4UWvW1QfelQNXv1ICNkwYhfxjwfnqivYB6bFg==}
+ peerDependencies:
+ '@types/react': ~19.1.17
+
resolution: {integrity: sha512-RS8XN5O159YQ6tu3tGZIQz1/9StMLTg/FCIPxwqh2gwVixJnlfIodtVx+fpXVMZHe7A58lAX1Q4XTgAGOQaCQg==}
@@ -3951,6 +3976,11 @@ packages:
resolution: {integrity: sha512-7a9yo1NbGcHPS8zXTdz8tCOymHZp2pvCuYOChCaXKjOX8EIwdV3SLd4D7RGIqZt1UhffypYBUcAV2gDcTgK0rA==}
+ resolution: {integrity: sha512-vmptmU/20UdIWHHhq7qCSHhHzK7Ro3YJ1utU0fBG7ujUc58LEfTtilKxcF0IOgSjT5XLcm7CBzDjbv4lcKApGQ==}
+ peerDependencies:
+ react: '>=17.0.1'
+
resolution: {integrity: sha512-VUpsf/qykW0heRlC8LooCq28Kxn3mAqKohhDG/49rrsQ1dT1CXyj/pgXS+5BSRzFTR/3DyIBOqQOrGyZOh71Aw==}
@@ -5374,6 +5404,11 @@ packages:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
+ resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
+ engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
+ os: [darwin]
+
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
@@ -6118,6 +6153,10 @@ packages:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
+ resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
+ engines: {node: '>=6'}
+
resolution: {integrity: sha512-hwgdqEJ+7DNJ5jE8BCPu7b57TY7vUwP6MzWYgCgPpg6iPCee/jKPShDNIlFER2koti4oz5xF88VJbKCb4Wl71g==}
engines: {node: '>=18.18.0'}
@@ -6568,6 +6607,10 @@ packages:
resolution: {integrity: sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==}
+ resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==}
+ engines: {node: '>=4'}
+
resolution: {integrity: sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==}
engines: {node: '>=10'}
@@ -6920,6 +6963,16 @@ packages:
resolution: {integrity: sha512-SIqCzDRg0s9npO5XQ3tNZioRY1uK06lA41ynBC1YmFTmnY6FjUjVt6s4LoADmwoig1qqD0oK8h1p/8mlMx8Oig==}
+ resolution: {integrity: sha512-agTcKlMw/mjBWOnD6kFZttAAGHgi/Nw0CZ2o6JqWSbMlI219lAFLZZCyqByTsvVAJq5XA5H8cA6PrvBRpBWEuQ==}
+ engines: {node: '>=18'}
+ hasBin: true
+
+ resolution: {integrity: sha512-ilYQj1s8sr2ppEJ2YVadYBN0Mb3mdo9J0wQ+UuDhzYqURwSoW4n1Xs5vs7ORwgDGmyEh33tRMeS8KhdkMoLXQw==}
+ engines: {node: '>=18'}
+ hasBin: true
+
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
engines: {node: '>=4'}
@@ -7033,6 +7086,9 @@ packages:
resolution: {integrity: sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==}
engines: {node: ^10 || ^12 || >=14}
+ resolution: {integrity: sha512-rytDAoiXr3+t6OIP3WGlDd0ouCUG1iCWzkcY3++Nreuoi17y6T5i/zRhe6uYfoVcxq6YU+sBtJouuRDsq8vvqA==}
+
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
engines: {node: '>=10'}
@@ -7271,6 +7327,26 @@ packages:
react: '>=16.3.0'
react-dom: '>=16.3.0'
+ resolution: {integrity: sha512-jhAQuQ1nja6HUYrSpbmNFHqZPsRCXk8Yqu0lHoRIw9eb8N96uTfXCpVyQhTTnJ/nWqnwuvxbpKVG/oWZT8+iTQ==}
+ hasBin: true
+ peerDependencies:
+ '@remix-run/react': '>=1.0.0'
+ next: '>=13.0.0'
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-router: ^5.0.0 || ^6.0.0 || ^7.0.0
+ react-router-dom: ^5.0.0 || ^6.0.0 || ^7.0.0
+ peerDependenciesMeta:
+ '@remix-run/react':
+ optional: true
+ next:
+ optional: true
+ react-router:
+ optional: true
+ react-router-dom:
+ optional: true
+
resolution: {integrity: sha512-gJxG1HwmuMTJ+oWIRCmVWvgwotNCbByTwRkFZC6U4MBsHqJBmxwbYRJUmxy4Tke1ef8r9jfXjgkmY/uHOCEvbA==}
peerDependencies:
@@ -8080,6 +8156,11 @@ packages:
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
+ resolution: {integrity: sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==}
+ engines: {node: '>=18.0.0'}
+ hasBin: true
+
resolution: {integrity: sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==}
@@ -8188,6 +8269,10 @@ packages:
resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==}
engines: {node: '>=14.0.0'}
+ resolution: {integrity: sha512-us4j03/499KhbGP8BU7Hrzrgseo+KdfJYWcbcajCOqsAyb8Gk0Yn2kiUIcZISYCb1JFaZfIuG3b42HmguVOKCQ==}
+ engines: {node: '>=18.12.0'}
+
resolution: {integrity: sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==}
engines: {node: '>=4'}
@@ -9663,6 +9748,11 @@ snapshots:
- '@chromatic-com/cypress'
- '@chromatic-com/playwright'
+ '@clack/[email protected]':
+ dependencies:
+ picocolors: 1.1.1
+ sisteransi: 1.0.5
+
dependencies:
picocolors: 1.1.1
@@ -9674,6 +9764,12 @@ snapshots:
picocolors: 1.1.1
sisteransi: 1.0.5
+ '@clack/[email protected]':
+ dependencies:
+ '@clack/core': 0.3.5
+ picocolors: 1.1.1
+ sisteransi: 1.0.5
+
'@code-inspector/[email protected]':
dependencies:
'@vue/compiler-dom': 3.5.25
@@ -11063,6 +11159,11 @@ snapshots:
'@parcel/watcher-win32-x64': 2.5.1
optional: true
+ dependencies:
+ react: 19.1.1
+ react-dom: 19.1.1([email protected])
+
'@pkgr/[email protected]': {}
@@ -11084,6 +11185,11 @@ snapshots:
'@preact/[email protected]': {}
+ dependencies:
+ '@preact/signals-core': 1.12.1
+ preact: 10.28.0
+
'@radix-ui/[email protected]': {}
@@ -11690,10 +11796,10 @@ snapshots:
dependencies:
defer-to-connect: 2.0.1
dependencies:
postcss-selector-parser: 6.0.10
- tailwindcss: 3.4.18([email protected])
+ tailwindcss: 3.4.18([email protected])([email protected])
'@tanstack/[email protected]': {}
@@ -12065,6 +12171,10 @@ snapshots:
dependencies:
'@types/react': 19.1.17
+ dependencies:
+ '@types/react': 19.1.17
+
dependencies:
'@types/react': 19.1.17
@@ -12644,6 +12754,13 @@ snapshots:
dependencies:
got: 11.8.6
+ dependencies:
+ '@types/react-reconciler': 0.28.9(@types/[email protected])
+ react: 19.1.1
+ transitivePeerDependencies:
+ - '@types/react'
+
@@ -13898,11 +14015,11 @@ snapshots:
- supports-color
- typescript
dependencies:
fast-glob: 3.3.3
postcss: 8.5.6
- tailwindcss: 3.4.18([email protected])
+ tailwindcss: 3.4.18([email protected])([email protected])
dependencies:
@@ -14307,6 +14424,9 @@ snapshots:
+ optional: true
+
optional: true
@@ -15257,6 +15377,8 @@ snapshots:
+
dependencies:
'@nodelib/fs.walk': 1.2.8
@@ -16029,6 +16151,8 @@ snapshots:
dompurify: 3.2.7
marked: 14.0.0
+
@@ -16414,6 +16538,14 @@ snapshots:
exsolve: 1.0.8
pathe: 2.0.3
+
+ dependencies:
+ playwright-core: 1.57.0
+ optionalDependencies:
+ fsevents: 2.3.2
+
@@ -16446,12 +16578,13 @@ snapshots:
camelcase-css: 2.0.1
postcss: 8.5.6
dependencies:
lilconfig: 3.1.3
optionalDependencies:
jiti: 1.21.7
postcss: 8.5.6
+ tsx: 4.21.0
yaml: 2.8.2
@@ -16520,6 +16653,8 @@ snapshots:
picocolors: 1.1.1
source-map-js: 1.2.1
+
dependencies:
detect-libc: 2.1.2
@@ -16782,6 +16917,35 @@ snapshots:
tslib: 2.6.2
+ dependencies:
+ '@babel/core': 7.28.5
+ '@babel/generator': 7.28.5
+ '@babel/types': 7.28.5
+ '@clack/core': 0.3.5
+ '@clack/prompts': 0.8.2
+ '@preact/signals': 1.3.2([email protected])
+ '@rollup/pluginutils': 5.3.0([email protected])
+ '@types/node': 20.19.25
+ bippy: 0.3.34(@types/[email protected])([email protected])
+ esbuild: 0.25.0
+ estree-walker: 3.0.3
+ kleur: 4.1.5
+ mri: 1.2.0
+ playwright: 1.57.0
+ preact: 10.28.0
+ react: 19.1.1
+ react-dom: 19.1.1([email protected])
+ tsx: 4.21.0
+ optionalDependencies:
+ unplugin: 2.1.0
+ transitivePeerDependencies:
+ - '@types/react'
+ - rollup
+ - supports-color
+
dependencies:
prop-types: 15.8.1
@@ -17536,7 +17700,7 @@ snapshots:
dependencies:
'@alloc/quick-lru': 5.2.0
arg: 5.0.2
@@ -17555,7 +17719,7 @@ snapshots:
postcss: 8.5.6
postcss-import: 15.1.0([email protected])
postcss-js: 4.1.0([email protected])
postcss-nested: 6.2.0([email protected])
postcss-selector-parser: 6.1.2
resolve: 1.22.11
@@ -17732,6 +17896,13 @@ snapshots:
+ dependencies:
+ esbuild: 0.25.0
+ get-tsconfig: 4.13.0
+ optionalDependencies:
+ fsevents: 2.3.3
+
@@ -17834,6 +18005,12 @@ snapshots:
acorn: 8.15.0
webpack-virtual-modules: 0.6.2
+ dependencies:
+ acorn: 8.15.0
+ webpack-virtual-modules: 0.6.2
+ optional: true
+