fix: stop prompting for bitcoin: protocol handler on every load#2369
Conversation
Browsers re-show the registerProtocolHandler prompt every time it is called if the user dismissed (X'd) the previous one without explicitly accepting or denying. Gate the call with sessionStorage so we ask at most once per browser session. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe hook computes a handler URL and uses a module-level ChangesSession-aware protocol handler registration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/hooks/useRegisterProtocolHandler.ts`:
- Around line 20-22: The hook useRegisterProtocolHandler currently calls
sessionStorage.getItem(STORAGE_KEY) outside the existing try/catch, which can
throw in restricted/private browsing; wrap the getItem access in the same
defensive logic as setItem (either pre-check window.sessionStorage existence or
move both getItem and setItem inside the try/catch) so both reads and writes are
protected, referencing STORAGE_KEY and the sessionStorage getItem/setItem calls
in useRegisterProtocolHandler.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6b4c2e7a-0195-4eb1-8388-576c2ee7057c
📒 Files selected for processing (1)
frontend/src/hooks/useRegisterProtocolHandler.ts
sessionStorage.getItem and setItem can throw in private browsing or restricted storage modes. Move both inside the existing try/catch so an exception doesn't break the hook. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
sessionStorage is tab-scoped and ephemeral, so comparing the stored handler URL gains nothing over a plain truthy check. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit