Skip to content

Commit 96d9328

Browse files
feat
1 parent a814bd6 commit 96d9328

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

packages/shared/src/env.server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ export const env = createEnv({
216216
SOURCEBOT_LOG_LEVEL: z.enum(["info", "debug", "warn", "error"]).default("info"),
217217
SOURCEBOT_STRUCTURED_LOGGING_ENABLED: booleanSchema.default("false"),
218218
SOURCEBOT_STRUCTURED_LOGGING_FILE: z.string().optional(),
219+
220+
// Configure the default maximum number of search results to return by default.
221+
DEFAULT_MAX_MATCH_COUNT: numberSchema.default(10_000),
219222
},
220223
runtimeEnv,
221224
emptyStringAsUndefined: true,

packages/web/src/app/[domain]/search/components/searchResultsPage.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ import { FilterPanel } from "./filterPanel";
3535
import { useFilteredMatches } from "./filterPanel/useFilterMatches";
3636
import { SearchResultsPanel } from "./searchResultsPanel";
3737

38-
const DEFAULT_MAX_MATCH_COUNT = 100_000;
39-
4038
interface SearchResultsPageProps {
4139
searchQuery: string;
40+
defaultMaxMatchCount: number;
4241
}
4342

4443
export const SearchResultsPage = ({
4544
searchQuery,
45+
defaultMaxMatchCount,
4646
}: SearchResultsPageProps) => {
4747
const router = useRouter();
4848
const { setSearchHistory } = useSearchHistory();
@@ -51,8 +51,8 @@ export const SearchResultsPage = ({
5151
const { toast } = useToast();
5252

5353
// Encodes the number of matches to return in the search response.
54-
const _maxMatchCount = parseInt(useNonEmptyQueryParam(SearchQueryParams.matches) ?? `${DEFAULT_MAX_MATCH_COUNT}`);
55-
const maxMatchCount = isNaN(_maxMatchCount) ? DEFAULT_MAX_MATCH_COUNT : _maxMatchCount;
54+
const _maxMatchCount = parseInt(useNonEmptyQueryParam(SearchQueryParams.matches) ?? `${defaultMaxMatchCount}`);
55+
const maxMatchCount = isNaN(_maxMatchCount) ? defaultMaxMatchCount : _maxMatchCount;
5656

5757
const {
5858
data: searchResponse,

packages/web/src/app/[domain]/search/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { env } from "@sourcebot/shared";
12
import { SearchLandingPage } from "./components/searchLandingPage";
23
import { SearchResultsPage } from "./components/searchResultsPage";
34

@@ -18,6 +19,7 @@ export default async function SearchPage(props: SearchPageProps) {
1819
return (
1920
<SearchResultsPage
2021
searchQuery={query}
22+
defaultMaxMatchCount={env.DEFAULT_MAX_MATCH_COUNT}
2123
/>
2224
)
2325
}

0 commit comments

Comments
 (0)