IOS fix: only insert Kapa.ai script for newer versions of IOS#3803
Conversation
|
@Blargian is attempting to deploy a commit to the ClickHouse Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
There was a problem hiding this comment.
Pull Request Overview
This PR prevents the Kapa.ai widget from loading on iOS versions 16.4 or lower by dynamically inserting the loader script only on supported devices.
- Add
static/js/kapa_widget.jsfor runtime iOS version detection and conditional script insertion - Update
docusaurus.config.en.jsto load the new dynamic loader instead of directly embedding Kapa’s bundle
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| static/js/kapa_widget.js | New utility script that checks navigator.userAgent and inserts the widget only on iOS > 16.4 or non-iOS devices |
| docusaurus.config.en.js | Replaced direct Kapa script entry with reference to the dynamic loader at /docs/js/kapa_widget.js |
Comments suppressed due to low confidence (3)
static/js/kapa_widget.js:43
- The comment references a "look behind regex," but the code uses a standard
/OS (\d+)(?:_(\d+))?/pattern. Update or remove the misleading comment.
// Only insert script if not running on older iOS as Kapa does not support it (using a look behind regex)
static/js/kapa_widget.js:12
- The
isOldiOSfunction contains branching logic for parsing versions and fallbacks, but there are no unit tests covering iOS UA edge cases (e.g., missing version, malformed strings). Consider adding tests to cover these code paths.
const iosVersionMatch = ua.match(/OS (\d+)(?:_(\d+))?/);
docusaurus.config.en.js:30
- The path
/docs/js/kapa_widget.jsmay not match where Docusaurus serves static files (static/js/kapa_widget.jstypically becomes/js/kapa_widget.js). Verify the correct URL or adjust the path accordingly to avoid a 404.
src: "/docs/js/kapa_widget.js",
| try { | ||
| insertKapaWidget(); | ||
| } catch (e) { | ||
| console.log("An error occured while trying to load the Kapa.ai widget:", e); |
There was a problem hiding this comment.
Fix typo in the log message: change occured to occurred.
| console.log("An error occured while trying to load the Kapa.ai widget:", e); | |
| console.log("An error occurred while trying to load the Kapa.ai widget:", e); |
| // Return true if iOS version is 16.4 or lower | ||
| // (major < 16) OR (major == 16 AND minor <= 4) | ||
| return majorVersion < 16 || (majorVersion === 16 && minorVersion <= 4); |
There was a problem hiding this comment.
[nitpick] Consider extracting 16 and 4 into named constants (e.g., MIN_SUPPORTED_MAJOR, MIN_SUPPORTED_MINOR) to improve readability and simplify future version updates.
| // Return true if iOS version is 16.4 or lower | |
| // (major < 16) OR (major == 16 AND minor <= 4) | |
| return majorVersion < 16 || (majorVersion === 16 && minorVersion <= 4); | |
| // Return true if iOS version is below the minimum supported version | |
| // (major < MIN_SUPPORTED_MAJOR) OR (major == MIN_SUPPORTED_MAJOR AND minor <= MIN_SUPPORTED_MINOR) | |
| return majorVersion < MIN_SUPPORTED_MAJOR || (majorVersion === MIN_SUPPORTED_MAJOR && minorVersion <= MIN_SUPPORTED_MINOR); |
Summary
Several users reported issues on IPhone and IPad such as:
I was able to replicate on several older IOS devices and in each case the Ask AI widget is missing and I get this in the console:
Kapa confirmed this is an issue but they will not fix it as it is an incompatibility with older IOS devices.
We will not load the widget on these older devices.
Checklist