From f29ffdbb33022eb41327fec836f9cfbc16bf01d8 Mon Sep 17 00:00:00 2001 From: T <6601329+cookesan@users.noreply.github.com> Date: Fri, 3 Jul 2026 03:59:57 -0400 Subject: [PATCH] fix: preserve Agent Studio DocSearch options (#5254) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- .../theme-default/support/docsearch.test.ts | 106 ++++++++++++++++++ .../components/VPAlgoliaSearchBox.vue | 17 ++- src/client/theme-default/support/docsearch.ts | 47 ++++++-- 3 files changed, 153 insertions(+), 17 deletions(-) diff --git a/__tests__/unit/client/theme-default/support/docsearch.test.ts b/__tests__/unit/client/theme-default/support/docsearch.test.ts index 4da8f113..78c5ee68 100644 --- a/__tests__/unit/client/theme-default/support/docsearch.test.ts +++ b/__tests__/unit/client/theme-default/support/docsearch.test.ts @@ -1,5 +1,6 @@ import { buildAskAiConfig, + buildSidePanelProps, hasAskAi, hasKeywordSearch, mergeLangFacetFilters, @@ -192,5 +193,110 @@ describe('client/theme-default/support/docsearch', () => { ) expect(result.searchParameters?.facetFilters).toEqual(['lang:en']) }) + + test('preserves Agent Studio search parameters by index', () => { + const result = buildAskAiConfig( + { + assistantId: 'assistant123', + agentStudio: true, + searchParameters: { + index: { + distinct: false + } + } + } as any, + { + appId: 'app', + apiKey: 'key', + indexName: 'index', + searchParameters: { + facetFilters: ['tag:docs'] + } + } as any, + 'en' + ) + + expect(result.searchParameters).toEqual({ + index: { + distinct: false + } + }) + expect(result.searchParameters).not.toHaveProperty('facetFilters') + }) + + test('does not add legacy facet filters to Agent Studio config', () => { + const result = buildAskAiConfig( + { + assistantId: 'assistant123', + agentStudio: true + } as any, + { + appId: 'app', + apiKey: 'key', + indexName: 'index', + searchParameters: { + facetFilters: ['tag:docs'] + } + } as any, + 'en' + ) + + expect(result.searchParameters).toBeUndefined() + }) + }) + + describe('buildSidePanelProps', () => { + test('passes resolved Ask AI options to the side panel', () => { + const result = buildSidePanelProps( + { + assistantId: 'assistant123', + agentStudio: true, + searchParameters: { + index: { + facetFilters: ['lang:en'] + } + }, + suggestedQuestions: true, + useStagingEnv: true, + sidePanel: { + button: { + variant: 'inline' + }, + panel: { + width: 420, + suggestedQuestions: true + } + } + } as any, + { + appId: 'app', + apiKey: 'key', + indexName: 'index' + } as any + ) + + expect(result).toEqual({ + container: '#vp-docsearch-sidepanel', + appId: 'app', + apiKey: 'key', + indexName: 'index', + assistantId: 'assistant123', + agentStudio: true, + searchParameters: { + index: { + facetFilters: ['lang:en'] + } + }, + suggestedQuestions: true, + useStagingEnv: true, + button: { + variant: 'inline' + }, + panel: { + width: 420, + suggestedQuestions: true + } + }) + }) }) }) diff --git a/src/client/theme-default/components/VPAlgoliaSearchBox.vue b/src/client/theme-default/components/VPAlgoliaSearchBox.vue index 26df2b7c..3d56c670 100644 --- a/src/client/theme-default/components/VPAlgoliaSearchBox.vue +++ b/src/client/theme-default/components/VPAlgoliaSearchBox.vue @@ -1,12 +1,16 @@