You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(amazonq): Add support for multi-content-root workspaces. (#5411)
**Problem:**
Q does not support multi-root workspaces for /dev, /doc, and related features.
**Solution:**
This change starts by adding a `Workspace` construct for uploads involving the `FeatureDevSessionContext`, which detects the IDE workspace's root directory as the common ancestor of the workspace's "content roots", to serve as the root of the addressable workspace filesystem layout. Then, when choosing what files to upload, files within this tree which are members of the workspace's content roots are included. This broadens /dev and /doc to support a multi-content-root workspace as a single working tree, while continuing to respect content roots of the workspace and not uploading extraneous content.
The change itself is straightforward, identifying the common ancestor and basing further work on that root. From here, a few changes unravel:
1. **Problem:** We need to add support for `.gitignore` in subdirectories (across 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. **Solution:** I've **removed nearly all custom gitignore parsing** for FeatureDev, offloading the work to the IDE's VCS manager for more native gitignore support.
2. **Problem:** We need to require that uploaded files are part of a project "content root" directory, and not simply included because they are under the common ancestor directory (which would otherwise over-include ancillary directories that are not content roots as members of the IDE workspace). **Solution:** Filter uploaded content based on content roots. This matches the handling already performed by `ProjectContextProvider`, moving incrementally in the direction of common handling of workspaces across features. (**Note:** /test and /review appear to use `guessModuleDir` in their own independent context implementations, and so would continue to have minor symptoms for complex workspaces after these changes. I have not touched these areas.)
3. **Problem:** `ProjectContextProvider` had a dependency on `FeatureDevSessionContext` for its own ignore rules. **Solution:** I've reworked this implementation so that `ProjectContextProvider` and `FeatureDevSessionContext` now depend on a simplified shared primitive, which should be easier to audit and understand than the use-case specific rules that were inside `FeatureDevSessionContext`. However, `FeatureDevSessionContext` is kept in a global location to be consumed by /doc. (Removing this /doc -> /dev coupling is deeper than I was willing to go with these changes as broad as they already are.)
Additional granular changes to behavior:
1. **Problem:** We had inconsistent behaviors when auto build for /dev was enabled vs disabled. Overzealous filtering of file types was applied when it was not enabled. **Solution:** Now, filtering is applied based on what was previously the more permissive behavior of the two. Now, in both cases, only `.gitignore` and a few additional artifact-exclusion filters are applied (e.g. `.git`, `node_modules`, etc).
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/common/session/SessionStateTypes.kt
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/controller/DocController.kt
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/DocSession.kt
+5-7
Original file line number
Diff line number
Diff line change
@@ -107,14 +107,12 @@ class DocSession(val tabID: String, val project: Project) {
107
107
* Triggered by the Insert code follow-up button to apply code changes.
// Taken from https://intellij-support.jetbrains.com/hc/en-us/community/posts/206118439-Refresh-after-external-changes-to-project-structure-and-sources
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqDoc/session/DocSessionContext.kt
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/FeatureDevExceptions.kt
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/CodeGenerationState.kt
+1-1
Original file line number
Diff line number
Diff line change
@@ -96,7 +96,7 @@ class CodeGenerationState(
96
96
var insertedCharacters =0
97
97
codeGenerationResult.newFiles.forEach { file ->
98
98
// FIXME: Ideally, the before content should be read from the uploaded context instead of from disk, to avoid drift
99
-
val before = config.repoContext.selectedSourceFolder
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/PrepareCodeGenerationState.kt
+1-1
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ class PrepareCodeGenerationState(
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/Session.kt
// Taken from https://intellij-support.jetbrains.com/hc/en-us/community/posts/206118439-Refresh-after-external-changes-to-project-structure-and-sources
Copy file name to clipboardexpand all lines: plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/session/SessionStateTypes.kt
0 commit comments