diff --git a/frontend/app/components/Kai/SocketManager.ts b/frontend/app/components/Kai/SocketManager.ts index e7711b6fe..e34ccc155 100644 --- a/frontend/app/components/Kai/SocketManager.ts +++ b/frontend/app/components/Kai/SocketManager.ts @@ -28,6 +28,7 @@ export class ChatManager { query: { project_id: projectId, thread_id: threadId, + timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }, auth: { token: `Bearer ${token}`, @@ -46,15 +47,26 @@ export class ChatManager { this.socket = socket; } + reconnect = () => { + this.socket.connect(); + }; + sendMessage = (message: string, isReplace = false) => { - this.socket.emit( - 'message', - JSON.stringify({ - message, - threadId: this.threadId, - replace: isReplace, - }), - ); + if (!this.socket.connected) { + this.reconnect(); + setTimeout(() => { + this.sendMessage(message, isReplace); + }, 500); + } else { + this.socket.emit( + 'message', + JSON.stringify({ + message, + threadId: this.threadId, + replace: isReplace, + }), + ); + } }; setOnMsgHook = ({ diff --git a/frontend/app/utils/split-utils.ts b/frontend/app/utils/split-utils.ts index bb0b27971..e17306a4c 100644 --- a/frontend/app/utils/split-utils.ts +++ b/frontend/app/utils/split-utils.ts @@ -2,4 +2,4 @@ * can be overwritten in saas or ee editions * */ -export const hasAi = false; +export const hasAi = true//false;