From 25ecb02f35ff23a3fab68fcd159f4696c91c4ec6 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Fri, 10 Jul 2026 14:36:55 -0700 Subject: [PATCH 1/2] fix(web): lazy-load search code preview --- .../search/components/searchResultsPage.tsx | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/web/src/app/(app)/search/components/searchResultsPage.tsx b/packages/web/src/app/(app)/search/components/searchResultsPage.tsx index f16ed7726..42a02c896 100644 --- a/packages/web/src/app/(app)/search/components/searchResultsPage.tsx +++ b/packages/web/src/app/(app)/search/components/searchResultsPage.tsx @@ -15,13 +15,14 @@ import { RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search import useCaptureEvent from "@/hooks/useCaptureEvent"; import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam"; import { useSearchHistory } from "@/hooks/useSearchHistory"; +import { getCodeParserByLanguageName } from "@/lib/codeHighlight"; import { ServiceErrorException } from "@/lib/serviceError"; import { SearchQueryParams } from "@/lib/types"; import { createPathWithQueryParams } from "@/lib/utils"; import { InfoCircledIcon } from "@radix-ui/react-icons"; import { useLocalStorage } from "@uidotdev/usehooks"; import { AlertTriangleIcon, BugIcon, FilterIcon, RefreshCwIcon } from "lucide-react"; -import { Session } from "next-auth"; +import dynamic from "next/dynamic"; import { useRouter } from "next/navigation"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useHotkeys } from "react-hotkeys-hook"; @@ -29,11 +30,27 @@ import { ImperativePanelHandle } from "react-resizable-panels"; import { CopyIconButton } from "../../components/copyIconButton"; import { SearchBar } from "../../components/searchBar"; import { useStreamedSearch } from "../useStreamedSearch"; -import { CodePreviewPanel } from "./codePreviewPanel"; import { FilterPanel } from "./filterPanel"; import { useFilteredMatches } from "./filterPanel/useFilterMatches"; import { SearchResultsPanel, SearchResultsPanelHandle } from "./searchResultsPanel"; +const CodePreviewPanel = dynamic( + () => import("./codePreviewPanel").then(module => ({ default: module.CodePreviewPanel })), + { ssr: false }, +); + +const commonSearchResultLanguages = [ + "TypeScript", + "JavaScript", + "Python", + "Go", + "Rust", + "Java", + "C++", + "C#", + "JSON", +]; + interface SearchResultsPageProps { searchQuery: string; defaultMaxMatchCount: number; @@ -54,6 +71,12 @@ export const SearchResultsPage = ({ const { toast } = useToast(); const captureEvent = useCaptureEvent(); + useEffect(() => { + void Promise.allSettled( + commonSearchResultLanguages.map(getCodeParserByLanguageName), + ); + }, []); + // Encodes the number of matches to return in the search response. const _maxMatchCount = parseInt(useNonEmptyQueryParam(SearchQueryParams.matches) ?? `${defaultMaxMatchCount}`); const maxMatchCount = isNaN(_maxMatchCount) ? defaultMaxMatchCount : _maxMatchCount; From 4a5c1a7f0d61fdf4289ab221c82ccf5ed267b024 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Fri, 10 Jul 2026 14:37:41 -0700 Subject: [PATCH 2/2] chore: update changelog for search preview fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b67260ef9..1fc65eaa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [EE] Fixed connector setup dialogs to add scrolling when connector setup content goes out of view. - Fixed Gitea sync failing with `ERR_STREAM_PREMATURE_CLOSE` by forcing identity encoding on the Gitea API fetch and guarding against null repository responses. [#1405](https://github.com/sourcebot-dev/sourcebot/pull/1405) - [EE] Fixed Ask connector MCP tools with provider-invalid names failing to run by sanitizing model-facing tool names while preserving raw names in the UI. +- Lazy-loaded the search result code preview and pre-warmed common language parsers to improve initial search page load performance. [#1433](https://github.com/sourcebot-dev/sourcebot/pull/1433) ## [5.0.4] - 2026-06-18