feat(chat): add initialUserMessage option#6956
Open
aymeric-giraudet wants to merge 2 commits intomasterfrom
Open
feat(chat): add initialUserMessage option#6956aymeric-giraudet wants to merge 2 commits intomasterfrom
initialUserMessage option#6956aymeric-giraudet wants to merge 2 commits intomasterfrom
Conversation
Sends a user message automatically when the chat is initialized, unless messages already exist (e.g. restored from localStorage).
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 2 |
TIP This summary will be updated as you push new changes. Give us feedback
More templates
algoliasearch-helper
instantsearch-ui-components
instantsearch.css
instantsearch.js
react-instantsearch
react-instantsearch-core
react-instantsearch-nextjs
react-instantsearch-router-nextjs
vue-instantsearch
commit: |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an initialUserMessage option to the Chat connector so a predefined user message is sent automatically on initialization when there is no existing chat history (e.g., restored state), with accompanying tests.
Changes:
- Extend
connectChatparams withinitialUserMessage?: string. - Trigger an automatic
chat.sendMessage({ text })during connectorinitwhen there are no existing messages. - Add widget and connector option tests covering the new behavior (and one guard case on the widget side).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/common/widgets/chat/options.tsx | Adds widget-level tests for sending initialUserMessage on init and skipping when messages already exist. |
| tests/common/connectors/chat/options.ts | Adds connector-level test asserting initialUserMessage is sent on init. |
| packages/instantsearch.js/src/connectors/chat/connectChat.ts | Introduces initialUserMessage param and sends it during init when the message list is empty. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… exist - Add !resume guard so initialUserMessage doesn't conflict with resumeStream - Expand JSDoc to document skip conditions - Add connector-level test for existing messages guard
Haroenv
reviewed
Apr 8, 2026
| * | ||
| * When `resume` is enabled, this message is not sent. | ||
| */ | ||
| initialUserMessage?: string; |
Contributor
There was a problem hiding this comment.
have you also considered passing messages or initialMessages? that would be a bit more flexible, but I'm not sure if it's useful for anything
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FX-3767
Sends a user message automatically when the chat is initialized, unless messages already exist (e.g. restored from localStorage).