From bdf7faf0c804725da79cc1fd45273c2534cbbc37 Mon Sep 17 00:00:00 2001 From: Alex Krawiec Date: Mon, 1 Jun 2026 14:21:49 -0700 Subject: [PATCH] fix(search): Skip stored SDK bias on SDK-agnostic doc pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Search component restores the user's last-used SDK from localStorage whenever the page passes no platform. On `/platforms/*` that's correct, but on product/concepts/cli/guides/integrations pages — which have no SDK — the stored platform was still attached to every query as an `optionalFilters: sdk:` boost, surfacing irrelevant SDK pages above the product doc the user is actually reading. Detect these SDK-agnostic prefixes and clear `currentSearchPlatforms` instead of restoring. The set mirrors `PRODUCT_DOC_PREFIXES` in `scripts/algolia.ts`, which already treats the same pages as the top-popularity non-SDK group in the index ranking. Behavior on the homepage (`useStoredSearchPlatforms={false}`) and on `/platforms/*` pages is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/search/index.tsx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/search/index.tsx b/src/components/search/index.tsx index 3a6de970188cde..0ef143b54584e6 100644 --- a/src/components/search/index.tsx +++ b/src/components/search/index.tsx @@ -74,6 +74,18 @@ type Props = { const STORAGE_KEY = 'sentry-docs-search-platforms'; +// Paths outside `/platforms/` whose pages are not about any specific SDK. +// Restoring the user's last-used SDK on these pages biases query results +// toward irrelevant SDK pages instead of the product/concept docs they're +// actually reading. Mirrors PRODUCT_DOC_PREFIXES in scripts/algolia.ts. +const SDK_AGNOSTIC_PATH_PREFIXES = [ + '/product/', + '/concepts/', + '/cli/', + '/guides/', + '/integrations/', +]; + export function Search({ path, autoFocus, @@ -91,6 +103,9 @@ export function Search({ // Load stored platforms on mount useEffect(() => { + const isSdkAgnosticPath = SDK_AGNOSTIC_PATH_PREFIXES.some(prefix => + pathname?.startsWith(prefix) + ); const storedPlatforms = localStorage.getItem(STORAGE_KEY) ?? '[]'; if (!storedPlatforms) { localStorage.setItem(STORAGE_KEY, JSON.stringify(searchPlatforms)); @@ -99,10 +114,14 @@ export function Search({ searchPlatforms.length === 0 && useStoredSearchPlatforms ) { - const platforms = JSON.parse(storedPlatforms); - setCurrentSearchPlatforms(platforms); + if (isSdkAgnosticPath) { + setCurrentSearchPlatforms([]); + } else { + const platforms = JSON.parse(storedPlatforms); + setCurrentSearchPlatforms(platforms); + } } - }, [useStoredSearchPlatforms, searchPlatforms]); + }, [useStoredSearchPlatforms, searchPlatforms, pathname]); // Update stored platforms when they change useEffect(() => {