Feat: Allow users to enter text in the middle of a chat #3221 (#8569)

### What problem does this PR solve?

Feat: Allow users to enter text in the middle of a chat #3221
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-06-30 10:36:52 +08:00
committed by GitHub
parent aafeffa292
commit 356d1f3485
12 changed files with 166 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import {
import { useFetchAgent } from '@/hooks/use-agent-request';
import {
IEventList,
IInputEvent,
IMessageEvent,
MessageEventType,
useSendMessageBySSE,
@ -66,6 +67,21 @@ function findMessageFromList(eventList: IEventList) {
};
}
function findInputFromList(eventList: IEventList) {
const inputEvent = eventList.find(
(x) => x.event === MessageEventType.UserInputs,
) as IInputEvent;
if (!inputEvent) {
return {};
}
return {
id: inputEvent?.message_id,
data: inputEvent?.data,
};
}
const useGetBeginNodePrologue = () => {
const getNode = useGraphStore((state) => state.getNode);
@ -136,10 +152,12 @@ export const useSendNextMessage = () => {
useEffect(() => {
const { content, id } = findMessageFromList(answerList);
const inputAnswer = findInputFromList(answerList);
if (answerList.length > 0) {
addNewestOneAnswer({
answer: content,
id: id,
...inputAnswer,
});
}
}, [answerList, addNewestOneAnswer]);
@ -181,5 +199,6 @@ export const useSendNextMessage = () => {
ref,
removeMessageById,
stopOutputMessage,
send,
};
};