Skip to content

fix: unmount kapa widget from default error page#2598

Merged
vinckr merged 1 commit into
masterfrom
vinckr/fix-kapa-spam
Jun 3, 2026
Merged

fix: unmount kapa widget from default error page#2598
vinckr merged 1 commit into
masterfrom
vinckr/fix-kapa-spam

Conversation

@vinckr
Copy link
Copy Markdown
Member

@vinckr vinckr commented Jun 3, 2026

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    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.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Widget no longer displays on excluded routes, improving page experience and properly cleaning up resources.

Copilot AI review requested due to automatic review settings June 3, 2026 07:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/theme/KapaWidget.tsx
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

KapaWidget now imports useLocation and useEffect to become route-aware. It defines an EXCLUDED_PATHS list, checks if the current pathname is excluded, unmounts the Kapa widget via useEffect when present on excluded routes, and returns null to prevent rendering the widget button.

Changes

Route-aware Kapa widget exclusion

Layer / File(s) Summary
Exclude Kapa widget from specified routes
src/theme/KapaWidget.tsx
Import useEffect and useLocation to enable route detection. Define EXCLUDED_PATHS, compute exclusion status from current pathname, unmount the Kapa widget on excluded routes via useEffect, and return null to prevent widget rendering on those paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • aeneasr
  • zepatrik
  • wassimoo
  • piotrmsc

Poem

🐰 A widget so clever, now knows where to go,
On paths that are hidden, it bows out of show,
With hooks and location, so smart and so quick,
This route-aware friend has a very neat trick! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only the template placeholders with no actual content filled in - no explanation of changes, no issue reference, and all checklist items are unchecked. Add a meaningful description explaining why the Kapa widget needs to be unmounted from the error page, reference a related issue, and check applicable checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: unmounting the Kapa widget from the default error page, which aligns with the code changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vinckr/fix-kapa-spam

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa45903 and 517062c.

📒 Files selected for processing (1)
  • src/theme/KapaWidget.tsx

Comment thread src/theme/KapaWidget.tsx
@vinckr vinckr merged commit a35d541 into master Jun 3, 2026
16 checks passed
@vinckr vinckr deleted the vinckr/fix-kapa-spam branch June 3, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants