-
Notifications
You must be signed in to change notification settings - Fork 208
fix(ask): Properly handle regex filters that include parenthesis #786
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
This comment has been minimized.
This comment has been minimized.
WalkthroughPR addresses issue Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/web/src/features/chat/tools.ts (1)
142-173: Fix minor typos in the tool description text.“expresion” → “expression”, “paranthesis” → “parenthesis”.
✏️ Proposed fix
- .describe(`Filter results from filepaths that match the regex. When this option is not specified, all files are searched. If the regex expresion includes a paranthesis **YOU MUST** wrap this value in quotes when passing it in.`) + .describe(`Filter results from filepaths that match the regex. When this option is not specified, all files are searched. If the regex expression includes a parenthesis **YOU MUST** wrap this value in quotes when passing it in.`)packages/mcp/src/index.ts (1)
24-49: Fix minor typos in schema/description text.“expresion” → “expression”, “paranthesis” → “parenthesis”.
✏️ Proposed fix
- .describe("Scope the search to results inside filepaths that match the provided regex expression. By default all files are searched, so **only use this filter if you need to filter on specific files**. **YOU MUST** ensure that this is a valid regex expression and any special characters are properly escaped. If the regex expresion includes a paranthesis **YOU MUST** wrap this value in quotes when passing it in.") + .describe("Scope the search to results inside filepaths that match the provided regex expression. By default all files are searched, so **only use this filter if you need to filter on specific files**. **YOU MUST** ensure that this is a valid regex expression and any special characters are properly escaped. If the regex expression includes a parenthesis **YOU MUST** wrap this value in quotes when passing it in.")
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Line 12: Update the changelog entry text to use the plural form "parentheses"
instead of "parenthesis" for clarity; locate the line containing "Properly
handle regex filters that include parenthesis.
[`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)" and change it to
"Properly handle regex filters that include parentheses.
[`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)".
| ### Fixed | ||
| - Properly map all hotkeys in UI based on the platform [#784](https://github.com/sourcebot-dev/sourcebot/pull/784) | ||
| - Properly map all hotkeys in UI based on the platform. [#784](https://github.com/sourcebot-dev/sourcebot/pull/784) | ||
| - Properly handle regex filters that include parenthesis. [#786](https://github.com/sourcebot-dev/sourcebot/pull/786) |
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.
Use “parentheses” (plural) for clarity.
Minor wording nit in the changelog entry.
✏️ Suggested tweak
-- Properly handle regex filters that include parenthesis. [`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)
+- Properly handle regex filters that include parentheses. [`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Properly handle regex filters that include parenthesis. [#786](https://github.com/sourcebot-dev/sourcebot/pull/786) | |
| - Properly handle regex filters that include parentheses. [`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786) |
🤖 Prompt for AI Agents
In `@CHANGELOG.md` at line 12, Update the changelog entry text to use the plural
form "parentheses" instead of "parenthesis" for clarity; locate the line
containing "Properly handle regex filters that include parenthesis.
[`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)" and change it to
"Properly handle regex filters that include parentheses.
[`#786`](https://github.com/sourcebot-dev/sourcebot/pull/786)".
| // Entry point for the MCP server | ||
| import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; | ||
| import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; | ||
| import { preprocessRegexp } from '@sourcebot/shared'; |
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.
nit: mcp cannot take a dependency on @sourcebot/shared since we do not publish it to npm
|
I wonder if we could improve our parsing to not throw a exception in the case of a unmatched paren? |
Closing in favor of #788 |
Weird edge case where if a regex filter like filename/reponame contained a parenthesis the parser would fail. This is because the query language forbids parenthesis in the value since they're used to match against the ParenExpr symbol.
The ideal case is that the agent would be smart enough to wrap the regexp in quotes, which would solve this problem. I've added instructions in the tool call to tell it to do this, but it rarely does. As a result, I've added basic logic to process the regexp before adding it in the query string to wrap it in quotes if a parenthesis is included.
Fixes #771
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.