Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 10, 2025

This PR improves support for multi-folder workspaces in Roo Code, addressing issues #6897 and #6720.

Changes

1. Fixed Task workspace path consistency

  • Modified Task class to store the initial workspace folder when created
  • The workspace path now remains consistent throughout the task lifetime, preventing CWD switching issues
  • Tasks inherit workspace path from parent tasks when created as subtasks

2. Improved file mention handling

  • File mentions now use relative paths in multi-folder workspaces
  • Absolute paths from different workspace folders are converted to workspace-relative paths (e.g., backend/src/server.ts instead of /absolute/path/to/backend/src/server.ts)
  • This makes file references clearer and more portable

3. Fixed .roo folder detection

  • Added support for detecting when .roo is itself a workspace folder
  • MCP configuration and custom modes now properly detect .roo folders in multi-folder setups
  • The system prioritizes the workspace folder containing the active file when determining which .roo folder to use

4. Added comprehensive tests

  • Created new test suite for multi-folder workspace functionality
  • Tests cover workspace path initialization, consistency, and file mention path handling

Testing

  • All existing tests pass
  • Linting and type checking pass
  • New test suite covers the multi-folder workspace scenarios

Fixes

Impact

These changes ensure that Roo Code works seamlessly in multi-folder workspaces, preventing confusion when switching between different folders and maintaining consistent context throughout tasks.


Important

Enhances multi-folder workspace support in Roo Code by ensuring consistent task workspace paths, converting file mentions to relative paths, and improving .roo folder detection, with comprehensive tests added.

  • Task Workspace Path:
    • Task class now stores initial workspace folder on creation, ensuring consistent workspace path throughout task lifetime.
    • Subtasks inherit workspace path from parent tasks.
  • File Mentions:
    • Converts absolute paths to workspace-relative paths in multi-folder workspaces in index.ts.
    • Handles file mentions across different workspace folders.
  • .roo Folder Detection:
    • Detects .roo as a workspace folder in CustomModesManager.ts, webviewMessageHandler.ts, and McpHub.ts.
    • Prioritizes workspace folder containing active file for .roo folder usage.
  • Testing:
    • New test suite multi-folder-workspace.spec.ts for multi-folder workspace functionality.
    • Tests cover workspace path initialization, consistency, and file mention path handling.

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

- Fix Task to store initial workspace folder and use it consistently throughout task lifetime
- Fix file mentions to use relative paths in multi-folder workspaces
- Fix .roo folder detection to check if .roo is a workspace folder itself
- Add support for workspace folder selection based on active editor
- Add tests for multi-folder workspace functionality

Fixes #6897 and #6720
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 10, 2025 13:39
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Aug 10, 2025
@roomote roomote bot mentioned this pull request Aug 10, 2025
4 tasks
Copy link
Contributor 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.

I reviewed my own code and found bugs I didn't know I was capable of writing.

if (workspaceFolder) {
// Use relative path from the workspace folder
const relativePath = path.relative(workspaceFolder.uri.fsPath, absPath)
displayPath = path.join(workspaceFolder.name, relativePath).toPosix()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is .toPosix() an extension method defined elsewhere? I don't see it in standard JavaScript/TypeScript. This could cause runtime errors. Consider using path.posix.join() or creating a utility function to normalize paths consistently.

const projectMcpPattern = new vscode.RelativePattern(workspaceFolder, ".roo/mcp.json")
this.projectMcpWatcher = vscode.workspace.createFileSystemWatcher(projectMcpPattern)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I notice multiple file watchers are created in the loop but only the last one gets stored in this.projectMcpWatcher. Could this lead to memory leaks since the earlier watchers won't be properly disposed? Consider storing all watchers or refactoring this logic.

let roomodesPath: string
if (rooWorkspaceFolder) {
// .roo is a workspace folder itself, look for .roomodes directly in it
roomodesPath = path.join(rooWorkspaceFolder.uri.fsPath, ROOMODES_FILENAME.replace(".roo/", ""))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replace operation doesn't seem to do anything since ROOMODES_FILENAME is defined as .roomodes not .roo/roomodes. Was this intended for a different purpose?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 10, 2025
@daniel-lxs
Copy link
Member

Closing, the author will be implementing this

@daniel-lxs daniel-lxs closed this Aug 12, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 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

Archived in project

Development

Successfully merging this pull request may close these issues.

Improve Multiple folder workspace support Roo does not identify .roo folder in multiroot workspace

4 participants