impact-chatbot 2.3.84 → 2.3.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -675,8 +675,11 @@ const handleMessageLike = async (question, liked, setLoadingState, displaySnackM
675
675
  try {
676
676
  let request;
677
677
  if (currentMode === "agent") {
678
+ // Use the session stored on this specific message. The live sessionId is
679
+ // reset once a flow completes / awaits follow-up, so relying on it would
680
+ // send an empty session_id or the session of a newer chat.
678
681
  const agentPayload = {
679
- session_id: sessionId,
682
+ session_id: activeMessage?.chatSessionId || activeMessage?.sessionId || sessionId,
680
683
  liked,
681
684
  };
682
685
  request = await likeDislikeCommentForAgent(agentPayload, baseUrl);
@@ -5337,6 +5340,13 @@ const sseevent = (message, messageToStoreRef) => {
5337
5340
  ? parsedData.chat_id
5338
5341
  : "";
5339
5342
  messageToStoreRef.current.sessionId = parsedData?.session_id;
5343
+ // Sticky copy of the session id this message belongs to. sessionId gets
5344
+ // cleared on completed/follow-up so the next user message starts a fresh
5345
+ // session, but message level actions (like/dislike) still need to refer
5346
+ // to the session that actually produced this response.
5347
+ if (parsedData?.session_id) {
5348
+ messageToStoreRef.current.chatSessionId = parsedData.session_id;
5349
+ }
5340
5350
  }
5341
5351
  if (messageToStoreRef.current.currentMode === "navigation" &&
5342
5352
  parsedData?.session_id) {
@@ -9683,7 +9693,12 @@ const StreamedContent = ({ botData, botProps }) => {
9683
9693
  },
9684
9694
  };
9685
9695
  const hasStepFormWidgets = !isEmpty(stepFormDataMapRef.current);
9686
- processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9696
+ // response.session_id is intentionally blank once the flow completes, so
9697
+ // keep the retained session separately and stamp it on the stored message.
9698
+ const messageChatSessionId = messageToStoreRef.current.chatSessionId ||
9699
+ messageToStoreRef.current.sessionId ||
9700
+ "";
9701
+ Promise.resolve(processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9687
9702
  newChatData: chatDataInfoRef,
9688
9703
  isTabEnabled: true,
9689
9704
  steps: stepRef.current.map(s => ({ ...s })),
@@ -9691,7 +9706,15 @@ const StreamedContent = ({ botData, botProps }) => {
9691
9706
  questions: [...questionsRef.current],
9692
9707
  questionsStepsMap: { ...questionsStepsMapRef.current },
9693
9708
  stepFormDataMap: { ...stepFormDataMapRef.current },
9694
- }, activeConversationId);
9709
+ }, activeConversationId)).then(() => {
9710
+ if (!messageChatSessionId)
9711
+ return;
9712
+ const storedMessages = chatDataInfoRef.current?.[currentMode]?.conversations?.[activeConversationId]?.messages;
9713
+ if (storedMessages?.length) {
9714
+ storedMessages[storedMessages.length - 1].chatSessionId =
9715
+ messageChatSessionId;
9716
+ }
9717
+ });
9695
9718
  // [
9696
9719
  // {
9697
9720
  // header: "Finding relevant information",