lisichatbot 1.4.2 → 1.4.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +18 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -1815,6 +1815,21 @@ async function handleNext() {
1815
1815
  }
1816
1816
  }
1817
1817
 
1818
+ // ✅ FIX: Remove old user message for this step (if exists)
1819
+ // This handles cases where user edits and changes/deselects their answer
1820
+ const existingUserMessage = elements.messages.querySelector(
1821
+ `[data-chat-element="user-message-wrapper"][data-chat-step="${chatState.step}"]`
1822
+ );
1823
+ if (existingUserMessage) {
1824
+ existingUserMessage.remove();
1825
+ console.log(` đŸ—‘ī¸ Removed old user message for step ${chatState.step}`);
1826
+ }
1827
+
1828
+ // ✅ FIX: Remove from history for this step
1829
+ chatState.history = chatState.history.filter(h => h.step !== chatState.step);
1830
+ console.log(` đŸ—‘ī¸ Cleared history for step ${chatState.step}`);
1831
+
1832
+ // ✅ Only add new user message if there's a selection
1818
1833
  if (chatState.currentSelection) {
1819
1834
  const inputConfig = currentStep.input || {};
1820
1835
  const valueType = inputConfig.selectedInputValueType;
@@ -1834,6 +1849,7 @@ async function handleNext() {
1834
1849
  if (suffix) displayName = `${displayName} ${suffix}`;
1835
1850
 
1836
1851
  addMessage(displayName, 'user', false, chatState.step);
1852
+ console.log(` ✅ Added new user message: "${displayName}"`);
1837
1853
 
1838
1854
  chatState.history.push({
1839
1855
  step: chatState.step,
@@ -1841,6 +1857,8 @@ async function handleNext() {
1841
1857
  value: chatState.currentSelection.value,
1842
1858
  name: displayName
1843
1859
  });
1860
+ } else {
1861
+ console.log(` â„šī¸ No selection - no user message added (deselected or optional empty)`);
1844
1862
  }
1845
1863
 
1846
1864
  chatState.currentSelection = null;