Skip to content

refactor(chat): move search index tool component to ui-components#6874

Draft
shaejaz wants to merge 33 commits into
masterfrom
refactor/move-search-index-tool
Draft

refactor(chat): move search index tool component to ui-components#6874
shaejaz wants to merge 33 commits into
masterfrom
refactor/move-search-index-tool

Conversation

@shaejaz
Copy link
Copy Markdown
Contributor

@shaejaz shaejaz commented Jan 26, 2026

This PR moves the chat search tool's default component definition to the ui-components. This prevents repeating layout logic for both react and js versions of component. The approach is similar to how it is done for the new Autocomplete components.

Base automatically changed from feat/view-all-refinements to master February 11, 2026 11:52
@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci Bot commented Feb 11, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d34ff81:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@shaejaz shaejaz marked this pull request as ready for review February 16, 2026 15:38
@shaejaz shaejaz requested a review from Haroenv February 16, 2026 15:38
@Haroenv
Copy link
Copy Markdown
Contributor

Haroenv commented Feb 16, 2026

this increases bundlesize, but should a deduplication not reduce bundlesize @shaejaz ?

@shaejaz
Copy link
Copy Markdown
Contributor Author

shaejaz commented Feb 16, 2026

this increases bundlesize, but should a deduplication not reduce bundlesize @shaejaz ?

Yes, I'm not sure what the cause is. I thought it could due to the unnecessary code but it seems like it increased even more after that change :/

Maybe it's how the ui-components is bundled into the js and react packages which causes it to increase?

@Haroenv Haroenv removed their request for review February 18, 2026 09:00
# Conflicts:
#	bundlesize.config.json
#	packages/instantsearch.js/src/widgets/chat/chat.tsx
#	packages/react-instantsearch/src/widgets/chat/tools/SearchIndexTool.tsx
Copilot AI review requested due to automatic review settings April 22, 2026 14:17
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 22, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 35 complexity

Metric Results
Complexity 35

View in Codacy

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 22, 2026

More templates

algoliasearch-helper

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

instantsearch-ui-components

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

instantsearch.css

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

instantsearch.js

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

react-instantsearch

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

react-instantsearch-core

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

react-instantsearch-nextjs

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

react-instantsearch-router-nextjs

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

vue-instantsearch

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

commit: e98b39f

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 centralizes the chat search-index tool layout into instantsearch-ui-components so both the React and InstantSearch.js (Preact) implementations can reuse the same UI/component logic (similar to the Autocomplete component approach), reducing duplicated layout code.

Changes:

  • Refactors React InstantSearch chat search-index tool to delegate rendering to a new shared createSearchIndexToolComponent.
  • Adds a new InstantSearch.js (Preact) search-index-tool.tsx that reuses the shared UI component.
  • Introduces the shared chat tool UI component in instantsearch-ui-components and exports it, plus a small Carousel type refactor.

Reviewed changes

Copilot reviewed 7 out of 7 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 Switches to using createSearchIndexToolComponent instead of local layout logic.
packages/instantsearch.js/src/widgets/chat/search-index-tool.tsx New Preact tool wrapper delegating UI to shared component.
packages/instantsearch.js/src/widgets/chat/chat.tsx Removes inline carousel tool implementation and imports the new wrapper.
packages/instantsearch-ui-components/src/components/index.ts Exports the new shared chat tool component.
packages/instantsearch-ui-components/src/components/chat/tools/SearchIndexTool.tsx Adds shared SearchIndexTool UI component implementation.
packages/instantsearch-ui-components/src/components/Carousel.tsx Extracts header prop type into HeaderComponentProps and reuses it.
bundlesize.config.json Updates bundle size thresholds to match new output.

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

Comment on lines +193 to +196
nextButtonRef: useRef(null),
previousButtonRef: useRef(null),
carouselIdRef: useRef(generateCarouselId()),
canScrollLeft,
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

generateCarouselId() is executed on every render because it’s passed directly to useRef(...). Even though the ref keeps the initial value, this still increments lastCarouselId each render and can produce gaps/extra work. Consider lazily initializing the ID (e.g., initialize the ref to an empty value and set it once, or compute the ID with useMemo and pass that into useRef).

Copilot uses AI. Check for mistakes.
shaejaz added 2 commits May 18, 2026 12:30
# Conflicts:
#	bundlesize.config.json
#	packages/instantsearch.js/src/widgets/chat/chat.tsx
#	packages/react-instantsearch/src/widgets/chat/tools/SearchIndexTool.tsx
@Haroenv Haroenv marked this pull request as draft May 20, 2026 08:03
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.

3 participants