fix: unmount kapa widget from default error page#2598
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the global KapaWidget theme component to ensure the Kapa AI widget is not shown on the Kratos fallback error page, aligning the widget’s behavior with that page’s intended “error/fallback” UX.
Changes:
- Adds route detection via
useLocation()to identify excluded paths. - Unmounts the Kapa widget and prevents rendering the trigger button on
/docs/kratos/fallback/error.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthrough
ChangesRoute-aware Kapa widget exclusion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 `@src/theme/KapaWidget.tsx`:
- Around line 11-19: When isExcluded changes the effect currently calls (window
as any).Kapa("unmount") but the component returns null leaving isScriptLoaded
true so the widget never remounts; update the KapaWidget logic to reset the
isScriptLoaded state (or call setIsScriptLoaded(false)) when performing the
unmount in the useEffect that references isExcluded, and ensure loadKapaWidget
checks for the component returning from an excluded route by calling (window as
any).Kapa("render") (or re-running the script load) when isExcluded transitions
from true to false so the widget actually remounts; locate the useEffect in
KapaWidget, the isScriptLoaded state variable, and the loadKapaWidget function
to implement this behavior.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ca27a345-a8b2-45ef-a729-ebf1fccdb755
📒 Files selected for processing (1)
src/theme/KapaWidget.tsx
Related Issue or Design Document
Checklist
If this pull request addresses a security vulnerability,
I confirm that I got approval (please contact security@ory.com) from the maintainers to push the changes.
Further comments
Summary by CodeRabbit