@hef2024/llmasaservice-ui 0.19.0 → 0.19.1

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
@@ -1670,6 +1670,7 @@ var ChatPanel = ({
1670
1670
  const continueChat = (suggestion) => {
1671
1671
  setThinkingBlocks([]);
1672
1672
  setCurrentThinkingIndex(0);
1673
+ setResponse("");
1673
1674
  if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
1674
1675
  const newId = (currentCustomer == null ? void 0 : currentCustomer.customer_id) && currentCustomer.customer_id !== "" && currentCustomer.customer_id !== (currentCustomer == null ? void 0 : currentCustomer.customer_user_email) ? currentCustomer.customer_id : emailInput;
1675
1676
  setEmailInputSet(true);
@@ -3898,6 +3899,7 @@ var AIChatPanel = ({
3898
3899
  setThinkingBlocks([]);
3899
3900
  setCurrentThinkingIndex(0);
3900
3901
  setUserHasScrolled(false);
3902
+ setResponse("");
3901
3903
  if (!idle) {
3902
3904
  stop(lastController);
3903
3905
  setHistory((prevHistory) => __spreadProps(__spreadValues({}, prevHistory), {
@@ -3994,7 +3996,8 @@ ${followOnPrompt}`;
3994
3996
  ensureConversation,
3995
3997
  dataWithExtras,
3996
3998
  scrollToBottom,
3997
- onConversationCreated
3999
+ onConversationCreated,
4000
+ setResponse
3998
4001
  ]);
3999
4002
  const handleSuggestionClick = (0, import_react11.useCallback)((question) => {
4000
4003
  continueChat(question);
@@ -4242,8 +4245,8 @@ ${followOnPrompt}`;
4242
4245
  ))), /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-thinking__content" }, cleanContentForDisplay(currentBlock.content)));
4243
4246
  }, [thinkingBlocks, currentThinkingIndex, cleanContentForDisplay]);
4244
4247
  const panelClasses = ["ai-chat-panel", theme === "dark" ? "dark-theme" : ""].filter(Boolean).join(" ");
4245
- return /* @__PURE__ */ import_react11.default.createElement("div", { className: panelClasses }, title && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-panel__title" }, title), /* @__PURE__ */ import_react11.default.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__content" }, /* @__PURE__ */ import_react11.default.createElement(import_react_markdown2.default, { remarkPlugins: [import_remark_gfm2.default], rehypePlugins: [import_rehype_raw2.default] }, initialMessage))), Object.entries(history).map(([prompt, entry], index) => {
4246
- const isLastEntry = index === Object.keys(history).length - 1;
4248
+ return /* @__PURE__ */ import_react11.default.createElement("div", { className: panelClasses }, title && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-panel__title" }, title), /* @__PURE__ */ import_react11.default.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "ai-chat-message__content" }, /* @__PURE__ */ import_react11.default.createElement(import_react_markdown2.default, { remarkPlugins: [import_remark_gfm2.default], rehypePlugins: [import_rehype_raw2.default] }, initialMessage))), Object.entries(history).map(([prompt, entry], index, entries) => {
4249
+ const isLastEntry = index === entries.length - 1;
4247
4250
  const isSystemMessage = prompt.startsWith("__system__:");
4248
4251
  const { cleanedText } = processThinkingTags(entry.content);
4249
4252
  const processedContent = processActions(cleanedText);
package/dist/index.mjs CHANGED
@@ -1631,6 +1631,7 @@ var ChatPanel = ({
1631
1631
  const continueChat = (suggestion) => {
1632
1632
  setThinkingBlocks([]);
1633
1633
  setCurrentThinkingIndex(0);
1634
+ setResponse("");
1634
1635
  if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
1635
1636
  const newId = (currentCustomer == null ? void 0 : currentCustomer.customer_id) && currentCustomer.customer_id !== "" && currentCustomer.customer_id !== (currentCustomer == null ? void 0 : currentCustomer.customer_user_email) ? currentCustomer.customer_id : emailInput;
1636
1637
  setEmailInputSet(true);
@@ -3865,6 +3866,7 @@ var AIChatPanel = ({
3865
3866
  setThinkingBlocks([]);
3866
3867
  setCurrentThinkingIndex(0);
3867
3868
  setUserHasScrolled(false);
3869
+ setResponse("");
3868
3870
  if (!idle) {
3869
3871
  stop(lastController);
3870
3872
  setHistory((prevHistory) => __spreadProps(__spreadValues({}, prevHistory), {
@@ -3961,7 +3963,8 @@ ${followOnPrompt}`;
3961
3963
  ensureConversation,
3962
3964
  dataWithExtras,
3963
3965
  scrollToBottom,
3964
- onConversationCreated
3966
+ onConversationCreated,
3967
+ setResponse
3965
3968
  ]);
3966
3969
  const handleSuggestionClick = useCallback2((question) => {
3967
3970
  continueChat(question);
@@ -4209,8 +4212,8 @@ ${followOnPrompt}`;
4209
4212
  ))), /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-thinking__content" }, cleanContentForDisplay(currentBlock.content)));
4210
4213
  }, [thinkingBlocks, currentThinkingIndex, cleanContentForDisplay]);
4211
4214
  const panelClasses = ["ai-chat-panel", theme === "dark" ? "dark-theme" : ""].filter(Boolean).join(" ");
4212
- return /* @__PURE__ */ React11.createElement("div", { className: panelClasses }, title && /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-panel__title" }, title), /* @__PURE__ */ React11.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-message__content" }, /* @__PURE__ */ React11.createElement(ReactMarkdown2, { remarkPlugins: [remarkGfm2], rehypePlugins: [rehypeRaw2] }, initialMessage))), Object.entries(history).map(([prompt, entry], index) => {
4213
- const isLastEntry = index === Object.keys(history).length - 1;
4215
+ return /* @__PURE__ */ React11.createElement("div", { className: panelClasses }, title && /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-panel__title" }, title), /* @__PURE__ */ React11.createElement(ScrollArea, { className: "ai-chat-panel__messages", ref: responseAreaRef }, initialMessage && /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-message ai-chat-message--assistant" }, /* @__PURE__ */ React11.createElement("div", { className: "ai-chat-message__content" }, /* @__PURE__ */ React11.createElement(ReactMarkdown2, { remarkPlugins: [remarkGfm2], rehypePlugins: [rehypeRaw2] }, initialMessage))), Object.entries(history).map(([prompt, entry], index, entries) => {
4216
+ const isLastEntry = index === entries.length - 1;
4214
4217
  const isSystemMessage = prompt.startsWith("__system__:");
4215
4218
  const { cleanedText } = processThinkingTags(entry.content);
4216
4219
  const processedContent = processActions(cleanedText);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hef2024/llmasaservice-ui",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1042,6 +1042,11 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1042
1042
  // Reset scroll tracking for new message - enable auto-scroll
1043
1043
  setUserHasScrolled(false);
1044
1044
 
1045
+ // IMPORTANT: Clear the response BEFORE setting new lastKey
1046
+ // This prevents the old response from being written to the new history entry
1047
+ // when the history update effect runs
1048
+ setResponse('');
1049
+
1045
1050
  // Handle stop if not idle (matches ChatPanel)
1046
1051
  if (!idle) {
1047
1052
  stop(lastController);
@@ -1174,6 +1179,7 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1174
1179
  dataWithExtras,
1175
1180
  scrollToBottom,
1176
1181
  onConversationCreated,
1182
+ setResponse,
1177
1183
  ]);
1178
1184
 
1179
1185
  // Handle suggestion click - directly sends like ChatPanel does
@@ -1635,8 +1641,8 @@ const AIChatPanel: React.FC<AIChatPanelProps> = ({
1635
1641
  )}
1636
1642
 
1637
1643
  {/* History */}
1638
- {Object.entries(history).map(([prompt, entry], index) => {
1639
- const isLastEntry = index === Object.keys(history).length - 1;
1644
+ {Object.entries(history).map(([prompt, entry], index, entries) => {
1645
+ const isLastEntry = index === entries.length - 1;
1640
1646
  // Check if this is a system message (injected by page context, etc.)
1641
1647
  const isSystemMessage = prompt.startsWith('__system__:');
1642
1648
  // Process thinking tags first, then apply actions at render time
package/src/ChatPanel.tsx CHANGED
@@ -2154,6 +2154,11 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
2154
2154
  setThinkingBlocks([]);
2155
2155
  setCurrentThinkingIndex(0);
2156
2156
 
2157
+ // IMPORTANT: Clear the response BEFORE setting new lastKey
2158
+ // This prevents the old response from being written to the new history entry
2159
+ // when the history update effect runs
2160
+ setResponse("");
2161
+
2157
2162
  // Auto-set email if valid before proceeding
2158
2163
  if (emailInput && isEmailAddress(emailInput) && !emailInputSet) {
2159
2164
  const newId =