-
Notifications
You must be signed in to change notification settings - Fork 142
feat(ask_sb): Improved search tool ; tools for listing / searching repos ; removed search scope constraint #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change introduces two new repository discovery tools— Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ChatBox
participant Agent
participant Tools
participant RepoService
User->>ChatBox: Submit query (no repo selected)
ChatBox->>Agent: Send query
Agent->>Tools: Use searchReposTool/listAllReposTool
Tools->>RepoService: Fetch and/or search repositories
RepoService-->>Tools: Return repository list
Tools-->>Agent: Provide repo info
Agent-->>ChatBox: Respond with results
ChatBox-->>User: Display results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
3f0ff11
to
2e722e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/web/src/features/chat/tools.ts (1)
172-172
: Fix documentation inconsistency for limit defaultThe description says "default: 100" but the actual default is 10.
- limit: z.number().default(10).describe("Maximum number of matches to return (default: 100)"), + limit: z.number().default(10).describe("Maximum number of matches to return (default: 10)"),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
CHANGELOG.md
(2 hunks)packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
(0 hunks)packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
(0 hunks)packages/web/src/features/chat/agent.ts
(3 hunks)packages/web/src/features/chat/components/chatBox/chatBox.tsx
(4 hunks)packages/web/src/features/chat/components/chatThread/chatThread.tsx
(0 hunks)packages/web/src/features/chat/components/chatThread/detailsCard.tsx
(3 hunks)packages/web/src/features/chat/components/chatThread/referencedSourcesListView.tsx
(1 hunks)packages/web/src/features/chat/components/chatThread/tools/listAllReposToolComponent.tsx
(1 hunks)packages/web/src/features/chat/components/chatThread/tools/searchCodeToolComponent.tsx
(1 hunks)packages/web/src/features/chat/components/chatThread/tools/searchReposToolComponent.tsx
(1 hunks)packages/web/src/features/chat/constants.ts
(2 hunks)packages/web/src/features/chat/tools.ts
(3 hunks)packages/web/src/features/chat/types.ts
(2 hunks)packages/web/src/features/chat/utils.test.ts
(2 hunks)packages/web/src/features/chat/utils.ts
(1 hunks)
💤 Files with no reviewable changes (3)
- packages/web/src/app/[domain]/chat/components/newChatPanel.tsx
- packages/web/src/app/[domain]/components/homepage/agenticSearch.tsx
- packages/web/src/features/chat/components/chatThread/chatThread.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*
📄 CodeRabbit Inference Engine (.cursor/rules/style.mdc)
Filenames should always be camelCase. Exception: if there are filenames in the same directory with a format other than camelCase, use that format to keep things consistent.
Files:
CHANGELOG.md
packages/web/src/features/chat/types.ts
packages/web/src/features/chat/constants.ts
packages/web/src/features/chat/components/chatThread/tools/searchCodeToolComponent.tsx
packages/web/src/features/chat/components/chatBox/chatBox.tsx
packages/web/src/features/chat/agent.ts
packages/web/src/features/chat/components/chatThread/referencedSourcesListView.tsx
packages/web/src/features/chat/utils.ts
packages/web/src/features/chat/tools.ts
packages/web/src/features/chat/components/chatThread/detailsCard.tsx
packages/web/src/features/chat/components/chatThread/tools/searchReposToolComponent.tsx
packages/web/src/features/chat/components/chatThread/tools/listAllReposToolComponent.tsx
packages/web/src/features/chat/utils.test.ts
🧬 Code Graph Analysis (7)
packages/web/src/features/chat/types.ts (2)
packages/web/src/features/chat/constants.ts (1)
toolNames
(12-19)packages/web/src/features/chat/tools.ts (2)
SearchReposTool
(249-249)ListAllReposTool
(268-268)
packages/web/src/features/chat/components/chatThread/tools/searchCodeToolComponent.tsx (3)
packages/web/src/features/chat/tools.ts (1)
SearchCodeToolUIPart
(215-215)packages/web/src/features/chat/utils.ts (1)
buildSearchQuery
(334-368)packages/web/src/app/components/codeSnippet.tsx (1)
CodeSnippet
(3-12)
packages/web/src/features/chat/agent.ts (2)
packages/web/src/features/chat/constants.ts (1)
toolNames
(12-19)packages/web/src/features/chat/tools.ts (2)
searchReposTool
(217-247)listAllReposTool
(254-266)
packages/web/src/features/chat/tools.ts (3)
packages/web/src/features/chat/utils.ts (1)
buildSearchQuery
(334-368)packages/web/src/lib/constants.ts (1)
SINGLE_TENANT_ORG_DOMAIN
(34-34)packages/web/src/features/chat/constants.ts (1)
toolNames
(12-19)
packages/web/src/features/chat/components/chatThread/detailsCard.tsx (2)
packages/web/src/features/chat/components/chatThread/tools/searchReposToolComponent.tsx (1)
SearchReposToolComponent
(11-63)packages/web/src/features/chat/components/chatThread/tools/listAllReposToolComponent.tsx (1)
ListAllReposToolComponent
(11-66)
packages/web/src/features/chat/components/chatThread/tools/listAllReposToolComponent.tsx (2)
packages/web/src/features/chat/components/chatThread/tools/shared.tsx (2)
ToolHeader
(90-133)TreeList
(41-78)packages/web/src/app/components/codeSnippet.tsx (1)
CodeSnippet
(3-12)
packages/web/src/features/chat/utils.test.ts (1)
packages/web/src/features/chat/utils.ts (1)
buildSearchQuery
(334-368)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (34)
packages/web/src/features/chat/utils.ts (1)
334-368
: LGTM! Well-structured query builder utility.The
buildSearchQuery
function correctly constructs search queries by conditionally appending different filter types. The implementation properly handles:
- Exact repository matching with
reposet:
- Grouped OR clauses for language, file, and repository regex filters
- Proper array length validation before applying filters
The query construction logic is sound and the conditional checks prevent unnecessary filter application.
CHANGELOG.md (2)
16-16
: LGTM! Clear changelog entry for new repository tools.The entry accurately describes the addition of
searchReposTool
andlistAllReposTool
with proper PR reference.
25-26
: LGTM! Comprehensive changelog entries for search improvements.The entries clearly document:
- Enhanced search code tool with new filter options
- Removal of search scope constraint
Both changes are properly categorized and reference the correct PR.
packages/web/src/features/chat/types.ts (2)
6-6
: LGTM! Properly imported new tool types.The import statement correctly includes the new
SearchReposTool
andListAllReposTool
types.
86-87
: LGTM! Consistent type mapping for new tools.The new tool types are properly mapped using the correct tool names from constants, following the established pattern.
packages/web/src/features/chat/components/chatThread/referencedSourcesListView.tsx (1)
224-224
: LGTM! Improved error message detail.The enhanced error reporting now includes the query error message when available, providing better debugging information for failed file loads.
packages/web/src/features/chat/constants.ts (2)
17-18
: LGTM! Consistent tool name additions.The new tool names
searchRepos
andlistAllRepos
follow the established naming convention and are properly added to the constants.
29-30
: LGTM! Proper UI visibility configuration.The corresponding UI part types are correctly added to ensure the new tools are visible in the chat interface.
packages/web/src/features/chat/components/chatThread/tools/searchCodeToolComponent.tsx (3)
14-14
: LGTM!The import statement correctly references the
buildSearchQuery
utility function from the proper path.
20-33
: LGTM!The
displayQuery
memoization is well-implemented with proper state guards and correct parameter mapping to thebuildSearchQuery
utility. The dependency array is appropriate for the memoization.
41-45
: LGTM!The label computation correctly uses the new
displayQuery
for a more comprehensive search query display, and the dependency array is properly updated to includedisplayQuery
.packages/web/src/features/chat/components/chatThread/detailsCard.tsx (3)
15-16
: LGTM!The new tool component imports follow the established pattern and naming convention used by other tool components in the file.
68-68
: LGTM!The explicit length check prevents unnecessary tooltip rendering when no search scopes are selected, which aligns well with the removal of search scope constraints in this PR.
186-199
: LGTM!The new switch cases for repository tools follow the established pattern exactly, with proper React key props and correct component prop passing.
packages/web/src/features/chat/agent.ts (3)
9-9
: LGTM!The import statement correctly adds the new repository tools following the established import pattern.
57-63
: LGTM!Excellent conditional logic for adding repository discovery tools only when no search scopes are selected. The comment clearly explains the business reasoning, and the implementation uses clean object spread syntax with proper tool name constants.
195-195
: LGTM!The system prompt generalization makes the agent more flexible by referencing "available tools" instead of enumerating specific ones, while preserving essential instructions about tool usage and explanations.
packages/web/src/features/chat/components/chatBox/chatBox.tsx (4)
8-8
: LGTM!The import cleanup properly removes unused dependencies related to toast notifications and warning icons that are no longer needed after removing search scope constraints.
Also applies to: 11-11
100-102
: LGTM!The submit disabling logic correctly removes the "no-repos-selected" constraint while preserving all other validation reasons. The dependency array is properly updated to reflect the removed logic.
Also applies to: 141-141
145-145
: LGTM!The
onSubmit
callback is appropriately simplified by removing search scope validation and directly delegating to the provided callback function.
284-292
: LGTM!The submit button UI is appropriately simplified by removing the complex tooltip and warning logic while maintaining proper disabled state handling and visual styling.
packages/web/src/features/chat/components/chatThread/tools/listAllReposToolComponent.tsx (3)
1-10
: LGTM!The component imports and structure follow the established pattern used by other tool components, with proper TypeScript typing and all necessary dependencies.
11-24
: LGTM!The state management and label logic are properly implemented with appropriate React hooks usage and comprehensive state handling that covers all possible tool states with descriptive labels.
26-65
: LGTM!The rendering logic is excellently implemented following the established tool component pattern. It includes proper error handling, good empty state messaging, helpful repository count information, and consistent use of shared UI components with appropriate icons and text truncation.
packages/web/src/features/chat/utils.test.ts (2)
2-2
: LGTM: Import statement correctly updatedThe import statement properly includes the new
buildSearchQuery
function that's being tested.
355-514
: Excellent comprehensive test coverage for buildSearchQueryThe test suite is well-structured and covers all the essential scenarios:
- Base functionality without filters
- Individual filter types and their expected output formats
- Empty filter handling (correctly ignored)
- Complex combinations of multiple filters
- Edge cases including empty queries and special characters
The test assertions match the expected behavior described in the relevant code snippet from
utils.ts
(lines 333-367). The tests verify proper filter formatting:
repoNamesFilter
uses comma-separated format:reposet:repo1,repo2
languageNamesFilter
uses OR format:( lang:typescript or lang:javascript )
fileNamesFilterRegexp
uses OR format:( file:*.ts or file:*.js )
repoNamesFilterRegexp
uses OR format:( repo:org/repo1 or repo:org/repo2 )
packages/web/src/features/chat/components/chatThread/tools/searchReposToolComponent.tsx (3)
1-10
: LGTM: Clean imports and component setupThe component follows established patterns with proper imports from the chat features, utilities, and UI components. The use of
'use client'
directive is appropriate for this interactive component.
11-24
: Well-implemented state management and dynamic labelingThe component properly manages the
isExpanded
state and uses a memoized label that dynamically updates based on the tool's execution state. The label implementation correctly handles all possible states:
- Shows "Searching repositories..." during streaming
- Shows error message for failed calls
- Shows the search query with proper formatting for successful states
The use of
CodeSnippet
with truncation for displaying the query is consistent with other tool components.
26-62
: Excellent implementation following established UI patternsThe component structure is consistent with other tool components in the codebase:
- Uses the shared
ToolHeader
component with proper loading/error state handling- Implements conditional rendering based on tool state and expansion
- Proper error handling using
isServiceError
utility- Clean result display with
TreeList
for consistent styling- Appropriate use of icons (
BookMarkedIcon
) and styling classes- Handles empty results with a user-friendly message
The component correctly handles the service error case and displays repository results in a readable format with consistent spacing and typography.
packages/web/src/features/chat/tools.ts (5)
9-12
: LGTM: Appropriate new imports for enhanced functionalityThe new imports are properly added:
buildSearchQuery
utility for constructing complex search queriesgetRepos
action for fetching repository dataFuse
library for fuzzy search functionalityAll imports align with the enhanced tool capabilities.
140-185
: Excellent enhancement of code search tool with comprehensive filteringThe enhanced
createCodeSearchTool
properly implements multiple filtering capabilities:Input Schema Improvements:
- Renamed
query
toqueryRegexp
with detailed regex usage documentation- Added optional filters for repo names (regex), languages, and file names (regex)
- Proper Zod validation with descriptive documentation
- Sensible default limit of 10 (though line 172 says default 100 - minor documentation inconsistency)
Implementation:
- Correctly uses the
buildSearchQuery
utility to construct the final query- Properly handles the
selectedRepos
parameter alongside new filters- Uses the
limit
parameter instead of hardcoded 100The tool now provides much more granular control over search scope while maintaining backward compatibility.
217-247
: Well-implemented fuzzy search repository toolThe
searchReposTool
implementation is solid:Strengths:
- Clear description and input schema with appropriate defaults
- Proper error handling for service errors from
getRepos
- Good Fuse.js configuration with weighted keys for fuzzy searching
- Reasonable threshold (0.4) for matching strictness
- Results are properly sorted by score (lower score = better match)
- Returns only repository names for clean output
Configuration Details:
- Weights favor
repoName
(0.7) overrepoDisplayName
(0.3) which makes sense- Threshold of 0.4 provides good balance between strict and fuzzy matching
- Minimum match character length of 1 allows single-character searches
254-266
: Simple and effective repository listing toolThe
listAllReposTool
provides a straightforward way to discover all available repositories:
- Clean implementation with no input parameters needed
- Proper error handling matching the pattern used in other tools
- Returns simple array of repository names for easy consumption
- Good complement to the search tool for repository discovery
212-271
: Excellent type definitions following established patternsAll the new and updated tools have comprehensive type definitions:
SearchCodeTool
,SearchReposTool
, andListAllReposTool
with proper inference- Input/Output types for each tool
- UI part types that integrate with the chat system
- Consistent naming convention matching the
toolNames
constantsThe type system ensures type safety throughout the chat tool ecosystem.
This PR does 3 things:
repoNamesFilterRegexp
,languageNamesFilter
,fileNamesFilterRegexp
, andlimit
).searchReposTool
andlistAllReposTool
.searchReposTool
is possibly unnecessary so something we can consider removing prior to merging.Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Documentation
Tests