Skip to content

fix(handoff): no duplicar tickets al repetir el traspaso (#09A022) - #78

Draft
santmun wants to merge 1 commit into
mainfrom
cursor/handoff-ticket-dedup-d738
Draft

santmun wants to merge 1 commit into
mainfrom
cursor/handoff-ticket-dedup-d738

Conversation

@santmun

@santmun santmun commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Qué cambia

Ticket de soporte #09A022. La plantilla del bot del miembro (horizontes-bot-template v1.0.77, la que baja npx forjabot update) no vive en este repo. Este código es el starter de santmun/forja. Confirmé cada síntoma contra main (07b8cee) y no inventé los módulos que el reporte cita y aquí no existen.

1. iOS Safari amplía la página — no confirmado, sin cambio

El reporte apunta a src/web/temas.ts (textarea a 14.5px). Esa ruta no está en main, ni hay widget de chat web. Los textareas que sí existen son del panel /admin, otra superficie. No toqué estilos.

2. Autofoco levanta el teclado — no confirmado, sin cambio

El reporte apunta a src/web/script.ts (ta.focus() al abrir). Ese archivo no existe y el widget no tiene detección de móvil. No hay arreglo que aplicar sin inventar el chat web.

3. Markdown como asteriscos — no confirmado, sin cambio

En este repo el <style_guide> de src/system-prompt.ts ya pide texto plano, y stripMarkdown() en src/replies/chunker.ts quita **negritas** antes de enviar. No hay renderMarkdown() ni widget que pinte con textContent. El síntoma del reporte (el prompt permite markdown y el widget lo pinta crudo) no está en este código.

4. Blindaje en idioma base con modo espejo — no confirmado, sin cambio

No existen src/blindaje/verify.ts, idiomaEfectivo(), SAFE_REPLY_BY_LANG ni test/idioma.test.ts. El idioma sale de BOT_LANGUAGE. No hay modo espejo que alterar, así que la regla de que idiomaEfectivo() siga devolviendo el idioma base no aplica aquí.

5. Traspaso a humano duplica tickets — confirmado y arreglado

El reporte cita createHandoffTicket() y cleanupStaleOpenTicketRefs(), que aquí no existen, pero el síntoma sí. handoffHuman llamaba tickets.create() y notifyOwner() en cada pedido, y setOpenTicket() pisaba open_ticket_id. Tres pedidos seguidos dejaban tres tickets open y tres avisos; el puntero quedaba en el último.

Ahora, si la conversación ya tiene un ticket no resuelto (open o in_progress), se reutiliza ese id, no se avisa otra vez y open_ticket_id sigue apuntando a él. Un ticket ya resolved sí abre uno nuevo. No cierra tickets huérfanos que ya existan: solo deja de crear más.

Este arreglo está en el starter de este repo. No publica el artifact horizontes-bot-template ni cambia la versión de npm. El bot del miembro no lo recibe con npx forjabot update hasta que esa plantilla se publique aparte.

Por qué

Un cliente que insiste en hablar con una persona (visto en WhatsApp: 3 tickets product abiertos en ~2 minutos) no debe abrir un ticket ni un aviso por mensaje. Ticket #09A022.

Cómo lo probaste

  • pnpm test pasa — 79 archivos, 565 pruebas
  • pnpm typecheck limpio (tsc --noEmit)
  • (si aplica) probado contra un bot real

El test reuses the open ticket and notifies the owner only once when the customer repeats the request falla si se quita el early-return: el segundo execute devuelve otro id. También cubre ticket in_progress (se reutiliza) y ticket resolved (sí abre uno nuevo).

Checklist

  • No toqué la carpeta member/ (config de cada quien)
  • El PR es de un solo tema (enfocado y chico)
  • Si tu agente (Claude) hizo el PR, revisaste el diff tú mismo antes de abrirlo
  • No hay secrets ni API keys en el código
Open in Web Open in Cursor 

Si el cliente pide humano otra vez, handoffHuman ya no abre un ticket
nuevo ni vuelve a avisar al dueño. open_ticket_id se queda en el ticket
que sigue abierto. Ticket #09A022.

Co-authored-by: santmun <santmun@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants