Skip to content

fix(web): don't include sources in grep tool when groupByRepo=true#1032

Merged
brendan-kellam merged 2 commits intomainfrom
brendan-kellam/fix-grep-groupbyrepo-sources-SOU-730
Mar 23, 2026
Merged

fix(web): don't include sources in grep tool when groupByRepo=true#1032
brendan-kellam merged 2 commits intomainfrom
brendan-kellam/fix-grep-groupbyrepo-sources-SOU-730

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Mar 23, 2026

Summary

  • When groupByRepo=true, the grep tool was still including all matched files as sources in the tool result, even though the LLM only receives a repo-level summary and never references individual files
  • This caused 1000+ individual setSources() state updates to be dispatched to the client, each triggering a full re-render of the chat thread and all message pairs
  • Fix: omit sources from the return value when groupByRepo=true

Test plan

  • Run a search that uses groupByRepo=true and confirm the UI no longer freezes when results return
  • Confirm the hover card in the grep tool component still shows repo-grouped results correctly
  • Run a normal (non-grouped) grep and confirm file sources still appear as expected

Fixes SOU-730

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Resolved UI freeze that occurred when the grep tool returned large result sets with group-by-repository enabled.

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>
@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Walkthrough

The pull request fixes a UI freeze issue that occurred when the grep tool returned large result sets with groupByRepo enabled. The fix restructures when the sources field is constructed in the grep execution logic, deferring its creation in the grouped-by-repo path.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added entry documenting resolution of UI freeze when grep returns large result sets with groupByRepo=true.
Grep Tool Execution
packages/web/src/features/tools/grep.ts
Modified grepDefinition.execute to defer sources construction: returns undefined when groupByRepo=true, and constructs sources after output/truncation handling only in the non-grouped path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: preventing the grep tool from including sources when groupByRepo=true, which directly addresses the UI freeze bug documented in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan-kellam/fix-grep-groupbyrepo-sources-SOU-730

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brendan-kellam brendan-kellam merged commit 783acaa into main Mar 23, 2026
8 checks passed
@brendan-kellam brendan-kellam deleted the brendan-kellam/fix-grep-groupbyrepo-sources-SOU-730 branch March 23, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant