#17 create new contact#18
Merged
Merged
Conversation
x1strategyltda-art
pushed a commit
to x1strategyltda-art/ChatbotX
that referenced
this pull request
May 27, 2026
…hatbotXIO#20.3) Quick wins da auditoria ChatbotXIO#20 da Camada 3 — 2 features marginais do Respond.io que faltavam: ChatbotXIO#20.2 — DeleteContactDialog ganha confirmação numérica Quando o(s) contato(s) selecionado(s) têm tags ou conversa vinculadas, exige digitar o número total (tags + conversas) pra liberar Excluir — mesmo padrão do DeleteTagsDialog (ChatbotXIO#13). Contatos vazios mantém o flow rápido "Tem certeza?" anterior. - Nova prop opcional usageCounts: { tags, conversations } - Caller calcula no client (já tem dados no schema) - contacts-list-action.tsx (bulk delete na /contacts) soma de cada row - conversation-action.tsx (delete do Inbox) passa { tags: 0, conversations: 1 } porque contactResource não carrega tags lá — comentário explica - i18n: contacts.delete.* em en, pt-BR e vi ChatbotXIO#20.3 — Columns picker /contacts persistido em localStorage Botão "Colunas" no toolbar abre Popover com checkbox por coluna. TanStack column.toggleVisibility() nativo + meta.label em todas as hideable. 3 colunas fixas (select, nome, criado em) com enableHiding: false não aparecem no picker. - ContactsColumnsPicker reutilizável (recebe table) - localStorage key chatbotx.contacts.columnVisibility (SSR-safe via lazy useState + effect on change) - Atalho "Mostrar/Ocultar todas" no header - meta.label em 8 colunas que faltavam (channels, lifecycleStage, email, phoneNumber, tags, country, locale, conversationStatus, lastMessage) - i18n: contacts.columnsPicker.* em en, pt-BR e vi Camada 3: 1/5 (ChatbotXIO#20 fechado). Falta ChatbotXIO#16, ChatbotXIO#17, ChatbotXIO#18, ChatbotXIO#19. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
x1strategyltda-art
pushed a commit
to x1strategyltda-art/ChatbotX
that referenced
this pull request
May 27, 2026
…oft-delete)
Estratégia A escolhida pelo Pedro: soft-delete via mergedIntoId em vez
de DELETE físico. Reverter é trivial (UPDATE 3 campos pra NULL), histórico
preservado, auditável.
Schema (Contact)
- mergedIntoId bigint → Contact.id (self-ref via AnyPgColumn pra
quebrar circularidade de tipos; ON DELETE SET NULL)
- mergedAt timestamp with timezone
- mergedByUserId bigint → User.id (ON DELETE SET NULL)
- INDEX Contact_mergedIntoId_idx pra acelerar lookups "fundidos em X"
- Migration custom: 20260527155004_unmerge_contact_fields
mergeContacts() refator
- Etapa 5 (era DELETE FROM Contact) virou UPDATE SET mergedIntoId,
mergedAt, mergedByUserId. Conversation/tag/customField/etc continuam
sendo MOVIDOS no momento do merge (não snapshot) — unmerge restaura
o contato MAS NÃO reverte movimentos. UI avisa explicitamente.
- Docstring atualizada explicando soft-delete
Filtros mergedIntoId IS NULL
- list-contacts.queries.ts → generateWhere adiciona mergedIntoId:isNull
- count-blocked-contacts.ts → isNull no AND do count
- listConversations NÃO precisa filtrar (conversation foi movida no
merge; duplicate fica sem conversation, naturalmente não aparece)
- Bulk actions (add tag, custom field, etc) ficam como debt list —
o pior cenário hoje é "bulk action atinge contato fundido", não
visível na UI mas ainda no banco
unmergeContactsAction
- bindArgs workspaceId + inputSchema { primaryId, duplicateIds[] }
- Valida: todos os duplicates têm mergedIntoId = primaryId (evita
unmerge cruzado entre primaries diferentes)
- UPDATE SET 3 campos pra NULL
- logAudit CONTACT_UNMERGED + recordContactEvent UNMERGED no PRIMARY
UI
- MergedContactsPanel — lazy fetch via listContactsMergedInto;
banner amarelo no drawer do contato primary; lista com botão
"Desfazer fusão" por linha; warning sobre conversas/tags
- Plugado em ContactDetailDrawer antes do "Ver no Inbox"
- i18n contacts.unmerge.* em en, pt-BR, vi
Camada 3: 2/5 (ChatbotXIO#17 + ChatbotXIO#20 fechados). Falta ChatbotXIO#16, ChatbotXIO#18, ChatbotXIO#19.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.