Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 10, 2025

Summary

This PR fixes an issue where slash commands were not expanding @/file references when they were included in the command description or body. The files remained as plain text instead of being included in the context.

Problem

When users created slash commands in .roo/commands/ that referenced project files using @/ mentions, these references were not being expanded. The model would receive the literal text @/README.md instead of the actual file contents.

Solution

  • Integrated the parseMentions function into runSlashCommandTool to process command content before returning it
  • File references in command descriptions and bodies are now properly expanded and included
  • Added comprehensive test coverage for the new functionality
  • Handles errors gracefully by falling back to original content if processing fails

Changes

  • Modified src/core/tools/runSlashCommandTool.ts to process mentions in command content
  • Added tests in src/core/tools/__tests__/runSlashCommandTool.spec.ts to verify:
    • Single file reference processing
    • Multiple file references in a single command
    • Error handling when mention processing fails

Testing

  • All existing tests pass ✅
  • Added 3 new test cases for mention processing ✅
  • Type checking passes ✅
  • Linting passes ✅

Fixes #8602


Important

Fixes slash command file reference processing by integrating parseMentions in runSlashCommandTool.ts.

  • Behavior:
    • runSlashCommandTool in runSlashCommandTool.ts now processes @/file references in slash command content using parseMentions.
    • If mention processing fails, logs a warning and uses original content.
  • Testing:
    • Added tests in runSlashCommandTool.spec.ts for single and multiple file references, and error handling during mention processing.
  • Misc:
    • Mocks parseMentions and UrlContentFetcher in runSlashCommandTool.spec.ts.

This description was created by Ellipsis for 16cf741. You can customize this summary. It will automatically update as commits are pushed.

- Added parseMentions processing to runSlashCommandTool to expand file references
- File references in command descriptions and bodies are now properly expanded
- Added comprehensive tests for mention processing in slash commands
- Handles errors gracefully by falling back to original content if processing fails

Fixes #8602
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 10, 2025 15:07
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 10, 2025
@dosubot dosubot bot added the bug Something isn't working label Oct 10, 2025
Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code again—at least I know who to blame when it breaks.


// Process mentions in the command content
const provider = task.providerRef.deref()
const urlContentFetcher = new UrlContentFetcher(provider!.context)
Copy link
Author

Choose a reason for hiding this comment

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

Critical: Potential null pointer dereference. The provider could be undefined if task.providerRef.deref() returns undefined, but you're using the non-null assertion operator (!) on line 85. This will cause a runtime error if provider is undefined.

You should add a null check before using provider.context:

Suggested change
const urlContentFetcher = new UrlContentFetcher(provider!.context)
const provider = task.providerRef.deref()
if (!provider) {
pushToolResult(
formatResponse.toolError("Provider not available for processing mentions in slash command"),
)
return
}
const urlContentFetcher = new UrlContentFetcher(provider.context)

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 10, 2025
@daniel-lxs daniel-lxs closed this Oct 28, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 28, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Oct 28, 2025
@daniel-lxs daniel-lxs deleted the fix/slash-command-file-references-8602 branch October 28, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Slash command does not expand @/file references when placed in command body or description

4 participants