Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 11 |
| Duplication | 3 |
TIP This summary will be updated as you push new changes. Give us feedback
| headerMaximizeIconComponent?: ChatUiProps['headerProps']['maximizeIconComponent']; | ||
| messagesLoaderComponent?: ChatUiProps['messagesProps']['loaderComponent']; | ||
| messagesErrorComponent?: ChatUiProps['messagesProps']['errorComponent']; | ||
| messagesGreetingComponent?: ChatUiProps['messagesProps']['greetingComponent']; |
There was a problem hiding this comment.
I've added it as messages component for now since the greeting component would have to be rendered inside the messages container.
Can be renamed if or when we rename the other messages components to remove the messages prefix (messagesLoaderComponent, messagesErrorComponent).
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: |
There was a problem hiding this comment.
Pull request overview
Adds a “greeting” (empty-state) surface for the Chat widget so the UI can render a custom or built-in greeting when there are no messages yet, across InstantSearch.js templates and React.
Changes:
- Added a
greetingtemplate /messagesGreetingComponenthook to render a greeting whenmessagesis empty. - Introduced built-in greeting exports:
chatGreeting()(InstantSearch.js templates) andChatGreeting(React component). - Added CSS styles and updated bundlesize thresholds; added tests covering greeting rendering behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/common/widgets/chat/templates.tsx | Adds coverage for greeting rendering when empty vs non-empty messages. |
| packages/react-instantsearch/src/widgets/Chat.tsx | Wires messagesGreetingComponent into the React Chat widget and passes needed actions to messages props. |
| packages/react-instantsearch/src/components/index.ts | Re-exports the new ChatGreeting component. |
| packages/react-instantsearch/src/components/ChatGreeting.tsx | Adds React wrapper for the built-in UI greeting component. |
| packages/instantsearch.js/src/widgets/chat/chat.tsx | Adds greeting template support and forwards sendMessage/setInput into messages props for greeting usage. |
| packages/instantsearch.js/src/templates/index.ts | Exports the new chatGreeting template helper. |
| packages/instantsearch.js/src/templates/chat-greeting.tsx | Implements the built-in greeting template for InstantSearch.js (Preact). |
| packages/instantsearch.css/src/components/chat/_chat-greeting.scss | Adds default styling for the greeting component. |
| packages/instantsearch.css/src/components/chat.scss | Includes the new greeting styles in the chat stylesheet entry. |
| packages/instantsearch-ui-components/src/components/index.ts | Re-exports ChatGreeting from UI components. |
| packages/instantsearch-ui-components/src/components/chat/ChatMessages.tsx | Renders an optional greeting component when there are no messages; forwards sendMessage/setInput. |
| packages/instantsearch-ui-components/src/components/chat/ChatGreeting.tsx | Implements the base greeting UI component and translations. |
| bundlesize.config.json | Updates size limits to account for added functionality. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -449,6 +468,15 @@ export function createChatMessagesComponent({ | |||
| } | |||
| }} | |||
| > | |||
| {showGreeting && GreetingComponent && ( | |||
| <GreetingComponent | |||
| sendMessage={sendMessage} | |||
| setInput={setInput} | |||
| status={status} | |||
| onClose={onClose} | |||
| /> | |||
| )} | |||
There was a problem hiding this comment.
showGreeting becomes true when status === 'error' and there are no messages (showLoader is false), which will render the greeting and the error state at the same time. This looks unintended; the greeting should likely be hidden when the chat is in an error state (and possibly other non-ready states).
| return ( | ||
| <div | ||
| className={cx('ais-ChatGreeting', classNames.root)} | ||
| {...props} | ||
| > | ||
| <h2 className={cx('ais-ChatGreeting-heading', classNames.heading)}> | ||
| {translations.greetingHeading} | ||
| </h2> |
There was a problem hiding this comment.
The root <div> spreads {...props} after setting className. If the caller passes className, it will override the computed ais-ChatGreeting/classNames.root classes and break default styling. Consider merging props.className into the computed class name and/or spreading props before setting className (while avoiding passing the raw className through the spread).
FX-3766
This PR adds support for a greeting component/template. This allows the chat widget to show a UI when there are no messages in the Chat. It also introduces an importable
ChatGreeting/chatGreetingcomponent for a built in greeting component that can be used.Reference example implementation for a React greeting component: