Skip to content

feat(chat): split chat trigger widget#6966

Draft
Haroenv wants to merge 7 commits intomasterfrom
feat/chat-trigger
Draft

feat(chat): split chat trigger widget#6966
Haroenv wants to merge 7 commits intomasterfrom
feat/chat-trigger

Conversation

@Haroenv
Copy link
Copy Markdown
Contributor

@Haroenv Haroenv commented Apr 10, 2026

Adds a separate chat trigger widget, and give a warning if you don't use it, ai mode or inline layout

still to do: validate this is the right approach, ensure there's no leftover code from previous iterations.

Adds a separate chat trigger widget, and give a warning if you don't use it, ai mode or inline layout
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 10, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 15 complexity · -1 duplication

Metric Results
Complexity 15
Duplication -1

View in Codacy

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 10, 2026

More templates

algoliasearch-helper

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

instantsearch-ui-components

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

instantsearch.css

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

instantsearch.js

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

react-instantsearch

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

react-instantsearch-core

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

react-instantsearch-nextjs

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

react-instantsearch-router-nextjs

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

vue-instantsearch

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

commit: 067e282

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 splits the “open chat” entry point out of the Chat UI into a dedicated chatTrigger widget/component, and adds runtime validation to ensure the Chat widget has a configured way to open (via chatTrigger, AI-mode inputs, or opting out).

Changes:

  • Introduces chatTrigger across InstantSearch.js + React InstantSearch (+ a useChatTrigger connector) and updates exports.
  • Adds entry-point validation in connectChat and propagates opensChat from AI-mode input widgets.
  • Refactors tests and shared UI types to accommodate removal of the built-in toggle button.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tests/common/widgets/chat/utils.ts Switches test “open chat” helper from DOM click to a global setter hook
tests/common/widgets/chat/index.ts Resets the global setter hook between tests
packages/react-instantsearch/src/widgets/SearchBox.tsx Marks AI-mode search box as an entry point (opensChat)
packages/react-instantsearch/src/widgets/index.ts Exports new ChatTrigger component
packages/react-instantsearch/src/widgets/ChatTrigger.tsx Adds React ChatTrigger component and registers presence via useChatTrigger
packages/react-instantsearch/src/widgets/Chat.tsx Removes toggle-button wiring; adds disableTriggerValidation plumbing + getOpen handle
packages/react-instantsearch/src/widgets/Autocomplete.tsx Marks AI-mode autocomplete as an entry point (opensChat)
packages/react-instantsearch/src/widgets/tests/utils/all-widgets.tsx Disables trigger validation for widget catalog tests
packages/react-instantsearch/src/tests/common-widgets.test.tsx Wires chat ref for tests via global setter hook
packages/react-instantsearch-core/src/index.ts Exports useChatTrigger
packages/react-instantsearch-core/src/connectors/useChatTrigger.ts Adds useChatTrigger connector wrapper
packages/instantsearch.js/src/widgets/search-box/search-box.tsx Marks AI-mode SearchBox widget as an entry point (opensChat)
packages/instantsearch.js/src/widgets/index.ts Exports new chatTrigger widget
packages/instantsearch.js/src/widgets/chat/chat.tsx Adds setOpen/getOpen widget API + disableTriggerValidation param
packages/instantsearch.js/src/widgets/chat/tests/chat.test.tsx Adds a negative test for entry-point validation
packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx Adds the new JS chatTrigger widget implementation
packages/instantsearch.js/src/widgets/autocomplete/autocomplete.tsx Marks AI-mode Autocomplete widget as an entry point (opensChat)
packages/instantsearch.js/src/connectors/index.ts Exports connectChatTrigger
packages/instantsearch.js/src/connectors/chat/connectChatTrigger.ts Adds presence-marker connector that sets opensChat
packages/instantsearch.js/src/connectors/chat/connectChat.ts Adds entry-point validation logic (+ opt-out flag)
packages/instantsearch.js/src/connectors/chat/tests/connectChat-test.ts Adjusts tests to bypass validation where needed
packages/instantsearch.js/src/tests/common-widgets.test.tsx Updates Chat test setup to bypass validation + expose setOpen
packages/instantsearch-ui-components/src/components/chat/types.ts Makes toggleButtonComponent optional in layout props
packages/instantsearch-ui-components/src/components/chat/Chat.tsx Removes built-in toggle button rendering
packages/instantsearch-ui-components/src/components/chat/tests/Chat.test.tsx Snapshot updated after toggle button removal (currently shows leaked prop)
.claude/skills/port-widget/SKILL.md Adds migration checklist guidance for cross-package API changes

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

Comment thread packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx
Comment thread packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx Outdated
Comment thread packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx Outdated
Comment thread packages/instantsearch.js/src/widgets/chat/chat.tsx Outdated
Comment thread packages/react-instantsearch/src/widgets/ChatTrigger.tsx Outdated
Comment thread tests/common/widgets/chat/utils.ts Outdated
Comment thread packages/react-instantsearch/src/widgets/SearchBox.tsx Outdated
Comment thread packages/react-instantsearch/src/widgets/Autocomplete.tsx Outdated
Comment thread packages/instantsearch.js/src/widgets/chat/__tests__/chat.test.tsx
Comment thread packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx Outdated
Comment thread packages/instantsearch.js/src/connectors/chat/connectChat.ts Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

packages/react-instantsearch/src/widgets/tests/utils/all-widgets.tsx:40

  • ChatTrigger is listed in NON_COMPONENTS, so it’s filtered out of getAllWidgets() and won’t be covered by all-components.test.tsx. It also makes the case 'ChatTrigger' in Widget() unreachable from the SingleWidget union. If ChatTrigger is intended to be a public widget component, it should be removed from NON_COMPONENTS so it participates in the generic component tests.
const NON_COMPONENTS = [
  'createDefaultTools',
  'SearchIndexToolType',
  'RecommendToolType',
  'MemorizeToolType',
  'MemorySearchToolType',
  'PonderToolType',
] as const;
type ComponentWidgets = Omit<typeof widgets, typeof NON_COMPONENTS[number]>;


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

Comment thread packages/instantsearch.js/src/widgets/chat-trigger/chat-trigger.tsx
Comment thread packages/instantsearch.js/src/connectors/chat/connectChatTrigger.ts
Comment thread packages/instantsearch.js/src/connectors/chat/connectChatTrigger.ts
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