This repository was archived by the owner on Sep 15, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 15, 2026. It is now read-only.
Improve carpincho-wallet popup INP: debounce password scoring and trim recurring work #62
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestpriority: highMust be addressed in current sprintMust be addressed in current sprint
Description
Part of epic #40. Track: INP (interaction responsiveness). Paths are relative to
carpincho-wallet/.
Priority
High
User story / Problem statement
Currently, password strength scoring blocks the main thread on every keystroke in the carpincho-wallet popup, and recurring background work (status polling, un-memoized handlers) competes with interactions while Home is mounted. This degrades the popup's INP on the common unlock/home path.
Expected outcome
- Password strength scoring no longer blocks keystroke repaint and is computed once per render rather than redundantly.
- Recurring main-thread work does not run while the popup is hidden and is cheaper while visible.
- Home-view re-renders are not defeated by handler closures recreated every render.
Acceptance criteria
- Password strength scoring is debounced (150–250 ms via
useDeferredValueor a timer) so keystrokes paint immediately, and the score is computed once per render and passed down (no doublescorePasswordcall). -
useWalletServiceStatuspolling pauses when the popup is hidden (document.visibilityState) and backs off its interval. -
usePendingActionshandler closures are memoized (useCallback/ stable object) andPendingActionsSectionisReact.memo'd so spreading handlers no longer defeats memoization.
Technical notes
- [High]
src/components/PasswordStrengthIndicator.tsx:23—scorePassword(password)runszxcvbn()synchronously inside render; the component re-renders on every keystroke becausepasswordis controlled state inNewPasswordFields(src/components/NewPasswordFields.tsx:59). zxcvbn is a known INP killer; every keypress blocks the main thread before the input repaints. The 1-entry memo (src/vault/passwordStrength.ts:34) only helps repeated identical strings.isNewPasswordPairValid(src/components/NewPasswordFields.tsx:39) callsscorePassworda second time per render, doubling the work. Fix: debounce scoring and compute once, pass down. - [High / resolved-by-feedback]
src/vault/crypto.ts:4—KDF_ITERATIONS = 600_000PBKDF2-HMAC-SHA256 viacrypto.subtle.deriveKey(src/vault/crypto.ts:35), invoked byunlock()on the unlock click.crypto.subtleis async and typically off the main thread in Chrome, so it does not fully block the event loop; 600k is a deliberate security trade-off.UnlockViewsets busy synchronously and shows "Unlocking…" (src/views/UnlockView.tsx:74). No code change needed beyond existing feedback. Flag only if profiling shows the click handler itself janks. - [Medium]
src/hooks/useWalletServiceStatus.ts:65— a 5-secondsetIntervalfireswalletServiceRequest('status')continuously while Home is mounted, each tick re-renderingHomeViewand below — recurring main-thread work competing with interactions. Fix: pause polling when the popup is hidden (document.visibilityState) and back off the interval. - [Medium]
src/views/HomeView.tsx:148—HomeViewholds ~7useStateslices;usePendingActions(src/views/home/usePendingActions.ts:57) returns six handler closures recreated every render (nouseCallback), spread intoPendingActionsSectionvia{...pendingActions}(src/views/HomeView.tsx:172), defeating memoization. Cost is wasted re-renders. Fix: memoize the handler object / wrap inuseCallbackandReact.memothe section. - [Low]
src/vault/VaultContext.tsx:419— idle auto-lock effect registers mousemove/keydown/click/scroll/touchstart; reset runs per event but is passive and storage writes are throttled to 5 s, so per-event cost is just clearTimeout/setTimeout. Noted for completeness; throttle is the right mitigation.
Additional context
Method: static (lab/heuristic) review — extension popups have no CrUX field data. Finding 7 is resolved by existing UX feedback and carries no code change.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpriority: highMust be addressed in current sprintMust be addressed in current sprint
Activity