Repository navigation
feat(web): implement share link creation with loading state - #577
Merged
Merged
Conversation
Added functionality to prevent multiple submissions of the share link creation request by introducing a loading state. The button is disabled during the request, and the UI reflects the loading status. Updated tests to ensure only one request is sent when the button is clicked multiple times and to restore the button state after a failed request. Signed-off-by: Okiri Gabriel <okirigabriel24@gmail.com> Signed-off-by: Maxerns <maksafk@gmail.com>
Maxerns
force-pushed
the
fix/share-link-loading
branch
from
October 13, 2026 10:05
a4b55a9 to
316d82c
Compare
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: Disable the one-time share button and guard the request in-flight so duplicate clicks cannot mint extra burn-after-reading links.
Closes #243
References #331
Why
Clicking "Create one-time share link" dispatches
api.createShare(...)asynchronously. Without an in-flight guard or disabled button state, rapid clicks (such as double-clicking or clicking while on a high-latency connection) dispatch multiple concurrent requests.Because one-time share links are ephemeral zero-knowledge fragments designed to burn after reading, duplicate requests create orphaned burn links on the server and race against the client state.
What it does
creatingShareRefandcreatingSharestate inVaultView.tsx, matching the existing concurrency protection patterns used by environment rotation (rotatingEnvRef) and environment sharing (sharingEnvRef).share(current): subsequent clicks while a request is in flight return immediately.disabled={creatingShare}during request processing.creatingShareRef.current = falseandsetCreatingShare(false)in afinallyblock, ensuring the button re-enables if the request fails so the user can retry.revealGeneration.currentcheck introduced onmainso that late-resolving or stale share completions do not corrupt the view if the user switched or hid secrets.Decisions worth arguing with
creatingShareRefwithrevealGeneration:PR Web: prevent duplicate one-time share-link creation #331 originally added
creatingShareRef/creatingSharebeforemainintroduced therevealGenerationguard. During rebase onto currentmain, both guards are preserved: the ref guard rejects concurrent clicks before request dispatch, while the generation check discards completions if the user navigated away.React state updates (
setCreatingShare) are asynchronous and do not prevent multiple clicks occurring in the same microtask/event turn.creatingShareRef.currentsynchronously gates re-entry, whilecreatingSharedrives the UI disabled/loading state.Proving tests have teeth
npm --prefix web test -- src/__tests__/VaultView.test.tsx. All 44 tests pass.if (creatingShareRef.current) return;causes the double-click test inVaultView.test.tsxto fail immediately:createSharepromise asserts that the error is surfaced in an alert role and the button returns to the enabled state.What is tested and what is not
Tested:
VaultView.test.tsx, 160/160 tests passing across all 17 test suites inweb/.act().npm --prefix web run build).What is not tested:
I signed off every commit (
git commit -s/ Developer Certificate of Origin).