Skip to content

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.

refactor: url param for chat

Brad Barbin54c8ac9d4ecb
diff --git a/apps/erp/app/components/Chat/hooks/useChatInterface.tsx b/apps/erp/app/components/Chat/hooks/useChatInterface.tsx
index bc39aa4378..00b6607b3f 100644
--- a/apps/erp/app/components/Chat/hooks/useChatInterface.tsx
+++ b/apps/erp/app/components/Chat/hooks/useChatInterface.tsx
@@ -1,27 +1,26 @@
import { useMount } from "@carbon/react";
-import { useUrlParams } from "@carbon/remix";
-import { useLocation } from "@remix-run/react";
+import { useOptimisticLocation, useUrlParams } from "@carbon/remix";
import { generateId } from "ai";
import { useCallback } from "react";
import { path } from "~/utils/path";
export function useChatInterface() {
const [params, setParams] = useUrlParams();
- const location = useLocation();
- const chatId = params.get("chatId") || null;
+ const location = useOptimisticLocation();
+ const chatId = params.get("c") || null;
const isChatPage = !!chatId;
const isHome = location.pathname === path.to.authenticatedRoot;
useMount(() => {
if (isHome && !chatId) {
- setParams({ chatId: generateId() });
+ setParams({ c: generateId() });
}
});
const setChatId = useCallback(
(id: string) => {
- setParams({ chatId: id });
+ setParams({ c: id });
},
[setParams]
);