Skip to content

Conversation

@jhaaaa
Copy link
Collaborator

@jhaaaa jhaaaa commented Oct 17, 2025

Inject DocsBotAI chat widget loader into all pages via head in vocs.config.tsx to test XMTP DocsBot

This change adds an inline <script> to the head output in vocs.config.tsx that defines window.DocsBotAI.init, dynamically inserts https://widget.docsbot.ai/chat.js, waits for the script to load, mounts the widget, uses a MutationObserver to wait for #docsbotai-root, and immediately invokes DocsBotAI.init with a specific id string. The script is rendered alongside existing head scripts.

📍Where to Start

Start with the head function in vocs.config.tsx to review the inline script injection and initialization logic.


📊 Macroscope summarized 3759ea7. 1 files reviewed, 5 issues evaluated, 4 issues filtered, 0 comments posted

🗂️ Filtered Issues

vocs.config.tsx — 0 comments posted, 5 evaluated, 4 filtered
  • line 26: search.boostDocument calls documentId.includes(...) without guarding for non-string inputs. If documentId is undefined, null, or a non-string, this will throw at runtime and may break search indexing or result boosting. Add a type check or default to an empty string before calling includes. [ Low confidence ]
  • line 39: search.filter calls result.id.includes(...) without guarding for result.id being undefined, null, or non-string. This can cause a runtime exception during search result filtering. Add a check (e.g., typeof result.id === 'string') before using includes. Also, mutating result.section assumes the object is mutable and that the framework reads this property; if vocs expects immutability or ignores mutations, this may have no effect or cause subtle issues. [ Invalidated by documentation search ]
  • line 67: DocsBotAI.init does not guard against multiple invocations across SPA navigations or re-renders of head. Each call inserts a new <script src="https://widget.docsbot.ai/chat.js"> and triggers mount, potentially leading to duplicate script loads, duplicate widget instances, or re-entrancy errors. Implement an idempotency guard (e.g., check for an existing script by src, or a window.DocsBotAI.__initialized flag) and ensure at-most-once mounting with a swap-and-clear or state transition. [ Invalidated by documentation search ]
  • line 82: The DocsBotAI.init logic waits for a DOM element #docsbotai-root using a MutationObserver and a Promise, but does not implement a timeout. If the element never appears (e.g., due to widget failure or markup differences), the Promise will never resolve, DocsBotAI.init will never fulfill, and the MutationObserver will continue observing indefinitely, leaking resources. Add a timeout with rejection and ensure the observer disconnects on all exit paths. [ Invalidated by documentation search ]

@jhaaaa jhaaaa requested a review from a team as a code owner October 17, 2025 23:58
@vercel
Copy link

vercel bot commented Oct 17, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs-xmtp-org Ready Ready Preview Comment Nov 7, 2025 0:48am

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