Skip to content

fix(bot): honor nested capture and WELCOME fallbacks - #1293

Merged
leifermendez merged 1 commit into
builderbotfrom
feat/core-handlemsg-fallbacks
Nov 18, 2026
Merged

leifermendez merged 1 commit into
builderbotfrom
feat/core-handlemsg-fallbacks

Conversation

@leifermendez

Copy link
Copy Markdown
Member

Que tipo de Pull Request es?

  • Mejoras
  • Bug
  • Docs / tests

Descripción

The behaviour changes that were bundled into #1281, split out after the Redis feature already landed in #1292.

Unit A (Redis adapter + persistent state) is merged as 09638c12. This is unit B, which no longer touches Redis at all.

Cambios

Archivo Cambio
packages/bot/src/core/coreClass.ts Nested flow with no match and a pending capture now processes as free capture instead of falling through to global keywords; the capture branch guards on a non-empty match and tolerates a missing refToContinue ref; WELCOME is evaluated last, only when no event keyword matched
packages/bot/src/io/methods/addAnswer.ts Step ref derived deterministically from the parent ref, so repeated .addAnswer() on the same node keeps one stable callback key instead of a random ans_<uuid>
packages/bot/src/utils/interactive.ts BUILDERBOT_SILENT env flag silences printer output
scripts/generate/index.ts Normalize CRLF before rewriting starter entry points
packages/bot/__tests__/** New 0.2.5-handlemsg-fallbacks suite (4 cases) plus updated coreClass, events and 0.0.1-flow-events expectations

Comportamiento que cambia

  1. Orden de fallback: antes WELCOME se asignaba al entrar al bloque de eventos y cualquier evento podía sobrescribirlo; ahora solo se usa si ningún keyword coincidió. Un bot que dependía de que WELCOME respondiera además de un evento ya no duplicará respuesta.
  2. Nested + capture: si el flujo hijo no matchea y el mensaje previo pedía captura, se procesa como captura libre, en lugar de buscar keywords globales.
  3. Refs de addAnswer: pasan a ser deterministas (<ref>A). Antes cada .addAnswer() generaba un ans_<uuid>; dos .addAnswer() sobre el mismo nodo ahora comparten ref, así que el último callback registrado es el que gana.
  4. Silencio opcional: BUILDERBOT_SILENT solo cambia salida por consola.

Verificación ejecutada

Check Resultado
packages/bot suite completa 235 passed, 1 skip preexistente
packages/bot units 175/175
0.2.5-handlemsg-fallbacks + 0.0.1-flow-events 10/10
Full monorepo suite (pre-push) 30 projects OK
pnpm run generate:check passed, starters unchanged (the CRLF change is a no-op on this checkout)
@builderbot/bot build OK

Fuera de alcance

Redis, el contrato async BotState, la zona Redis y los starters: todo eso ya está mergeado en #1292. No hay cambios de dependencias ni de lockfile en este PR.

Checklist

  • Tests, build and generate:check executed on this tree
  • Full monorepo suite green (30 projects)
  • CI at this PR head (pending at creation)

Unit B split from #1281, the behaviour changes that are unrelated to Redis:

- handleMsg: when a nested flow has no match and the previous message asked for
  capture, process it as free capture instead of falling through to global
  keywords; WELCOME is evaluated last, only when no event keyword matched.
- handleMsg: guard the capture branch on a non-empty match and tolerate a
  missing refToContinue ref.
- addAnswer: derive the step ref deterministically from the parent ref so the
  same node keeps a stable callback key.
- interactive: BUILDERBOT_SILENT env flag to silence printer output.
- generator: normalize CRLF before rewriting starter entry points.
@leifermendez leifermendez added the type:bug Bug fix label Nov 18, 2026
@leifermendez
leifermendez merged commit 08fdccd into builderbot Nov 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant