From 3e5e87930c61379527efe41e0922a3e8f96cb70b Mon Sep 17 00:00:00 2001 From: GuanMu Date: Tue, 14 Oct 2025 19:06:31 +0800 Subject: [PATCH 1/5] feat: add Knip configuration for dead code detection and remove unused icon components (#26758) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> --- .../icons/assets/vender/knowledge/index.ts | 13 - .../src/image/llm/BaichuanTextCn.module.css | 5 - .../icons/src/image/llm/BaichuanTextCn.tsx | 20 -- .../icons/src/image/llm/Minimax.module.css | 5 - .../base/icons/src/image/llm/Minimax.tsx | 20 -- .../src/image/llm/MinimaxText.module.css | 5 - .../base/icons/src/image/llm/MinimaxText.tsx | 20 -- .../icons/src/image/llm/Tongyi.module.css | 5 - .../base/icons/src/image/llm/Tongyi.tsx | 20 -- .../icons/src/image/llm/TongyiText.module.css | 5 - .../base/icons/src/image/llm/TongyiText.tsx | 20 -- .../src/image/llm/TongyiTextCn.module.css | 5 - .../base/icons/src/image/llm/TongyiTextCn.tsx | 20 -- .../base/icons/src/image/llm/Wxyy.module.css | 5 - .../base/icons/src/image/llm/Wxyy.tsx | 20 -- .../icons/src/image/llm/WxyyText.module.css | 5 - .../base/icons/src/image/llm/WxyyText.tsx | 20 -- .../icons/src/image/llm/WxyyTextCn.module.css | 5 - .../base/icons/src/image/llm/WxyyTextCn.tsx | 20 -- .../base/icons/src/image/llm/index.ts | 9 - .../base/icons/src/public/model/Checked.tsx | 20 -- .../base/icons/src/public/model/index.ts | 1 - .../base/icons/src/public/plugins/Google.tsx | 20 -- .../icons/src/public/plugins/WebReader.tsx | 20 -- .../icons/src/public/plugins/Wikipedia.tsx | 20 -- .../base/icons/src/public/plugins/index.ts | 7 - .../base/icons/src/public/thought/DataSet.tsx | 1 + .../base/icons/src/public/thought/Loading.tsx | 20 -- .../base/icons/src/public/thought/Search.tsx | 20 -- .../icons/src/public/thought/ThoughtList.tsx | 20 -- .../icons/src/public/thought/WebReader.tsx | 20 -- .../base/icons/src/public/thought/index.ts | 5 +- .../src/vender/line/layout/AlignLeft01.tsx | 20 -- .../src/vender/line/layout/AlignRight01.tsx | 20 -- .../icons/src/vender/line/layout/Grid01.tsx | 20 -- .../icons/src/vender/line/layout/index.ts | 3 - .../src/vender/line/mapsAndTravel/Route.tsx | 20 -- .../src/vender/line/mapsAndTravel/index.ts | 1 - .../icons/src/vender/line/users/User01.tsx | 20 -- .../icons/src/vender/line/users/Users01.tsx | 20 -- .../base/icons/src/vender/line/users/index.ts | 2 - .../icons/src/vender/line/weather/Stars02.tsx | 20 -- .../icons/src/vender/line/weather/index.ts | 1 - .../src/vender/solid/arrows/ChevronDown.tsx | 20 -- .../src/vender/solid/arrows/HighPriority.tsx | 20 -- .../icons/src/vender/solid/arrows/index.ts | 2 - .../icons/src/vender/solid/layout/Grid01.tsx | 20 -- .../icons/src/vender/solid/layout/index.ts | 1 - web/knip.config.ts | 288 ++++++++++++++++++ 49 files changed, 290 insertions(+), 629 deletions(-) delete mode 100644 web/app/components/base/icons/assets/vender/knowledge/index.ts delete mode 100644 web/app/components/base/icons/src/image/llm/BaichuanTextCn.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/BaichuanTextCn.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/Minimax.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/Minimax.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/MinimaxText.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/MinimaxText.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/Tongyi.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/Tongyi.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/TongyiText.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/TongyiText.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/TongyiTextCn.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/TongyiTextCn.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/Wxyy.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/Wxyy.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/WxyyText.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/WxyyText.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/WxyyTextCn.module.css delete mode 100644 web/app/components/base/icons/src/image/llm/WxyyTextCn.tsx delete mode 100644 web/app/components/base/icons/src/image/llm/index.ts delete mode 100644 web/app/components/base/icons/src/public/model/Checked.tsx delete mode 100644 web/app/components/base/icons/src/public/model/index.ts delete mode 100644 web/app/components/base/icons/src/public/plugins/Google.tsx delete mode 100644 web/app/components/base/icons/src/public/plugins/WebReader.tsx delete mode 100644 web/app/components/base/icons/src/public/plugins/Wikipedia.tsx delete mode 100644 web/app/components/base/icons/src/public/plugins/index.ts delete mode 100644 web/app/components/base/icons/src/public/thought/Loading.tsx delete mode 100644 web/app/components/base/icons/src/public/thought/Search.tsx delete mode 100644 web/app/components/base/icons/src/public/thought/ThoughtList.tsx delete mode 100644 web/app/components/base/icons/src/public/thought/WebReader.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/layout/AlignLeft01.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/layout/AlignRight01.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/layout/Grid01.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/mapsAndTravel/Route.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/mapsAndTravel/index.ts delete mode 100644 web/app/components/base/icons/src/vender/line/users/User01.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/users/Users01.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/users/index.ts delete mode 100644 web/app/components/base/icons/src/vender/line/weather/Stars02.tsx delete mode 100644 web/app/components/base/icons/src/vender/line/weather/index.ts delete mode 100644 web/app/components/base/icons/src/vender/solid/arrows/ChevronDown.tsx delete mode 100644 web/app/components/base/icons/src/vender/solid/arrows/HighPriority.tsx delete mode 100644 web/app/components/base/icons/src/vender/solid/arrows/index.ts delete mode 100644 web/app/components/base/icons/src/vender/solid/layout/Grid01.tsx delete mode 100644 web/app/components/base/icons/src/vender/solid/layout/index.ts create mode 100644 web/knip.config.ts diff --git a/web/app/components/base/icons/assets/vender/knowledge/index.ts b/web/app/components/base/icons/assets/vender/knowledge/index.ts deleted file mode 100644 index 7ef6f1b8e4..0000000000 --- a/web/app/components/base/icons/assets/vender/knowledge/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { default as Chunk } from './Chunk' -export { default as Collapse } from './Collapse' -export { default as Divider } from './Divider' -export { default as File } from './File' -export { default as GeneralType } from './GeneralType' -export { default as LayoutRight2LineMod } from './LayoutRight2LineMod' -export { default as OptionCardEffectBlueLight } from './OptionCardEffectBlueLight' -export { default as OptionCardEffectBlue } from './OptionCardEffectBlue' -export { default as OptionCardEffectOrange } from './OptionCardEffectOrange' -export { default as OptionCardEffectPurple } from './OptionCardEffectPurple' -export { default as ParentChildType } from './ParentChildType' -export { default as SelectionMod } from './SelectionMod' -export { default as Watercrawl } from './Watercrawl' diff --git a/web/app/components/base/icons/src/image/llm/BaichuanTextCn.module.css b/web/app/components/base/icons/src/image/llm/BaichuanTextCn.module.css deleted file mode 100644 index 97ab9b22f9..0000000000 --- a/web/app/components/base/icons/src/image/llm/BaichuanTextCn.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/baichuan-text-cn.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/BaichuanTextCn.tsx b/web/app/components/base/icons/src/image/llm/BaichuanTextCn.tsx deleted file mode 100644 index be9a407eb2..0000000000 --- a/web/app/components/base/icons/src/image/llm/BaichuanTextCn.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './BaichuanTextCn.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'BaichuanTextCn' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/Minimax.module.css b/web/app/components/base/icons/src/image/llm/Minimax.module.css deleted file mode 100644 index 551ecc3c62..0000000000 --- a/web/app/components/base/icons/src/image/llm/Minimax.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/minimax.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/Minimax.tsx b/web/app/components/base/icons/src/image/llm/Minimax.tsx deleted file mode 100644 index 7df7e3fcbc..0000000000 --- a/web/app/components/base/icons/src/image/llm/Minimax.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './Minimax.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'Minimax' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/MinimaxText.module.css b/web/app/components/base/icons/src/image/llm/MinimaxText.module.css deleted file mode 100644 index a63be49e8b..0000000000 --- a/web/app/components/base/icons/src/image/llm/MinimaxText.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/minimax-text.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/MinimaxText.tsx b/web/app/components/base/icons/src/image/llm/MinimaxText.tsx deleted file mode 100644 index 840e8cb439..0000000000 --- a/web/app/components/base/icons/src/image/llm/MinimaxText.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './MinimaxText.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'MinimaxText' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/Tongyi.module.css b/web/app/components/base/icons/src/image/llm/Tongyi.module.css deleted file mode 100644 index 3ca440768c..0000000000 --- a/web/app/components/base/icons/src/image/llm/Tongyi.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/tongyi.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/Tongyi.tsx b/web/app/components/base/icons/src/image/llm/Tongyi.tsx deleted file mode 100644 index 2f62f1a355..0000000000 --- a/web/app/components/base/icons/src/image/llm/Tongyi.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './Tongyi.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'Tongyi' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/TongyiText.module.css b/web/app/components/base/icons/src/image/llm/TongyiText.module.css deleted file mode 100644 index f713671808..0000000000 --- a/web/app/components/base/icons/src/image/llm/TongyiText.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/tongyi-text.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/TongyiText.tsx b/web/app/components/base/icons/src/image/llm/TongyiText.tsx deleted file mode 100644 index a52f63c248..0000000000 --- a/web/app/components/base/icons/src/image/llm/TongyiText.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './TongyiText.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'TongyiText' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/TongyiTextCn.module.css b/web/app/components/base/icons/src/image/llm/TongyiTextCn.module.css deleted file mode 100644 index d07e6e8bc4..0000000000 --- a/web/app/components/base/icons/src/image/llm/TongyiTextCn.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/tongyi-text-cn.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/TongyiTextCn.tsx b/web/app/components/base/icons/src/image/llm/TongyiTextCn.tsx deleted file mode 100644 index c982c73aed..0000000000 --- a/web/app/components/base/icons/src/image/llm/TongyiTextCn.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './TongyiTextCn.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'TongyiTextCn' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/Wxyy.module.css b/web/app/components/base/icons/src/image/llm/Wxyy.module.css deleted file mode 100644 index 44344a495f..0000000000 --- a/web/app/components/base/icons/src/image/llm/Wxyy.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/wxyy.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/Wxyy.tsx b/web/app/components/base/icons/src/image/llm/Wxyy.tsx deleted file mode 100644 index a3c494811e..0000000000 --- a/web/app/components/base/icons/src/image/llm/Wxyy.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './Wxyy.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'Wxyy' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/WxyyText.module.css b/web/app/components/base/icons/src/image/llm/WxyyText.module.css deleted file mode 100644 index 58a0c62047..0000000000 --- a/web/app/components/base/icons/src/image/llm/WxyyText.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/wxyy-text.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/WxyyText.tsx b/web/app/components/base/icons/src/image/llm/WxyyText.tsx deleted file mode 100644 index e5dd6e8803..0000000000 --- a/web/app/components/base/icons/src/image/llm/WxyyText.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './WxyyText.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'WxyyText' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/WxyyTextCn.module.css b/web/app/components/base/icons/src/image/llm/WxyyTextCn.module.css deleted file mode 100644 index fb5839ab07..0000000000 --- a/web/app/components/base/icons/src/image/llm/WxyyTextCn.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.wrapper { - display: inline-flex; - background: url(~@/app/components/base/icons/assets/image/llm/wxyy-text-cn.png) center center no-repeat; - background-size: contain; -} diff --git a/web/app/components/base/icons/src/image/llm/WxyyTextCn.tsx b/web/app/components/base/icons/src/image/llm/WxyyTextCn.tsx deleted file mode 100644 index 32108adab4..0000000000 --- a/web/app/components/base/icons/src/image/llm/WxyyTextCn.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import cn from '@/utils/classnames' -import s from './WxyyTextCn.module.css' - -const Icon = ( - { - ref, - className, - ...restProps - }: React.DetailedHTMLProps, HTMLSpanElement> & { - ref?: React.RefObject; - }, -) => - -Icon.displayName = 'WxyyTextCn' - -export default Icon diff --git a/web/app/components/base/icons/src/image/llm/index.ts b/web/app/components/base/icons/src/image/llm/index.ts deleted file mode 100644 index 3a4e64ac18..0000000000 --- a/web/app/components/base/icons/src/image/llm/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export { default as BaichuanTextCn } from './BaichuanTextCn' -export { default as MinimaxText } from './MinimaxText' -export { default as Minimax } from './Minimax' -export { default as TongyiTextCn } from './TongyiTextCn' -export { default as TongyiText } from './TongyiText' -export { default as Tongyi } from './Tongyi' -export { default as WxyyTextCn } from './WxyyTextCn' -export { default as WxyyText } from './WxyyText' -export { default as Wxyy } from './Wxyy' diff --git a/web/app/components/base/icons/src/public/model/Checked.tsx b/web/app/components/base/icons/src/public/model/Checked.tsx deleted file mode 100644 index 7854479cd2..0000000000 --- a/web/app/components/base/icons/src/public/model/Checked.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Checked.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Checked' - -export default Icon diff --git a/web/app/components/base/icons/src/public/model/index.ts b/web/app/components/base/icons/src/public/model/index.ts deleted file mode 100644 index 719a6f0309..0000000000 --- a/web/app/components/base/icons/src/public/model/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Checked } from './Checked' diff --git a/web/app/components/base/icons/src/public/plugins/Google.tsx b/web/app/components/base/icons/src/public/plugins/Google.tsx deleted file mode 100644 index 3e19ecd2f8..0000000000 --- a/web/app/components/base/icons/src/public/plugins/Google.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Google.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Google' - -export default Icon diff --git a/web/app/components/base/icons/src/public/plugins/WebReader.tsx b/web/app/components/base/icons/src/public/plugins/WebReader.tsx deleted file mode 100644 index 5606e32f88..0000000000 --- a/web/app/components/base/icons/src/public/plugins/WebReader.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './WebReader.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'WebReader' - -export default Icon diff --git a/web/app/components/base/icons/src/public/plugins/Wikipedia.tsx b/web/app/components/base/icons/src/public/plugins/Wikipedia.tsx deleted file mode 100644 index c2fde5c1f8..0000000000 --- a/web/app/components/base/icons/src/public/plugins/Wikipedia.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Wikipedia.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Wikipedia' - -export default Icon diff --git a/web/app/components/base/icons/src/public/plugins/index.ts b/web/app/components/base/icons/src/public/plugins/index.ts deleted file mode 100644 index 87dc37167c..0000000000 --- a/web/app/components/base/icons/src/public/plugins/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { default as Google } from './Google' -export { default as PartnerDark } from './PartnerDark' -export { default as PartnerLight } from './PartnerLight' -export { default as VerifiedDark } from './VerifiedDark' -export { default as VerifiedLight } from './VerifiedLight' -export { default as WebReader } from './WebReader' -export { default as Wikipedia } from './Wikipedia' diff --git a/web/app/components/base/icons/src/public/thought/DataSet.tsx b/web/app/components/base/icons/src/public/thought/DataSet.tsx index f35ff4efbc..e279c77ec7 100644 --- a/web/app/components/base/icons/src/public/thought/DataSet.tsx +++ b/web/app/components/base/icons/src/public/thought/DataSet.tsx @@ -18,3 +18,4 @@ const Icon = ( Icon.displayName = 'DataSet' export default Icon + diff --git a/web/app/components/base/icons/src/public/thought/Loading.tsx b/web/app/components/base/icons/src/public/thought/Loading.tsx deleted file mode 100644 index af959fba40..0000000000 --- a/web/app/components/base/icons/src/public/thought/Loading.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Loading.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Loading' - -export default Icon diff --git a/web/app/components/base/icons/src/public/thought/Search.tsx b/web/app/components/base/icons/src/public/thought/Search.tsx deleted file mode 100644 index ecd98048d5..0000000000 --- a/web/app/components/base/icons/src/public/thought/Search.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Search.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Search' - -export default Icon diff --git a/web/app/components/base/icons/src/public/thought/ThoughtList.tsx b/web/app/components/base/icons/src/public/thought/ThoughtList.tsx deleted file mode 100644 index e7f0e312ef..0000000000 --- a/web/app/components/base/icons/src/public/thought/ThoughtList.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './ThoughtList.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'ThoughtList' - -export default Icon diff --git a/web/app/components/base/icons/src/public/thought/WebReader.tsx b/web/app/components/base/icons/src/public/thought/WebReader.tsx deleted file mode 100644 index 5606e32f88..0000000000 --- a/web/app/components/base/icons/src/public/thought/WebReader.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './WebReader.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'WebReader' - -export default Icon diff --git a/web/app/components/base/icons/src/public/thought/index.ts b/web/app/components/base/icons/src/public/thought/index.ts index 8a45489dbf..35adcb50bb 100644 --- a/web/app/components/base/icons/src/public/thought/index.ts +++ b/web/app/components/base/icons/src/public/thought/index.ts @@ -1,5 +1,2 @@ export { default as DataSet } from './DataSet' -export { default as Loading } from './Loading' -export { default as Search } from './Search' -export { default as ThoughtList } from './ThoughtList' -export { default as WebReader } from './WebReader' + diff --git a/web/app/components/base/icons/src/vender/line/layout/AlignLeft01.tsx b/web/app/components/base/icons/src/vender/line/layout/AlignLeft01.tsx deleted file mode 100644 index 0761e89f56..0000000000 --- a/web/app/components/base/icons/src/vender/line/layout/AlignLeft01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './AlignLeft01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'AlignLeft01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/layout/AlignRight01.tsx b/web/app/components/base/icons/src/vender/line/layout/AlignRight01.tsx deleted file mode 100644 index ffe1889ff8..0000000000 --- a/web/app/components/base/icons/src/vender/line/layout/AlignRight01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './AlignRight01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'AlignRight01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/layout/Grid01.tsx b/web/app/components/base/icons/src/vender/line/layout/Grid01.tsx deleted file mode 100644 index bc9b6115be..0000000000 --- a/web/app/components/base/icons/src/vender/line/layout/Grid01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Grid01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Grid01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/layout/index.ts b/web/app/components/base/icons/src/vender/line/layout/index.ts index 7c12b1f58f..a6aa205faa 100644 --- a/web/app/components/base/icons/src/vender/line/layout/index.ts +++ b/web/app/components/base/icons/src/vender/line/layout/index.ts @@ -1,4 +1 @@ -export { default as AlignLeft01 } from './AlignLeft01' -export { default as AlignRight01 } from './AlignRight01' -export { default as Grid01 } from './Grid01' export { default as LayoutGrid02 } from './LayoutGrid02' diff --git a/web/app/components/base/icons/src/vender/line/mapsAndTravel/Route.tsx b/web/app/components/base/icons/src/vender/line/mapsAndTravel/Route.tsx deleted file mode 100644 index 9cbde4a15e..0000000000 --- a/web/app/components/base/icons/src/vender/line/mapsAndTravel/Route.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Route.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Route' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/mapsAndTravel/index.ts b/web/app/components/base/icons/src/vender/line/mapsAndTravel/index.ts deleted file mode 100644 index 82cb320ff2..0000000000 --- a/web/app/components/base/icons/src/vender/line/mapsAndTravel/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Route } from './Route' diff --git a/web/app/components/base/icons/src/vender/line/users/User01.tsx b/web/app/components/base/icons/src/vender/line/users/User01.tsx deleted file mode 100644 index 42f2144b97..0000000000 --- a/web/app/components/base/icons/src/vender/line/users/User01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './User01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'User01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/users/Users01.tsx b/web/app/components/base/icons/src/vender/line/users/Users01.tsx deleted file mode 100644 index b63daf7242..0000000000 --- a/web/app/components/base/icons/src/vender/line/users/Users01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Users01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Users01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/users/index.ts b/web/app/components/base/icons/src/vender/line/users/index.ts deleted file mode 100644 index 9f8a35152f..0000000000 --- a/web/app/components/base/icons/src/vender/line/users/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as User01 } from './User01' -export { default as Users01 } from './Users01' diff --git a/web/app/components/base/icons/src/vender/line/weather/Stars02.tsx b/web/app/components/base/icons/src/vender/line/weather/Stars02.tsx deleted file mode 100644 index 8a42448c70..0000000000 --- a/web/app/components/base/icons/src/vender/line/weather/Stars02.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Stars02.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Stars02' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/line/weather/index.ts b/web/app/components/base/icons/src/vender/line/weather/index.ts deleted file mode 100644 index 1a68bce765..0000000000 --- a/web/app/components/base/icons/src/vender/line/weather/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Stars02 } from './Stars02' diff --git a/web/app/components/base/icons/src/vender/solid/arrows/ChevronDown.tsx b/web/app/components/base/icons/src/vender/solid/arrows/ChevronDown.tsx deleted file mode 100644 index 643ddfbf79..0000000000 --- a/web/app/components/base/icons/src/vender/solid/arrows/ChevronDown.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './ChevronDown.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'ChevronDown' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/solid/arrows/HighPriority.tsx b/web/app/components/base/icons/src/vender/solid/arrows/HighPriority.tsx deleted file mode 100644 index af6fa05e5c..0000000000 --- a/web/app/components/base/icons/src/vender/solid/arrows/HighPriority.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './HighPriority.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'HighPriority' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/solid/arrows/index.ts b/web/app/components/base/icons/src/vender/solid/arrows/index.ts deleted file mode 100644 index 468f0e52d9..0000000000 --- a/web/app/components/base/icons/src/vender/solid/arrows/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as ChevronDown } from './ChevronDown' -export { default as HighPriority } from './HighPriority' diff --git a/web/app/components/base/icons/src/vender/solid/layout/Grid01.tsx b/web/app/components/base/icons/src/vender/solid/layout/Grid01.tsx deleted file mode 100644 index bc9b6115be..0000000000 --- a/web/app/components/base/icons/src/vender/solid/layout/Grid01.tsx +++ /dev/null @@ -1,20 +0,0 @@ -// GENERATE BY script -// DON NOT EDIT IT MANUALLY - -import * as React from 'react' -import data from './Grid01.json' -import IconBase from '@/app/components/base/icons/IconBase' -import type { IconData } from '@/app/components/base/icons/IconBase' - -const Icon = ( - { - ref, - ...props - }: React.SVGProps & { - ref?: React.RefObject>; - }, -) => - -Icon.displayName = 'Grid01' - -export default Icon diff --git a/web/app/components/base/icons/src/vender/solid/layout/index.ts b/web/app/components/base/icons/src/vender/solid/layout/index.ts deleted file mode 100644 index 73a2513d51..0000000000 --- a/web/app/components/base/icons/src/vender/solid/layout/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Grid01 } from './Grid01' diff --git a/web/knip.config.ts b/web/knip.config.ts new file mode 100644 index 0000000000..b9fb43f171 --- /dev/null +++ b/web/knip.config.ts @@ -0,0 +1,288 @@ +import type { KnipConfig } from 'knip' + +/** + * Knip Configuration for Dead Code Detection + * + * This configuration helps identify unused files, exports, and dependencies + * in the Dify web application (Next.js 15 + TypeScript + React 19). + * + * ⚠️ SAFETY FIRST: This configuration is designed to be conservative and + * avoid false positives that could lead to deleting actively used code. + * + * @see https://knip.dev/reference/configuration + */ +const config: KnipConfig = { + // ============================================================================ + // Next.js Framework Configuration + // ============================================================================ + // Configure entry points specific to Next.js application structure. + // These files are automatically treated as entry points by the framework. + next: { + entry: [ + // Next.js App Router pages (must exist for routing) + 'app/**/page.tsx', + 'app/**/layout.tsx', + 'app/**/loading.tsx', + 'app/**/error.tsx', + 'app/**/not-found.tsx', + 'app/**/template.tsx', + 'app/**/default.tsx', + + // Middleware (runs before every route) + 'middleware.ts', + + // Configuration files + 'next.config.js', + 'tailwind.config.js', + 'tailwind-common-config.ts', + 'postcss.config.js', + + // Testing configuration + 'jest.config.ts', + 'jest.setup.ts', + + // Linting configuration + 'eslint.config.mjs', + ], + }, + + // ============================================================================ + // Global Entry Points + // ============================================================================ + // Files that serve as entry points for the application. + // The '!' suffix means these patterns take precedence and are always included. + entry: [ + // Next.js App Router patterns (high priority) + 'app/**/page.tsx!', + 'app/**/layout.tsx!', + 'app/**/loading.tsx!', + 'app/**/error.tsx!', + 'app/**/not-found.tsx!', + 'app/**/template.tsx!', + 'app/**/default.tsx!', + + // Core configuration files + 'middleware.ts!', + 'next.config.js!', + 'tailwind.config.js!', + 'tailwind-common-config.ts!', + 'postcss.config.js!', + + // Testing setup + 'jest.config.ts!', + 'jest.setup.ts!', + + // Linting setup + 'eslint.config.mjs!', + + // ======================================================================== + // πŸ”’ CRITICAL: Global Initializers and Providers + // ======================================================================== + // These files are imported by root layout.tsx and provide global functionality. + // Even if not directly imported elsewhere, they are essential for app initialization. + + // Browser initialization (runs on client startup) + 'app/components/browser-initializer.tsx!', + 'app/components/sentry-initializer.tsx!', + 'app/components/swr-initializer.tsx!', + + // i18n initialization (server and client) + 'app/components/i18n.tsx!', + 'app/components/i18n-server.tsx!', + + // Route prefix handling (used in root layout) + 'app/routePrefixHandle.tsx!', + + // ======================================================================== + // πŸ”’ CRITICAL: Context Providers + // ======================================================================== + // Context providers might be used via React Context API and imported dynamically. + // Protecting all context files to prevent breaking the provider chain. + 'context/**/*.ts?(x)!', + + // Component-level contexts (also used via React.useContext) + 'app/components/**/*.context.ts?(x)!', + + // ======================================================================== + // πŸ”’ CRITICAL: State Management Stores + // ======================================================================== + // Zustand stores might be imported dynamically or via hooks. + // These are often imported at module level, so they should be protected. + 'app/components/**/*.store.ts?(x)!', + 'context/**/*.store.ts?(x)!', + + // ======================================================================== + // πŸ”’ CRITICAL: Provider Components + // ======================================================================== + // Provider components wrap the app and provide global state/functionality + 'app/components/**/*.provider.ts?(x)!', + 'context/**/*.provider.ts?(x)!', + + // ======================================================================== + // Development tools + // ======================================================================== + // Storybook configuration + '.storybook/**/*', + ], + + // ============================================================================ + // Project Files to Analyze + // ============================================================================ + // Glob patterns for files that should be analyzed for unused code. + // Excludes test files to avoid false positives. + project: [ + '**/*.{js,jsx,ts,tsx,mjs,cjs}', + ], + + // ============================================================================ + // Ignored Files and Directories + // ============================================================================ + // Files and directories that should be completely excluded from analysis. + // These typically contain: + // - Test files + // - Internationalization files (loaded dynamically) + // - Static assets + // - Build outputs + // - External libraries + ignore: [ + // Test files and directories + '**/__tests__/**', + '**/*.spec.{ts,tsx}', + '**/*.test.{ts,tsx}', + + // ======================================================================== + // πŸ”’ CRITICAL: i18n Files (Dynamically Loaded) + // ======================================================================== + // Internationalization files are loaded dynamically at runtime via i18next. + // Pattern: import(`@/i18n/${locale}/messages`) + // These will NEVER show up in static analysis but are essential! + 'i18n/**', + + // ======================================================================== + // πŸ”’ CRITICAL: Static Assets + // ======================================================================== + // Static assets are referenced by URL in the browser, not via imports. + // Examples: /logo.png, /icons/*, /embed.js + 'public/**', + + // Build outputs and caches + 'node_modules/**', + '.next/**', + 'coverage/**', + + // Development tools + '**/*.stories.{ts,tsx}', + + // ======================================================================== + // πŸ”’ Utility scripts (not part of application runtime) + // ======================================================================== + // These scripts are run manually (e.g., pnpm gen-icons, pnpm check-i18n) + // and are not imported by the application code. + 'scripts/**', + 'bin/**', + 'i18n-config/**', + + // Icon generation script (generates components, not used in runtime) + 'app/components/base/icons/script.mjs', + ], + + // ============================================================================ + // Ignored Dependencies + // ============================================================================ + // Dependencies that are used but not directly imported in code. + // These are typically: + // - Build tools + // - Plugins loaded by configuration files + // - CLI tools + ignoreDependencies: [ + // ======================================================================== + // Next.js plugins (loaded by next.config.js) + // ======================================================================== + 'next-pwa', + '@next/bundle-analyzer', + '@next/mdx', + + // ======================================================================== + // Build tools (used by webpack/next.js build process) + // ======================================================================== + 'code-inspector-plugin', + + // ======================================================================== + // Development and translation tools (used by scripts) + // ======================================================================== + 'bing-translate-api', + 'uglify-js', + 'magicast', + ], + + // ============================================================================ + // Export Analysis Configuration + // ============================================================================ + // Configure how exports are analyzed + + // Ignore exports that are only used within the same file + // (e.g., helper functions used internally in the same module) + ignoreExportsUsedInFile: true, + + // ⚠️ SAFETY: Include exports from entry files in the analysis + // This helps find unused public APIs, but be careful with: + // - Context exports (useContext hooks) + // - Store exports (useStore hooks) + // - Type exports (might be used in other files) + includeEntryExports: true, + + // ============================================================================ + // Ignored Binaries + // ============================================================================ + // Binary executables that are used but not listed in package.json + ignoreBinaries: [ + 'only-allow', // Used in preinstall script to enforce pnpm usage + ], + + // ============================================================================ + // Reporting Rules + // ============================================================================ + // Configure what types of issues to report and at what severity level + rules: { + // ======================================================================== + // Unused files are ERRORS + // ======================================================================== + // These should definitely be removed or used. + // However, always manually verify before deleting! + files: 'error', + + // ======================================================================== + // Unused dependencies are WARNINGS + // ======================================================================== + // Dependencies might be: + // - Used in production builds but not in dev + // - Peer dependencies + // - Used by other tools + dependencies: 'warn', + devDependencies: 'warn', + + // ======================================================================== + // Unlisted imports are ERRORS + // ======================================================================== + // Missing from package.json - will break in production! + unlisted: 'error', + + // ======================================================================== + // Unused exports are WARNINGS (not errors!) + // ======================================================================== + // Exports might be: + // - Part of public API for future use + // - Used by external tools + // - Exported for type inference + // ⚠️ ALWAYS manually verify before removing exports! + exports: 'warn', + + // Unused types are warnings (might be part of type definitions) + types: 'warn', + + // Duplicate exports are warnings (could cause confusion but not breaking) + duplicates: 'warn', + }, +} + +export default config From 9e39be0770323afc3598b24bdd684df0454e5067 Mon Sep 17 00:00:00 2001 From: GuanMu Date: Tue, 14 Oct 2025 19:41:01 +0800 Subject: [PATCH 2/5] fix: correct indentation in JSON payloads (#26871) --- web/app/components/develop/template/template_chat.en.mdx | 4 ++-- web/app/components/develop/template/template_chat.zh.mdx | 2 +- web/app/components/develop/template/template_workflow.zh.mdx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/app/components/develop/template/template_chat.en.mdx b/web/app/components/develop/template/template_chat.en.mdx index 82b50d58ea..3c664a3d3f 100644 --- a/web/app/components/develop/template/template_chat.en.mdx +++ b/web/app/components/develop/template/template_chat.en.mdx @@ -199,7 +199,7 @@ Chat applications support session persistence, allowing previous chat history to --header 'Authorization: Bearer {api_key}' \\ --header 'Content-Type: application/json' \\ --data-raw '{ - "inputs": ${JSON.stringify(props.inputs)}, + "inputs": ${JSON.stringify(props.inputs)}, "query": "What are the specs of the iPhone 13 Pro Max?", "response_mode": "streaming", "conversation_id": "", @@ -1182,7 +1182,7 @@ Chat applications support session persistence, allowing previous chat history to --header 'Content-Type: application/json' \\ --data-raw '{ "value": "Updated Value", - "user": "abc-123" + "user": "abc-123" }'`} /> diff --git a/web/app/components/develop/template/template_chat.zh.mdx b/web/app/components/develop/template/template_chat.zh.mdx index 581daef726..2273290d03 100644 --- a/web/app/components/develop/template/template_chat.zh.mdx +++ b/web/app/components/develop/template/template_chat.zh.mdx @@ -1188,7 +1188,7 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx' --header 'Content-Type: application/json' \\ --data-raw '{ "value": "Updated Value", - "user": "abc-123" + "user": "abc-123" }'`} /> diff --git a/web/app/components/develop/template/template_workflow.zh.mdx b/web/app/components/develop/template/template_workflow.zh.mdx index 2cdc88de5a..8b47e88293 100644 --- a/web/app/components/develop/template/template_workflow.zh.mdx +++ b/web/app/components/develop/template/template_workflow.zh.mdx @@ -182,7 +182,7 @@ Workflow εΊ”η”¨ζ— δΌšθ―ζ”―ζŒοΌŒι€‚εˆη”¨δΊŽηΏ»θ―‘/ζ–‡η« ε†™δ½œ/ζ€»η»“ AI η­‰ --header 'Authorization: Bearer {api_key}' \\ --header 'Content-Type: application/json' \\ --data-raw '{ - "inputs": ${JSON.stringify(props.inputs)}, + "inputs": ${JSON.stringify(props.inputs)}, "response_mode": "streaming", "user": "abc-123" }'`} From 7b5132034678744b1b75952ac6199fd784edc224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Tue, 14 Oct 2025 19:42:48 +0800 Subject: [PATCH 3/5] fix: when create provider credential set the provider record to vaild (#26868) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- api/core/entities/provider_configuration.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/core/entities/provider_configuration.py b/api/core/entities/provider_configuration.py index 29b8f8f610..b069955836 100644 --- a/api/core/entities/provider_configuration.py +++ b/api/core/entities/provider_configuration.py @@ -472,6 +472,9 @@ class ProviderConfiguration(BaseModel): provider_model_credentials_cache.delete() self.switch_preferred_provider_type(provider_type=ProviderType.CUSTOM, session=session) + else: + # some historical data may have a provider record but not be set as valid + provider_record.is_valid = True session.commit() except Exception: From 8ddc4f22927655d337fc80d2e2e17d1ba611b195 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Wed, 15 Oct 2025 00:42:55 +0900 Subject: [PATCH 4/5] example to auto rollback (#26200) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../clean_workflow_runlogs_precise.py | 125 +++++++++--------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/api/schedule/clean_workflow_runlogs_precise.py b/api/schedule/clean_workflow_runlogs_precise.py index 485a79782c..db4198720d 100644 --- a/api/schedule/clean_workflow_runlogs_precise.py +++ b/api/schedule/clean_workflow_runlogs_precise.py @@ -1,8 +1,11 @@ import datetime import logging import time +from collections.abc import Sequence import click +from sqlalchemy import select +from sqlalchemy.orm import Session, sessionmaker import app from configs import dify_config @@ -35,50 +38,53 @@ def clean_workflow_runlogs_precise(): retention_days = dify_config.WORKFLOW_LOG_RETENTION_DAYS cutoff_date = datetime.datetime.now() - datetime.timedelta(days=retention_days) + session_factory = sessionmaker(db.engine, expire_on_commit=False) try: - total_workflow_runs = db.session.query(WorkflowRun).where(WorkflowRun.created_at < cutoff_date).count() - if total_workflow_runs == 0: - logger.info("No expired workflow run logs found") - return - logger.info("Found %s expired workflow run logs to clean", total_workflow_runs) + with session_factory.begin() as session: + total_workflow_runs = session.query(WorkflowRun).where(WorkflowRun.created_at < cutoff_date).count() + if total_workflow_runs == 0: + logger.info("No expired workflow run logs found") + return + logger.info("Found %s expired workflow run logs to clean", total_workflow_runs) total_deleted = 0 failed_batches = 0 batch_count = 0 - while True: - workflow_runs = ( - db.session.query(WorkflowRun.id).where(WorkflowRun.created_at < cutoff_date).limit(BATCH_SIZE).all() - ) + with session_factory.begin() as session: + workflow_run_ids = session.scalars( + select(WorkflowRun.id) + .where(WorkflowRun.created_at < cutoff_date) + .order_by(WorkflowRun.created_at, WorkflowRun.id) + .limit(BATCH_SIZE) + ).all() - if not workflow_runs: - break - - workflow_run_ids = [run.id for run in workflow_runs] - batch_count += 1 - - success = _delete_batch_with_retry(workflow_run_ids, failed_batches) - - if success: - total_deleted += len(workflow_run_ids) - failed_batches = 0 - else: - failed_batches += 1 - if failed_batches >= MAX_RETRIES: - logger.error("Failed to delete batch after %s retries, aborting cleanup for today", MAX_RETRIES) + if not workflow_run_ids: break + + batch_count += 1 + + success = _delete_batch(session, workflow_run_ids, failed_batches) + + if success: + total_deleted += len(workflow_run_ids) + failed_batches = 0 else: - # Calculate incremental delay times: 5, 10, 15 minutes - retry_delay_minutes = failed_batches * 5 - logger.warning("Batch deletion failed, retrying in %s minutes...", retry_delay_minutes) - time.sleep(retry_delay_minutes * 60) - continue + failed_batches += 1 + if failed_batches >= MAX_RETRIES: + logger.error("Failed to delete batch after %s retries, aborting cleanup for today", MAX_RETRIES) + break + else: + # Calculate incremental delay times: 5, 10, 15 minutes + retry_delay_minutes = failed_batches * 5 + logger.warning("Batch deletion failed, retrying in %s minutes...", retry_delay_minutes) + time.sleep(retry_delay_minutes * 60) + continue logger.info("Cleanup completed: %s expired workflow run logs deleted", total_deleted) except Exception: - db.session.rollback() logger.exception("Unexpected error in workflow log cleanup") raise @@ -87,69 +93,56 @@ def clean_workflow_runlogs_precise(): click.echo(click.style(f"Cleaned workflow run logs from db success latency: {execution_time:.2f}s", fg="green")) -def _delete_batch_with_retry(workflow_run_ids: list[str], attempt_count: int) -> bool: - """Delete a single batch with a retry mechanism and complete cascading deletion""" +def _delete_batch(session: Session, workflow_run_ids: Sequence[str], attempt_count: int) -> bool: + """Delete a single batch of workflow runs and all related data within a nested transaction.""" try: - with db.session.begin_nested(): + with session.begin_nested(): message_data = ( - db.session.query(Message.id, Message.conversation_id) + session.query(Message.id, Message.conversation_id) .where(Message.workflow_run_id.in_(workflow_run_ids)) .all() ) message_id_list = [msg.id for msg in message_data] conversation_id_list = list({msg.conversation_id for msg in message_data if msg.conversation_id}) if message_id_list: - db.session.query(AppAnnotationHitHistory).where( - AppAnnotationHitHistory.message_id.in_(message_id_list) - ).delete(synchronize_session=False) + message_related_models = [ + AppAnnotationHitHistory, + MessageAgentThought, + MessageChain, + MessageFile, + MessageAnnotation, + MessageFeedback, + ] + for model in message_related_models: + session.query(model).where(model.message_id.in_(message_id_list)).delete(synchronize_session=False) # type: ignore + # error: "DeclarativeAttributeIntercept" has no attribute "message_id". But this type is only in lib + # and these 6 types all have the message_id field. - db.session.query(MessageAgentThought).where(MessageAgentThought.message_id.in_(message_id_list)).delete( + session.query(Message).where(Message.workflow_run_id.in_(workflow_run_ids)).delete( synchronize_session=False ) - db.session.query(MessageChain).where(MessageChain.message_id.in_(message_id_list)).delete( - synchronize_session=False - ) - - db.session.query(MessageFile).where(MessageFile.message_id.in_(message_id_list)).delete( - synchronize_session=False - ) - - db.session.query(MessageAnnotation).where(MessageAnnotation.message_id.in_(message_id_list)).delete( - synchronize_session=False - ) - - db.session.query(MessageFeedback).where(MessageFeedback.message_id.in_(message_id_list)).delete( - synchronize_session=False - ) - - db.session.query(Message).where(Message.workflow_run_id.in_(workflow_run_ids)).delete( - synchronize_session=False - ) - - db.session.query(WorkflowAppLog).where(WorkflowAppLog.workflow_run_id.in_(workflow_run_ids)).delete( + session.query(WorkflowAppLog).where(WorkflowAppLog.workflow_run_id.in_(workflow_run_ids)).delete( synchronize_session=False ) - db.session.query(WorkflowNodeExecutionModel).where( + session.query(WorkflowNodeExecutionModel).where( WorkflowNodeExecutionModel.workflow_run_id.in_(workflow_run_ids) ).delete(synchronize_session=False) if conversation_id_list: - db.session.query(ConversationVariable).where( + session.query(ConversationVariable).where( ConversationVariable.conversation_id.in_(conversation_id_list) ).delete(synchronize_session=False) - db.session.query(Conversation).where(Conversation.id.in_(conversation_id_list)).delete( + session.query(Conversation).where(Conversation.id.in_(conversation_id_list)).delete( synchronize_session=False ) - db.session.query(WorkflowRun).where(WorkflowRun.id.in_(workflow_run_ids)).delete(synchronize_session=False) + session.query(WorkflowRun).where(WorkflowRun.id.in_(workflow_run_ids)).delete(synchronize_session=False) - db.session.commit() - return True + return True except Exception: - db.session.rollback() logger.exception("Batch deletion failed (attempt %s)", attempt_count + 1) return False From e74097afdfa6974a5284e5439fcfbef191f39a6e Mon Sep 17 00:00:00 2001 From: -LAN- Date: Wed, 15 Oct 2025 00:43:11 +0800 Subject: [PATCH 5/5] Remove unused after_request hooks from console API keys (#26896) --- api/controllers/console/apikey.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/api/controllers/console/apikey.py b/api/controllers/console/apikey.py index efab1bc03c..7c39b04464 100644 --- a/api/controllers/console/apikey.py +++ b/api/controllers/console/apikey.py @@ -1,5 +1,4 @@ import flask_restx -from flask import Response from flask_restx import Resource, fields, marshal_with from flask_restx._http import HTTPStatus from sqlalchemy import select @@ -156,11 +155,6 @@ class AppApiKeyListResource(BaseApiKeyListResource): """Create a new API key for an app""" return super().post(resource_id) - def after_request(self, resp: Response): - resp.headers["Access-Control-Allow-Origin"] = "*" - resp.headers["Access-Control-Allow-Credentials"] = "true" - return resp - resource_type = "app" resource_model = App resource_id_field = "app_id" @@ -177,11 +171,6 @@ class AppApiKeyResource(BaseApiKeyResource): """Delete an API key for an app""" return super().delete(resource_id, api_key_id) - def after_request(self, resp): - resp.headers["Access-Control-Allow-Origin"] = "*" - resp.headers["Access-Control-Allow-Credentials"] = "true" - return resp - resource_type = "app" resource_model = App resource_id_field = "app_id" @@ -206,11 +195,6 @@ class DatasetApiKeyListResource(BaseApiKeyListResource): """Create a new API key for a dataset""" return super().post(resource_id) - def after_request(self, resp: Response): - resp.headers["Access-Control-Allow-Origin"] = "*" - resp.headers["Access-Control-Allow-Credentials"] = "true" - return resp - resource_type = "dataset" resource_model = Dataset resource_id_field = "dataset_id" @@ -227,11 +211,6 @@ class DatasetApiKeyResource(BaseApiKeyResource): """Delete an API key for a dataset""" return super().delete(resource_id, api_key_id) - def after_request(self, resp: Response): - resp.headers["Access-Control-Allow-Origin"] = "*" - resp.headers["Access-Control-Allow-Credentials"] = "true" - return resp - resource_type = "dataset" resource_model = Dataset resource_id_field = "dataset_id"