-
Notifications
You must be signed in to change notification settings - Fork 243
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 complex workspaces for /dev and /doc. #5411
Conversation
a7c114d
to
78d68d6
Compare
...ity/src/software/aws/toolkits/jetbrains/services/amazonq/project/FeatureDevSessionContext.kt
Fixed
Show fixed
Hide fixed
...etbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/Workspace.kt
Fixed
Show fixed
Hide fixed
185a18e
to
342b5a4
Compare
138964f
to
8854f88
Compare
import software.aws.toolkits.jetbrains.services.amazonq.QConstants.MAX_FILE_SIZE_BYTES | ||
import software.aws.toolkits.jetbrains.utils.isDevFile | ||
import software.aws.toolkits.resources.AwsCoreBundle | ||
import software.aws.toolkits.telemetry.AmazonqTelemetry |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
import software.aws.toolkits.jetbrains.services.amazonq.QConstants.MAX_FILE_SIZE_BYTES | ||
import software.aws.toolkits.jetbrains.utils.isDevFile | ||
import software.aws.toolkits.resources.AwsCoreBundle | ||
import software.aws.toolkits.telemetry.AmazonqTelemetry |
Check warning
Code scanning / QDJVMC
Usage of redundant or deprecated syntax or deprecated symbols Warning
43f93d6
to
494314e
Compare
|
||
private suspend fun createTemporaryZipFileAsync(block: suspend (FileSystem) -> Unit): Path = withContext(getCoroutineBgContext()) { | ||
// Don't use Files.createTempFile since the file must not be created for ZipFS to work | ||
val tempFilePath: Path = Paths.get(FileUtils.getTempDirectory().absolutePath, "${UUID.randomUUID()}.zip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to create specific folder in the temp location and store zip there.
Also how is the zip file deleted after upload ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the existing impl, so I'm confident in how it works already. It just looks new here because the file is moved.
@@ -967,7 +966,7 @@ class DocController( | |||
message = message("amazonqDoc.prompt.choose_folder_to_continue") | |||
) | |||
|
|||
val selectedFolder = selectFolder(context.project, currentSourceFolder) | |||
val selectedFolder = selectFolder(context.project, workspaceRoot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it be session.context.selectionRoot instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a small change in behavior, which handles a niche case slightly more in line with a workspace-oriented view. This behavior changes when a user selects a folder, and then triggers folder selection again.
- Before: The file tree is opened on the current source folder to select new source folder.
- Now: The file tree is opened on the workspace root to select a new source folder. (Like it was for the initial selection.)
This is a more workspace-oriented behavior (i.e. "select what you want") instead of nudging the user toward a folder inside their selected working folder, when the user selects a different folder multiple times.
...etbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/Workspace.kt
Outdated
Show resolved
Hide resolved
bd75d40
to
24a65dc
Compare
ffbc9d8
to
ce0e40c
Compare
import kotlin.io.path.deleteExisting | ||
import kotlin.io.path.exists | ||
|
||
class WorkspaceTest : LightPlatformTestCase() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally we've been trying to move to junit5 but ok
|
||
// This function checks for existence of `devfile.yaml` in customer's repository, currently only `devfile.yaml` is supported for this feature. | ||
fun checkForDevFile(): Boolean { | ||
val devFile = File(addressableRoot.toString(), "devfile.yaml") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devfile.yml
is also valid according to spec
val filesToIncludeFlow = channelFlow { | ||
// chunk with some reasonable number because we don't actually need a new job for each file | ||
files.chunked(50).forEach { chunk -> | ||
launch { | ||
for (file in chunk) { | ||
send(file) | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see that this is the existing impl, but the flow seems superfluous for what is being accomplished here
val additionalGlobalIgnoreRulesForStrictSources = | ||
additionalGlobalIgnoreRules + | ||
listOf( | ||
// FIXME: It is incredibly brittle that this source of truth is a "telemetry" component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
This provides multi-content-root workspace support for /dev and /doc.
Types of changes
Description
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 theFeatureDevSessionContext
, 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:
.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.ProjectContextProvider
, moving incrementally in the direction of common handling of workspaces across features. (Note: /test and /review appear to useguessModuleDir
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.)ProjectContextProvider
had a dependency onFeatureDevSessionContext
for its own ignore rules. Solution: I've reworked this implementation so thatProjectContextProvider
andFeatureDevSessionContext
now depend on a simplified shared primitive, which should be easier to audit and understand than the use-case specific rules that were insideFeatureDevSessionContext
. 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:
.gitignore
and a few additional artifact-exclusion filters are applied (e.g..git
,node_modules
, etc).Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.