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.esm.js CHANGED
@@ -653,8 +653,11 @@ const handleMessageLike = async (question, liked, setLoadingState, displaySnackM
653
653
  try {
654
654
  let request;
655
655
  if (currentMode === "agent") {
656
+ // Use the session stored on this specific message. The live sessionId is
657
+ // reset once a flow completes / awaits follow-up, so relying on it would
658
+ // send an empty session_id or the session of a newer chat.
656
659
  const agentPayload = {
657
- session_id: sessionId,
660
+ session_id: activeMessage?.chatSessionId || activeMessage?.sessionId || sessionId,
658
661
  liked,
659
662
  };
660
663
  request = await likeDislikeCommentForAgent(agentPayload, baseUrl);
@@ -5315,6 +5318,13 @@ const sseevent = (message, messageToStoreRef) => {
5315
5318
  ? parsedData.chat_id
5316
5319
  : "";
5317
5320
  messageToStoreRef.current.sessionId = parsedData?.session_id;
5321
+ // Sticky copy of the session id this message belongs to. sessionId gets
5322
+ // cleared on completed/follow-up so the next user message starts a fresh
5323
+ // session, but message level actions (like/dislike) still need to refer
5324
+ // to the session that actually produced this response.
5325
+ if (parsedData?.session_id) {
5326
+ messageToStoreRef.current.chatSessionId = parsedData.session_id;
5327
+ }
5318
5328
  }
5319
5329
  if (messageToStoreRef.current.currentMode === "navigation" &&
5320
5330
  parsedData?.session_id) {
@@ -9661,7 +9671,12 @@ const StreamedContent = ({ botData, botProps }) => {
9661
9671
  },
9662
9672
  };
9663
9673
  const hasStepFormWidgets = !isEmpty(stepFormDataMapRef.current);
9664
- processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9674
+ // response.session_id is intentionally blank once the flow completes, so
9675
+ // keep the retained session separately and stamp it on the stored message.
9676
+ const messageChatSessionId = messageToStoreRef.current.chatSessionId ||
9677
+ messageToStoreRef.current.sessionId ||
9678
+ "";
9679
+ Promise.resolve(processResponse(response, botData.inputBody, currentMode, botData.utilityObject.customChatConfig, {
9665
9680
  newChatData: chatDataInfoRef,
9666
9681
  isTabEnabled: true,
9667
9682
  steps: stepRef.current.map(s => ({ ...s })),
@@ -9669,7 +9684,15 @@ const StreamedContent = ({ botData, botProps }) => {
9669
9684
  questions: [...questionsRef.current],
9670
9685
  questionsStepsMap: { ...questionsStepsMapRef.current },
9671
9686
  stepFormDataMap: { ...stepFormDataMapRef.current },
9672
- }, activeConversationId);
9687
+ }, activeConversationId)).then(() => {
9688
+ if (!messageChatSessionId)
9689
+ return;
9690
+ const storedMessages = chatDataInfoRef.current?.[currentMode]?.conversations?.[activeConversationId]?.messages;
9691
+ if (storedMessages?.length) {
9692
+ storedMessages[storedMessages.length - 1].chatSessionId =
9693
+ messageChatSessionId;
9694
+ }
9695
+ });
9673
9696
  // [
9674
9697
  // {
9675
9698
  // header: "Finding relevant information",