-
-
Notifications
You must be signed in to change notification settings - Fork 27
Test SPA js fix #220
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
Test SPA js fix #220
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
π Hello @glenn-jocher, thank you for submitting a
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! π |
UltralyticsAssistant
left a comment
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.
π 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 = { |
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.
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:
| const body = { | |
| messages: this.messages.concat({ role: "user", content: text }), |
| }); | ||
| } | ||
|
|
||
| ensureViewport() { |
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.
π‘ 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() { |
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.
π‘ 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.
π οΈ 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
docs/overrides/javascript/chat.jsimplementation for the Ultralytics Chat widget, optimized for SPA/Turbo/Turbolinks behavior and in-page resilience.mkdocs.ymlto stop loading the CDN-hostedchat.min.jsand instead load the new localjavascript/chat.js.π― Purpose & Impact