makeAssistantVisible
makeAssistantVisible
is a higher-order component (HOC) that makes React components "visible" by the assistant, allowing it to understand and interact with the component's HTML structure.
Usage
API Reference
Parameters
Component
: The base React component to enhanceconfig
: Optional configuration objectclickable
: When true, enables the assistant to programmatically click the component
Behavior
The HOC will:
- Make the component's HTML structure available to the assistant via the system context
- Optionally provide a
click
tool ifclickable
is true - Handle nested readable components (only the outermost component's HTML is provided)
- Forward refs and maintain component props
Example
Technical Details
When a component is made readable:
- It's wrapped in a
ReadableContext.Provider
to handle nesting - The component's
outerHTML
is provided as system context - If
clickable
is true, a uniquedata-click-id
is added and aclick
tool is provided - The click tool uses
querySelector
and simulates a click event - All props and refs are properly forwarded to maintain component functionality