1- import { fetchEventSource } from "@microsoft/fetch-event-source" ;
1+ import {
2+ fetchEventSource ,
3+ type EventSourceMessage
4+ } from "@microsoft/fetch-event-source" ;
25import { useEffect , useRef , useState } from "react" ;
36import { useNavigate } from "react-router" ;
47import { useAgenticDispatch } from "../../../../containers/Agentic/hooks" ;
@@ -93,6 +96,11 @@ export const CreateIncidentChatOverlay = () => {
9396 setIncidentId (
9497 response . headers . get ( "agentic-conversation-id" ) ?? ""
9598 ) ;
99+ // eslint-disable-next-line no-console
100+ console . log (
101+ `[${ new Date ( ) . toISOString ( ) } ] Got conversation ID:` ,
102+ response . headers . get ( "agentic-conversation-id" ) ?? ""
103+ ) ;
96104 setIsStartMessageSending ( false ) ;
97105 return Promise . resolve ( ) ;
98106 } else {
@@ -102,26 +110,31 @@ export const CreateIncidentChatOverlay = () => {
102110 ) ;
103111 }
104112 } ,
105- // onmessage: (message: EventSourceMessage) => {
106- // if (message.data) {
107- // try {
108- // const parsedData = JSON.parse(
109- // message.data
110- // ) as IncidentAgentEvent;
111- // if (["human", "token"].includes(parsedData.type)) {
112- // setAccumulatedData((prev) =>
113- // prev ? [...prev, parsedData] : [parsedData]
114- // );
115- // }
116- // if (parsedData.type === "input_user_required") {
117- // setIsStartMessageSending(false);
118- // }
119- // } catch (error) {
120- // // eslint-disable-next-line no-console
121- // console.error("Error parsing message data:", error);
122- // }
123- // }
124- // },
113+ onmessage : ( message : EventSourceMessage ) => {
114+ // eslint-disable-next-line no-console
115+ console . log (
116+ `[${ new Date ( ) . toISOString ( ) } ] Received message:` ,
117+ message
118+ ) ;
119+ // if (message.data) {
120+ // try {
121+ // const parsedData = JSON.parse(
122+ // message.data
123+ // ) as IncidentAgentEvent;
124+ // if (["human", "token"].includes(parsedData.type)) {
125+ // setAccumulatedData((prev) =>
126+ // prev ? [...prev, parsedData] : [parsedData]
127+ // );
128+ // }
129+ // if (parsedData.type === "input_user_required") {
130+ // setIsStartMessageSending(false);
131+ // }
132+ // } catch (error) {
133+ // // eslint-disable-next-line no-console
134+ // console.error("Error parsing message data:", error);
135+ // }
136+ // }
137+ } ,
125138 onerror : ( err : unknown ) => {
126139 abortControllerRef . current = null ;
127140 setIsStartMessageSending ( false ) ;
@@ -138,10 +151,8 @@ export const CreateIncidentChatOverlay = () => {
138151 }
139152 }
140153 ) ;
141- }
142-
143- // Send subsequent messages to the incident creation chat
144- if ( incidentId ) {
154+ } else {
155+ // Send subsequent messages to the incident creation chat
145156 void sendMessage ( {
146157 incidentId,
147158 data : { text }
0 commit comments