mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 20:38:32 +02:00
Fix double message send
This commit is contained in:
@@ -408,7 +408,7 @@ def seed_chat(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return ChatSeedResponse(
|
return ChatSeedResponse(
|
||||||
redirect_url=f"{WEB_DOMAIN}/chat?chatId={new_chat_session.id}"
|
redirect_url=f"{WEB_DOMAIN}/chat?chatId={new_chat_session.id}&seeded=true"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -180,20 +180,27 @@ export function ChatPage({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const newMessageHistory = processRawChatHistory(chatSession.messages);
|
const newMessageHistory = processRawChatHistory(chatSession.messages);
|
||||||
setMessageHistory(newMessageHistory);
|
// if the last message is an error, don't overwrite it
|
||||||
|
if (messageHistory[messageHistory.length - 1]?.type !== "error") {
|
||||||
|
setMessageHistory(newMessageHistory);
|
||||||
|
|
||||||
const latestMessageId =
|
const latestMessageId =
|
||||||
newMessageHistory[newMessageHistory.length - 1]?.messageId;
|
newMessageHistory[newMessageHistory.length - 1]?.messageId;
|
||||||
setSelectedMessageForDocDisplay(
|
setSelectedMessageForDocDisplay(
|
||||||
latestMessageId !== undefined ? latestMessageId : null
|
latestMessageId !== undefined ? latestMessageId : null
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
setChatSessionSharedStatus(chatSession.shared_status);
|
setChatSessionSharedStatus(chatSession.shared_status);
|
||||||
|
|
||||||
setIsFetchingChatMessages(false);
|
setIsFetchingChatMessages(false);
|
||||||
|
|
||||||
// if this is a seeded chat, then kick off the AI message generation
|
// if this is a seeded chat, then kick off the AI message generation
|
||||||
if (newMessageHistory.length === 1 && !submitOnLoadPerformed.current) {
|
if (
|
||||||
|
newMessageHistory.length === 1 &&
|
||||||
|
!submitOnLoadPerformed.current &&
|
||||||
|
searchParams.get(SEARCH_PARAM_NAMES.SEEDED) === "true"
|
||||||
|
) {
|
||||||
submitOnLoadPerformed.current = true;
|
submitOnLoadPerformed.current = true;
|
||||||
const seededMessage = newMessageHistory[0].message;
|
const seededMessage = newMessageHistory[0].message;
|
||||||
await onSubmit({
|
await onSubmit({
|
||||||
|
@@ -13,6 +13,8 @@ export const SEARCH_PARAM_NAMES = {
|
|||||||
SUBMIT_ON_LOAD: "submit-on-load",
|
SUBMIT_ON_LOAD: "submit-on-load",
|
||||||
// chat title
|
// chat title
|
||||||
TITLE: "title",
|
TITLE: "title",
|
||||||
|
// for seeding chats
|
||||||
|
SEEDED: "seeded",
|
||||||
};
|
};
|
||||||
|
|
||||||
export function shouldSubmitOnLoad(searchParams: ReadonlyURLSearchParams) {
|
export function shouldSubmitOnLoad(searchParams: ReadonlyURLSearchParams) {
|
||||||
|
Reference in New Issue
Block a user