Skip to content

feat: add confirmation dialog to instance disconnect#33

Open
michumichifu wants to merge 1 commit into
evolution-foundation:developfrom
michumichifu:feat/instance-logout-confirmation
Open

feat: add confirmation dialog to instance disconnect#33
michumichifu wants to merge 1 commit into
evolution-foundation:developfrom
michumichifu:feat/instance-logout-confirmation

Conversation

@michumichifu

@michumichifu michumichifu commented Jul 23, 2026

Copy link
Copy Markdown

📋 Description

Adds a confirmation dialog to the instance Disconnect (logout) action on the instance dashboard.

Today, clicking Disconnect logs the instance out immediately, with no confirmation. Because this unlinks the WhatsApp session and requires re-scanning the QR code to reconnect, an accidental click is disruptive — in a multi-instance setup it can knock a live client instance offline in one click. This PR adds a simple yes/no confirmation before the logout runs.

The implementation reuses the existing confirmation-dialog pattern already used for the user-session logout in src/components/header.tsx (Radix Dialog), so it introduces no new dependencies or components and stays consistent with the project's conventions.

🔗 Related Issues

  • Related to # (feature suggested in the community Discord)

🧪 Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🎨 Style/UI changes

🧪 Testing

Test Environment

  • Production-like environment

Test Cases

  • Manual testing completed

Test Instructions

  1. Open the dashboard of a connected instance (connectionStatus === "open").
  2. Click the Disconnect button.
  3. A confirmation dialog appears ("Disconnect instance?") with Cancel and Disconnect buttons.
  4. Cancel closes the dialog with no side effects; Disconnect performs the logout as before.

Also verified locally: npm run type-check, eslint, and prettier --check all pass.

📸 Screenshots

Screenshot From 2026-07-22 22-16-13

After

Confirmation dialog shown before the logout runs (screenshot in PR discussion).

Notes

  • New i18n keys instance.dashboard.disconnectConfirm.title / description added to all four locales (pt-BR, en-US, es-ES, fr-FR).
  • The confirm button reuses the existing instance.dashboard.button.disconnect label; the cancel button reuses button.cancel.
  • No API/behavior change beyond gating the existing logout call behind a confirmation.

Summary by Sourcery

Add a confirmation dialog before disconnecting an instance from the dashboard to prevent accidental logouts.

New Features:

  • Prompt users with a confirmation dialog when triggering the instance disconnect action on the dashboard.

Enhancements:

  • Extend existing dialog UI components and translations to support the new disconnect confirmation flow across all locales.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a confirmation dialog flow around the instance disconnect/logout action on the dashboard, reusing the shared Dialog component and wiring it to i18n, while keeping the underlying logout behavior unchanged.

Sequence diagram for new instance disconnect confirmation flow

sequenceDiagram
  actor User
  participant DashboardInstance
  participant Dialog

  User->>DashboardInstance: clickDisconnectButton
  DashboardInstance->>DashboardInstance: setLogoutConfirmation(true)
  DashboardInstance->>Dialog: render Dialog open=true

  User->>Dialog: clickCancel
  Dialog->>DashboardInstance: setLogoutConfirmation(false)

  User->>Dialog: clickConfirmDisconnect
  Dialog->>DashboardInstance: setLogoutConfirmation(false)
  Dialog->>DashboardInstance: handleLogout(instance.name)
Loading

File-Level Changes

Change Details Files
Gate the instance disconnect/logout action behind a confirmation dialog using the existing Dialog component.
  • Introduce logoutConfirmation state to control dialog visibility.
  • Change the Disconnect action handler to open the confirmation dialog instead of calling handleLogout directly.
  • Render a Dialog tied to logoutConfirmation with title, description, and footer actions.
  • Wire the cancel button to close the dialog without side effects.
  • Wire the confirm button to close the dialog and then call handleLogout with the instance name.
src/pages/instance/DashboardInstance/index.tsx
Add localized strings for the new disconnect confirmation dialog across all supported locales.
  • Add instance.dashboard.disconnectConfirm.title and instance.dashboard.disconnectConfirm.description keys in English.
  • Add the same disconnectConfirm title/description keys in Spanish.
  • Add the same disconnectConfirm title/description keys in French.
  • Add the same disconnectConfirm title/description keys in Portuguese (pt-BR).
src/translate/languages/en-US.json
src/translate/languages/es-ES.json
src/translate/languages/fr-FR.json
src/translate/languages/pt-BR.json
Minor JSX formatting adjustments for consistency and compactness.
  • Inline single-expression conditional rendering of ownerJid.
  • Inline single-expression AlertTitle translation call.
  • Condense QR code / loading spinner ternary into a single line.
src/pages/instance/DashboardInstance/index.tsx

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


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.

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