Skip to content

fix(APP-958): prevent app crash on wallet disconnect during transaction dialogs#1215

Open
harryburger wants to merge 11 commits into
mainfrom
app-958-app-crashes-if-wallet-disconnects-during-transaction-dialog
Open

fix(APP-958): prevent app crash on wallet disconnect during transaction dialogs#1215
harryburger wants to merge 11 commits into
mainfrom
app-958-app-crashes-if-wallet-disconnects-during-transaction-dialog

Conversation

@harryburger

@harryburger harryburger commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the application crashing when the wallet disconnects while a transaction dialog is open (APP-958).

Wallet-requiring dialogs (vote, execute, publish proposal, token approve, …) assert a connected address during render. Disconnecting the wallet from the wallet itself while one of them was open made the assertion throw during render, and since DialogRoot renders outside the page-level error boundary, the throw unmounted the entire application.

Changes:

  • Add a requiresWallet flag to IDialogComponentDefinitions and set it on the 15 dialogs carrying the connected-wallet assertion
  • DialogRoot unmounts flagged dialogs as soon as the wallet address is gone — before they can re-render and throw — and removes them from the dialog stack once the disconnect settles. Connector switches are unaffected: while reconnecting, dialogs are only hidden and restored once the address returns
  • Dialogs opened without a wallet (e.g. connect-wallet) are untouched, so the user can always reconnect
  • Add a guardrail test that fails when a dialog carries the connected-wallet assertion but its definition lacks the flag, so new dialogs cannot reintroduce the crash

Type of Change

  • Patch: Bug fix (non-breaking change which fixes an issue)

Developer Checklist:

  • Manually smoke tested the functionality in a preview or locally
  • Confirmed there are no new warnings or errors in the browser console
  • (For User Stories only) Double-checked that all Acceptance Criteria are satisfied
  • Confirmed there are no new warnings on automated tests
  • Merged and published any dependent changes in downstream modules
  • Selected the correct base branch
  • Commented the code in hard-to-understand areas
  • Followed the code style guidelines of this project
  • Reviewed that the Files Changed in Github's UI reflect my intended changes
  • Confirmed the pipeline checks are not failing

Review Checklist:

  • (For User Stories only) Tested in a preview or locally that all Acceptance Criteria are satisfied
  • Confirmed that changes follow the code style guidelines of this project

Copilot AI review requested due to automatic review settings July 9, 2026 04:34
@harryburger harryburger requested a review from a team as a code owner July 9, 2026 04:34
@linear-code

linear-code Bot commented Jul 9, 2026

Copy link
Copy Markdown

APP-958

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

🚀 Preview Deployment: View Here

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents the app from crashing when a connected wallet disconnects while certain transaction-related dialogs are open, by introducing an explicit requiresWallet dialog definition flag and using it to unmount/close affected dialogs before they can re-render without an address.

Changes:

  • Add requiresWallet?: boolean to dialog definitions and use it in DialogRoot to hide/unmount and close wallet-dependent dialogs on disconnect (while not closing during reconnects).
  • Mark several existing dialogs across modules/plugins as requiresWallet: true.
  • Add DialogRoot tests covering connected/disconnected/reconnecting behavior and the “disconnect while open” crash scenario; add a changeset entry.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/shared/components/dialogRoot/dialogRoot.tsx Adds wallet-awareness to dialog rendering and closes wallet-dependent dialogs on disconnect to prevent render-time assertion crashes.
src/shared/components/dialogRoot/dialogRoot.test.tsx Adds unit tests to verify wallet-dependent dialog behavior across disconnect/reconnect states and prevent regressions.
src/shared/components/dialogProvider/dialogProvider.api.ts Extends dialog definition API with a requiresWallet flag.
src/plugins/tokenPlugin/constants/tokenPluginDialogsDefinitions.ts Marks token plugin dialogs that require a connected wallet.
src/plugins/sppPlugin/constants/sppPluginDialogsDefinitions.ts Marks SPP dialog(s) that require a connected wallet.
src/plugins/lockToVotePlugin/constants/lockToVotePluginDialogsDefinitions.ts Marks lock/unlock dialog as requiring a connected wallet.
src/plugins/gaugeVoterPlugin/constants/gaugeVoterPluginDialogsDefinitions.ts Marks lock/unlock dialog as requiring a connected wallet.
src/modules/settings/constants/settingsDialogDefinitions.ts Marks plugin uninstallation preparation dialog as requiring a connected wallet.
src/modules/governance/constants/governanceDialogsDefinitions.ts Marks publish/execute/vote dialogs as requiring a connected wallet.
src/modules/createDao/constants/createDaoDialogsDefinitions.ts Marks publish/prepare dialogs as requiring a connected wallet.
src/modules/capitalFlow/constants/capitalFlowDialogsDefinitions.ts Marks policy preparation/transaction dispatch dialogs as requiring a connected wallet.
.changeset/dialog-wallet-disconnect-crash.md Adds a patch changeset describing the crash fix and the new requiresWallet behavior.
.agents/shared/metrics/hits.jsonl Appends new guardrail-metrics log entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/shared/components/dialogRoot/dialogRoot.tsx Outdated
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

E2E results (preview)

Smoke

Base URL https://app-next-83w7jauph-aragon-app.vercel.app
Suite smoke
Playwright result ⚠️ completed with flaky tests
Summary 76 passed, 3 flaky, 1 skipped
HTML report View report
GitHub job ✅ completed

View run #4539

@harryburger harryburger force-pushed the app-958-app-crashes-if-wallet-disconnects-during-transaction-dialog branch from 5e37589 to 0ef07de Compare July 10, 2026 08:18
@harryburger harryburger changed the title fix: prevent app crash on wallet disconnect during transaction dialogs fix(APP-958): prevent app crash on wallet disconnect during transaction dialogs Jul 10, 2026

@thekidnamedkd thekidnamedkd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really nice fix overall — the unmount-before-throw ordering is race-free (we re-render DialogRoot before the dialog child on the same wagmi store update), the integration test reproducing the actual invariant crash is great, and I checked the flag coverage: all 5 dialogs with render-time address invariants are flagged, and the unflagged address != null matches elsewhere are benign. One thing we should fix before merge (the wagmi state-model comment inline), the rest is non-blocking polish.

Non-blocking extras:

  • Test gaps we could close cheaply: reconnect-restore (address returns → dialog re-renders, close never called), multi-dialog stack (flagged top closes, unflagged below becomes visible), and open-while-already-disconnected.
  • Follow-up ticket material rather than this PR: DialogRoot still renders outside the page-level error boundary, so the flag only protects dialogs someone remembered to flag — an error boundary around the dialog layer would kill the whole crash class. Might also be a good rule-skill ("dialog asserts wallet ⇒ set requiresWallet").

Comment thread apps/app/src/shared/components/dialogRoot/dialogRoot.tsx Outdated
Comment thread apps/app/src/shared/components/dialogProvider/dialogProvider.api.ts
Comment thread .changeset/dialog-wallet-disconnect-crash.md Outdated

@milosh86 milosh86 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @harryburger, it looks good!

What I mentioned today, I was thinking about wrapping ActiveDialogComponent in an ErrorBoundary which would catch all errors, log em, and close the dialog. After thinking more about it, I think it's better to start with your more focused approach and we can consider this more general approach if needed later.

One thing only regarding your approach. Since now one must know about requiresWallet flag when creating a new dialog, let's add something like this to AGENTS.md: "When creating a new dialog which uses TransactionDialog internally pass requiresWallet flag to dialog definition.

…f-wallet-disconnects-during-transaction-dialog

# Conflicts:
#	.agents/shared/metrics/hits.jsonl
isReconnecting is only true for wagmi's 'reconnecting' status, which is
the mount-time reconnectOnMount path. A mid-session connector switch goes
through 'connecting', where the address can be undefined while
isReconnecting is false, so wallet-requiring dialogs were closed instead
of being waited out.

Expose isConnecting from useWalletAccount and close only when neither
transient state is active. Also reword the requiresWallet JSDoc and the
changeset to describe the behavioural contract rather than an assertion.
…f-wallet-disconnects-during-transaction-dialog

# Conflicts:
#	.agents/shared/metrics/hits.jsonl
…ction-dialog' of github.com:aragon/app into app-958-app-crashes-if-wallet-disconnects-during-transaction-dialog

@milosh86 milosh86 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good 👍

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.

4 participants