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): own parameter schema preview dialogs (#43527)
yyh7dd8f642d200
diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.tsindex 27bcd0b3b1a..1a96f401d96 100644--- a/web/app/components/header/account-setting/model-provider-page/declarations.ts+++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts@@ -1,4 +1,4 @@-import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'+import type { Field } from '@/app/components/workflow/nodes/llm/types'export type FormValue = Record<string, any>@@ -125,7 +125,7 @@ export type CredentialFormSchemaBase = {show_on: FormShowOnObject[]url?: stringscope?: string- input_schema?: SchemaRoot+ input_schema?: Field | null}export type CredentialFormSchemaTextInput = CredentialFormSchemaBase & {diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/reasoning-config-form.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/reasoning-config-form.spec.tsxindex e0122da3d13..b7ab018780a 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/reasoning-config-form.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/reasoning-config-form.spec.tsx@@ -1,14 +1,15 @@-import type { ReactNode } from 'react'+import type { ReasoningConfigValue } from '../reasoning-config-form'import type { AppSelectorValue } from '@/app/components/plugins/plugin-detail-panel/app-selector'import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schema'-import { fireEvent, screen } from '@testing-library/react'+import { fireEvent, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'+import { useState } from 'react'import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'+import { renderWorkflowComponent as render } from '@/app/components/workflow/__tests__/workflow-test-env'import { VarKindType } from '@/app/components/workflow/nodes/_base/types'import { Type } from '@/app/components/workflow/nodes/llm/types'-import { renderWithAccountProfile as render } from '@/test/console/account-profile'-import ReasoningConfigForm from '../reasoning-config-form'+import { ReasoningConfigForm } from '../reasoning-config-form'vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({useLanguage: () => 'en_US',@@ -40,23 +41,6 @@ vi.mock('@/app/components/plugins/plugin-detail-panel/model-selector', () => ({),}))-vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', () => ({- default: ({- onChange,- placeholder,- }: {- onChange: (value: string) => void- placeholder?: ReactNode- }) => (- <div>- <div data-testid="code-editor-placeholder">{placeholder}</div>- <button data-testid="code-editor" onClick={() => onChange('{"foo":"bar"}')}>- Update JSON- </button>- </div>- ),-}))-vi.mock('@/app/components/workflow/nodes/_base/components/form-input-boolean', () => ({default: ({ onChange }: { onChange: (value: boolean) => void }) => (<button data-testid="boolean-input" onClick={() => onChange(true)}>@@ -99,47 +83,105 @@ vi.mock('@/app/components/workflow/nodes/tool/components/mixed-variable-text-inp),}))-vi.mock('../schema-modal', () => ({- SchemaModal: ({- isShow,- rootName,- onClose,- }: {- isShow: boolean- rootName: string- onClose: () => void- }) =>- isShow ? (- <div data-testid="schema-modal">- <span>{rootName}</span>- <button data-testid="close-schema" onClick={onClose}>- Close- </button>- </div>- ) : null,-}))--const createSchema = (overrides: Partial<ToolFormSchema> = {}): ToolFormSchema =>- ({- variable: 'field',- type: FormTypeEnum.textInput,- default: '',- required: false,- label: { en_US: 'Field', zh_Hans: '字段' },- tooltip: { en_US: 'Tooltip', zh_Hans: '提示' },- scope: 'all',- url: '',- input_schema: {},- placeholder: { en_US: 'Placeholder', zh_Hans: '占位符' },- options: [],- ...overrides,- }) as ToolFormSchema+const createSchema = (overrides: Partial<ToolFormSchema> = {}): ToolFormSchema => ({+ name: 'field',+ _type: 'string',+ form: 'llm',+ show_on: [],+ variable: 'field',+ type: FormTypeEnum.textInput,+ default: '',+ required: false,+ label: { en_US: 'Field', zh_Hans: '字段' },+ tooltip: { en_US: 'Tooltip', zh_Hans: '提示' },+ scope: 'all',+ url: '',+ input_schema: undefined,+ placeholder: { en_US: 'Placeholder', zh_Hans: '占位符' },+ options: [],+ ...overrides,+})describe('ReasoningConfigForm', () => {beforeEach(() => {vi.clearAllMocks()})+ it('opens the selected parameter schema without changing current form values', async () => {+ const user = userEvent.setup()+ const onChange = vi.fn()+ function Fixture() {+ const [value, setValue] = useState<ReasoningConfigValue>({+ count: { auto: 0, value: { type: VarKindType.constant, value: '3' } },+ config: { auto: 0, value: { type: VarKindType.constant, value: '{}' } },+ records: { auto: 0, value: { type: VarKindType.constant, value: '[]' } },+ })+ return (+ <ReasoningConfigForm+ value={value}+ onChange={(next) => {+ onChange(next)+ setValue(next)+ }}+ schemas={[+ createSchema({+ variable: 'count',+ type: FormTypeEnum.textNumber,+ label: { en_US: 'Count', zh_Hans: '数量' },+ }),+ createSchema({+ variable: 'config',+ type: FormTypeEnum.object,+ label: { en_US: 'Config', zh_Hans: '配置' },+ input_schema: { type: Type.object, properties: { city: { type: Type.string } } },+ }),+ createSchema({+ variable: 'records',+ type: FormTypeEnum.array,+ label: { en_US: 'Records', zh_Hans: '记录' },+ input_schema: {+ type: Type.array,+ items: { type: Type.object, properties: { id: { type: Type.number } } },+ },+ }),+ ]}+ nodeOutputVars={[]}+ availableNodes={[]}+ nodeId="node-1"+ />+ )+ }+ render(<Fixture />)+ const count = screen.getByRole('spinbutton', { name: 'Count' })+ const [configEditor] = screen.getAllByTestId('monaco-editor')+ await user.clear(count)+ await user.type(count, '8')+ fireEvent.change(configEditor!, { target: { value: '{"city":"Shanghai"}' } })+ const previousChanges = onChange.mock.calls.length+ const entries = screen.getAllByRole('button', {+ name: /workflowAgent.nodes.agent.clickToViewParameterSchema/,+ })+ for (const [index, rootName, property] of [+ [0, 'Config', 'city'],+ [1, 'Records', 'id'],+ ] as const) {+ await user.click(entries[index]!)+ const dialog = screen.getByRole('dialog', {+ name: 'workflowAgent.nodes.agent.parameterSchema',+ })+ expect(within(dialog).getByText(rootName)).toBeInTheDocument()+ expect(within(dialog).getByText(property)).toBeInTheDocument()+ await user.click(within(dialog).getByRole('button', { name: 'common.operation.close' }))+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ expect(entries[index]).toHaveFocus()+ }+ expect(screen.getByRole('spinbutton', { name: 'Count' })).toHaveValue(8)+ const editors = screen.getAllByTestId('monaco-editor')+ expect(editors[0]).toHaveValue('{"city":"Shanghai"}')+ expect(editors[1]).toHaveValue('[]')+ expect(onChange).toHaveBeenCalledTimes(previousChanges)+ })+it('names date parameters from their field title and emits tool storage values', async () => {const user = userEvent.setup()const onChange = vi.fn()@@ -248,7 +290,7 @@ describe('ReasoningConfigForm', () => {)})- it('should open schema modal for object fields and support app selection', () => {+ it('stores the selected app configuration', () => {const onChange = vi.fn()render(@@ -283,12 +325,6 @@ describe('ReasoningConfigForm', () => {/>,)- fireEvent.click(- screen.getByRole('button', { name: 'workflowAgent.nodes.agent.clickToViewParameterSchema' }),- )- expect(screen.getByTestId('schema-modal')).toHaveTextContent('Config')- fireEvent.click(screen.getByTestId('close-schema'))-fireEvent.click(screen.getByTestId('app-selector'))expect(onChange).toHaveBeenCalledWith(@@ -523,9 +559,9 @@ describe('ReasoningConfigForm', () => {)expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0)- expect(screen.getByTestId('code-editor-placeholder')).toHaveTextContent('"foo": "bar"')+ expect(screen.getByTestId('monaco-editor')).toHaveValue('{}')- fireEvent.click(screen.getByTestId('code-editor'))+ fireEvent.change(screen.getByTestId('monaco-editor'), { target: { value: '{"foo":"bar"}' } })expect(onChange).toHaveBeenCalledWith(expect.objectContaining({@@ -545,7 +581,7 @@ describe('ReasoningConfigForm', () => {value={{config: {auto: 0,- value: { type: VarKindType.constant, value: '{}' },+ value: { type: VarKindType.constant, value: '' },},app: {auto: 0,@@ -581,7 +617,8 @@ describe('ReasoningConfigForm', () => {/>,)- expect(screen.getByTestId('code-editor-placeholder')).toHaveTextContent('"foo": "bar"')+ expect(screen.getByTestId('monaco-editor')).toHaveValue('')+ expect(screen.getByText('{ "foo": "bar" }')).toBeInTheDocument()expect(screen.getByTestId('app-selector')).toHaveAttribute('data-scope', 'all')expect(screen.getByTestId('var-picker')).toHaveAttribute('data-value', '[]')expect(screen.getByRole('link', { name: 'tools.howToGet' })).toHaveAttribute(diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.browser.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.browser.spec.tsxnew file mode 100644index 00000000000..efea5dee3b0--- /dev/null+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.browser.spec.tsx@@ -0,0 +1,84 @@+import { page } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { Type } from '@/app/components/workflow/nodes/llm/types'+import { SchemaDialog } from '../schema-dialog'++vi.mock('react-i18next', async () => {+ const actual = await vi.importActual<typeof import('react-i18next')>('react-i18next')+ const { createReactI18nextMock } = await import('@/test/i18n-mock')+ const { default: workflowAgent } = await import('@/i18n/locales/en-US/workflow-agent.json')+ return {+ ...actual,+ ...createReactI18nextMock({+ 'workflowAgent.nodes.agent.parameterSchema': workflowAgent['nodes.agent.parameterSchema'],+ }),+ }+})++it('keeps a long schema scrollable and Close reachable on a small viewport', async () => {+ await page.viewport(414, 640)+ const properties = Object.fromEntries(+ Array.from({ length: 50 }, (_, index) => [`property_${index}`, { type: Type.string }]),+ )+ const screen = await render(+ <SchemaDialog rootName="Profile" schema={{ type: Type.object, properties }} />,+ )+ const entry = screen.getByRole('button', { name: 'JSON Schema: Profile' })+ await entry.click()+ const dialog = screen.getByRole('dialog', { name: 'Parameter Schema' })+ const close = dialog.getByRole('button', { name: 'common.operation.close' })+ const closeBounds = close.element().getBoundingClientRect()+ expect(closeBounds.left).toBeGreaterThanOrEqual(0)+ expect(closeBounds.right).toBeLessThanOrEqual(window.innerWidth)+ expect(closeBounds.top).toBeGreaterThanOrEqual(0)+ expect(closeBounds.bottom).toBeLessThanOrEqual(window.innerHeight)+ await dialog.getByText('property_0').wheel({ delta: { y: 1800 } })+ await expect+ .poll(() => {+ const fieldBounds = dialog.getByText('property_49').element().getBoundingClientRect()+ return fieldBounds.top >= 0 && fieldBounds.bottom <= window.innerHeight+ })+ .toBe(true)+ await close.click()+ await expect.element(dialog).not.toBeInTheDocument()+})++it('shows complete schema names and descriptions on a narrow viewport', async () => {+ await page.viewport(414, 900)+ const description = `Choose the destination used for delivery. ${'Include the full warehouse address. '.repeat(6)}\nReference: ${'warehouse-reference-'.repeat(12)}`+ const nestedDescription =+ 'Use the receiving warehouse address, including the building, floor, and loading bay.'+ const fieldName = 'receiving_warehouse_building_floor_and_loading_bay_identifier'+ const screen = await render(+ <SchemaDialog+ rootName="Profile"+ schema={{+ type: Type.object,+ description,+ properties: {+ destination: {+ type: Type.object,+ description: nestedDescription,+ properties: { [fieldName]: { type: Type.string } },+ },+ },+ }}+ />,+ )+ await screen.getByRole('button', { name: 'JSON Schema: Profile' }).click()+ const dialog = screen.getByRole('dialog', { name: 'Parameter Schema' })+ for (const text of [description, nestedDescription, fieldName]) {+ const content = dialog.getByText(text).element()+ const bounds = content.getBoundingClientRect()+ const dialogBounds = dialog.element().getBoundingClientRect()+ expect(bounds.left).toBeGreaterThanOrEqual(dialogBounds.left)+ expect(bounds.right).toBeLessThanOrEqual(dialogBounds.right)+ const range = document.createRange()+ range.selectNodeContents(content)+ for (const line of range.getClientRects()) {+ expect(line.left).toBeGreaterThanOrEqual(bounds.left)+ expect(line.right).toBeLessThanOrEqual(bounds.right)+ expect(line.bottom).toBeLessThanOrEqual(bounds.bottom)+ }+ }+})diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.spec.tsxnew file mode 100644index 00000000000..7e673152108--- /dev/null+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-dialog.spec.tsx@@ -0,0 +1,81 @@+import type { Field } from '@/app/components/workflow/nodes/llm/types'+import { act, fireEvent, render, screen, within } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { SchemaDialog } from '../schema-dialog'++const objectSchema = {+ type: 'object',+ properties: {+ address: {+ type: 'object',+ properties: { city: { type: 'string', description: 'Destination city' } },+ required: ['city'],+ },+ },+ additionalProperties: false,+} satisfies Field++const arraySchema = {+ type: 'array',+ items: {+ type: 'object',+ properties: {+ entry: {+ type: 'object',+ properties: { quantity: { type: 'number' } },+ required: ['quantity'],+ },+ },+ },+} satisfies Field++const dialogName = 'workflowAgent.nodes.agent.parameterSchema'+const compactName = 'workflowAgent.nodes.agent.clickToViewParameterSchema: response'++describe('SchemaDialog', () => {+ it('keeps nested object and array fields read-only while supporting keyboard collapse', async () => {+ const user = userEvent.setup()+ render(+ <SchemaDialog+ schema={{ type: 'object', properties: { ...objectSchema.properties, list: arraySchema } }}+ rootName="response"+ />,+ )+ await user.click(screen.getByRole('button', { name: 'JSON Schema: response' }))+ const dialog = await screen.findByRole('dialog', { name: dialogName })++ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })+ try {+ fireEvent.mouseEnter(within(dialog).getByText('city'))+ act(() => vi.advanceTimersByTime(60))+ expect(within(dialog).queryByRole('textbox')).not.toBeInTheDocument()+ fireEvent.mouseEnter(within(dialog).getByText('quantity'))+ act(() => vi.advanceTimersByTime(60))+ expect(within(dialog).queryByRole('textbox')).not.toBeInTheDocument()+ expect(within(dialog).queryByRole('combobox')).not.toBeInTheDocument()+ } finally {+ vi.useRealTimers()+ }++ const address = within(dialog).getByRole('button', { name: 'address' })+ expect(address).toHaveAttribute('aria-expanded', 'true')+ address.focus()+ await user.keyboard('{Enter}')+ expect(address).toHaveAttribute('aria-expanded', 'false')+ expect(within(dialog).queryByText('city')).not.toBeInTheDocument()+ await user.keyboard(' ')+ expect(address).toHaveAttribute('aria-expanded', 'true')+ expect(within(dialog).getByText('city')).toBeInTheDocument()+ })++ it.each([undefined, null])('keeps a missing schema (%s) entry disabled', async (schema) => {+ const user = userEvent.setup()+ const { rerender } = render(<SchemaDialog schema={schema} rootName="response" />)+ const trigger = screen.getByRole('button', { name: 'JSON Schema: response' })+ expect(trigger).toBeDisabled()+ await user.click(trigger)+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument()+ rerender(<SchemaDialog schema={schema} rootName="response" compact />)+ expect(screen.getByRole('button', { name: compactName })).toBeDisabled()+ })+})diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-modal.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-modal.spec.tsxdeleted file mode 100644index d56c9eb94aa..00000000000--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/schema-modal.spec.tsx+++ /dev/null@@ -1,51 +0,0 @@-import { fireEvent, render, screen } from '@testing-library/react'-import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'-import { SchemaModal } from '../schema-modal'--vi.mock(- '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor',- () => ({- default: ({ rootName }: { rootName: string }) => (- <div data-testid="visual-editor">{rootName}</div>- ),- }),-)--vi.mock(- '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context',- () => ({- MittProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,- VisualEditorContextProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,- }),-)--describe('SchemaModal', () => {- beforeEach(() => {- vi.clearAllMocks()- })-- it('does not render content when hidden', () => {- render(<SchemaModal isShow={false} schema={{} as never} rootName="root" onClose={vi.fn()} />)-- expect(screen.queryByTestId('modal')).not.toBeInTheDocument()- })-- it('renders the schema title and closes when the close control is clicked', () => {- const onClose = vi.fn()- render(- <SchemaModal- isShow- schema={{ type: 'object' } as never}- rootName="response"- onClose={onClose}- />,- )-- expect(screen.getByText('workflowAgent.nodes.agent.parameterSchema')).toBeInTheDocument()- expect(screen.getByTestId('visual-editor')).toHaveTextContent('response')-- fireEvent.click(screen.getByRole('button', { name: 'common.operation.close' }))-- expect(onClose).toHaveBeenCalled()- })-})diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsxindex 3cc8e339108..bbc923bff81 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx@@ -12,7 +12,7 @@ vi.mock('@/app/components/workflow/nodes/tool/components/tool-form', () => ({}))vi.mock('../reasoning-config-form', () => ({- default: ({ schemas }: { schemas: Array<{ name: string }> }) => (+ ReasoningConfigForm: ({ schemas }: { schemas: Array<{ name: string }> }) => (<div data-testid="reasoning-config-form">{schemas.map((item) => item.name).join(',')}</div>),}))diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsxindex 4a14332a656..c6eff351693 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx@@ -1,7 +1,6 @@import type { Node } from 'reactflow'import type { ReasoningConfigValue as ReasoningConfigValueShape } from './reasoning-config-form.helpers'import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schema'-import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'import type { NodeOutPutVar, ValueSelector } from '@/app/components/workflow/types'import { cn } from '@langgenius/dify-ui/cn'import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'@@ -15,9 +14,7 @@ import {SelectTrigger,} from '@langgenius/dify-ui/select'import { Switch } from '@langgenius/dify-ui/switch'-import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import { useBoolean } from 'ahooks'-import { useCallback, useId, useState } from 'react'+import { useCallback, useId } from 'react'import { useTranslation } from 'react-i18next'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'@@ -43,7 +40,7 @@ import {updateVariableSelectorValue,updateVariableTypeValue,} from './reasoning-config-form.helpers'-import { SchemaModal } from './schema-modal'+import { SchemaDialog } from './schema-dialog'export type ReasoningConfigValue = ReasoningConfigValueShape@@ -56,14 +53,14 @@ type Props = Readonly<{nodeId: string}>-const ReasoningConfigForm: React.FC<Props> = ({+export function ReasoningConfigForm({value,onChange,schemas,nodeOutputVars,availableNodes,nodeId,-}) => {+}: Props) {const fieldLabelId = useId()const { t } = useTranslation(['plugin', 'tools', 'workflowAgent'])@@ -118,15 +115,7 @@ const ReasoningConfigForm: React.FC<Props> = ({[onChange, value],)- const [isShowSchema, { setTrue: showSchema, setFalse: hideSchema }] = useBoolean(false)-- const [schema, setSchema] = useState<SchemaRoot | null>(null)- const [schemaRootName, setSchemaRootName] = useState<string>('')-- const renderField = (- schema: ToolFormSchema,- showSchema: (schema: SchemaRoot, rootName: string) => void,- ) => {+ const renderField = (schema: ToolFormSchema) => {const {default: defaultValue,variable,@@ -195,25 +184,7 @@ const ReasoningConfigForm: React.FC<Props> = ({{resolveTargetVarType(type)}</span>{isShowJSONEditor && (- <Tooltip>- <TooltipTrigger- render={- <button- type="button"- aria-label={t(($) => $['nodes.agent.clickToViewParameterSchema'], {- ns: 'workflowAgent',- })}- className="ml-0.5 cursor-pointer rounded-sm border-0 bg-transparent p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary"- onClick={() => showSchema(input_schema as SchemaRoot, fieldTitle!)}- >- <span aria-hidden className="i-ri-braces-line size-3.5" />- </button>- }- />- <TooltipContent>- {t(($) => $['nodes.agent.clickToViewParameterSchema'], { ns: 'workflowAgent' })}- </TooltipContent>- </Tooltip>+ <SchemaDialog schema={input_schema} rootName={fieldTitle || variable} compact />)}</div><label className="flex cursor-pointer items-center gap-1 rounded-md border border-divider-subtle bg-background-default-lighter px-2 py-1 hover:bg-state-base-hover">@@ -369,26 +340,5 @@ const ReasoningConfigForm: React.FC<Props> = ({</div>)}- return (- <div className="space-y-3 px-4 py-2">- {!isShowSchema &&- schemas.map((schema) =>- renderField(schema, (s: SchemaRoot, rootName: string) => {- setSchema(s)- setSchemaRootName(rootName)- showSchema()- }),- )}- {isShowSchema && (- <SchemaModal- isShow={isShowSchema}- schema={schema!}- rootName={schemaRootName}- onClose={hideSchema}- />- )}- </div>- )+ return <div className="space-y-3 px-4 py-2">{schemas.map(renderField)}</div>}--export default ReasoningConfigFormdiff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsxnew file mode 100644index 00000000000..74e11de8536--- /dev/null+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog.tsx@@ -0,0 +1,92 @@+'use client'+import type { Field } from '@/app/components/workflow/nodes/llm/types'+import { Button } from '@langgenius/dify-ui/button'+import {+ Dialog,+ DialogClose,+ DialogContent,+ DialogTitle,+ DialogTrigger,+} from '@langgenius/dify-ui/dialog'+import { IconButton } from '@langgenius/dify-ui/icon-button'+import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'+import { useTranslation } from 'react-i18next'+import {+ MittProvider,+ VisualEditorContextProvider,+} from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context'+import { SchemaPreview } from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-preview'++type SchemaDialogProps = {+ schema?: Field | null+ rootName: string+ compact?: boolean+}++export function SchemaDialog({ schema, rootName, compact = false }: SchemaDialogProps) {+ const { t } = useTranslation(['common', 'workflowAgent'])+ const label = t(($) => $['nodes.agent.clickToViewParameterSchema'], { ns: 'workflowAgent' })+ const button = compact ? (+ <IconButton+ aria-label={`${label}: ${rootName}`}+ size="xs"+ className="ml-0.5"+ disabled={!schema}+ >+ <span aria-hidden className="i-ri-braces-line size-3.5" />+ </IconButton>+ ) : (+ <Button+ aria-label={`JSON Schema: ${rootName}`}+ variant="ghost"+ size="small"+ className="px-1 system-xs-regular text-text-tertiary"+ disabled={!schema}+ >+ <span aria-hidden className="i-ri-braces-line size-3.5" />+ <span>JSON Schema</span>+ </Button>+ )+ const trigger = schema ? <DialogTrigger render={button} /> : button+ const entry = compact ? (+ <Tooltip>+ <TooltipTrigger render={trigger} />+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ ) : (+ trigger+ )++ if (!schema) return entry++ return (+ <Dialog>+ {entry}+ <DialogContent className="flex max-h-[calc(100dvh-2rem)] w-240 min-w-0 flex-col overflow-hidden p-0">+ <div className="relative shrink-0 p-6 pr-14 pb-3">+ <DialogTitle className="title-2xl-semi-bold text-text-primary">+ {t(($) => $['nodes.agent.parameterSchema'], { ns: 'workflowAgent' })}+ </DialogTitle>+ <DialogClose+ render={+ <IconButton+ aria-label={t(($) => $['operation.close'], { ns: 'common' })}+ size="lg"+ className="absolute top-5 right-5"+ >+ <span aria-hidden className="i-ri-close-line size-4.5" />+ </IconButton>+ }+ />+ </div>+ <div className="min-h-0 overflow-y-auto px-6 pt-2 pb-6">+ <MittProvider>+ <VisualEditorContextProvider>+ <SchemaPreview schema={schema} rootName={rootName} />+ </VisualEditorContextProvider>+ </MittProvider>+ </div>+ </DialogContent>+ </Dialog>+ )+}diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal.tsxdeleted file mode 100644index 4795bfd55c2..00000000000--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal.tsx+++ /dev/null@@ -1,55 +0,0 @@-'use client'-import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'-import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'-import { useTranslation } from 'react-i18next'-import VisualEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor'-import {- MittProvider,- VisualEditorContextProvider,-} from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context'--type Props = Readonly<{- isShow: boolean- schema: SchemaRoot- rootName: string- onClose: () => void-}>--export function SchemaModal({ isShow, schema, rootName, onClose }: Props) {- const { t } = useTranslation(['common', 'workflowAgent'])- return (- <Dialog open={isShow} onOpenChange={(open) => !open && onClose()}>- <DialogContent className="w-full max-w-240 p-0">- <div className="pb-6">- {/* Header */}- <div className="relative flex p-6 pr-14 pb-3">- <DialogTitle className="grow truncate title-2xl-semi-bold text-text-primary">- {t(($) => $['nodes.agent.parameterSchema'], { ns: 'workflowAgent' })}- </DialogTitle>- <button- type="button"- aria-label={t(($) => $['operation.close'], { ns: 'common' })}- className="absolute top-5 right-5 flex size-8 items-center justify-center p-1.5"- onClick={onClose}- >- <span className="i-ri-close-line h-4.5 w-4.5 text-text-tertiary" />- </button>- </div>- {/* Content */}- <div className="flex max-h-175 overflow-y-auto px-6 py-2">- <MittProvider>- <VisualEditorContextProvider>- <VisualEditor- className="w-full"- schema={schema}- rootName={rootName}- readOnly- ></VisualEditor>- </VisualEditorContextProvider>- </MittProvider>- </div>- </div>- </DialogContent>- </Dialog>- )-}diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsxindex 35ed90f1bdb..0a67cf44c8d 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx@@ -11,7 +11,7 @@ import { Separator } from '@langgenius/dify-ui/separator'import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import { useTranslation } from 'react-i18next'import ToolForm from '@/app/components/workflow/nodes/tool/components/tool-form'-import ReasoningConfigForm from './reasoning-config-form'+import { ReasoningConfigForm } from './reasoning-config-form'type ToolSettingsPanelProps = {value?: ToolValuediff --git a/web/app/components/tools/utils/to-form-schema.ts b/web/app/components/tools/utils/to-form-schema.tsindex bdaa5fe2e3e..a00a5f2a1fe 100644--- a/web/app/components/tools/utils/to-form-schema.ts+++ b/web/app/components/tools/utils/to-form-schema.ts@@ -1,7 +1,7 @@import type { TriggerEventParameter } from '../../plugins/types'import type { ToolCredential, ToolParameter } from '../types'import type { TypeWithI18N } from '@/app/components/header/account-setting/model-provider-page/declarations'-import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'+import type { Field } from '@/app/components/workflow/nodes/llm/types'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { VarKindType } from '@/app/components/workflow/nodes/_base/types'@@ -62,7 +62,7 @@ export type ToolFormSchema = {multiple?: booleanurl?: stringscope?: string- input_schema?: SchemaRoot+ input_schema?: Field | null}export const toType = (type: string) => {diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/card.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/card.tsxindex 4bc13c540a4..08b1e432a23 100644--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/card.tsx+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/card.tsx@@ -1,4 +1,5 @@import type { FC } from 'react'+import { cn } from '@langgenius/dify-ui/cn'import * as React from 'react'import { useTranslation } from 'react-i18next'@@ -7,15 +8,21 @@ type CardProps = {type: stringrequired: booleandescription?: string+ readOnly?: boolean}-const Card: FC<CardProps> = ({ name, type, required, description }) => {+const Card: FC<CardProps> = ({ name, type, required, description, readOnly }) => {const { t } = useTranslation(['workflowModels'])return (<div className="flex flex-col py-0.5">- <div className="flex h-6 items-center gap-x-1 pr-0.5 pl-1">- <div className="truncate border border-transparent px-1 py-px system-sm-semibold text-text-primary">+ <div className={cn('flex items-center gap-x-1 pr-0.5 pl-1', readOnly ? 'min-h-6' : 'h-6')}>+ <div+ className={cn(+ 'border border-transparent px-1 py-px system-sm-semibold text-text-primary',+ readOnly ? 'wrap-anywhere whitespace-pre-wrap' : 'truncate',+ )}+ >{name}</div><div className="px-1 py-0.5 system-xs-medium text-text-tertiary">{type}</div>@@ -27,7 +34,14 @@ const Card: FC<CardProps> = ({ name, type, required, description }) => {</div>{description && (- <div className="truncate px-2 pb-1 system-xs-regular text-text-tertiary">{description}</div>+ <div+ className={cn(+ 'px-2 pb-1 system-xs-regular text-text-tertiary',+ readOnly ? 'wrap-anywhere whitespace-pre-wrap' : 'truncate',+ )}+ >+ {description}+ </div>)}</div>)diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-node.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-node.tsxindex 87ddadc2506..3acc1255cab 100644--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-node.tsx+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-node.tsx@@ -2,7 +2,6 @@ import type { FC } from 'react'import type { Field } from '../../../types'import { cn } from '@langgenius/dify-ui/cn'import { Separator } from '@langgenius/dify-ui/separator'-import { RiArrowDropDownLine, RiArrowDropRightLine } from '@remixicon/react'import { useDebounceFn } from 'ahooks'import * as React from 'react'import { useMemo, useState } from 'react'@@ -77,7 +76,7 @@ const SchemaNode: FC<SchemaNodeProps> = ({const hasChildren = useMemo(() => getHasChildren(schema), [schema])const type = useMemo(() => getFieldType(schema), [schema])- const isHovering = hoveringProperty === path.join('.')+ const isHovering = !readOnly && hoveringProperty === path.join('.')const handleExpand = () => {setIsExpanded(!isExpanded)@@ -108,12 +107,14 @@ const SchemaNode: FC<SchemaNodeProps> = ({<buttontype="button"onClick={handleExpand}- className="py-0.5 text-text-tertiary hover:text-text-accent"+ aria-label={name}+ aria-expanded={isExpanded}+ className="rounded-sm py-0.5 text-text-tertiary hover:text-text-accent focus-visible:ring-1 focus-visible:ring-components-input-border-active focus-visible:outline-hidden">{isExpanded ? (- <RiArrowDropDownLine className="size-4" />+ <span aria-hidden className="i-ri-arrow-drop-down-line size-4" />) : (- <RiArrowDropRightLine className="size-4" />+ <span aria-hidden className="i-ri-arrow-drop-right-line size-4" />)}</button></div>@@ -134,60 +135,64 @@ const SchemaNode: FC<SchemaNodeProps> = ({depth={depth}/>) : (- <Card name={name} type={type} required={required} description={schema.description} />+ <Card+ name={name}+ type={type}+ required={required}+ description={schema.description}+ readOnly={readOnly}+ />)}</div></div>- <div- className={cn(- 'absolute z-0 flex w-5 justify-center',- schema.description ? 'top-12 h-[calc(100%-3rem)]' : 'top-7 h-[calc(100%-1.75rem)]',- indentLeft[depth],+ <div className="relative">+ <div className={cn('absolute inset-y-0 z-0 flex w-5 justify-center', indentLeft[depth])}>+ <Separator+ decorative+ orientation="vertical"+ className={cn('mx-0', isHovering ? 'bg-divider-deep' : 'bg-divider-subtle')}+ />+ </div>++ {isExpanded && hasChildren && depth < JSON_SCHEMA_MAX_DEPTH && (+ <>+ {schema.type === Type.object &&+ schema.properties &&+ Object.entries(schema.properties).map(([key, childSchema]) => (+ <SchemaNode+ key={key}+ name={key}+ required={!!schema.required?.includes(key)}+ schema={childSchema}+ path={[...path, 'properties', key]}+ parentPath={path}+ depth={depth + 1}+ readOnly={readOnly}+ />+ ))}++ {schema.type === Type.array &&+ schema.items &&+ schema.items.type === Type.object &&+ schema.items.properties &&+ Object.entries(schema.items.properties).map(([key, childSchema]) => (+ <SchemaNode+ key={key}+ name={key}+ required={!!schema.items?.required?.includes(key)}+ schema={childSchema}+ path={[...path, 'items', 'properties', key]}+ parentPath={path}+ depth={depth + 1}+ readOnly={readOnly}+ />+ ))}+ </>)}- >- <Separator- decorative- orientation="vertical"- className={cn('mx-0', isHovering ? 'bg-divider-deep' : 'bg-divider-subtle')}- />- </div>- {isExpanded && hasChildren && depth < JSON_SCHEMA_MAX_DEPTH && (- <>- {schema.type === Type.object &&- schema.properties &&- Object.entries(schema.properties).map(([key, childSchema]) => (- <SchemaNode- key={key}- name={key}- required={!!schema.required?.includes(key)}- schema={childSchema}- path={[...path, 'properties', key]}- parentPath={path}- depth={depth + 1}- />- ))}-- {schema.type === Type.array &&- schema.items &&- schema.items.type === Type.object &&- schema.items.properties &&- Object.entries(schema.items.properties).map(([key, childSchema]) => (- <SchemaNode- key={key}- name={key}- required={!!schema.items?.required?.includes(key)}- schema={childSchema}- path={[...path, 'items', 'properties', key]}- parentPath={path}- depth={depth + 1}- />- ))}- </>- )}-- {!readOnly && depth === 0 && !isAddingNewField && <AddField />}+ {!readOnly && depth === 0 && !isAddingNewField && <AddField />}+ </div></div>)}diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-preview.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-preview.tsxnew file mode 100644index 00000000000..e737a59544b--- /dev/null+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/schema-preview.tsx@@ -0,0 +1,22 @@+import type { Field } from '../../../types'+import SchemaNode from './schema-node'++type SchemaPreviewProps = {+ schema: Field+ rootName: string+}++export function SchemaPreview({ schema, rootName }: SchemaPreviewProps) {+ return (+ <div className="w-full rounded-xl bg-background-section-burn p-1 pl-2">+ <SchemaNode+ name={rootName || 'structured_output'}+ schema={schema}+ required={false}+ path={[]}+ depth={0}+ readOnly+ />+ </div>+ )+}diff --git a/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/index.spec.tsx b/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/index.spec.tsxindex 0f629f48763..76081e0f592 100644--- a/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/index.spec.tsx+++ b/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/index.spec.tsx@@ -20,7 +20,7 @@ type MockToolFormItemProps = {const mockToolFormItem = vi.fn<(props: MockToolFormItemProps) => void>()vi.mock('../item', () => ({- default: (props: MockToolFormItemProps) => {+ ToolFormItem: (props: MockToolFormItemProps) => {mockToolFormItem(props)return (<div data-testid={`tool-form-item-${props.schema.variable}`}>{props.schema.label.en_US}</div>diff --git a/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/item.spec.tsx b/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/item.spec.tsxindex d35a387f646..2be114dca71 100644--- a/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/item.spec.tsx+++ b/web/app/components/workflow/nodes/tool/components/tool-form/__tests__/item.spec.tsx@@ -1,140 +1,119 @@import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'-import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'-import { fireEvent, render, screen, within } from '@testing-library/react'+import { screen, waitFor, within } from '@testing-library/react'+import userEvent from '@testing-library/user-event'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'-import ToolFormItem from '../item'+import { renderWorkflowFlowComponent } from '@/app/components/workflow/__tests__/workflow-test-env'+import { VarKindType } from '@/app/components/workflow/nodes/_base/types'+import { Type } from '@/app/components/workflow/nodes/llm/types'+import { TriggerFormItem } from '@/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item'+import { ToolFormItem } from '../item'-type MockSchemaModalProps = {- isShow: boolean- onClose: () => void- rootName: string- schema: SchemaRoot-}--type MockFormInputItemProps = Readonly<{- schema: CredentialFormSchema-}>--const mockUseLanguage = vi.fn()-const mockSchemaModal = vi.fn<(props: MockSchemaModalProps) => void>()--vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({- useLanguage: () => mockUseLanguage(),-}))--vi.mock(- '@/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal',- () => ({- SchemaModal: (props: MockSchemaModalProps) => {- mockSchemaModal(props)- return props.isShow ? (- <div data-testid="schema-modal">- <span>{props.rootName}</span>- <button type="button" onClick={props.onClose}>- close-schema- </button>- </div>- ) : null- },- }),-)--vi.mock('@/app/components/workflow/nodes/_base/components/form-input-item', () => ({- default: ({ schema }: MockFormInputItemProps) => <div>{schema.variable}</div>,-}))+beforeEach(() => {+ const paths = new Set([+ '/console/api/spec/schema-definitions',+ '/console/api/workspaces/current/tools/builtin',+ '/console/api/workspaces/current/tools/api',+ '/console/api/workspaces/current/tools/workflow',+ '/console/api/workspaces/current/tools/mcp',+ ])+ vi.spyOn(globalThis, 'fetch').mockImplementation(async (input) => {+ const url = new URL(input instanceof Request ? input.url : String(input))+ if (paths.has(url.pathname)) return Response.json([])+ throw new Error(`Unexpected request: ${url}`)+ })+})const createSchema = (overrides: Partial<CredentialFormSchema> = {}): CredentialFormSchema => ({- name: 'api_key',- variable: 'api_key',- label: {- en_US: 'API Key',- zh_Hans: 'API Key',- },- type: FormTypeEnum.textInput,+ name: 'config',+ variable: 'config',+ label: { en_US: 'Config', zh_Hans: 'Config' },+ type: FormTypeEnum.object,required: true,- tooltip: {- en_US: 'Enter API key',- zh_Hans: 'Enter API key',- },show_on: [],+ input_schema: { type: Type.object, properties: { city: { type: Type.string } } },...overrides,})-describe('tool/tool-form/item', () => {- beforeEach(() => {- vi.clearAllMocks()- mockUseLanguage.mockReturnValue('en_US')- })-- // URL fragments inside descriptions should be rendered as external links.- it('should render URLs in descriptions as external links', () => {- render(- <ToolFormItem- readOnly={false}- nodeId="tool-node"- schema={createSchema({- tooltip: {- en_US: 'Visit https://docs.dify.ai/tools for docs',- zh_Hans: 'Visit https://docs.dify.ai/tools for docs',- },- })}- value={{}}- onChange={vi.fn()}- />,- )-- const link = screen.getByRole('link', { name: 'https://docs.dify.ai/tools' })- expect(link)!.toHaveAttribute('href', 'https://docs.dify.ai/tools')- expect(link)!.toHaveAttribute('target', '_blank')- expect(link)!.toHaveAttribute('rel', 'noopener noreferrer')- expect(link.parentElement)!.toHaveTextContent('Visit https://docs.dify.ai/tools for docs')- })+const consumers = [+ ['tool', ToolFormItem],+ ['trigger', TriggerFormItem],+] as const- // Non-text fields keep their descriptions inside the tooltip and support JSON schema preview.- it('should show tooltip for non-description fields and open the schema modal', () => {- const objectSchema = createSchema({- name: 'tool_config',- variable: 'tool_config',- label: {- en_US: 'Tool Config',- zh_Hans: 'Tool Config',- },- type: FormTypeEnum.object,- tooltip: {- en_US: 'Select from tools',- zh_Hans: 'Select from tools',- },- input_schema: {- type: 'object',- properties: {- city: {- type: 'string',- },- },- additionalProperties: false,- } as unknown as SchemaRoot,- })+describe.each(consumers)('%s parameter schema entry', (_name, Item) => {+ it.each([+ { type: FormTypeEnum.object, readOnly: false, value: '{}' },+ { type: FormTypeEnum.array, readOnly: true, value: '[]' },+ ])(+ 'inspects $type parameters with readOnly=$readOnly without changing their value',+ async ({ type, readOnly, value }) => {+ const user = userEvent.setup()+ const onChange = vi.fn()+ renderWorkflowFlowComponent(+ <Item+ readOnly={readOnly}+ nodeId="node-1"+ schema={createSchema({+ type,+ input_schema:+ type === FormTypeEnum.array+ ? {+ type: Type.array,+ items: { type: Type.object, properties: { city: { type: Type.string } } },+ }+ : { type: Type.object, properties: { city: { type: Type.string } } },+ })}+ value={{ config: { type: VarKindType.constant, value } }}+ onChange={onChange}+ />,+ { nodes: [], edges: [], hooksStoreProps: {} },+ )+ const trigger = screen.getByRole('button', { name: /^JSON Schema:/ })+ await user.click(trigger)+ const dialog = screen.getByRole('dialog', {+ name: 'workflowAgent.nodes.agent.parameterSchema',+ })+ expect(within(dialog).getByText('config')).toBeInTheDocument()+ expect(within(dialog).getByText('city')).toBeInTheDocument()+ await user.click(within(dialog).getByRole('button', { name: 'common.operation.close' }))+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())+ expect(trigger).toHaveFocus()+ expect(screen.getByTestId('monaco-editor')).toHaveValue(value)+ expect(onChange).not.toHaveBeenCalled()+ },+ )- render(- <ToolFormItem- readOnly={false}- nodeId="tool-node"- schema={objectSchema}- value={{}}+ it('does not offer schema inspection for scalar parameters', () => {+ renderWorkflowFlowComponent(+ <Item+ readOnly+ nodeId="node-1"+ schema={createSchema({ type: FormTypeEnum.textNumber })}+ value={{ config: { type: VarKindType.constant, value: 7 } }}onChange={vi.fn()}- providerType="trigger"/>,+ { nodes: [], edges: [], hooksStoreProps: {} },)-- const infotipTrigger = screen.getByRole('button', { name: 'Tool Config' })- fireEvent.click(infotipTrigger)- expect(screen.getByText('Select from tools'))!.toBeInTheDocument()-- fireEvent.click(screen.getByRole('button', { name: 'JSON Schema' }))- const schemaModal = screen.getByTestId('schema-modal')- expect(schemaModal)!.toBeInTheDocument()- expect(within(schemaModal).getByText('tool_config'))!.toBeInTheDocument()- fireEvent.click(screen.getByRole('button', { name: 'close-schema' }))- expect(screen.queryByTestId('schema-modal')).not.toBeInTheDocument()+ expect(screen.queryByRole('button', { name: /^JSON Schema:/ })).not.toBeInTheDocument()+ expect(screen.getByRole('textbox', { name: 'Config' })).toHaveValue('7')})})++it('keeps tool parameter descriptions linked to external documentation', () => {+ renderWorkflowFlowComponent(+ <ToolFormItem+ readOnly+ nodeId="node-1"+ schema={createSchema({+ type: FormTypeEnum.textNumber,+ tooltip: { en_US: 'Visit https://docs.dify.ai/tools for docs', zh_Hans: '' },+ })}+ value={{}}+ onChange={vi.fn()}+ />,+ { nodes: [], edges: [], hooksStoreProps: {} },+ )+ const link = screen.getByRole('link', { name: 'https://docs.dify.ai/tools' })+ expect(link).toHaveAttribute('href', 'https://docs.dify.ai/tools')+ expect(link).toHaveAttribute('target', '_blank')+ expect(link).toHaveAttribute('rel', 'noopener noreferrer')+})diff --git a/web/app/components/workflow/nodes/tool/components/tool-form/index.tsx b/web/app/components/workflow/nodes/tool/components/tool-form/index.tsxindex e1658481c75..2f1920c4dc2 100644--- a/web/app/components/workflow/nodes/tool/components/tool-form/index.tsx+++ b/web/app/components/workflow/nodes/tool/components/tool-form/index.tsx@@ -4,7 +4,7 @@ import type { Tool } from '@/app/components/tools/types'import type { FormInputSchema } from '@/app/components/workflow/nodes/_base/components/form-input-item.helpers'import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'import type { ToolWithProvider } from '@/app/components/workflow/types'-import ToolFormItem from './item'+import { ToolFormItem } from './item'type Props = Readonly<{staticSchema?: booleandiff --git a/web/app/components/workflow/nodes/tool/components/tool-form/item.tsx b/web/app/components/workflow/nodes/tool/components/tool-form/item.tsxindex 76720e1cbce..ae73825b2bd 100644--- a/web/app/components/workflow/nodes/tool/components/tool-form/item.tsx+++ b/web/app/components/workflow/nodes/tool/components/tool-form/item.tsx@@ -1,15 +1,14 @@'use client'-import type { FC, ReactNode } from 'react'+import type { ReactNode } from 'react'import type { Tool } from '@/app/components/tools/types'import type { FormInputSchema } from '@/app/components/workflow/nodes/_base/components/form-input-item.helpers'import type { ResourceVarInputs } from '@/app/components/workflow/nodes/_base/types'import type { ToolWithProvider } from '@/app/components/workflow/types'-import { Button } from '@langgenius/dify-ui/button'import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'-import { useId, useState } from 'react'+import { useId } from 'react'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'-import { SchemaModal } from '@/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal'+import { SchemaDialog } from '@/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog'import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'const URL_REGEX = /(https?:\/\/\S+)/g@@ -63,7 +62,7 @@ type Props = Readonly<{providerType?: 'tool' | 'trigger'}>-const ToolFormItem: FC<Props> = ({+export function ToolFormItem({readOnly,staticSchema = false,nodeId,@@ -76,7 +75,7 @@ const ToolFormItem: FC<Props> = ({onManageInputField,extraParams,providerType = 'tool',-}) => {+}: Props) {const language = useLanguage()const labelId = useId()const { name, label, type, required, tooltip, input_schema } = schema@@ -87,7 +86,6 @@ const ToolFormItem: FC<Props> = ({type === FormTypeEnum.secretInput ||type === FormTypeEnum.date ||type === FormTypeEnum.dateRange- const [isShowSchema, setIsShowSchema] = useState(false)return (<div className="space-y-0.5 py-1"><div>@@ -112,15 +110,7 @@ const ToolFormItem: FC<Props> = ({{showSchemaButton && (<><div className="mr-0.5 ml-1 system-xs-regular text-text-quaternary">·</div>- <Button- variant="ghost"- size="small"- onClick={() => setIsShowSchema(true)}- className="px-1 system-xs-regular text-text-tertiary"- >- <span aria-hidden className="i-ri-braces-line size-3.5" />- <span>JSON Schema</span>- </Button>+ <SchemaDialog schema={input_schema} rootName={name} /></>)}</div>@@ -145,16 +135,6 @@ const ToolFormItem: FC<Props> = ({extraParams={extraParams}providerType={providerType}/>-- {isShowSchema && (- <SchemaModal- isShow- onClose={() => setIsShowSchema(false)}- rootName={name}- schema={input_schema!}- />- )}</div>)}-export default ToolFormItemdiff --git a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsxindex d3f941e8608..463980abc36 100644--- a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx+++ b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/index.tsx@@ -4,7 +4,7 @@ import type { CredentialFormSchema } from '@/app/components/header/account-settiimport type { Event } from '@/app/components/tools/types'import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'-import TriggerFormItem from './item'+import { TriggerFormItem } from './item'type Props = Readonly<{readOnly: booleandiff --git a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsxindex b21883110d7..50cc2a7d890 100644--- a/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx+++ b/web/app/components/workflow/nodes/trigger-plugin/components/trigger-form/item.tsx@@ -1,15 +1,13 @@'use client'-import type { FC } from 'react'import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'import type { Event } from '@/app/components/tools/types'import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'-import { Button } from '@langgenius/dify-ui/button'import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'-import { useId, useState } from 'react'+import { useId } from 'react'import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'-import { SchemaModal } from '@/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-modal'+import { SchemaDialog } from '@/app/components/plugins/plugin-detail-panel/tool-selector/components/schema-dialog'import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'type Props = Readonly<{@@ -24,7 +22,7 @@ type Props = Readonly<{disableVariableInsertion?: boolean}>-const TriggerFormItem: FC<Props> = ({+export function TriggerFormItem({readOnly,nodeId,schema,@@ -34,7 +32,7 @@ const TriggerFormItem: FC<Props> = ({currentProvider,extraParams,disableVariableInsertion = false,-}) => {+}: Props) {const language = useLanguage()const labelId = useId()const { name, label, type, required, tooltip, input_schema } = schema@@ -45,7 +43,6 @@ const TriggerFormItem: FC<Props> = ({type === FormTypeEnum.secretInput ||type === FormTypeEnum.date ||type === FormTypeEnum.dateRange- const [isShowSchema, setIsShowSchema] = useState(false)return (<div className="space-y-0.5 py-1"><div>@@ -67,15 +64,7 @@ const TriggerFormItem: FC<Props> = ({{showSchemaButton && (<><div className="mr-0.5 ml-1 system-xs-regular text-text-quaternary">·</div>- <Button- variant="ghost"- size="small"- onClick={() => setIsShowSchema(true)}- className="px-1 system-xs-regular text-text-tertiary"- >- <span aria-hidden className="i-ri-braces-line size-3.5" />- <span>JSON Schema</span>- </Button>+ <SchemaDialog schema={input_schema} rootName={name} /></>)}</div>@@ -98,16 +87,6 @@ const TriggerFormItem: FC<Props> = ({extraParams={extraParams}disableVariableInsertion={disableVariableInsertion}/>-- {isShowSchema && (- <SchemaModal- isShow- onClose={() => setIsShowSchema(false)}- rootName={name}- schema={input_schema!}- />- )}</div>)}-export default TriggerFormItem