lisichatbot 2.0.2 → 2.0.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 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisichatbot",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
package/src/index.js CHANGED
@@ -580,7 +580,19 @@ function renderMultiSelectDropdown(options, field) {
580
580
  // ✅ Initial tag render if pre-filled (edit mode)
581
581
  if (selectedValues.size > 0) {
582
582
  renderTags(field, options, tagsContainer, tagTemplateClone, optionsContainer);
583
+
584
+ // ✅ NEW: Set currentSelection for pre-filled data so user message shows
585
+ chatState.currentSelection = {
586
+ field,
587
+ value: existingData,
588
+ name: existingData.map(v => {
589
+ const opt = options.find(o => o.value === v);
590
+ return opt ? opt.name : v;
591
+ }).join(', ')
592
+ };
593
+
583
594
  console.log(` ✅ Pre-filled ${selectedValues.size} selections, Next button enabled`);
595
+ console.log(` 📝 Set currentSelection.name: "${chatState.currentSelection.name}"`);
584
596
  }
585
597
 
586
598
  elements.messages.appendChild(clone);
@@ -3183,6 +3195,26 @@ async function showNextStep() {
3183
3195
  console.log(` ⏱️ Auto-advance delay: ${delay}ms ${nextStep.autoAdvanceDelay !== undefined ? '(step-level)' : '(global)'}`);
3184
3196
 
3185
3197
  setTimeout(() => {
3198
+ // ✅ NEW: Add user message if there's a currentSelection (pre-filled value)
3199
+ if (chatState.currentSelection && chatState.currentSelection.name) {
3200
+ const prefix = nextStep.input?.selectedInputPrefix || '';
3201
+ const suffix = nextStep.input?.selectedInputSuffix || '';
3202
+ let displayName = chatState.currentSelection.name;
3203
+
3204
+ if (prefix) displayName = `${prefix} ${displayName}`;
3205
+ if (suffix) displayName = `${displayName} ${suffix}`;
3206
+
3207
+ console.log(`📝 Adding user message for auto-advance: "${displayName}"`);
3208
+ addMessage(displayName, 'user', false, chatState.step);
3209
+
3210
+ chatState.history.push({
3211
+ step: chatState.step,
3212
+ field: chatState.currentSelection.field,
3213
+ value: chatState.currentSelection.value,
3214
+ displayName: displayName
3215
+ });
3216
+ }
3217
+
3186
3218
  // ✅ NEW: Find next accessible step
3187
3219
  chatState.step = findNextAccessibleStep(chatState.step);
3188
3220
  updateEditIcons();