Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
337cd100
authored
Aug 06, 2026
by
Finley Ge
Committed by
GitHub
Aug 06, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(workflow): avoid duplicate tool parameter rendering (#7465)
parent
d0a890e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
12 deletions
+68
-12
projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowUtilsContext.tsx
+26
-12
projects/app/test/pageComponents/app/detail/WorkflowComponents/context/workflowUtilsContext.test.ts
+42
-0
No files found.
projects/app/src/pageComponents/app/detail/WorkflowComponents/context/workflowUtilsContext.tsx
View file @
337cd100
...
...
@@ -74,6 +74,31 @@ type WorkflowUtilsContextValue = {
errorOutputs
:
FlowNodeOutputItemType
[];
};
};
/** 将工具输入和普通节点输入分开,避免 Agent 生成参数在节点内重复渲染。 */
export
const
splitToolInputsByMode
=
(
inputs
:
FlowNodeInputItemType
[],
isTool
:
boolean
)
=>
{
const
toolInputs
:
FlowNodeInputItemType
[]
=
[];
const
commonInputs
:
FlowNodeInputItemType
[]
=
[];
inputs
.
forEach
((
item
)
=>
{
const
normalizedInput
=
normalizeFlowNodeInputType
(
item
,
{
isTool
});
const
isAgentGeneratedInput
=
isAgentGeneratedToolInput
(
normalizedInput
)
&&
canInputBeAgentGenerated
(
normalizedInput
);
if
(
isTool
&&
isAgentGeneratedInput
&&
item
.
canEdit
)
{
toolInputs
.
push
(
item
);
return
;
}
commonInputs
.
push
(
normalizedInput
);
});
return
{
toolInputs
,
commonInputs
};
};
export
const
WorkflowUtilsContext
=
createContext
<
WorkflowUtilsContextValue
>
({
initData
:
(...
args
:
Parameters
<
WorkflowUtilsContextValue
[
'initData'
]
>
)
=>
{
void
args
;
...
...
@@ -148,18 +173,7 @@ export const WorkflowUtilsProvider = ({ children }: { children: ReactNode }) =>
const
splitToolInputs
=
useCallback
(
(
inputs
:
FlowNodeInputItemType
[],
nodeId
:
string
)
=>
{
const
isTool
=
toolNodesMap
[
nodeId
]
??
false
;
const
toolInputs
:
FlowNodeInputItemType
[]
=
[];
const
commonInputs
:
FlowNodeInputItemType
[]
=
[];
inputs
.
forEach
((
item
)
=>
{
const
normalizedInput
=
normalizeFlowNodeInputType
(
item
,
{
isTool
});
const
isAgentGeneratedInput
=
isAgentGeneratedToolInput
(
normalizedInput
)
&&
canInputBeAgentGenerated
(
normalizedInput
);
if
(
isTool
&&
isAgentGeneratedInput
&&
item
.
canEdit
)
{
toolInputs
.
push
(
item
);
}
commonInputs
.
push
(
normalizedInput
);
});
const
{
toolInputs
,
commonInputs
}
=
splitToolInputsByMode
(
inputs
,
isTool
);
return
{
isTool
,
...
...
projects/app/test/pageComponents/app/detail/WorkflowComponents/context/workflowUtilsContext.test.ts
0 → 100644
View file @
337cd100
import
{
describe
,
expect
,
it
}
from
'vitest'
;
import
{
splitToolInputsByMode
}
from
'@/pageComponents/app/detail/WorkflowComponents/context/workflowUtilsContext'
;
import
{
FlowNodeInputTypeEnum
}
from
'@fastgpt/global/core/workflow/node/constant'
;
describe
(
'splitToolInputsByMode'
,
()
=>
{
it
(
'keeps Agent-generated editable inputs out of common inputs'
,
()
=>
{
const
toolInput
=
{
key
:
'query'
,
label
:
'query'
,
canEdit
:
true
,
toolDescription
:
'Search query'
,
isToolParam
:
true
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
]
};
const
commonInput
=
{
key
:
'url'
,
label
:
'url'
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
]
};
const
result
=
splitToolInputsByMode
([
toolInput
,
commonInput
],
true
);
expect
(
result
.
toolInputs
).
toEqual
([
toolInput
]);
expect
(
result
.
commonInputs
.
map
((
input
)
=>
input
.
key
)).
toEqual
([
'url'
]);
});
it
(
'keeps the same input in common inputs when it is not a tool'
,
()
=>
{
const
input
=
{
key
:
'query'
,
label
:
'query'
,
canEdit
:
true
,
toolDescription
:
'Search query'
,
isToolParam
:
true
,
renderTypeList
:
[
FlowNodeInputTypeEnum
.
reference
]
};
const
result
=
splitToolInputsByMode
([
input
],
false
);
expect
(
result
.
toolInputs
).
toEqual
([]);
expect
(
result
.
commonInputs
).
toHaveLength
(
1
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment