Skip to content

Commit

Permalink
fix: fix issue with chat-input-area clearing during Responding state.
Browse files Browse the repository at this point in the history
Fixed an issue where sending a message while in the Responding state would clear the input box content. Now, it checks if the state isResponding, and if true, it shows a prompt and does not clear the input box.
  • Loading branch information
Woo0ood committed Jan 3, 2025
1 parent 7069802 commit dca3770
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/app/components/base/chat/chat/chat-input-area/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ChatInputAreaProps = {
inputs?: Record<string, any>
inputsForm?: InputForm[]
theme?: Theme | null
isResponding?: boolean
}
const ChatInputArea = ({
showFeatureBar,
Expand All @@ -51,6 +52,7 @@ const ChatInputArea = ({
inputs = {},
inputsForm = [],
theme,
isResponding,
}: ChatInputAreaProps) => {
const { t } = useTranslation()
const { notify } = useToastContext()
Expand All @@ -77,6 +79,11 @@ const ChatInputArea = ({
const historyRef = useRef([''])
const [currentIndex, setCurrentIndex] = useState(-1)
const handleSend = () => {
if (isResponding) {
notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })
return
}

if (onSend) {
const { files, setFiles } = filesStore.getState()
if (files.find(item => item.transferMethod === TransferMethod.local_file && !item.uploadedId)) {
Expand Down Expand Up @@ -116,7 +123,7 @@ const ChatInputArea = ({
setQuery(historyRef.current[currentIndex + 1])
}
else if (currentIndex === historyRef.current.length - 1) {
// If it is the last element, clear the input box
// If it is the last element, clear the input box
setCurrentIndex(historyRef.current.length)
setQuery('')
}
Expand Down
1 change: 1 addition & 0 deletions web/app/components/base/chat/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ const Chat: FC<ChatProps> = ({
inputs={inputs}
inputsForm={inputsForm}
theme={themeBuilder?.theme}
isResponding={isResponding}
/>
)
}
Expand Down

0 comments on commit dca3770

Please sign in to comment.