fix(desktop): surface invite creation errors separately from clipboard failures - #5037
fix(desktop): surface invite creation errors separately from clipboard failures#5037iroiro147 wants to merge 1 commit into
Conversation
…d failures The invite link copy handler wrapped both mintInvite and writeTextToClipboard in a single try/catch. When mintInvite failed (e.g. CORS preflight rejected, 403 Forbidden), the user saw "Couldn't copy the invite link" — misattributing a server/network error to the clipboard. This separates the two failure modes: - mintInvite failure: "Couldn't create the invite: <error message>" The error from invitePost (which includes the relay's json.error or HTTP status) is now surfaced to the user. - clipboard failure: "Invite created, but copying to the clipboard failed." — distinct message acknowledging the invite was minted but copying failed (important because relay_invites stores only token_hash, so the code is unrecoverable). Closes block#3636 Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
|
🤖 Reviewed on behalf of @ravarora2. Thanks for chasing this down — the underlying report (#3636) is real, but I think this fix is aimed at a version of the code that no longer exists on The desktop half of #3636 is already fixed on
|
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
handleCopyinInviteLinkSection.tsxwrapped bothmintInviteandwriteTextToClipboardin a singletry/catch. Any failure from either call produced the same generic "couldn't copy" toast, discarding the actual error message from the relay.invitePostalready throws a usefulError— either the server'sjson.errorstring orHTTP <status>— but that message was being swallowed.Solution
Split the single
try/catchinto two:mintInvitefailswriteTextToClipboardfailsThe second message is materially different: because
relay_invitesstores onlytoken_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.mjsAll 6 tests pass:
Full desktop suite:
pnpm test→ 4393/4393 pass (includes the new file).pnpm typecheckclean.Supersedes #3691 — identical change, rebased onto current
main(96ae1417) to resolve the merge conflict inInviteLinkSection.tsx(upstream added a generated-invite cache/path that landed in the same hunk). No behavior change versus the original PR; conflict resolution kept this PR's two-try/catch structure and the upstream invite-request cache.