Skip to content

feat(chat): add 'metadata' to chat sub widgets#7123

Draft
shaejaz wants to merge 2 commits into
masterfrom
feat/chat-components-metadata
Draft

feat(chat): add 'metadata' to chat sub widgets#7123
shaejaz wants to merge 2 commits into
masterfrom
feat/chat-components-metadata

Conversation

@shaejaz

@shaejaz shaejaz commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes.

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown
More templates

algoliasearch-helper

npm i https://pkg.pr.new/algolia/instantsearch/algoliasearch-helper@7123

instantsearch-ui-components

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch-ui-components@7123

instantsearch.css

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.css@7123

instantsearch.js

npm i https://pkg.pr.new/algolia/instantsearch/instantsearch.js@7123

react-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch@7123

react-instantsearch-core

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-core@7123

react-instantsearch-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-nextjs@7123

react-instantsearch-router-nextjs

npm i https://pkg.pr.new/algolia/instantsearch/react-instantsearch-router-nextjs@7123

vue-instantsearch

npm i https://pkg.pr.new/algolia/instantsearch/vue-instantsearch@7123

commit: 0e07519

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a consistent metadata object that is injected into Chat “sub-widgets” (tools, messages, loader/error/empty/actions overrides) across the shared UI layer, InstantSearch.js widget, and React wrapper, so custom components/templates can access common chat state and callbacks from one place.

Changes:

  • Added ChatComponentMetadata / ChatComponentPropsWithMetadata and refactored chat override points to receive metadata instead of multiple ad-hoc props (e.g., onClose).
  • Updated Chat tool layout components (e.g., search index tool) and template typing in instantsearch.js to align with the new metadata contract.
  • Updated and extended tests to pass/verify metadata forwarding.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react-instantsearch/src/widgets/chat/tools/SearchIndexTool.tsx Reads onClose from metadata for the search carousel tool layout.
packages/react-instantsearch/src/widgets/chat/tools/tests/SearchIndexTool.test.tsx Updates tests to provide metadata instead of onClose prop.
packages/react-instantsearch/src/widgets/chat/tools/tests/DisplayResultsTool.test.tsx Updates tests to provide metadata instead of onClose prop.
packages/react-instantsearch/src/widgets/Chat.tsx Ensures error is correctly included in messagesProps (avoids duplication).
packages/instantsearch.js/src/widgets/chat/chat.tsx Types templates/components to accept ChatComponentPropsWithMetadata and threads those through the renderer wrappers.
packages/instantsearch.js/src/templates/chat-message-loader.tsx Updates loader template helper typing to accept props-with-metadata.
packages/instantsearch.js/src/templates/chat-greeting/chat-greeting.tsx Updates greeting template helper typing to accept props-with-metadata.
packages/instantsearch-ui-components/src/components/chat/types.ts Introduces ChatComponentMetadata + ChatComponentPropsWithMetadata; updates tool props typing and removes ChatEmptyProps.
packages/instantsearch-ui-components/src/components/chat/ChatMessages.tsx Constructs and forwards metadata to all overridable components (message/loader/error/empty/actions).
packages/instantsearch-ui-components/src/components/chat/ChatMessageLoader.tsx Accepts props-with-metadata and strips metadata from DOM props.
packages/instantsearch-ui-components/src/components/chat/ChatMessageError.tsx Accepts props-with-metadata and strips metadata from DOM props.
packages/instantsearch-ui-components/src/components/chat/ChatMessage.tsx Reads status/tools from metadata and forwards metadata into tool layouts/actions overrides.
packages/instantsearch-ui-components/src/components/chat/ChatGreeting.tsx Accepts props-with-metadata (empty/greeting state now relies on metadata).
packages/instantsearch-ui-components/src/components/chat/tests/ChatMessages.test.tsx Adds coverage to assert metadata is forwarded to overridable components.
packages/instantsearch-ui-components/src/components/chat/tests/ChatMessage.test.tsx Updates tests to pass metadata and validates tool rendering with metadata-provided tools.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to 29
return function ChatMessageLoader(
userProps: ChatComponentPropsWithMetadata<ChatMessageLoaderProps>
) {
const { translations: userTranslations, metadata, ...props } = userProps;
const translations: Required<ChatMessageLoaderTranslations> = {
Comment on lines +64 to 75
return function ChatMessageError(
userProps: ChatComponentPropsWithMetadata<ChatMessageErrorProps>
) {
const {
errorMessage,
onReload,
onNewConversation,
actions,
translations: userTranslations,
metadata,
...props
} = userProps;
Comment on lines +56 to 65
return function ChatGreeting(
userProps: ChatComponentPropsWithMetadata<ChatGreetingProps>
) {
const {
translations: userTranslations,
classNames = {},
sendMessage: _sendMessage,
status: _status,
onClose: _onClose,
setInput: _setInput,
metadata,
banner,
...props
} = userProps;
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