-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Integrate LLM side panel chat using CrawlChat #5787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| type: 'html', | ||
| position: 'right', | ||
| value: | ||
| '<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed.toggleSidePanel()"></button>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| '<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed.toggleSidePanel()"></button>', | |
| '<button aria-label="Ask AI" class="crawlchat-nav-askai header-ask-ai-link" onclick="window.crawlchatEmbed?.toggleSidePanel()"></button>', |
The "Ask AI" button's onclick handler doesn't check if window.crawlchatEmbed exists before calling toggleSidePanel(), which will cause a runtime error if the CrawlChat embed script fails to load.
View Details
Analysis
Runtime error in Ask AI button onclick handler when CrawlChat script fails to load
What fails: The "Ask AI" button's onclick handler in packages/docs/docusaurus.config.ts calls window.crawlchatEmbed.toggleSidePanel() without null checking, causing TypeError: Cannot read properties of undefined (reading 'toggleSidePanel') when the external CrawlChat script fails to load.
How to reproduce:
- Block the CrawlChat script (https://crawlchat.app/embed.js) via ad blocker, network failure, or CSP
- Load the docs website
- Click the "Ask AI" button in the navbar
Result: Browser throws TypeError: Cannot read properties of undefined (reading 'toggleSidePanel') in console and button functionality fails
Expected: Button should gracefully degrade when external script unavailable (no error, silent failure acceptable for optional feature)
Fix: Added optional chaining operator (?.) to safely handle undefined window.crawlchatEmbed object, consistent with existing defensive programming patterns in the codebase (e.g., window.location?.origin?.includes() in src/pages/index.tsx).
No description provided.