Skip to content

Commit 783acaa

Browse files
fix(web): don't include sources in grep tool when groupByRepo=true (#1032)
* fix(web): don't include sources in grep tool when groupByRepo=true When `groupByRepo=true`, the LLM only sees a repo-level summary and never references individual files. Previously, all matched files were still streamed to the client as sources, causing 1000+ individual setSources() calls and cascading re-renders that froze the UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: update CHANGELOG for #1032 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2a3bd2a commit 783acaa

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525
- Fixed issue where ask responses would sometimes appear in the details panel while generating. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
2626
- Fixed reference panel overflow issue in the ask UI. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
2727
- Fixed homepage scrolling issue in the ask UI. [#1014](https://github.com/sourcebot-dev/sourcebot/pull/1014)
28+
- Fixed UI freeze when the `grep` tool returns a large number of results with `groupByRepo=true`. [#1032](https://github.com/sourcebot-dev/sourcebot/pull/1032)
2829

2930
## [4.15.11] - 2026-03-20
3031

packages/web/src/features/tools/grep.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,6 @@ export const grepDefinition: ToolDefinition<'grep', typeof grepShape, GrepMetada
179179
};
180180
}
181181

182-
const sources: Source[] = files.map((file) => ({
183-
type: 'file' as const,
184-
repo: file.repo,
185-
path: file.path,
186-
name: file.path.split('/').pop() ?? file.path,
187-
revision: file.revision,
188-
}));
189-
190182
if (groupByRepo) {
191183
const repoCounts = new Map<string, { matches: number; files: number }>();
192184
for (const file of response.files) {
@@ -211,13 +203,16 @@ export const grepDefinition: ToolDefinition<'grep', typeof grepShape, GrepMetada
211203
return {
212204
output: outputLines.join('\n'),
213205
metadata,
214-
sources,
206+
// @note: we explicitly do not include sources here because `output` does not
207+
// contain any file sources. We previously _did_ include sources here, but it
208+
// was causing performance issues when a search returned a large (1k+) matches.
209+
sources: undefined,
215210
};
216211
} else {
217212
const outputLines: string[] = [
218213
`Found ${actualMatches} match${actualMatches !== 1 ? 'es' : ''} in ${totalFiles} file${totalFiles !== 1 ? 's' : ''}`,
219214
];
220-
215+
221216
for (const file of response.files) {
222217
outputLines.push('');
223218
outputLines.push(`[${file.repository}] ${file.fileName.text}:`);
@@ -234,12 +229,20 @@ export const grepDefinition: ToolDefinition<'grep', typeof grepShape, GrepMetada
234229
});
235230
}
236231
}
237-
232+
238233
if (!response.isSearchExhaustive) {
239234
outputLines.push('');
240235
outputLines.push(TRUNCATION_MESSAGE);
241236
}
242-
237+
238+
const sources: Source[] = files.map((file) => ({
239+
type: 'file' as const,
240+
repo: file.repo,
241+
path: file.path,
242+
name: file.path.split('/').pop() ?? file.path,
243+
revision: file.revision,
244+
}));
245+
243246
return {
244247
output: outputLines.join('\n'),
245248
metadata,

0 commit comments

Comments
 (0)