Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(agent): clear the chat error when starting or switching threads
Sidwebworksec2565b1d1f5
diff --git a/apps/erp/app/modules/agent/hooks/useAgentThread.ts b/apps/erp/app/modules/agent/hooks/useAgentThread.tsindex 3e956213d5..9f28afe2f4 100644--- a/apps/erp/app/modules/agent/hooks/useAgentThread.ts+++ b/apps/erp/app/modules/agent/hooks/useAgentThread.ts@@ -167,16 +167,19 @@ export function useAgentThread() {++loadSeq.current;unsentRef.current = null;void stop();+ // stop() and setMessages() leave useChat's error in place.+ clearError();setMessages([]);setSendError(null);setThread(null);threadIdRef.current = null;- }, [setMessages, setThread, stop]);+ }, [clearError, setMessages, setThread, stop]);const loadThread = useCallback(async (id: string) => {const seq = ++loadSeq.current;void stop();+ clearError();setSendError(null);setThread(id);threadIdRef.current = id;@@ -193,7 +196,7 @@ export function useAgentThread() {if (seq !== loadSeq.current) return;setMessages(data.messages);},- [newThread, setMessages, setThread, stop]+ [clearError, newThread, setMessages, setThread, stop]);// Resume the last chat when the panel opens: if it mounted with a persisted thread