Skip to content

IOS fix: only insert Kapa.ai script for newer versions of IOS #3803

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Blargian
Copy link
Member

Summary

Several users reported issues on IPhone and IPad such as:

  • missing Ask AI widget
  • unable to open search modal or menus
  • code blocks not loading
  • images not rendering

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:

SyntaxError: Invalid regular expression: invalid group specifier name
(anonymous)	@	kapa-widget.bundle.js:3

Kapa confirmed this is an issue but they will not fix it as it is an incompatibility with older IOS devices.

image
image

We will not load the widget on these older devices.

Checklist

@Blargian Blargian requested a review from a team as a code owner May 15, 2025 13:15
Copy link

vercel bot commented May 15, 2025

@Blargian is attempting to deploy a commit to the ClickHouse Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented May 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clickhouse-docs ✅ Ready (Inspect) Visit Preview May 17, 2025 5:49pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
clickhouse-docs-ru ⬜️ Ignored (Inspect) Visit Preview May 17, 2025 5:49pm
clickhouse-docs-zh ⬜️ Ignored (Inspect) Visit Preview May 17, 2025 5:49pm

@vercel vercel bot temporarily deployed to Preview – clickhouse-docs May 15, 2025 13:24 Inactive
Copy link
Contributor

@Copilot 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 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.js for runtime iOS version detection and conditional script insertion
  • Update docusaurus.config.en.js to 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 isOldiOS function 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.js may not match where Docusaurus serves static files (static/js/kapa_widget.js typically 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);
Copy link
Preview

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

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

Fix typo in the log message: change occured to occurred.

Suggested change
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);

Copilot uses AI. Check for mistakes.

Comment on lines +27 to +29
// 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);
Copy link
Preview

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

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

[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.

Suggested change
// 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);

Copilot uses AI. Check for mistakes.

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.

[BUG] Image rendering issues on Ipad browsers
1 participant