Skip to content

Conversation

@glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Nov 23, 2025

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Local SPA-friendly Ultralytics Chat widget is added to the handbook and wired into MkDocs, replacing the previous CDN-loaded script.

πŸ“Š Key Changes

  • βž• Introduces a full docs/overrides/javascript/chat.js implementation for the Ultralytics Chat widget, optimized for SPA/Turbo/Turbolinks behavior and in-page resilience.
  • 🎨 Adds custom styling, markdown rendering, code highlighting (Highlight.js), tooltips, and improved UX (editing, retrying, copying, downloading threads, search mode) directly in the handbook.
  • πŸ”§ Updates mkdocs.yml to stop loading the CDN-hosted chat.min.js and instead load the new local javascript/chat.js.

🎯 Purpose & Impact

  • βœ… Fixes SPA-related issues by making the chat widget robust to page transitions and DOM mutations within the handbook.
  • πŸš€ Improves reliability and control by bundling the chat client locally rather than relying on an external CDN script.
  • 🧭 Enhances the docs experience with a richer, more integrated Ultralytics Chat assistant, including search support and better message management for users.

@vercel
Copy link

vercel bot commented Nov 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
handbook Ready Ready Preview Comment Nov 23, 2025 6:18pm

@UltralyticsAssistant UltralyticsAssistant added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 23, 2025
@UltralyticsAssistant
Copy link
Member

πŸ‘‹ Hello @glenn-jocher, thank you for submitting a ultralytics/handbook πŸš€ PR! This is an automated review helper; a Ultralytics engineer will be with you shortly. In the meantime, please review the checklist below to ensure a seamless integration of your work:

  • βœ… Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • βœ… Synchronize with Source: Confirm your PR is synchronized with the ultralytics/handbook main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • βœ… Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • βœ… Update Documentation: Update the relevant documentation for any new or modified features.
  • βœ… Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • βœ… Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • βœ… Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." β€” Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! πŸš€

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

πŸ” PR Review

Made with ❀️ by Ultralytics Actions

Please restore multi-turn context when calling the chat API, harden the DOM watcher so SPA mutations can’t permanently remove the widget, and avoid disabling user zoom in ensureViewport() to keep the docs accessible.

πŸ’¬ Posted 3 inline comments

const safeEditIndex =
Number.isInteger(editIndex) && editIndex >= 0 && editIndex < this.messages.length ? editIndex : null;
try {
const body = {

Choose a reason for hiding this comment

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

⚠️ HIGH: sendMessage() always posts only the latest user message (messages: [{ role: "user", content: text }]) to the API, so the backend never receives the prior conversation. This breaks multi‑turn context, makes retries/edits inconsistent, and prevents the assistant from referencing earlier exchanges. Build the payload from the saved this.messages (or at least the trimmed history) so the API can generate contextual responses.

Suggested change:

Suggested change
const body = {
messages: this.messages.concat({ role: "user", content: text }),

});
}

ensureViewport() {

Choose a reason for hiding this comment

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

πŸ’‘ MEDIUM: ensureViewport() forces maximum-scale=1,user-scalable=no for every page. Disabling pinch‑zoom is an accessibility regression (WCAG 1.4.4/1.4.10) and will frustrate mobile readers of the handbook. Consider leaving the site’s existing viewport meta untouched or only adding missing attributes without blocking zoom.

viewport.content = "width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no";
}

watchForRemoval() {

Choose a reason for hiding this comment

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

πŸ’‘ MEDIUM: watchForRemoval() observes only direct children of document.documentElement (childList: true without subtree). Removing the pill or modal from document.body (common during SPA navigations) won’t trigger the observer, so the widget can disappear permanently until a full reload. Observe the parent nodes (e.g., document.body/document.head) with subtree: true to reliably reattach the permanent elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants