Skip to content

Commit 44a787a

Browse files
committed
fix(web): avoid bundling search API in client; address review
1 parent 5e1ea7f commit 44a787a

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

CHANGELOG.md

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

1010
### Added
11+
- Search results show an informational alert when a query may be incomplete (for example due to match limits, skipped index shards, or streaming flush), and non-exhaustive Zoekt searches are logged for operators. [#1098](https://github.com/sourcebot-dev/sourcebot/pull/1098)
1112
- Linear issue links in chat responses now render as a rich card-style UI showing the Linear logo, issue identifier, and title instead of plain hyperlinks. [#1060](https://github.com/sourcebot-dev/sourcebot/pull/1060)
1213

1314
### Changed

packages/web/src/app/(app)/search/components/searchResultsPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
} from "@/components/ui/resizable";
1212
import { Separator } from "@/components/ui/separator";
1313
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
14-
import { getSearchLimitExplanation, RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search";
14+
import { getSearchLimitExplanation } from "@/features/search/searchLimitExplanation";
15+
import type { RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search/types";
1516
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
1617
import useCaptureEvent from "@/hooks/useCaptureEvent";
1718
import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam";

packages/web/src/app/(app)/search/useStreamedSearch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { RepositoryInfo, SearchRequest, SearchResultFile, SearchStats, StreamedSearchResponse } from '@/features/search';
3+
import type { RepositoryInfo, SearchRequest, SearchResultFile, SearchStats, StreamedSearchResponse } from '@/features/search/types';
44
import { ServiceErrorException } from '@/lib/serviceError';
55
import { isServiceError } from '@/lib/utils';
66
import * as Sentry from '@sentry/nextjs';
@@ -116,6 +116,7 @@ export const useStreamedSearch = ({ query, matches, contextLines, whole, isRegex
116116
timeToSearchCompletionMs: 0,
117117
timeToFirstSearchResultMs: 0,
118118
numMatches: 0,
119+
stats: undefined,
119120
});
120121

121122
try {

packages/web/src/features/search/searchLimitExplanation.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,15 @@ test('flushReason timer when no higher-priority signal', () => {
8181
);
8282
expect(out.summary).toContain('streaming timer');
8383
});
84+
85+
test('flushReason max size when no higher-priority signal', () => {
86+
const out = getSearchLimitExplanation(
87+
stats({
88+
flushReason: 'FLUSH_REASON_MAX_SIZE',
89+
totalMatchCount: 10,
90+
actualMatchCount: 10,
91+
}),
92+
100,
93+
);
94+
expect(out.summary).toContain('size limit');
95+
});

packages/web/src/features/search/searchLimitExplanation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export function getSearchLimitExplanation(
5656
};
5757
}
5858

59+
// Defensive fallback: non-exhaustive searches should usually hit a branch above
60+
// (e.g. totalMatchCount vs display cap, skipped shards/files, or flush reason).
5961
return {
6062
summary: 'More matches may exist than are shown.',
6163
detail: 'Increase the match limit, narrow your query, or scope to a repository.',

0 commit comments

Comments
 (0)