Skip to content

Conversation

@RaFaeL-Cunha
Copy link

@RaFaeL-Cunha RaFaeL-Cunha commented Dec 7, 2025

📋 Description
Este PR adiciona duas melhorias na interface do Evolution Manager:

Toast de Sucesso/Erro: Implementa feedback visual ao usuário após reiniciar uma instancia que antes tava sem aparecer nada, melhorando a UX ao confirmar se a operação foi bem-sucedida ou se houve erro.

Campo mergeBrazil: Adiciona checkbox no formulário de configuração do Chatwoot para habilitar/desabilitar a funcionalidade de merge de contatos brasileiros (unifica números com/sem 9º dígito).

Correção do bug no campo signDelimiter

Problema:
O campo signDelimiter estava enviando null para a API mesmo quando o usuário preenchia o valor \n ou deixava vazio, causando problemas na formatação das mensagens assinadas no Chatwoot.

Solução:

  • Implementado .trim() para remover espaços em branco desnecessários
  • Corrigido o valor padrão para \n quando o campo estiver vazio
  • Removida conversão desnecessária que estava causando o envio de null

Comportamento após correção:

  • ✅ Campo vazio → envia \n (padrão)
  • ✅ Usuário digita \n → envia \n corretamente
  • ✅ Usuário digita outro delimitador (ex: -) → envia o valor digitado
  • ✅ Backend converte \n para quebra de linha real nas mensagens

Agora o delimitador de assinatura funciona corretamente em todas as situações.

🔗 Related Issues
N/A (melhoria de UX não vinculada a issue específica)
🧪 Type of Change
[x] ✨ New feature (non-breaking change which adds functionality)
[x] 🎨 Style/UI changes
🧪 Testing
Test Environment
[x] Local development
[ ] Staging environment
[ ] Production-like environment
Test Cases
[x] Manual testing completed
[x] Cross-browser testing (if applicable)
Test Instructions
Testando Toast de Feedback:

Acesse a página da instância
Clique no Botão "Reiniciar"
Verifique se aparece toast verde de sucesso no canto superior direito
Teste com dados inválidos para verificar toast vermelho de erro
Testando campo mergeBrazil:

Acesse a página de configuração do Chatwoot
Localize o checkbox "Merge Brazil" no formulário
Marque/desmarque a opção
Salve a configuração
Verifique se o valor é persistido corretamente ao recarregar a página
📸 Screenshots
Before
Sem feedback visual após salvar (usuário não sabia se salvou)
Campo mergeBrazil não existia no formulário
After
Toast de sucesso/erro aparece após salvar
image

Checkbox mergeBrazil disponível no formulário
image

✅ Checklist
Code Quality
[x] My code follows the project's style guidelines
[x] I have performed a self-review of my code
[x] My changes generate no new warnings or errors
[x] I have run npm run lint and fixed any issues
Testing
[x] I have tested the changes in multiple browsers (if applicable)
[x] New and existing unit tests pass locally with my changes
Documentation
[x] I have commented my code, particularly in hard-to-understand areas
Internationalization
[x] I have added translations for new text strings (mergeBrazil label)
Breaking Changes
[ ] This PR introduces breaking changes
📝 Additional Notes
Toast Implementation:

Utiliza biblioteca de toast já presente no projeto
Timeout de 3 segundos para auto-dismiss
Cores seguem o padrão do design system (verde=sucesso, vermelho=erro)
mergeBrazil Feature:

Quando habilitado, unifica contatos brasileiros que diferem apenas no 9º dígito
Útil para evitar conversas duplicadas no Chatwoot
Padrão: desabilitado (backward compatible)
🤝 Reviewer Guidelines
Focus Areas
[x] Code logic and correctness
[x] User experience
[x] Browser compatibility
Testing Checklist for Reviewers
[ ] Pull and test the branch locally
[ ] Verify the fix/feature works as described
[ ] Check for edge cases
[ ] Verify no regressions in existing functionality

Summary by Sourcery

Add user feedback to instance restart actions and expose a new Chatwoot configuration option for merging Brazilian contacts.

New Features:

  • Show success and error toast notifications when restarting an instance from the dashboard.
  • Add a mergeBrazilContacts toggle to the Chatwoot configuration form to control merging of Brazilian contacts.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 7, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Implements user feedback toasts on instance restart and adds a new mergeBrazilContacts toggle to the Chatwoot configuration form, including corresponding i18n strings.

Sequence diagram for instance restart with success/error toast feedback

sequenceDiagram
  actor User
  participant DashboardInstance
  participant InstanceService as restartService
  participant Toast

  User->>DashboardInstance: clickRestartButton(instanceName)
  DashboardInstance->>InstanceService: restart(instanceName)
  DashboardInstance->>InstanceService: reloadInstance()
  alt restartSuccess
    DashboardInstance->>Toast: toast.success(t(instance.dashboard.toast.restart.success))
  else restartError
    DashboardInstance->>Toast: toast.error(t(instance.dashboard.toast.restart.error))
  end
  Toast-->>User: displayToast(autoDismiss=3s)
Loading

File-Level Changes

Change Details Files
Add success/error toast feedback when restarting an instance from the dashboard.
  • Call toast.success with a translated message after a successful restart and reload of the instance.
  • Call toast.error with a translated message when the restart operation throws an error.
  • Wire toast messages through the existing i18n translation function.
src/pages/instance/DashboardInstance/index.tsx
src/translate/languages/pt-BR.json
Expose mergeBrazilContacts as a configurable checkbox in the Chatwoot settings UI.
  • Add a FormSwitch field bound to mergeBrazilContacts in the Chatwoot configuration form alongside existing boolean settings.
  • Provide label and helper text via new translation keys for the mergeBrazilContacts field.
  • Ensure the new field integrates with existing form handling and persistence logic by reusing the same FormSwitch pattern.
src/pages/instance/Chatwoot/index.tsx
src/translate/languages/pt-BR.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In the restart handler, consider adding a finally block (or shared helper) so any future UI state changes (e.g., loading indicators, button disable/enable) are consistently reset regardless of success or error, instead of only handling toasts in try/catch.
  • The new FormSwitch uses the mergeBrazilContacts field name while the description and feature name mention mergeBrazil; double-check the field naming aligns with the backend/DTO property to avoid silent mismatch when persisting this value.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the restart handler, consider adding a `finally` block (or shared helper) so any future UI state changes (e.g., loading indicators, button disable/enable) are consistently reset regardless of success or error, instead of only handling toasts in `try/catch`.
- The new `FormSwitch` uses the `mergeBrazilContacts` field name while the description and feature name mention `mergeBrazil`; double-check the field naming aligns with the backend/DTO property to avoid silent mismatch when persisting this value.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@RaFaeL-Cunha
Copy link
Author

Hey there - I've reviewed your changes - here's some feedback:

  • In the restart handler, consider adding a finally block (or shared helper) so any future UI state changes (e.g., loading indicators, button disable/enable) are consistently reset regardless of success or error, instead of only handling toasts in try/catch.
  • The new FormSwitch uses the mergeBrazilContacts field name while the description and feature name mention mergeBrazil; double-check the field naming aligns with the backend/DTO property to avoid silent mismatch when persisting this value.

Prompt for AI Agents

Please address the comments from this code review:

## Overall Comments
- In the restart handler, consider adding a `finally` block (or shared helper) so any future UI state changes (e.g., loading indicators, button disable/enable) are consistently reset regardless of success or error, instead of only handling toasts in `try/catch`.
- The new `FormSwitch` uses the `mergeBrazilContacts` field name while the description and feature name mention `mergeBrazil`; double-check the field naming aligns with the backend/DTO property to avoid silent mismatch when persisting this value.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sobre o finally block:

O código já implementa o padrão recomendado usando o callback onSettled da mutation, que funciona exatamente como um finally block:

await createChatwoot(
{ ... },
{
onSuccess: () => { ... },
onError: (error) => { ... },
onSettled: () => {
setLoading(false); // ✅ Sempre executado, independente de sucesso ou erro
},
},
);

O onSettled é chamado após onSuccess ou onError, garantindo que o estado da UI seja resetado consistentemente. Este é o padrão recomendado pelo React Query/TanStack Query para gerenciamento de estado de loading em mutations.

Não há handler de "restart" neste arquivo - o comentário parece ser genérico ou aplicável a outro componente.

@RaFaeL-Cunha RaFaeL-Cunha changed the title feat(ui): adiciona toast de feedback botão reiniciar e campo mergeBrazil no formulário Chatwoot feat(manager): adiciona mergeBrazilContacts, corrige signDelimiter, add Toast no botão Reiniciar da instancia todos com as traduções Dec 7, 2025
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.

1 participant