fix: commands clear in-progress state + per_type config rebuilt in DB

Two fixes:
1. Any command (menu, salir, etc.) now clears collecting/__foreach/__cap
   meta before executing, so navigation commands are always a clean reset
   regardless of what flow the user was in.

2. DB per_type was empty ([]); rebuilt with correct structure:
   - Type 1: greeting=submenu_subir, menu/inicio/volver → recibir_info
   - Type 2: greeting=submenu_informes, menu/inicio/volver → descargar_informes
   - Type 3: greeting=show_main_menu, inherits global commands

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-29 11:42:56 -05:00
co-authored by Claude Sonnet 4.6
parent b2abece097
commit 16a03b546d
+8
View File
@@ -22,6 +22,14 @@ class NormalBot
// 1. Commands always win — escape from any state (salir, menu, etc.)
foreach ($commands as $keyword => $action) {
if ($normalized === self::normalize((string)$keyword)) {
// Clear any in-progress multi-step state so the command is a clean reset
$m = ConversationContext::getMetadata($ctxId);
$dirty = false;
foreach (['collecting', '__foreach', '__cap'] as $stateKey) {
if (isset($m[$stateKey])) { unset($m[$stateKey]); $dirty = true; }
}
if ($dirty) ConversationContext::updateMetadata($ctxId, $m);
ConversationContext::updateNode($ctxId, $action);
// Commands that match a flow
if (isset($flows[$action])) {