Skip to content

Conversation

@logosstone
Copy link

@logosstone logosstone commented Apr 17, 2025

Fix @/ triggering mode menu instead of file/folder suggestions

Fixes: #2660


Bug

Typing @/ incorrectly opened the mode selection menu instead of showing file or folder suggestions.


Changes

  • Skip mode selection when context is File or Folder
  • Normalize paths by adding a leading / to improve fuzzy matching
  • Force File context when input starts with @/

Context

The / in @/ was misinterpreted as a slash command trigger. This caused the mode menu to appear instead of showing relevant file suggestions. The fix ensures correct behavior by enforcing the appropriate context and improving path handling.


Implementation

  • Explicitly set selectedType = File when detecting @/
  • Updated getContextMenuOptions to bypass mode logic when type is File or Folder
  • Normalized all paths to start with / before fuzzy matching
  • Kept changes scoped to context mention handling only

How to Test

  1. Type @/ in the mention input field.
  2. Confirm that file/folder suggestions are shown instead of the mode menu.
  3. Test with nested folders and various valid paths.
  4. Ensure mode selection still works in non-file mention contexts.

Contact

Discord: @logostone
Or comment directly in this pull request.


Important

Fix @/ triggering mode menu by enforcing File context and normalizing paths in ChatTextArea.tsx and context-mentions.ts.

  • Behavior:
    • Fix @/ triggering mode menu instead of file/folder suggestions.
    • Enforce File context when input starts with @/ in ChatTextArea.tsx.
    • Normalize paths to start with / in context-mentions.ts for better matching.
  • Functions:
    • Update getContextMenuOptions() to skip mode logic for File or Folder types.
    • Modify shouldShowContextMenu() to correctly handle @/ input.
  • Misc:
    • Adjust handleInputChange() in ChatTextArea.tsx to validate search queries and set default menu index.

This description was created by Ellipsis for 30c1c86. It will automatically update as commits are pushed.

Commit Body:
Fixes a bug where typing @/ opened the mode selection menu instead of file/folder suggestions.

Changes:

Skip mode selection if context is File or Folder

Normalize paths (add leading /) for better fuzzy matching

Force File type when @/ is detected in input

Fixes RooCodeInc#2660
@logosstone logosstone requested review from cte and mrubens as code owners April 17, 2025 01:41
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Apr 17, 2025
if (query.length > 0) {
// Check if the query is valid for initiating a file search
// It should have length > 0 AND not be just '/', '.', or '\' immediately after @
const isValidSearchQuery = query.length > 0 && !/^[/.\\\\]$/.test(query) // Removed \ before / and .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify the regex pattern used for isValidSearchQuery. The comment 'Removed \ before / and .' might be confusing. Consider explaining what cases it handles, or extract this pattern as a named constant for clarity.

Suggested change
const isValidSearchQuery = query.length > 0 && !/^[/.\\\\]$/.test(query) // Removed \ before / and .
const isValidSearchQuery = query.length > 0 && !/^[/.\\]$/.test(query) // Excludes queries that are only '/', '.', or '\' after @ mention; prevents invalid file searches.

@hannesrudolph
Copy link
Collaborator

@mrubens check this out!

@adamhill
Copy link
Contributor

adamhill commented Apr 17, 2025

Thanks for finding this!

@mrubens
Copy link
Collaborator

mrubens commented Apr 17, 2025

What do you think of this as a simpler approach? With the commands we have I think they only make sense at the beginning of the input, which lets us simplify a bit. #2702

@mrubens
Copy link
Collaborator

mrubens commented Apr 17, 2025

I went with ☝️ since the code was a little simpler, but thank you for the contribution and figuring out the problem!

@mrubens mrubens closed this Apr 17, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Apr 17, 2025
@logosstone
Copy link
Author

What do you think of this as a simpler approach? With the commands we have I think they only make sense at the beginning of the input, which lets us simplify a bit. #2702

I went with ☝️ since the code was a little simpler, but thank you for the contribution and figuring out the problem!

Yes, that makes sense, simpler and more general approach. Thank you for taking the time to review.

SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants