AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(chat): a failed reply shows its error once, with a retry button (#17174)
Hazem Adela0b35633dce9
diff --git a/packages/web/src/app/routes/chat-with-ai/ai-chat-box.tsx b/packages/web/src/app/routes/chat-with-ai/ai-chat-box.tsxindex 4ff239227de..d5376e77f0f 100644--- a/packages/web/src/app/routes/chat-with-ai/ai-chat-box.tsx+++ b/packages/web/src/app/routes/chat-with-ai/ai-chat-box.tsx@@ -136,6 +136,7 @@ function ChatBoxContent({wasCancelled,isLoadingHistory,error,+ failed,sendMessage,retryLastMessage,cancelStream,@@ -453,15 +454,23 @@ function ChatBoxContent({</div>)}- {error && (+ {failed && (<motion.div- className="flex items-center gap-2 rounded-xl border border-danger-6 bg-danger-3 px-3 py-2 text-danger-11 text-sm"+ className={cn(+ 'flex items-center gap-2 text-danger-11 text-sm',+ error &&+ 'rounded-xl border border-danger-6 bg-danger-3 px-3 py-2',+ )}initial={{ opacity: 0, y: 4 }}animate={{ opacity: 1, y: 0 }}transition={{ duration: 0.2 }}>- <AlertTriangle className="h-4 w-4 shrink-0" />- <span className="flex-1">{error}</span>+ {error && (+ <>+ <AlertTriangle className="h-4 w-4 shrink-0" />+ <span className="flex-1">{error}</span>+ </>+ )}<Buttonvariant="ghost"size="xs"diff --git a/packages/web/src/features/chat/lib/use-chat.ts b/packages/web/src/features/chat/lib/use-chat.tsindex 565efc4e7f8..4c4b9b24e75 100644--- a/packages/web/src/features/chat/lib/use-chat.ts+++ b/packages/web/src/features/chat/lib/use-chat.ts@@ -325,7 +325,7 @@ type SendStatus =| { type: 'idle' }| { type: 'submitting' }| { type: 'cancelled' }- | { type: 'error'; message: string };+ | { type: 'error'; message: string | null };export function useAgentChat({agentId,@@ -630,9 +630,7 @@ export function useAgentChat({);updateSendStatus({type: 'error',- message: failureIsInTranscript- ? t('The last reply did not finish. Please try again.')- : opts.errorMessage,+ message: failureIsInTranscript ? null : opts.errorMessage,});} else if (!hasReply && !opts?.suppressNoReply) {updateSendStatus({@@ -694,11 +692,8 @@ export function useAgentChat({]);const error =- sendStatus.type === 'error'- ? sendStatus.message- : streamError- ? streamError- : null;+ sendStatus.type === 'error' ? sendStatus.message : streamError ?? null;+ const failed = sendStatus.type === 'error' || !isNil(streamError);const wasCancelled = sendStatus.type === 'cancelled';@@ -1031,9 +1026,12 @@ export function useAgentChat({} else {setPersistedMessages(mapped);if (convResult.data.status === AgentConversationStatus.ERROR) {+ const failureIsInTranscript = mapped.at(-1)?.role === 'assistant';updateSendStatus({type: 'error',- message: t('The last reply did not finish. Please try again.'),+ message: failureIsInTranscript+ ? null+ : t('The last reply did not finish. Please try again.'),});}}@@ -1078,6 +1076,7 @@ export function useAgentChat({wasCancelled,isLoadingHistory,error,+ failed,sendMessage,retryLastMessage,cancelStream,