@informedai/react 0.4.3 → 0.4.4

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
@@ -541,13 +541,13 @@ function InformedAIProvider({ config, children }) {
541
541
  await clientRef.current.sendMessage(session.id, message, handleSSEEvent);
542
542
  } catch (err) {
543
543
  if (isSessionNotFoundError(err)) {
544
- setIsStreaming(false);
545
544
  await handleSessionDeleted();
546
545
  return;
547
546
  }
548
547
  const error2 = err instanceof Error ? err : new Error("Failed to send message");
549
548
  setError(error2);
550
549
  config.onError?.(error2);
550
+ } finally {
551
551
  setIsStreaming(false);
552
552
  }
553
553
  }, [session, handleSSEEvent, handleSessionDeleted, config]);
@@ -886,12 +886,13 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
886
886
  gap: "12px"
887
887
  },
888
888
  children: [
889
- session?.widgetMessages.map((msg) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
889
+ session?.widgetMessages.map((msg, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
890
890
  MessageBubble,
891
891
  {
892
892
  message: msg,
893
893
  theme,
894
- onQuickAction: handleQuickAction
894
+ onQuickAction: handleQuickAction,
895
+ isLatest: index === session.widgetMessages.length - 1
895
896
  },
896
897
  msg.id
897
898
  )),
@@ -1069,9 +1070,9 @@ function QuickActionButton({
1069
1070
  }
1070
1071
  );
1071
1072
  }
1072
- function MessageBubble({ message, theme, onQuickAction }) {
1073
+ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1073
1074
  const isUser = message.role === "user";
1074
- const hasQuickActions = message.quickActions && message.quickActions.length > 0;
1075
+ const hasQuickActions = isLatest && message.quickActions && message.quickActions.length > 0;
1075
1076
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
1076
1077
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
1077
1078
  display: "flex",
package/dist/index.mjs CHANGED
@@ -511,13 +511,13 @@ function InformedAIProvider({ config, children }) {
511
511
  await clientRef.current.sendMessage(session.id, message, handleSSEEvent);
512
512
  } catch (err) {
513
513
  if (isSessionNotFoundError(err)) {
514
- setIsStreaming(false);
515
514
  await handleSessionDeleted();
516
515
  return;
517
516
  }
518
517
  const error2 = err instanceof Error ? err : new Error("Failed to send message");
519
518
  setError(error2);
520
519
  config.onError?.(error2);
520
+ } finally {
521
521
  setIsStreaming(false);
522
522
  }
523
523
  }, [session, handleSSEEvent, handleSessionDeleted, config]);
@@ -856,12 +856,13 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
856
856
  gap: "12px"
857
857
  },
858
858
  children: [
859
- session?.widgetMessages.map((msg) => /* @__PURE__ */ jsx2(
859
+ session?.widgetMessages.map((msg, index) => /* @__PURE__ */ jsx2(
860
860
  MessageBubble,
861
861
  {
862
862
  message: msg,
863
863
  theme,
864
- onQuickAction: handleQuickAction
864
+ onQuickAction: handleQuickAction,
865
+ isLatest: index === session.widgetMessages.length - 1
865
866
  },
866
867
  msg.id
867
868
  )),
@@ -1039,9 +1040,9 @@ function QuickActionButton({
1039
1040
  }
1040
1041
  );
1041
1042
  }
1042
- function MessageBubble({ message, theme, onQuickAction }) {
1043
+ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1043
1044
  const isUser = message.role === "user";
1044
- const hasQuickActions = message.quickActions && message.quickActions.length > 0;
1045
+ const hasQuickActions = isLatest && message.quickActions && message.quickActions.length > 0;
1045
1046
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
1046
1047
  return /* @__PURE__ */ jsxs("div", { style: {
1047
1048
  display: "flex",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
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",