buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(desktop): surface invite creation errors separately from clipboard failures

Open iroiro147 opened this issue 4 months ago • 0 comments

Problem

When creating an invite link failed (e.g. CORS preflight rejected, 403 Forbidden, network timeout), the user saw "Couldn't copy the invite link. Try again." — misattributing a server/network error to the clipboard. This was actively misleading: the clipboard worked fine elsewhere in the app, but the error message sent users looking at Tauri clipboard permissions instead of the network.

Closes #3636 (desktop part)

Root Cause

handleCopy in InviteLinkSection.tsx wrapped both mintInvite and writeTextToClipboard in a single try/catch. Any failure from either call produced the same generic "couldn't copy" toast, discarding the actual error message from the relay.

invitePost already throws a useful Error — either the server's json.error string or HTTP <status> — but that message was being swallowed.

Solution

Split the single try/catch into two:

Failure Old message New message
mintInvite fails "Couldn't copy the invite link. Try again." "Couldn't create the invite: <error.message>"
writeTextToClipboard fails (same) "Invite created, but copying to the clipboard failed."

The second message is materially different: because relay_invites stores only token_hash, an invite whose code fails to reach the clipboard is unrecoverable. Telling the user it was created but not copied is different from telling them to just try again.

Test Plan

cd desktop
node --test src/features/community-members/ui/inviteLinkErrorSeparation.test.mjs

All 6 tests pass:

  • both succeed: copies invite and shows success toast
  • mintInvite fails: shows creation error, does not attempt clipboard
  • clipboard fails: shows clipboard-specific error, invite was created
  • mintInvite error message is surfaced to the user
  • non-Error thrown by mintInvite produces generic message
  • copying status is set during operation

iroiro147 avatar Jul 30 '26 05:07 iroiro147