SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
Enhance Chat Actions: Add error handling to onResponse callback
Salman-Ahamed0a0d1a8f7877
diff --git a/packages/app/src/react/features/ai-chat/hooks/use-chat-actions.ts b/packages/app/src/react/features/ai-chat/hooks/use-chat-actions.tsindex ed77dd23..dcbe5498 100644--- a/packages/app/src/react/features/ai-chat/hooks/use-chat-actions.ts+++ b/packages/app/src/react/features/ai-chat/hooks/use-chat-actions.ts@@ -115,7 +115,7 @@ export const useChatActions = ({fileKeys: attachedFiles?.map((f) => f.metadata.key).filter(Boolean) as string[],chatId,signal,- onResponse: (value: string) => {+ onResponse: (value: string, errorInfo?: { isError?: boolean; errorType?: string }) => {setChatHistoryMessages((bubbles) => {// Only remove thinking messages if we have actual contentif (value && value.trim() !== '') {@@ -129,11 +129,11 @@ export const useChatActions = ({.pop()?.index ?? -1;if (lastSystemMessageIndex !== -1) {- // Update the system message with final response+ // Update the system message with final response and error infoconst updatedBubbles = [...filteredBubbles];updatedBubbles[lastSystemMessageIndex].message = value;updatedBubbles[lastSystemMessageIndex].isReplying = false;- updatedBubbles[lastSystemMessageIndex].isError = false;+ updatedBubbles[lastSystemMessageIndex].isError = errorInfo?.isError || false;updatedBubbles[lastSystemMessageIndex].hideMessageBubble = false; // Show the message bubblereturn updatedBubbles;}@@ -292,7 +292,7 @@ export const useChatActions = ({.filter(Boolean) as string[],chatId,signal,- onResponse: (value: string) => {+ onResponse: (value: string, errorInfo?: { isError?: boolean; errorType?: string }) => {setChatHistoryMessages((bubbles) => {// Only remove thinking messages if we have actual contentif (value && value.trim() !== '') {@@ -306,11 +306,11 @@ export const useChatActions = ({.pop()?.index ?? -1;if (lastSystemMessageIndex !== -1) {- // Update the system message with final response+ // Update the system message with final response and error infoconst updatedBubbles = [...filteredBubbles];updatedBubbles[lastSystemMessageIndex].message = value;updatedBubbles[lastSystemMessageIndex].isReplying = false;- updatedBubbles[lastSystemMessageIndex].isError = false;+ updatedBubbles[lastSystemMessageIndex].isError = errorInfo?.isError || false;updatedBubbles[lastSystemMessageIndex].hideMessageBubble = false;return updatedBubbles;}