lisichatbot 1.5.2 → 1.5.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 +32 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -1880,6 +1880,36 @@ async function handleNext() {
1880
1880
  }
1881
1881
  }
1882
1882
 
1883
+ // ✅ NEW: Add user message BEFORE onNext executes (for autoAdvance flows)
1884
+ if (chatState.currentSelection) {
1885
+ const inputConfig = currentStep.input || {};
1886
+ const valueType = inputConfig.selectedInputValueType;
1887
+ const prefix = inputConfig.selectedInputPrefix || '';
1888
+ const suffix = inputConfig.selectedInputSuffix || '';
1889
+
1890
+ let displayName = chatState.currentSelection.name;
1891
+
1892
+ if (valueType === 'arrayRange' && Array.isArray(chatState.currentSelection.value)) {
1893
+ const [min, max] = chatState.currentSelection.value;
1894
+ const formattedMin = min.toLocaleString();
1895
+ const formattedMax = max.toLocaleString();
1896
+ displayName = `${formattedMin} - ${formattedMax}`;
1897
+ }
1898
+
1899
+ if (prefix) displayName = `${prefix} ${displayName}`;
1900
+ if (suffix) displayName = `${displayName} ${suffix}`;
1901
+
1902
+ console.log(`📝 Adding user message before onNext: "${displayName}"`);
1903
+ addMessage(displayName, 'user', false, chatState.step);
1904
+
1905
+ chatState.history.push({
1906
+ step: chatState.step,
1907
+ field: chatState.currentSelection.field,
1908
+ value: chatState.currentSelection.value,
1909
+ displayName: displayName
1910
+ });
1911
+ }
1912
+
1883
1913
  if (currentStep.onNext) {
1884
1914
  try {
1885
1915
  disableNextButton();
@@ -2019,34 +2049,8 @@ async function handleNext() {
2019
2049
  }
2020
2050
  }
2021
2051
 
2022
- if (chatState.currentSelection) {
2023
- const inputConfig = currentStep.input || {};
2024
- const valueType = inputConfig.selectedInputValueType;
2025
- const prefix = inputConfig.selectedInputPrefix || '';
2026
- const suffix = inputConfig.selectedInputSuffix || '';
2027
-
2028
- let displayName = chatState.currentSelection.name;
2029
-
2030
- if (valueType === 'arrayRange' && Array.isArray(chatState.currentSelection.value)) {
2031
- const [min, max] = chatState.currentSelection.value;
2032
- const formattedMin = min.toLocaleString();
2033
- const formattedMax = max.toLocaleString();
2034
- displayName = `${formattedMin} - ${formattedMax}`;
2035
- }
2036
-
2037
- if (prefix) displayName = `${prefix} ${displayName}`;
2038
- if (suffix) displayName = `${displayName} ${suffix}`;
2039
-
2040
- addMessage(displayName, 'user', false, chatState.step);
2041
-
2042
- chatState.history.push({
2043
- step: chatState.step,
2044
- field: chatState.currentSelection.field,
2045
- value: chatState.currentSelection.value,
2046
- name: displayName
2047
- });
2048
- }
2049
-
2052
+ // ✅ User message already added before onNext (line ~1883)
2053
+ // Clear current selection to prevent duplicate messages
2050
2054
  chatState.currentSelection = null;
2051
2055
  disableNextButton();
2052
2056