Skip to content

fix(desktop): surface leave-channel rejection in sidebar dialog - #3689

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/surface-leave-channel-rejection-3605
Open

fix(desktop): surface leave-channel rejection in sidebar dialog#3689
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/surface-leave-channel-rejection-3605

Conversation

@iroiro147

Copy link
Copy Markdown

Problem

Leaving a channel you solely own looks like a broken button. You confirm the dialog, it closes, and the channel is still sitting in the sidebar — no toast, no error, no explanation. The relay is refusing on purpose (it won't remove a channel's last owner), but the reason never reaches the UI.

Closes #3605

Root Cause

The sidebar's LeaveChannelAlertDialog (in ChannelSectionDialogs.tsx) called leaveChannel.mutate() and immediately cleared the target — closing the dialog regardless of success or failure. The mutation's .error field was never read or displayed.

In contrast, the ChannelManagementSheet leave button does surface errors via leaveChannelMutation.error.message. The two entry points disagreed about whether failures are worth mentioning.

Solution

Added error and pending state to the sidebar's leave dialog:

Change Detail
LeaveChannelAlertDialog props Added error?: Error | null and isPending?: boolean
Error display Renders error.message as a text-destructive paragraph inside the dialog
Dialog close behavior Dialog stays open on mutation failure; only closes on success
Button states Cancel and Leave disabled while isPending; Leave shows "Leaving..."
Mutation call Switched from .mutate() (fire-and-forget) to .mutateAsync().then(() => close)
Dismiss guard onOpenChange blocked while isPending to prevent premature dismissal

Acceptance Criteria

  • The rejection surfaces wherever leave is offered (sidebar now matches management sheet)
  • The error message from the relay is displayed to the user
  • The dialog stays open on failure so the user can read the error
  • The dialog closes on success
  • Buttons are disabled during the pending request
  • Existing manual Mark unread behavior remains coherent

Test Plan

cd desktop
node --test src/features/sidebar/ui/leaveChannelDialog.test.mjs

All 6 tests pass:

  • dialog stays open when leave mutation fails
  • dialog closes when leave mutation succeeds
  • dismiss is blocked while mutation is pending
  • dismiss works when not pending
  • error is cleared on a new leave request
  • isPending is true during mutation and false after

Leaving a channel you solely owner was silently rejected: the sidebar
dialog closed immediately regardless of success or failure, and the
relay's error message ("you are the only owner") never reached the user.

This change adds error and pending state to LeaveChannelAlertDialog:
- The dialog stays open when the mutation fails, showing the relay's
  error message as a destructive-foreground paragraph
- The dialog only closes on successful mutation
- Cancel and Leave buttons are disabled while the request is in flight
- A new leave request clears any prior error

This matches the behavior already present in ChannelManagementSheet's
leave button, which does surface errors. The two entry points now agree.

Closes block#3605
@iroiro147
iroiro147 requested a review from a team as a code owner July 30, 2026 05:49
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.

Desktop: leaving a channel you solely own fails silently — the relay's rejection is never surfaced

1 participant