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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): migrate workflow error default inputs (#41900)
yyh789cada297f2
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex f5a87615ccb..9d6abf0a5b4 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -3260,14 +3260,6 @@"count": 1}},- "web/app/components/workflow/nodes/_base/components/error-handle/default-value.tsx": {- "no-restricted-imports": {- "count": 1- },- "typescript/no-explicit-any": {- "count": 1- }- },"web/app/components/workflow/nodes/_base/components/error-handle/types.ts": {"erasable-syntax-only/enums": {"count": 1diff --git a/web/app/components/workflow/nodes/_base/components/error-handle/__tests__/index.spec.tsx b/web/app/components/workflow/nodes/_base/components/error-handle/__tests__/index.spec.tsxindex 7aafc97d05d..bccbc325c6e 100644--- a/web/app/components/workflow/nodes/_base/components/error-handle/__tests__/index.spec.tsx+++ b/web/app/components/workflow/nodes/_base/components/error-handle/__tests__/index.spec.tsx@@ -123,7 +123,8 @@ describe('error-handle path', () => {)})- it('should render string forms and surface array forms in the default value editor', () => {+ it('should edit a labeled string default and preserve the array editor', async () => {+ const user = userEvent.setup()const onFormChange = vi.fn()render(<DefaultValue@@ -135,16 +136,38 @@ describe('error-handle path', () => {/>,)- fireEvent.change(screen.getByDisplayValue('hello'), { target: { value: 'updated' } })+ const input = screen.getByRole('textbox', { name: 'message' })+ await user.click(screen.getByText('message'))+ expect(input).toHaveFocus()+ await user.type(input, '!')expect(onFormChange).toHaveBeenCalledWith({key: 'message',type: VarType.string,- value: 'updated',+ value: 'hello!',})expect(screen.getByText('items')).toBeInTheDocument()})+ it('should report a numeric default as a string to the workflow owner', async () => {+ const user = userEvent.setup()+ const onFormChange = vi.fn()+ render(+ <DefaultValue+ forms={[{ key: 'count', type: VarType.number, value: 12 }]}+ onFormChange={onFormChange}+ />,+ )++ await user.type(screen.getByRole('spinbutton', { name: 'count' }), '3')++ expect(onFormChange).toHaveBeenLastCalledWith({+ key: 'count',+ type: VarType.number,+ value: '123',+ })+ })+it('should toggle the selector popup and report the selected strategy', async () => {const user = userEvent.setup()const onSelected = vi.fn()diff --git a/web/app/components/workflow/nodes/_base/components/error-handle/default-value.tsx b/web/app/components/workflow/nodes/_base/components/error-handle/default-value.tsxindex eff1e6e7f9e..ab8c5102fed 100644--- a/web/app/components/workflow/nodes/_base/components/error-handle/default-value.tsx+++ b/web/app/components/workflow/nodes/_base/components/error-handle/default-value.tsx@@ -1,7 +1,7 @@import type { DefaultValueForm } from './types'-import { useCallback } from 'react'+import { Input } from '@langgenius/dify-ui/input'+import { useId } from 'react'import { useTranslation } from 'react-i18next'-import Input from '@/app/components/base/input'import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'import { VarType } from '@/app/components/workflow/types'@@ -12,27 +12,7 @@ type DefaultValueProps = {}const DefaultValue = ({ forms, onFormChange }: DefaultValueProps) => {const { t } = useTranslation()- const getFormChangeHandler = useCallback(- ({ key, type }: DefaultValueForm) => {- return (payload: any) => {- let value- if (type === VarType.string || type === VarType.number) value = payload.target.value-- if (- type === VarType.array ||- type === VarType.arrayNumber ||- type === VarType.arrayString ||- type === VarType.arrayObject ||- type === VarType.arrayFile ||- type === VarType.object- )- value = payload-- onFormChange({ key, type, value })- }- },- [onFormChange],- )+ const id = useId()return (<div className="px-4 pt-2">@@ -42,17 +22,27 @@ const DefaultValue = ({ forms, onFormChange }: DefaultValueProps) => {</div><div className="space-y-1">{forms.map((form, index) => {+ const isInput = form.type === VarType.string || form.type === VarType.number+ const inputId = `${id}-${index}`return (<div key={index} className="py-1"><div className="mb-1 flex items-center">- <div className="mr-1 system-sm-medium text-text-primary">{form.key}</div>+ {isInput ? (+ <label htmlFor={inputId} className="mr-1 system-sm-medium text-text-primary">+ {form.key}+ </label>+ ) : (+ <div className="mr-1 system-sm-medium text-text-primary">{form.key}</div>+ )}<div className="system-xs-regular text-text-tertiary">{form.type}</div></div>- {(form.type === VarType.string || form.type === VarType.number) && (+ {isInput && (<Input- type={form.type}+ id={inputId}+ type={form.type === VarType.number ? 'number' : 'text'}+ placeholder={t(($) => $['placeholder.input'], { ns: 'common' })}value={form.value || (form.type === VarType.string ? '' : 0)}- onChange={getFormChangeHandler({ key: form.key, type: form.type })}+ onValueChange={(value) => onFormChange({ key: form.key, type: form.type, value })}/>)}{(form.type === VarType.array ||@@ -63,7 +53,7 @@ const DefaultValue = ({ forms, onFormChange }: DefaultValueProps) => {<CodeEditorlanguage={CodeLanguage.json}value={form.value}- onChange={getFormChangeHandler({ key: form.key, type: form.type })}+ onChange={(value) => onFormChange({ key: form.key, type: form.type, value })}/>)}</div>