Skip to content

Commit cd49de0

Browse files
authored
Amazon Q: pattern should only match name without slashes (#4803)
1 parent 0036234 commit cd49de0

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"type" : "bugfix",
3-
"description" : "Amazon Q: Optimized the workspace indexing logic which makes the indexing time now only 5-10% of what it was before."
3+
"description" : "Amazon Q: Optimized the workspace file collection logic which makes the collection time now only 5-10% of what it was before."
44
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/project/ProjectContextProvider.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
146146
val indexStartTime = System.currentTimeMillis()
147147
val url = URL("http://localhost:${encoderServer.port}/indexFiles")
148148
val filesResult = collectFiles()
149+
var duration = (System.currentTimeMillis() - indexStartTime).toDouble()
150+
logger.debug { "project context file collection time: ${duration}ms" }
151+
logger.debug { "list of files collected: ${filesResult.files.joinToString("\n")}" }
149152
val projectRoot = project.guessProjectDir()?.path ?: return false
150153
val payload = IndexRequestPayload(filesResult.files, projectRoot, false)
151154
val payloadJson = mapper.writeValueAsString(payload)
@@ -155,13 +158,13 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
155158
setConnectionProperties(connection)
156159
setConnectionRequest(connection, encrypted)
157160
logger.info { "project context index response code: ${connection.responseCode} for ${project.name}" }
158-
val duration = (System.currentTimeMillis() - indexStartTime).toDouble()
161+
duration = (System.currentTimeMillis() - indexStartTime).toDouble()
159162
val startUrl = getStartUrl(project)
160163
logger.debug { "project context index time: ${duration}ms" }
161164
if (connection.responseCode == 200) {
162165
val usage = getUsage()
163166
TelemetryHelper.recordIndexWorkspace(duration, filesResult.files.size, filesResult.fileSize, true, usage?.memoryUsage, usage?.cpuUsage, startUrl)
164-
logger.debug { "project context index finished for ${project.name}, list of files indexed: ${filesResult.files.joinToString("\n")}" }
167+
logger.debug { "project context index finished for ${project.name}" }
165168
return true
166169
} else {
167170
TelemetryHelper.recordIndexWorkspace(duration, filesResult.files.size, filesResult.fileSize, false, null, null, startUrl)
@@ -263,9 +266,9 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
263266
return currentTotalFileSize.let { totalSize -> totalSize > (maxSize * 1024 * 1024 - currentFileSize) }
264267
}
265268

266-
private fun isBuildOrBin(filePath: String): Boolean {
267-
val regex = Regex("""[/\\](bin|build|node_modules|venv|.venv|env|\.idea|.conda)[/\\]""", RegexOption.IGNORE_CASE)
268-
return regex.find(filePath) != null
269+
private fun isBuildOrBin(fileName: String): Boolean {
270+
val regex = Regex("""bin|build|node_modules|venv|\.venv|env|\.idea|\.conda""", RegexOption.IGNORE_CASE)
271+
return regex.find(fileName) != null
269272
}
270273

271274
private fun collectFiles(): FileCollectionResult {

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
4343
private val ignorePatterns = setOf(
4444
"\\.aws-sam",
4545
"\\.svn",
46-
"\\.hg/",
46+
"\\.hg/?",
4747
"\\.rvm",
48-
"\\.git/",
48+
"\\.git/?",
4949
"\\.gitignore",
5050
"\\.project",
5151
"\\.gem",
52-
"/\\.idea/",
52+
"/\\.idea/?",
5353
"\\.zip$",
5454
"\\.bin$",
5555
"\\.png$",
@@ -62,9 +62,9 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
6262
"/license\\.md$",
6363
"/License\\.md$",
6464
"/LICENSE\\.md$",
65-
"node_modules/",
66-
"build/",
67-
"dist/"
65+
"node_modules/?",
66+
"build/?",
67+
"dist/?"
6868
).map { Regex(it) }
6969

7070
// projectRoot: is the directory where the project is located when selected to open a project.

0 commit comments

Comments
 (0)