Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(amazonq): Add support for multi-project workspaces. #5411

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ctidd
Copy link
Contributor

@ctidd ctidd commented Feb 26, 2025

This PR is a proof of concept for multi-project workspace support. Changes are still in progress, and I have performed only superficial local testing at time of writing.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Problem:

Q does not support multi-root workspaces for /dev, /doc, and related features.

Solution:

This change starts by adding a Workspace concept for uploads involving the FeatureDevSessionContext, which detects the IDE workspace's root directory as the common ancestor of the workspace's projects. When choosing what files to upload, files within the workspace root and in the workspace's projects are included to upload. This broadens /dev and /doc to support multi-project workspaces, while retaining intuitive behavior per-project if we imagine a composite workspace in a directory structure that is not strictly hierarchical.

The change itself is straightforward, identifying the common ancestor and basing further work on that root. From here, a few changes unravel:

  1. We add support for .gitignore in subdirectories (across all of Q, including ProjectContext and FeatureDev). Otherwise, we would confuse users with project-level .gitignore configurations, and it makes sense to fully support subdirectory .gitignore configurations rather than treat projects as a special case.
  2. We require that uploaded files are part of a project directory*, and not simply included because they are under a common directory ancestor that contains directories not added to the IDE workspace as projects.
  3. We begin some small (non-functional/non-breaking) refactoring the code within FeatureDev with an aim toward maintainability and future alignment with ProjectContext-based capabilities.

* From my research, JetBrains doesn't really have a concept that a project maps to a directory. For the time being I've implemented an approximation using it's project directory detection heuristic. In theory, JetBrains projects can themselves be composites of multiple modules in arbitrary directories. It would be straightforward to offer first-class alignment with the IDE's strong project/module concepts with small adjustments to isPathInWorkspace and findWorkspaceRoot to go a layer deeper with this same approach. We could enumerate modules and filter out what's not contained under the enumerated modules, which do themselves map to concrete directories. (This would remove use of guessProjectDir.)

Checklist

  • My code follows the code style of this project
  • [TODO] I have added tests to cover my changes
  • [TODO] A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
  • [N/A] I have added metrics for my changes (if required)

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

}
}

suspend fun zipFiles(root: VirtualFile, isAutoBuildFeatureEnabled: Boolean?): File = withContext(getCoroutineBgContext()) {

Check notice

Code scanning / QDJVMC

Class member can have 'private' visibility Note

Function 'zipFiles' could be private
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.util.io.toCanonicalPath
import java.nio.file.Path
import kotlin.io.path.Path

Check warning

Code scanning / QDJVMC

Unused import directive Warning

Unused import directive
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.

1 participant