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
ce3556c2
authored
Sep 27, 2025
by
heheer
Committed by
GitHub
Sep 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: react-hook-form Controller crash with special characters in field names (#5715)
parent
a6ba9741
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
11 deletions
+22
-11
projects/app/src/components/core/chat/components/AIResponseBox.tsx
+16
-5
projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx
+6
-6
No files found.
projects/app/src/components/core/chat/components/AIResponseBox.tsx
View file @
ce3556c2
...
@@ -217,20 +217,31 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
...
@@ -217,20 +217,31 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
const
defaultValues
=
useMemo
(()
=>
{
const
defaultValues
=
useMemo
(()
=>
{
if
(
interactive
.
type
===
'userInput'
)
{
if
(
interactive
.
type
===
'userInput'
)
{
return
interactive
.
params
.
inputForm
?.
reduce
((
acc
:
Record
<
string
,
any
>
,
item
)
=>
{
return
interactive
.
params
.
inputForm
?.
reduce
((
acc
:
Record
<
string
,
any
>
,
item
,
index
)
=>
{
acc
[
item
.
label
]
=
!!
item
.
value
?
item
.
value
:
item
.
defaultValue
;
acc
[
`field_
${
index
}
`
]
=
!!
item
.
value
?
item
.
value
:
item
.
defaultValue
;
return
acc
;
return
acc
;
},
{});
},
{});
}
}
return
{};
return
{};
},
[
interactive
]);
},
[
interactive
]);
const
handleFormSubmit
=
useCallback
((
data
:
Record
<
string
,
any
>
)
=>
{
const
handleFormSubmit
=
useCallback
(
(
data
:
Record
<
string
,
any
>
)
=>
{
const
finalData
:
Record
<
string
,
any
>
=
{};
interactive
.
params
.
inputForm
?.
forEach
((
item
,
index
)
=>
{
const
fieldName
=
`field_
${
index
}
`
;
if
(
fieldName
in
data
)
{
finalData
[
item
.
label
]
=
data
[
fieldName
];
}
});
onSendPrompt
({
onSendPrompt
({
text
:
JSON
.
stringify
(
d
ata
),
text
:
JSON
.
stringify
(
finalD
ata
),
isInteractivePrompt
:
true
isInteractivePrompt
:
true
});
});
},
[]);
},
[
interactive
.
params
.
inputForm
]
);
return
(
return
(
<
Flex
flexDirection=
{
'column'
}
gap=
{
2
}
w=
{
'250px'
}
>
<
Flex
flexDirection=
{
'column'
}
gap=
{
2
}
w=
{
'250px'
}
>
...
...
projects/app/src/components/core/chat/components/Interactive/InteractiveComponents.tsx
View file @
ce3556c2
import
React
,
{
useCallback
}
from
'react'
;
import
React
,
{
useCallback
}
from
'react'
;
import
{
Box
,
Button
,
Flex
}
from
'@chakra-ui/react'
;
import
{
Box
,
Flex
}
from
'@chakra-ui/react'
;
import
{
Controller
,
useForm
,
type
UseFormHandleSubmit
}
from
'react-hook-form'
;
import
{
Controller
,
useForm
,
type
UseFormHandleSubmit
}
from
'react-hook-form'
;
import
Markdown
from
'@/components/Markdown'
;
import
Markdown
from
'@/components/Markdown'
;
import
QuestionTip
from
'@fastgpt/web/components/common/MyTooltip/QuestionTip'
;
import
QuestionTip
from
'@fastgpt/web/components/common/MyTooltip/QuestionTip'
;
...
@@ -79,12 +79,12 @@ export const FormInputComponent = React.memo(function FormInputComponent({
...
@@ -79,12 +79,12 @@ export const FormInputComponent = React.memo(function FormInputComponent({
});
});
const
RenderFormInput
=
useCallback
(
const
RenderFormInput
=
useCallback
(
({
input
}:
{
input
:
UserInputFormItemType
})
=>
{
({
input
,
index
}:
{
input
:
UserInputFormItemType
;
index
:
number
})
=>
{
return
(
return
(
<
Controller
<
Controller
key=
{
input
.
label
}
key=
{
input
.
label
}
control=
{
control
}
control=
{
control
}
name=
{
input
.
label
}
name=
{
`field_${index}`
}
rules=
{
{
required
:
input
.
required
}
}
rules=
{
{
required
:
input
.
required
}
}
render=
{
({
field
:
{
onChange
,
value
},
fieldState
:
{
error
}
})
=>
{
render=
{
({
field
:
{
onChange
,
value
},
fieldState
:
{
error
}
})
=>
{
const
inputType
=
nodeInputTypeToInputType
([
input
.
type
]);
const
inputType
=
nodeInputTypeToInputType
([
input
.
type
]);
...
@@ -94,7 +94,7 @@ export const FormInputComponent = React.memo(function FormInputComponent({
...
@@ -94,7 +94,7 @@ export const FormInputComponent = React.memo(function FormInputComponent({
inputType=
{
inputType
}
inputType=
{
inputType
}
value=
{
value
}
value=
{
value
}
onChange=
{
onChange
}
onChange=
{
onChange
}
placeholder=
{
input
.
description
}
placeholder=
{
input
.
label
}
isDisabled=
{
submitted
}
isDisabled=
{
submitted
}
isInvalid=
{
!!
error
}
isInvalid=
{
!!
error
}
maxLength=
{
input
.
maxLength
}
maxLength=
{
input
.
maxLength
}
...
@@ -114,14 +114,14 @@ export const FormInputComponent = React.memo(function FormInputComponent({
...
@@ -114,14 +114,14 @@ export const FormInputComponent = React.memo(function FormInputComponent({
<
Box
>
<
Box
>
<
DescriptionBox
description=
{
description
}
/>
<
DescriptionBox
description=
{
description
}
/>
<
Flex
flexDirection=
{
'column'
}
gap=
{
3
}
>
<
Flex
flexDirection=
{
'column'
}
gap=
{
3
}
>
{
inputForm
.
map
((
input
)
=>
(
{
inputForm
.
map
((
input
,
index
)
=>
(
<
Box
key=
{
input
.
label
}
>
<
Box
key=
{
input
.
label
}
>
<
Flex
alignItems=
{
'center'
}
mb=
{
1
}
>
<
Flex
alignItems=
{
'center'
}
mb=
{
1
}
>
{
input
.
required
&&
<
Box
color=
{
'red.500'
}
>
*
</
Box
>
}
{
input
.
required
&&
<
Box
color=
{
'red.500'
}
>
*
</
Box
>
}
<
FormLabel
>
{
input
.
label
}
</
FormLabel
>
<
FormLabel
>
{
input
.
label
}
</
FormLabel
>
{
input
.
description
&&
<
QuestionTip
ml=
{
1
}
label=
{
input
.
description
}
/>
}
{
input
.
description
&&
<
QuestionTip
ml=
{
1
}
label=
{
input
.
description
}
/>
}
</
Flex
>
</
Flex
>
<
RenderFormInput
input=
{
input
}
/>
<
RenderFormInput
input=
{
input
}
index=
{
index
}
/>
</
Box
>
</
Box
>
))
}
))
}
</
Flex
>
</
Flex
>
...
...
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