Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: stop response enchancement (#352)
Joel87af414a5277
diff --git a/web/app/components/app/configuration/debug/index.tsx b/web/app/components/app/configuration/debug/index.tsxindex 3800795c766..9a2bdca3c33 100644--- a/web/app/components/app/configuration/debug/index.tsx+++ b/web/app/components/app/configuration/debug/index.tsx@@ -75,6 +75,8 @@ const Debug: FC<IDebug> = ({const [abortController, setAbortController] = useState<AbortController | null>(null)const [isShowFormattingChangeConfirm, setIsShowFormattingChangeConfirm] = useState(false)const [isShowSuggestion, setIsShowSuggestion] = useState(false)+ const [messageTaskId, setMessageTaskId] = useState('')+ const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)useEffect(() => {if (formattingChanged && chatList.some(item => !item.isAnswer))@@ -83,7 +85,7 @@ const Debug: FC<IDebug> = ({setFormattingChanged(false)}, [formattingChanged])- const clearConversation = () => {+ const clearConversation = async () => {setConversationId(null)abortController?.abort()setResponsingFalse()@@ -136,7 +138,6 @@ const Debug: FC<IDebug> = ({const doShowSuggestion = isShowSuggestion && !isResponsingconst [suggestQuestions, setSuggestQuestions] = useState<string[]>([])- const [messageTaskId, setMessageTaskId] = useState('')const onSend = async (message: string) => {if (isResponsing) {notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })@@ -203,6 +204,7 @@ const Debug: FC<IDebug> = ({let _newConversationId: null | string = null+ setHasStopResponded(false)setResponsingTrue()setIsShowSuggestion(false)sendChatMessage(appId, data, {@@ -255,7 +257,7 @@ const Debug: FC<IDebug> = ({}}))}- if (suggestedQuestionsAfterAnswerConfig.enabled) {+ if (suggestedQuestionsAfterAnswerConfig.enabled && !getHasStopResponded()) {const { data }: any = await fetchSuggestedQuestions(appId, responseItem.id)setSuggestQuestions(data)setIsShowSuggestion(true)@@ -379,8 +381,8 @@ const Debug: FC<IDebug> = ({isResponsing={isResponsing}canStopResponsing={!!messageTaskId}abortResponsing={async () => {- abortController?.abort()await stopChatMessageResponding(appId, messageTaskId)+ setHasStopResponded(true)setResponsingFalse()}}isShowSuggestion={doShowSuggestion}@@ -399,6 +401,7 @@ const Debug: FC<IDebug> = ({className="mt-2"content={completionRes}isLoading={!completionRes && isResponsing}+ isInstalledApp={false}/>)}</div>diff --git a/web/app/components/share/chat/index.tsx b/web/app/components/share/chat/index.tsxindex 81ccfa94a81..638f2ac23de 100644--- a/web/app/components/share/chat/index.tsx+++ b/web/app/components/share/chat/index.tsx@@ -191,7 +191,7 @@ const Main: FC<IMainProps> = ({}, [chatList, currConversationId])// user can not edit inputs if user had send messageconst canEditInpus = !chatList.some(item => item.isAnswer === false) && isNewConversation- const createNewChat = () => {+ const createNewChat = async () => {// if new chat is already exist, do not create new chatabortController?.abort()setResponsingFalse()@@ -333,6 +333,8 @@ const Main: FC<IMainProps> = ({const doShowSuggestion = isShowSuggestion && !isResponsingconst [suggestQuestions, setSuggestQuestions] = useState<string[]>([])const [messageTaskId, setMessageTaskId] = useState('')+ const [hasStopResponded, setHasStopResponded, getHasStopResponded] = useGetState(false)+const handleSend = async (message: string) => {if (isResponsing) {notify({ type: 'info', message: t('appDebug.errorMessage.waitForResponse') })@@ -371,6 +373,7 @@ const Main: FC<IMainProps> = ({let tempNewConversationId = ''+ setHasStopResponded(false)setResponsingTrue()setIsShowSuggestion(false)sendChatMessage(data, {@@ -411,7 +414,7 @@ const Main: FC<IMainProps> = ({resetNewConversationInputs()setChatNotStarted()setCurrConversationId(tempNewConversationId, appId, true)- if (suggestedQuestionsAfterAnswerConfig?.enabled) {+ if (suggestedQuestionsAfterAnswerConfig?.enabled && !getHasStopResponded()) {const { data }: any = await fetchSuggestedQuestions(responseItem.id, isInstalledApp, installedAppInfo?.id)setSuggestQuestions(data)setIsShowSuggestion(true)@@ -536,8 +539,8 @@ const Main: FC<IMainProps> = ({isResponsing={isResponsing}canStopResponsing={!!messageTaskId}abortResponsing={async () => {- abortController?.abort()await stopChatMessageResponding(appId, messageTaskId, isInstalledApp, installedAppInfo?.id)+ setHasStopResponded(true)setResponsingFalse()}}checkCanSend={checkCanSend}