@informedai/react 0.4.13 → 0.4.14

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.js CHANGED
@@ -755,14 +755,15 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
755
755
  streamingContent,
756
756
  sendMessage,
757
757
  sendQuickAction,
758
- applyPendingValue,
759
- skipTask
758
+ applyPendingValue
760
759
  } = useInformedAI();
761
760
  const [isCollapsed, setIsCollapsed] = (0, import_react2.useState)(defaultCollapsed);
762
761
  const [inputValue, setInputValue] = (0, import_react2.useState)("");
762
+ const [showPendingActions, setShowPendingActions] = (0, import_react2.useState)(true);
763
763
  const messagesEndRef = (0, import_react2.useRef)(null);
764
764
  const inputRef = (0, import_react2.useRef)(null);
765
765
  const wasStreamingRef = (0, import_react2.useRef)(false);
766
+ const lastPendingValueRef = (0, import_react2.useRef)(void 0);
766
767
  (0, import_react2.useEffect)(() => {
767
768
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
768
769
  }, [session?.widgetMessages, streamingContent]);
@@ -772,6 +773,15 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
772
773
  }
773
774
  wasStreamingRef.current = isStreaming;
774
775
  }, [isStreaming]);
776
+ const activeTask = session?.activeTask;
777
+ const pendingValue = activeTask ? session?.taskStates[activeTask]?.pendingValue : void 0;
778
+ const hasPendingValue = pendingValue !== void 0 && pendingValue !== null;
779
+ (0, import_react2.useEffect)(() => {
780
+ if (hasPendingValue && pendingValue !== lastPendingValueRef.current) {
781
+ setShowPendingActions(true);
782
+ }
783
+ lastPendingValueRef.current = pendingValue;
784
+ }, [hasPendingValue, pendingValue]);
775
785
  const handleSubmit = async (e) => {
776
786
  e.preventDefault();
777
787
  if (!inputValue.trim() || isStreaming) return;
@@ -782,9 +792,6 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
782
792
  const handleQuickAction = async (action) => {
783
793
  await sendQuickAction(action.action, action.payload);
784
794
  };
785
- const activeTask = session?.activeTask;
786
- const pendingValue = activeTask ? session?.taskStates[activeTask]?.pendingValue : void 0;
787
- const hasPendingValue = pendingValue !== void 0 && pendingValue !== null;
788
795
  const cssVars = {
789
796
  "--ia-primary": theme.primaryColor,
790
797
  "--ia-bg": theme.backgroundColor,
@@ -981,7 +988,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
981
988
  ]
982
989
  }
983
990
  ),
984
- hasPendingValue && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
991
+ hasPendingValue && showPendingActions ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
985
992
  "div",
986
993
  {
987
994
  style: {
@@ -1015,7 +1022,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
1015
1022
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1016
1023
  "button",
1017
1024
  {
1018
- onClick: skipTask,
1025
+ onClick: () => setShowPendingActions(false),
1019
1026
  disabled: isStreaming,
1020
1027
  style: {
1021
1028
  padding: "10px 16px",
@@ -1028,13 +1035,12 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
1028
1035
  fontSize: "14px",
1029
1036
  opacity: isStreaming ? 0.5 : 1
1030
1037
  },
1031
- children: "Skip"
1038
+ children: "Not yet"
1032
1039
  }
1033
1040
  )
1034
1041
  ]
1035
1042
  }
1036
- ),
1037
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1043
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1038
1044
  "form",
1039
1045
  {
1040
1046
  onSubmit: handleSubmit,
package/dist/index.mjs CHANGED
@@ -725,14 +725,15 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
725
725
  streamingContent,
726
726
  sendMessage,
727
727
  sendQuickAction,
728
- applyPendingValue,
729
- skipTask
728
+ applyPendingValue
730
729
  } = useInformedAI();
731
730
  const [isCollapsed, setIsCollapsed] = useState2(defaultCollapsed);
732
731
  const [inputValue, setInputValue] = useState2("");
732
+ const [showPendingActions, setShowPendingActions] = useState2(true);
733
733
  const messagesEndRef = useRef2(null);
734
734
  const inputRef = useRef2(null);
735
735
  const wasStreamingRef = useRef2(false);
736
+ const lastPendingValueRef = useRef2(void 0);
736
737
  useEffect2(() => {
737
738
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
738
739
  }, [session?.widgetMessages, streamingContent]);
@@ -742,6 +743,15 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
742
743
  }
743
744
  wasStreamingRef.current = isStreaming;
744
745
  }, [isStreaming]);
746
+ const activeTask = session?.activeTask;
747
+ const pendingValue = activeTask ? session?.taskStates[activeTask]?.pendingValue : void 0;
748
+ const hasPendingValue = pendingValue !== void 0 && pendingValue !== null;
749
+ useEffect2(() => {
750
+ if (hasPendingValue && pendingValue !== lastPendingValueRef.current) {
751
+ setShowPendingActions(true);
752
+ }
753
+ lastPendingValueRef.current = pendingValue;
754
+ }, [hasPendingValue, pendingValue]);
745
755
  const handleSubmit = async (e) => {
746
756
  e.preventDefault();
747
757
  if (!inputValue.trim() || isStreaming) return;
@@ -752,9 +762,6 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
752
762
  const handleQuickAction = async (action) => {
753
763
  await sendQuickAction(action.action, action.payload);
754
764
  };
755
- const activeTask = session?.activeTask;
756
- const pendingValue = activeTask ? session?.taskStates[activeTask]?.pendingValue : void 0;
757
- const hasPendingValue = pendingValue !== void 0 && pendingValue !== null;
758
765
  const cssVars = {
759
766
  "--ia-primary": theme.primaryColor,
760
767
  "--ia-bg": theme.backgroundColor,
@@ -951,7 +958,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
951
958
  ]
952
959
  }
953
960
  ),
954
- hasPendingValue && /* @__PURE__ */ jsxs(
961
+ hasPendingValue && showPendingActions ? /* @__PURE__ */ jsxs(
955
962
  "div",
956
963
  {
957
964
  style: {
@@ -985,7 +992,7 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
985
992
  /* @__PURE__ */ jsx2(
986
993
  "button",
987
994
  {
988
- onClick: skipTask,
995
+ onClick: () => setShowPendingActions(false),
989
996
  disabled: isStreaming,
990
997
  style: {
991
998
  padding: "10px 16px",
@@ -998,13 +1005,12 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
998
1005
  fontSize: "14px",
999
1006
  opacity: isStreaming ? 0.5 : 1
1000
1007
  },
1001
- children: "Skip"
1008
+ children: "Not yet"
1002
1009
  }
1003
1010
  )
1004
1011
  ]
1005
1012
  }
1006
- ),
1007
- /* @__PURE__ */ jsxs(
1013
+ ) : /* @__PURE__ */ jsxs(
1008
1014
  "form",
1009
1015
  {
1010
1016
  onSubmit: handleSubmit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "description": "React SDK for InformedAI Assistant - AI-powered content creation widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",