Conversation
…ndices config (AI-assisted)
Upgrade @docsearch/react from v4 to v5 and drop the DocSearch v3
compatibility layer that was carried during the v3/v4 transition.
Changes:
- Bump @docsearch/react to ^5.0.4 and update the lockfile
- Replace `algolia.indexName` + top-level `searchParameters` with an
`algolia.indices` array (string or {name, searchParameters} entries)
- Load the search vs. Ask AI modal via dedicated dynamic entry points
- Migrate Ask AI to Agent Studio: `assistantId` -> `agentId`, per-index
`searchParameters`, and add `memory` / `promptSuggestions` options
- Convert contextual `facetFilters` into Agent Studio `filters` strings
(new facetFiltersToFilterString / mergeFilters utils)
- Remove v3 version detection, module aliases, ambient declarations, and
the ensureAskAISupported guard
- Refresh SearchTranslations for v5 labels and update tests
- Migrate website dogfooding configs to `indices` and adjust DocSearch CSS
BREAKING CHANGE: `algolia.indexName` and top-level `algolia.searchParameters`
are removed in favor of `algolia.indices`. Ask AI now uses `agentId` instead
of `assistantId`. DocSearch v3 is no longer supported.
- Who does this affect: all sites using @docusaurus/theme-search-algolia
- How to migrate: replace `indexName: 'x'` with `indices: ['x']`; move
`searchParameters` into the relevant index entry; rename Ask AI
`assistantId` to `agentId`; ensure `@docsearch/react` v5 is installed
- Why make this breaking change: DocSearch v5 drops v3 APIs and introduces
multi-index + Agent Studio Ask AI, which cannot be expressed with the old
single-index config
- Severity: high reach (every Algolia search user) x low-to-medium effort
(mostly a config rename)
|
Hi @8bittitan! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
- Correct lint script typo lint:SPELLING -> lint:spelling - Fix "noisey" -> "noisy" typo in webpack warning comment - Add "askai" to project-words.txt and cSpell:ignore IMYF in config - Temporarily disable translation-consistency test (it.todo); translations are deferred to a follow-up PR to keep this PR small
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
slorber
left a comment
There was a problem hiding this comment.
Here's a quick initial review
| it('merges [array,array]', () => { | ||
| expect(mergeFacetFilters(['f1'], ['f2'])).toEqual(['f1', 'f2']); | ||
|
|
||
| // TODO this looks wrong to me, should be [['f1', 'f2'], ['f3', 'f4']] ? |
There was a problem hiding this comment.
Any opinion on this TODO?
| return facetFiltersToFilterStringInternal(facetFilters, 0) ?? ''; | ||
| } | ||
|
|
||
| export function mergeFilters( |
There was a problem hiding this comment.
All this looks quite complex Algolia logic, why don't you expose a package to do that instead of us having to maintain it?
| return existing; | ||
| } | ||
|
|
||
| return `(${existing}) AND (${added})`; |
There was a problem hiding this comment.
Why not support merging more than 2 filters?
Calling merge(merge(f1,f2),f3) is likely to create useless extra parentheses, no? Would this still work?
| it('has base messages files contain EXACTLY all the translations extracted from the theme. Please run "pnpm --filter @docusaurus/theme-translations update" to keep base messages files up-to-date', async () => { | ||
| // TODO re-enable during https://github.com/8bittitan/docusaurus/pull/1 since | ||
| // these current changes left translations out for PR size. | ||
| it.todo('has base messages files contain EXACTLY all the translations extracted from the theme. Please run "pnpm --filter @docusaurus/theme-translations update" to keep base messages files up-to-date', async () => { |
There was a problem hiding this comment.
I see this PR mostly add new translations
Aren't there a lot of legacy v3 keys that are now unused? We should also remove them.
| // TODO Enable once there is an Agent Studio agent to use | ||
| // askAi: { | ||
| // cSpell:ignore IMYF | ||
| // agentId: 'RgIMYFUmTfrN', | ||
| // suggestedQuestions: true, | ||
| // }, |
There was a problem hiding this comment.
Why can't we use Ask AI anymore?
Will this be a problem for our users too?
| | 'indices' | ||
| // TODO Enable once DocSearch releases fix for facets with multiple | ||
| // selected values. Currently the contextual search facets do no work. | ||
| // https://github.com/algolia/docsearch/issues/3037 |
| } | ||
| return undefined; | ||
| return { | ||
| ignoreWarnings: [ |
There was a problem hiding this comment.
what's this for? problem still there after ai sdk v6 upgrade?
| // The algoliasearch-helper only allows for a single index, here we just treat | ||
| // the FIRST index in the `indices` list as the "primary" index | ||
| const indexName = getIndexName(indices); | ||
|
|
||
| if (!indexName) { | ||
| throw new Error( | ||
| `Could not find a useable index in "algolia.indices" for the SearchPage. | ||
| Ensure you've added the correct index names in order for search to work. | ||
| `, | ||
| ); | ||
| } |
There was a problem hiding this comment.
looks like a limitation, maybe we'll have to document this?
I still don't know what's the reason to use multiple indices, and how this can be a probelm for us.
Do you expect many Docusaurus users to use multiple indices and encouter this limitation?
Motivation
Upgrades
@docsearch/reactfrom v4 to v5 and removes the DocSearch v3compatibility layer that was carried during the v3/v4 transition period.
DocSearch v5 drops the old v3 APIs and introduces multi-index search and
Agent Studio-based Ask AI, neither of which can be expressed with the previous
single-index (
indexName+ top-levelsearchParameters) configuration. This PRmigrates the theme config surface accordingly.
What changed
@docsearch/reactto^5.0.4(+ lockfile)algolia.indexNameand top-levelalgolia.searchParameterswith analgolia.indicesarray (acceptsstringor{name, searchParameters}entries)(
@docsearch/react/modal/@docsearch/react/askaiModal)assistantId→agentId, per-indexsearchParameters, and newmemory/promptSuggestionsoptionsfacetFiltersinto Agent Studiofiltersstrings(new
facetFiltersToFilterString/mergeFiltersutilities)declarations, and the
ensureAskAISupportedguardSearchTranslationsfor v5 labelsBreaking changes
@docusaurus/theme-search-algoliaindexName: 'x'withindices: ['x']searchParametersinto the relevant index entry:indices: [{name: 'x', searchParameters: {...}}]assistantId→agentId@docsearch/reactv5 is installedmulti-index + Agent Studio Ask AI, which the old single-index config cannot express
(mostly a config rename)
Bundle size
Note
There is an open issue to track removing the
@base-ui/reactdep from DocSearch here, which would reduce the overall bundles by~51 kB.Test Plan
pnpm --filter @docusaurus/theme-search-algolia buildpnpm test packages/docusaurus-theme-search-algoliapnpm --filter @docusaurus/theme-translations run update(sync catalogs)pnpm --filter website typecheckpnpm build:website:fastand manually verify search + modal open/closeTest links
Deploy preview: https://deploy-preview-12406--docusaurus-2.netlify.app/
Related issues/PRs
@docsearch/react: Allow facets to have multiple selected values algolia/docsearch#3037 lands