babylonlabs-io / babylonlabs-io/babylonlabs.github.io
Make the Ask Babylon AI widget page-aware: pre-populate the current page URL
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 10
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 1
Description
## Intent
Make the DevX AI Bot widget (Ask Babylon AI) page-aware. When a user opens the widget from a docs page, the bot must know which page the user reads.
## Behavior
When the user clicks **Ask Babylon AI**, pre-populate the chat input with:
1. A sentence that starts with: `I'm reading this page in this context. Please answer this question.`
2. The URL of the current page (`window.location.href`).
Example prefill:
```
I'm reading this page in this context. Please answer this question.
Page: https://docs.babylonlabs.io/guides/...
```
The user then types the question after the prefill and sends the message.
## Acceptance criteria
- [ ] A click on **Ask Babylon AI** opens the widget with the prefill in the input field.
- [ ] The prefill contains the full URL of the page that the user was on.
- [ ] The prefill starts with the sentence "I'm reading this page in this context. Please answer this question."
- [ ] The user can edit or delete the prefill before they send the message.
- [ ] The prefill does not push the input over the token limit check in `ChatWidget.tsx`.
## Implementation notes
- The widget code is in `src/components/ChatWidget.tsx`. The input state is the `input` state (approximately line 122).
- The widget already has open triggers from the header and a pending-query auto-submit effect (approximately lines 329–404). The prefill can use the same path.
- Other entry points that open the widget: `HeroSearch.tsx`, `TextSelectionToolbar.tsx`, `PageActionsDropdown.tsx`. Make sure that the behavior is consistent for each entry point.
- Apply the prefill only to a new message, not to a restored session.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.