Skip to content

Commit 850ae85

Browse files
pedrokniggeclaude
andcommitted
1.2.0: entity chip in send modal — confirma detección en vivo
Al abrir el modal de envío aparece un chip contextual: - verde: entidad detectada (💼 Deal, 🎯 Lead, 👤 Persona, 🏢 Org) + confirma que se creará la nota al enviar. - amarillo: no pude detectar la entidad. - gris: sin token de Pipedrive o registro desactivado. El chip se refresca cada 1.5 s, así que si abrís un preview después de abrir el modal, lo reflecta al toque. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cb27639 commit 850ae85

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.2.0 — 2026-04-22
4+
5+
- **Feedback visual de detección**: al abrir el modal de envío desde Pipedrive aparece un chip que dice qué entidad se detectó (`💼 Deal #31190`, `🎯 Lead #abc-123…`, etc.) y confirma que se creará la nota al enviar. Si no se pudo detectar, muestra aviso en amarillo. Si el token de Pipedrive no está configurado o el toggle de registro está apagado, avisa con chip gris. El chip se refresca cada 1.5 s mientras el modal está abierto, así que si abrís un preview después, se actualiza solo.
6+
37
## 1.1.4 — 2026-04-22
48

59
- **Preview de deals/leads finalmente detectada**: la detección ahora busca `a[data-test="nav-button"]` (el botón "Ábrelo en una pestaña nueva" que Pipedrive renderiza dentro de cualquier modal de preview). Es más confiable que intentar identificar el drawer por data-test, que Pipedrive cambia seguido. Aplica al mismo observer que sirve de fallback.

content/pipedrive.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,43 @@
190190
return null;
191191
}
192192

193+
const KIND_LABEL = { deal: 'Deal', person: 'Persona', organization: 'Organización', leads: 'Lead' };
194+
const KIND_ICON = { deal: '💼', person: '👤', organization: '🏢', leads: '🎯' };
195+
196+
// Pinta (o esconde) el chip que indica si la nota automática va a ir a
197+
// Pipedrive al enviar. Se lee en vivo cada vez, no cacheamos.
198+
async function renderEntityChip(modal) {
199+
const chip = modal.querySelector('#whatpipe-entity-chip');
200+
if (!chip) return;
201+
202+
const { logSentAsNote = true, pipedriveApiToken } = await new Promise((res) =>
203+
chrome.storage.local.get(['logSentAsNote', 'pipedriveApiToken'], res)
204+
);
205+
206+
if (!pipedriveApiToken) {
207+
chip.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;margin-bottom:12px;border-radius:8px;font-size:12.5px;background:#f1f5f9;color:#64748b;border:1px solid #e2e8f0;';
208+
chip.textContent = 'ℹ️ Sin token de Pipedrive — no se registrará nota al enviar.';
209+
return;
210+
}
211+
if (logSentAsNote === false) {
212+
chip.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;margin-bottom:12px;border-radius:8px;font-size:12.5px;background:#f1f5f9;color:#64748b;border:1px solid #e2e8f0;';
213+
chip.textContent = 'ℹ️ Registro de nota desactivado en Opciones.';
214+
return;
215+
}
216+
217+
const entity = detectCurrentEntity();
218+
if (entity) {
219+
const label = KIND_LABEL[entity.kind] || entity.kind;
220+
const icon = KIND_ICON[entity.kind] || '📌';
221+
const idShort = String(entity.id).length > 10 ? String(entity.id).slice(0, 8) + '…' : entity.id;
222+
chip.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;margin-bottom:12px;border-radius:8px;font-size:12.5px;background:#dcfce7;color:#166534;border:1px solid #86efac;font-weight:600;';
223+
chip.textContent = `${icon} ${label} #${idShort} detectado — se creará nota en Pipedrive al enviar`;
224+
} else {
225+
chip.style.cssText = 'display:flex;align-items:center;gap:8px;padding:8px 10px;margin-bottom:12px;border-radius:8px;font-size:12.5px;background:#fef3c7;color:#92400e;border:1px solid #fde68a;';
226+
chip.textContent = '⚠️ No pude detectar la entidad de Pipedrive — no se creará nota. Abrí un deal/lead/persona (o su preview) para que lo registre.';
227+
}
228+
}
229+
193230
// Observer global: cada vez que aparece un drawer/modal con un link a una
194231
// entity, cacheamos esa entity. Sirve de fallback cuando, en el momento del
195232
// envío, el DOM del drawer cambió y ya no tiene el link a la vista.
@@ -600,6 +637,8 @@
600637
</div>
601638
602639
<div class="whatpipe-modal-body">
640+
<div id="whatpipe-entity-chip" class="whatpipe-entity-chip" style="display:none;"></div>
641+
603642
<div class="whatpipe-form-group">
604643
<label>Número de teléfono (WhatsApp)</label>
605644
<div class="whatpipe-number-row">
@@ -705,6 +744,18 @@
705744
// Enrich from Pipedrive API if configured — overrides DOM guesses.
706745
enrichFromPipedriveAPI(modal);
707746

747+
// Entity chip: mostrar si detectamos deal/lead/persona/org para la nota.
748+
renderEntityChip(modal);
749+
// Refrescar periódicamente mientras el modal está abierto — la preview
750+
// puede abrirse o cambiar después de abrir el modal.
751+
const entityChipInterval = setInterval(() => {
752+
if (!document.body.contains(modal)) {
753+
clearInterval(entityChipInterval);
754+
return;
755+
}
756+
renderEntityChip(modal);
757+
}, 1500);
758+
708759
// Save-as-template button
709760
modal.querySelector('#whatpipe-save-tpl').addEventListener('click', () => saveCurrentAsTemplate(modal));
710761
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "SuperPipeWhat — Pipedrive ↔ Whaticket",
44
"description": "Un puente entre Pipedrive y Whaticket. En Whaticket: panel con deals/personas, timeline, creación de notas/actividades. En Pipedrive: envío de WhatsApp vía Whaticket con plantillas, variables y adjuntos.",
5-
"version": "1.1.4",
5+
"version": "1.2.0",
66
"permissions": ["storage", "scripting"],
77
"optional_host_permissions": ["https://*/*"],
88
"host_permissions": [

0 commit comments

Comments
 (0)