Skip to content

Conversation

arafatkatze
Copy link
Contributor

@arafatkatze arafatkatze commented Aug 27, 2025

Description

This PR lays the groundwork for Multi-Workspace Folder Support in Cline, addressing the need for enterprise users and modern development workflows to work across multiple repositories simultaneously.

Problem Solved

Currently, Cline is limited to a single root directory (cwd), which prevents users from:

  • Working on microservices architectures with multiple repositories
  • Coordinating changes across frontend/backend/shared library projects
  • Managing monorepo sub-projects effectively

What This PR Introduces

Phase 0 Implementation - Infrastructure and Migration Preparation:

  1. WorkspaceRootManager Class (src/core/workspace/WorkspaceRootManager.ts)

    • Central manager for multi-workspace operations
    • Handles workspace root resolution and path mapping
    • Provides backward compatibility through fromLegacyCwd() method
    • Supports Git/Mercurial VCS detection
  2. WorkspaceResolver Tracer Functions (src/core/workspace/WorkspaceResolver.ts)

    • Non-breaking tracer functions to track single-root assumptions
    • Already deployed across 52+ files in the codebase
    • Provides telemetry for migration planning

Technical Approach

The implementation follows a phased migration strategy:

  • Phase 0 (This PR): Infrastructure setup and migration tracking
  • Phase 1: Core state management migration (cwdworkspaceRoots[])
  • Phase 2: RPC & Task integration
  • Phase 3: Tool migration (18 tool handlers)
  • Phase 4: Distributed checkpoint system
  • Phase 5: Testing & validation

This approach ensures backward compatibility while gradually introducing multi-workspace capabilities.

Test Procedure

Testing Approach

  1. Backward Compatibility Testing

    • Verified existing single-root tasks continue to work unchanged
    • Tested WorkspaceRootManager.fromLegacyCwd() conversion
    • Ensured tracer functions don't break existing path operations
  2. WorkspaceRootManager Testing

    • Path resolution with nested workspaces
    • VCS detection (Git/Mercurial/None)
    • Serialization/deserialization for task persistence
    • Primary workspace management
  3. Integration Points Verified

    • All 52+ files with tracer functions continue to work
    • No performance degradation in path operations
    • Module exports properly configured

What Could Break & Verification

  • Path Resolution: Tested with absolute/relative paths, symlinks
  • Task Initialization: Verified legacy task loading still works
  • Tool Handlers: Confirmed tracer functions don't affect tool execution
  • Performance: Measured overhead of tracer functions (<1ms average)

Confidence Level

This PR is ready for merge because:

  • It's non-breaking (Phase 0 is purely additive)
  • All existing functionality remains intact
  • Comprehensive testing of backward compatibility
  • Clear migration path documented

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ♻️ Refactor Changes
  • 💅 Cosmetic Changes
  • 📚 Documentation update
  • 🏃 Workflow Changes

Pre-flight Checklist

  • Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
  • Tests are passing (npm test) and code is formatted and linted (npm run format && npm run lint)
  • I have created a changeset using npm run changeset (required for user-facing changes)
  • I have reviewed contributor guidelines

Screenshots

Migration Report Output Example

# Multi-Workspace Migration Report

## Executive Summary
- Total Components Tracked: 52 files
- Total Path Operations: 300+
- Performance Impact: <1ms average overhead

## Component Analysis
### Tool Handlers (18 files)
- High Usage: ExecuteCommandToolHandler (45 calls)
- Medium Usage: ReadFileToolHandler (32 calls)
...

## Risk Assessment
⚠️ High-Risk Components:
- CheckpointTracker: Complex refactor needed
- Terminal Management: Command context required

WorkspaceRootManager API

// Backward compatibility
const manager = await WorkspaceRootManager.fromLegacyCwd('/single/root')

// Multi-workspace
const manager = new WorkspaceRootManager([
  { path: '/frontend', name: 'frontend', vcs: VcsType.Git },
  { path: '/backend', name: 'backend', vcs: VcsType.Git }
], 0) // primary index

// Path resolution
const root = manager.resolvePathToRoot('/frontend/src/App.tsx')
// Returns: { path: '/frontend', name: 'frontend', ... }

Additional Notes

Important Notes for Reviewers:

  1. This is Phase 0 of a larger feature - This PR sets up the infrastructure without changing existing behavior. The actual multi-workspace functionality will come in subsequent PRs (Phases 1-5).

  2. Performance Considerations - The tracer functions add minimal overhead (<1ms) and can be disabled via environment variable if needed.

  3. Migration Strategy - The phased approach allows for gradual rollout with ability to pause/rollback at any phase if issues arise.

  4. Enterprise Focus - This feature primarily benefits enterprise users with multi-repository workflows, but maintains full backward compatibility for single-root users.

  5. Next Steps After Merge:

    • Phase 1 PR: Core state management migration
    • Phase 2 PR: RPC & task integration
    • Phase 3 PR: Tool migration
    • Phase 4 PR: Checkpoint distribution
    • Phase 5 PR: Final testing & documentation

Questions for Maintainers:

  • Should we add feature flag for gradual rollout?
  • Any concerns about the WorkspaceRoot data structure?
  • Preferences on checkpoint system architecture for multi-repo?

Related Documentation:


Important

Introduces foundational structure for multi-workspace support in Cline, including WorkspaceRootManager, WorkspaceResolver, and telemetry for migration planning.

  • Behavior:
    • Introduces WorkspaceRootManager in WorkspaceRootManager.ts for managing multi-workspace operations, including root resolution and VCS detection.
    • Adds WorkspaceResolver in WorkspaceResolver.ts for path resolution with migration tracing, supporting both single and multi-root modes.
    • Implements telemetry functions in WorkspaceResolver.ts to track path usage across 52+ files for migration planning.
  • Utilities:
    • Adds MigrationReporter in MigrationReporter.ts for generating migration reports from usage statistics.
    • Provides getWorkspaceBasename() and resolveWorkspacePath() functions for path operations with context tracking.
  • Testing:
    • Includes unit tests in WorkspaceResolver.test.ts to ensure correct path resolution and usage tracking behavior.
  • Integration:
    • Replaces path module usage with workspaceResolver in multiple files for path operations, ensuring compatibility with the new multi-workspace structure.

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

Copy link

changeset-bot bot commented Aug 27, 2025

🦋 Changeset detected

Latest commit: c4b7a62

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
claude-dev Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

github-actions bot commented Aug 27, 2025

Coverage Report

Extension Coverage

Base branch: 47%

PR branch: 48%

✅ Coverage increased or remained the same

Webview Coverage

Base branch: 18%

PR branch: 18%

✅ Coverage increased or remained the same

Overall Assessment

Test coverage has been maintained or improved

Last updated: 2025-09-02T23:07:04.589919

@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from 1b2156d to 3ec4a86 Compare August 28, 2025 01:26
@arafatkatze arafatkatze changed the title Arafatkatze/adding workspace root migration base Setup Raw Structure for implementing multi-workspace support with WorkspaceRoot Aug 28, 2025
@arafatkatze arafatkatze marked this pull request as ready for review August 28, 2025 01:29
@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 20:09
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from 4bf5a24 to 2495ade Compare August 28, 2025 20:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR establishes the foundational infrastructure for multi-workspace support in Cline by introducing WorkspaceRootManager and WorkspaceResolver classes. The implementation follows a phased migration strategy, with this Phase 0 focusing on infrastructure setup and backward compatibility while tracking single-root path operations for future migration planning.

Key changes include:

  • WorkspaceRootManager: Central manager for multi-workspace operations with VCS detection and backward compatibility
  • WorkspaceResolver: Path resolution tracer that wraps existing path.resolve and path.basename calls across 52+ files
  • Migration tracking: Telemetry system to identify single-root assumptions in the codebase

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/core/workspace/ New core workspace module with WorkspaceRootManager, WorkspaceRoot types, and WorkspaceResolver tracer
src/utils/*.ts Updated path utilities to use WorkspaceResolver for migration tracking
src/services/ Updated ripgrep, glob, and browser services to use workspace path resolution
src/integrations/ Updated file processing, checkpoints, and editor integrations with workspace-aware path handling
src/core/task/tools/handlers/ Updated all tool handlers to use workspace path resolution instead of direct path.resolve calls
src/core/controller/ Updated controller methods to use workspace-aware path resolution for task and file operations
Comments suppressed due to low confidence (1)

src/core/controller/file/toggleClineRule.ts:1

  • Duplicate telemetry calls detected. The same telemetry event is being captured twice with identical parameters. Remove the first occurrence (lines 36-37) as it's redundant.
import { getWorkspaceBasename } from "@core/workspace"

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch 2 times, most recently from 300dda7 to 64b00a6 Compare August 28, 2025 20:56
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from 64b00a6 to 695995c Compare August 28, 2025 21:01
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch 3 times, most recently from bdb08fe to f20ad9e Compare August 30, 2025 00:37
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from f20ad9e to b47d720 Compare August 30, 2025 03:12
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from b47d720 to b49a47b Compare August 31, 2025 07:54
Copy link

@JicLotus JicLotus left a comment

Choose a reason for hiding this comment

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

Hello @arafatkatze! Thanks so much for this, great work 🎉 I left a few comments for you to take a look at. Please note that I might be missing some context on how things usually work here, so I’ve approached the review as I normally would. I’ll defer my formal approval to @abeatrix and @canvrno. Thanks again!

@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch 3 times, most recently from a420771 to 351ba29 Compare September 1, 2025 19:43
@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from 943b7d0 to d7f9420 Compare September 1, 2025 20:06
@arafatkatze
Copy link
Contributor Author

@JicLotus Thanks a lot for such a detailed review, I have added tests and made the code much more modular than before.

@arafatkatze arafatkatze force-pushed the arafatkatze/adding-workspace-root-migration-base branch from d7f9420 to 8b35940 Compare September 2, 2025 22:46
@arafatkatze arafatkatze merged commit e3bc5f0 into main Sep 2, 2025
11 checks passed
@arafatkatze arafatkatze deleted the arafatkatze/adding-workspace-root-migration-base branch September 2, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants