Skip to content

Bring in kapa ai widget to docs site #1305

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

Merged
merged 3 commits into from
Jan 31, 2025
Merged

Bring in kapa ai widget to docs site #1305

merged 3 commits into from
Jan 31, 2025

Conversation

jvmi7
Copy link
Contributor

@jvmi7 jvmi7 commented Jan 30, 2025

Bringing in Kapa.ai to the docs site

@jvmi7 jvmi7 requested a review from a team as a code owner January 30, 2025 19:49
Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for docs-optimism ready!

Name Link
🔨 Latest commit efdf5b0
🔍 Latest deploy log https://app.netlify.com/sites/docs-optimism/deploys/679d0e249b5aca0008e437ab
😎 Deploy Preview https://deploy-preview-1305--docs-optimism.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

📝 Walkthrough

Walkthrough

The pull request introduces changes to two files: package.json and theme.config.tsx. A new dependency, @remixicon/react version 4.6.0, is added to the project, indicating the integration of a React icon library. In the theme.config.tsx file, several modifications are made, including the import of the RiSparkling2Fill icon, updates to the configuration object's structure, and formatting adjustments. A new navbar property is introduced, which includes a button element with a specific ID, while various configuration sections are refined for consistent quote usage and simplified JSX structures.

Possibly related PRs

  • Enable same-page navigation #979: The changes in theme.config.tsx regarding the configuration structure and the useNextSeoProps function are related to the modifications made in the main PR, particularly the updates to the theme.config.tsx file, which also involve configuration adjustments and the use of imports.

Suggested reviewers

  • cpengilly

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
theme.config.tsx (1)

44-86: Consider using CSS modules instead of inline styles.

The footer implementation would be more maintainable using CSS modules or styled-components instead of inline styles. This would improve code readability and reusability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f16660 and 0e84d4e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • theme.config.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules - docs-optimism
  • GitHub Check: Header rules - docs-optimism
  • GitHub Check: Pages changed - docs-optimism
  • GitHub Check: pr-workflow
🔇 Additional comments (3)
theme.config.tsx (2)

33-40: LGTM! Well-structured navbar integration.

The navbar implementation with the "Ask AI" button is clean and properly integrated with the Kapa widget configuration.


127-135: LGTM! Comprehensive meta tags implementation.

The meta tags implementation follows SEO best practices with proper OpenGraph and Twitter card integration.

package.json (1)

26-26: Verify the @remixicon/react package version.

Let's check for any security advisories and ensure we're using a stable version.

✅ Verification successful

@remixicon/react version is appropriate and secure

The package is using the latest available version (4.6.0) with no known security vulnerabilities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for security advisories and latest version
curl -s "https://registry.npmjs.org/@remixicon/react" | jq '.["dist-tags"].latest'

# Check for known vulnerabilities
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "@remixicon/react") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
    }
  }
}'

Length of output: 385

Copy link
Contributor

@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

🧹 Nitpick comments (2)
theme.config.tsx (2)

149-149: Consider increasing the max-tokens limit.

The current max-tokens limit of 100 might be too restrictive for comprehensive responses, especially for complex technical questions about Optimism's documentation.

Consider increasing the limit to 500-1000 tokens for more detailed responses:

-  data-max-tokens='100'
+  data-max-tokens='500'

144-145: Consider enhancing the modal disclaimer and examples.

The modal disclaimer and example questions could be more comprehensive to better guide users.

Consider updating the content:

-  data-modal-disclaimer='This is a custom LLM for OPLabs with access to [all help center documentation](https://docs.optimism.io/).'
-  data-modal-example-questions='What is the OP Stack?, How do I get started with Supersim?, How do I create a SuperERC20 token?, How do I get faucet funds?'
+  data-modal-disclaimer='This AI assistant is trained on Optimism documentation and can help answer your technical questions. For the latest information, always refer to [our official documentation](https://docs.optimism.io/).'
+  data-modal-example-questions='What is the OP Stack and its components?, How do I deploy and test a contract on Optimism?, What are the steps to bridge assets to Optimism?, How do I integrate Optimism into my dApp?'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e84d4e and 7c6d8f7.

📒 Files selected for processing (1)
  • theme.config.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pr-workflow
  • GitHub Check: Redirect rules - docs-optimism
  • GitHub Check: Header rules - docs-optimism
  • GitHub Check: Pages changed - docs-optimism
🔇 Additional comments (2)
theme.config.tsx (2)

33-39: LGTM! Well-structured AI button implementation.

The custom Ask AI button is well-implemented with clear styling and proper icon integration.


136-151: ⚠️ Potential issue

Security and configuration improvements needed.

Several configuration values in the Kapa.ai widget script should be moved to environment variables for better security and maintainability.

Apply this diff:

 <script
   async
   src='https://widget.kapa.ai/kapa-widget.bundle.js'
   data-website-id={process.env.NEXT_PUBLIC_KAPA_WEBSITE_ID}
-  data-project-name='OP Labs'
-  data-project-color='#FF0420'
-  data-modal-title='Optimism Docs Assistant ✨'
-  data-project-logo='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8nhCmw7cu6jVQI01JFtMAV5tkTNLJXMSAOg&s'
+  data-project-name={process.env.NEXT_PUBLIC_KAPA_PROJECT_NAME}
+  data-project-color={process.env.NEXT_PUBLIC_KAPA_PROJECT_COLOR}
+  data-modal-title={process.env.NEXT_PUBLIC_KAPA_MODAL_TITLE}
+  data-project-logo={process.env.NEXT_PUBLIC_KAPA_PROJECT_LOGO}
   data-modal-disclaimer='This is a custom LLM for OPLabs with access to [all help center documentation](https://docs.optimism.io/).'
   data-modal-example-questions='What is the OP Stack?, How do I get started with Supersim?, How do I create a SuperERC20 token?, How do I get faucet funds?'
   data-user-analytics-fingerprint-enabled='true'
   data-modal-override-open-id='custom-ask-ai-button'
   data-button-hide='true'
-  data-max-tokens='100'
+  data-max-tokens={process.env.NEXT_PUBLIC_KAPA_MAX_TOKENS || '100'}
   data-modal-theme='dark'
 ></script>

Likely invalid or redundant comment.

Copy link
Contributor

@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: 0

♻️ Duplicate comments (1)
theme.config.tsx (1)

136-149: ⚠️ Potential issue

Enhance security and privacy compliance of the Kapa.ai widget.

Several improvements are needed:

  1. Move more configuration values to environment variables
  2. Consider privacy implications of fingerprinting

Apply these changes:

         <script
           async
           src='https://widget.kapa.ai/kapa-widget.bundle.js'
           data-website-id={process.env.NEXT_PUBLIC_KAPA_WEBSITE_ID}
-          data-project-name='OP Labs'
-          data-project-color='#FF0420'
+          data-project-name={process.env.NEXT_PUBLIC_KAPA_PROJECT_NAME}
+          data-project-color={process.env.NEXT_PUBLIC_KAPA_PROJECT_COLOR}
           data-modal-title='Optimism Docs Assistant ✨'
-          data-project-logo='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8nhCmw7cu6jVQI01JFtMAV5tkTNLJXMSAOg&s'
+          data-project-logo={process.env.NEXT_PUBLIC_KAPA_PROJECT_LOGO}
           data-modal-example-questions='What is the OP Stack?, How do I get started with Supersim?, How do I create a SuperERC20 token?, How do I get faucet funds?'
-          data-user-analytics-fingerprint-enabled='true'
+          data-user-analytics-fingerprint-enabled={process.env.NEXT_PUBLIC_KAPA_ANALYTICS_ENABLED}
           data-modal-override-open-id='custom-ask-ai-button'
           data-button-hide='true'
-          data-max-tokens='100'
+          data-max-tokens={process.env.NEXT_PUBLIC_KAPA_MAX_TOKENS || '100'}
         ></script>
🧹 Nitpick comments (3)
theme.config.tsx (3)

35-38: Enhance accessibility and maintainability of the Ask AI button.

Consider these improvements:

  1. Add aria-label for screen readers
  2. Extract inline styles to maintain consistency
-      <button id='custom-ask-ai-button' className='nx-flex nx-gap-2 nx-items-center nx-py-1.5 nx-px-3 nx-rounded-lg nx-text-sm nx-font-semibold' style={{ backgroundColor: '#FF0420', color: 'white', display: 'flex', alignItems: 'center', gap: '4px' }}>
+      <button 
+        id='custom-ask-ai-button'
+        aria-label="Open AI Assistant"
+        className='nx-flex nx-gap-2 nx-items-center nx-py-1.5 nx-px-3 nx-rounded-lg nx-text-sm nx-font-semibold ask-ai-button'>
         <span>Ask AI</span>
         <RiSparkling2Fill size={14} />
       </button>

127-134: Enhance social sharing metadata.

The default description "Optimism Docs for developers" could be more specific and engaging.

         <meta property='og:url' content={url} />
         <meta property='og:title' content={frontMatter.title || 'Optimism Docs'} />
-        <meta property='og:description' content={frontMatter.description || 'Optimism Docs for developers'} />
+        <meta property='og:description' content={frontMatter.description || 'Learn how to build and deploy on Optimism - comprehensive guides, tutorials, and API references for developers.'} />
         <meta property='og:image' content='https://docs.optimism.io/logos/docs-header.png' />
         <meta name='twitter:card' content='summary_large_image' />
         <meta name='twitter:title' content={frontMatter.title || 'Optimism Docs'} />
-        <meta name='twitter:description' content={frontMatter.description || 'Optimism Docs for developers'} />
+        <meta name='twitter:description' content={frontMatter.description || 'Learn how to build and deploy on Optimism - comprehensive guides, tutorials, and API references for developers.'} />

28-28: Enhance the SDK deprecation announcement banner.

The banner could benefit from better styling and accessibility.

-    text: <a href='/builders/notices/sdk-deprecation'>🎉 We are deprecating the Optimism SDK and migrating all tutorials to use viem/op-stack. Read more →</a>
+    text: (
+      <a 
+        href='/builders/notices/sdk-deprecation'
+        className="nx-flex nx-items-center nx-gap-2 hover:nx-underline"
+        aria-label="Read more about SDK deprecation"
+      >
+        <span role="img" aria-label="Celebration">🎉</span>
+        We are deprecating the Optimism SDK and migrating all tutorials to use viem/op-stack. Read more →
+      </a>
+    )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c6d8f7 and efdf5b0.

📒 Files selected for processing (1)
  • theme.config.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Redirect rules - docs-optimism
  • GitHub Check: Header rules - docs-optimism
  • GitHub Check: Pages changed - docs-optimism
  • GitHub Check: pr-workflow

@jvmi7 jvmi7 merged commit 657635a into main Jan 31, 2025
8 checks passed
@jvmi7 jvmi7 deleted the ai-docs branch January 31, 2025 18:21
@coderabbitai coderabbitai bot mentioned this pull request Feb 28, 2025
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.

2 participants