Skip to content

Commit 2e959b7

Browse files
feat(web): Add env var to configure default max match count (#616)
1 parent a814bd6 commit 2e959b7

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Changed
11-
- Bumped the default requested search result count from 5k to 100k after optimization pass. [#615](https://github.com/sourcebot-dev/sourcebot/pull/615)
11+
- Bumped the default requested search result count from 5k to 10k after optimization pass. [#615](https://github.com/sourcebot-dev/sourcebot/pull/615)
1212

1313
### Fixed
1414
- Fixed incorrect shutdown of PostHog SDK in the worker. [#609](https://github.com/sourcebot-dev/sourcebot/pull/609)
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919

2020
### Added
2121
- Added force resync buttons for connections and repositories. [#610](https://github.com/sourcebot-dev/sourcebot/pull/610)
22+
- Added environment variable to configure default search result count. [#616](https://github.com/sourcebot-dev/sourcebot/pull/616)
2223

2324
## [4.9.1] - 2025-11-07
2425

docs/docs/configuration/environment-variables.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following environment variables allow you to configure your Sourcebot deploy
3434
| `SOURCEBOT_STRUCTURED_LOGGING_ENABLED` | `false` | <p>Enables/disable structured JSON logging. See [this doc](/docs/configuration/structured-logging) for more info.</p> |
3535
| `SOURCEBOT_STRUCTURED_LOGGING_FILE` | - | <p>Optional file to log to if structured logging is enabled</p> |
3636
| `SOURCEBOT_TELEMETRY_DISABLED` | `false` | <p>Enables/disables telemetry collection in Sourcebot. See [this doc](/docs/overview.mdx#telemetry) for more info.</p> |
37+
| `DEFAULT_MAX_MATCH_COUNT` | `10000` | <p>The default maximum number of search results to return when using search in the web app.</p> |
3738

3839
### Enterprise Environment Variables
3940
| Variable | Default | Description |

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)