Skip to content

Commit 58667cb

Browse files
Merge master into feature/cwltail
2 parents 9b67b72 + 56228d7 commit 58667cb

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q /dev: define first folder as a root path for LLM-created files when using workspaces"
4+
}

packages/core/src/amazonqFeatureDev/session/sessionState.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ function registerNewFiles(
6868
fs.registerProvider(uri, new VirtualMemoryFile(contents))
6969
const prefix =
7070
workspaceFolderPrefixes === undefined ? '' : zipFilePath.substring(0, zipFilePath.indexOf(path.sep))
71-
const folder = workspaceFolderPrefixes === undefined ? workspaceFolders[0] : workspaceFolderPrefixes[prefix]
71+
const folder =
72+
workspaceFolderPrefixes === undefined
73+
? workspaceFolders[0]
74+
: workspaceFolderPrefixes[prefix] ??
75+
workspaceFolderPrefixes[
76+
Object.values(workspaceFolderPrefixes).find((val) => val.index === 0)?.name ?? ''
77+
]
7278
if (folder === undefined) {
7379
getLogger().error(`No workspace folder found for file: ${zipFilePath} and prefix: ${prefix}`)
7480
continue
@@ -78,7 +84,9 @@ function registerNewFiles(
7884
fileContent,
7985
virtualMemoryUri: uri,
8086
workspaceFolder: folder,
81-
relativePath: zipFilePath.substring(workspaceFolderPrefixes === undefined ? 0 : prefix.length + 1),
87+
relativePath: zipFilePath.substring(
88+
workspaceFolderPrefixes === undefined ? 0 : prefix.length > 0 ? prefix.length + 1 : 0
89+
),
8290
rejected: false,
8391
})
8492
}

packages/core/src/amazonqFeatureDev/util/files.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,18 @@ export async function prepareRepoData(
6363
const iterator = ignoredExtensionMap.entries()
6464

6565
for (let i = 0; i < ignoredExtensionMap.size; i++) {
66-
const [key, value] = iterator.next().value
67-
await amznTelemetry.amazonq_bundleExtensionIgnored.run(async (bundleSpan) => {
68-
const event = {
69-
filenameExt: key,
70-
count: value,
71-
}
66+
const iteratorValue = iterator.next().value
67+
if (iteratorValue) {
68+
const [key, value] = iteratorValue
69+
await amznTelemetry.amazonq_bundleExtensionIgnored.run(async (bundleSpan) => {
70+
const event = {
71+
filenameExt: key,
72+
count: value,
73+
}
7274

73-
bundleSpan.record(event)
74-
})
75+
bundleSpan.record(event)
76+
})
77+
}
7578
}
7679

7780
telemetry.setRepositorySize(totalBytes)
@@ -117,7 +120,9 @@ export function getPathsFromZipFilePath(
117120
}
118121
// otherwise the first part of the zipPath is the prefix
119122
const prefix = zipFilePath.substring(0, zipFilePath.indexOf(path.sep))
120-
const workspaceFolder = workspacesByPrefix[prefix]
123+
const workspaceFolder =
124+
workspacesByPrefix[prefix] ??
125+
(workspacesByPrefix[Object.values(workspacesByPrefix).find((val) => val.index === 0)?.name ?? ''] || undefined)
121126
if (workspaceFolder === undefined) {
122127
throw new ToolkitError(`Could not find workspace folder for prefix ${prefix}`)
123128
}

0 commit comments

Comments
 (0)