Skip to content

Conversation

@snoyiatk
Copy link
Contributor

@snoyiatk snoyiatk commented Apr 28, 2025

Context

Problem

  • For multi-root workspaces, the cwd (workspace) path relies on current active editor, or default to the first root.
    When a task is running, if user change active editor file, or close all edit file, the cwd point to incorrect directory, causing tool-call and other actions to be mis-behave (eg file not found etc).

The fix:

  • Persist workspace path per task, init its value when a task started.
  • The workspace path is passed to sub-task to keep parent/child task workspace consistent

I heavily using multi-root workspace and would love this to be fixed.
Otherwise I must keep same active edit document while running roo task.

Other consideration:

  • When reopen task from history, the workspace should be kept same as history item, or change to new workspace?
    The current approach is to config to new workspace, as normal use-case is usually open/retry task in new workspace.

Implementation

  • Add workspacePath to Cline class and init its value in constructor

Screenshots

Setup

image

Before

image image

After

Correctly using workspace and tool-call when running task while user open file in another workspace
image

How to Test

  • Create multi-root workspaces https://code.visualstudio.com/docs/editing/workspaces/multi-root-workspaces
  • Open file in 1 workspace folder and start random roo task, eg list file in current workspace, check the prompt being sent and the output to see workspace folder
  • Keep same task open, open another file in another workspace folder, continue with other task (eg list file in current workspace), check sent prompt and output

Important

Adds workspacePath to Cline class to persist workspace paths for tasks, ensuring consistent task management in multi-root workspaces.

  • Behavior:
    • Adds workspacePath to Cline class in Cline.ts, initialized in the constructor to persist the workspace path for each task.
    • Updates get cwd() to return workspacePath instead of recalculating it.
    • Ensures consistent workspace path for parent and child tasks.
  • Implementation:
    • Initializes workspacePath in Cline constructor, using parent task's path or defaulting to the desktop path.
    • Modifies task resumption to use the new workspace path logic.
  • Misc:
    • Adjusts logic for reopening tasks from history to use the new workspace path.

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

@changeset-bot
Copy link

changeset-bot bot commented Apr 28, 2025

⚠️ No Changeset found

Latest commit: 183ec5f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Apr 28, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap Apr 28, 2025
@sachasayan
Copy link
Contributor

Looks good to me. I don't use mult-root much so are there any things we need to be aware where this might create odd edge case behaviours, @snoyiatk ?

@snoyiatk
Copy link
Contributor Author

snoyiatk commented Apr 29, 2025

@sachasayan
With original extension I only experience the issue when working with parent-child task and for history item task.
I looked up all cwd references in codebase and look-like current approach work well.
I installed and tried the extension locally for a day and didn't face any issue (basically tested all tool_call like read_file, list_file, apply_diff etc)

Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Thanks!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 29, 2025
@mrubens mrubens merged commit 97f0dd4 into RooCodeInc:main Apr 29, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Apr 29, 2025
SmartManoj pushed a commit to SmartManoj/Raa-Code that referenced this pull request May 6, 2025
…RooCodeInc#2999)

* using ndoe shell instead of vs code terminal for commands + always using latest vsix

* 30s max time for commands in test mode

* removed overwhelming logs

* better 30s termination
@snoyiatk snoyiatk deleted the feat/multi-root-workspace-path branch July 10, 2025 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants