in packages/core/src/amazonqTest/chat/controller/controller.ts [1353:1444]
private async sessionCleanUp() {
const session = this.sessionStorage.getSession()
const groupName = session.testGenerationJobGroupName
const filePath = session.generatedFilePath
getLogger().debug('Entering sessionCleanUp function with filePath: %s and groupName: %s', filePath, groupName)
vscode.window.tabGroups.all.flatMap(({ tabs }) =>
tabs.map((tab) => {
if (tab.label === `${path.basename(filePath)} ${amazonQTabSuffix}`) {
const tabClosed = vscode.window.tabGroups.close(tab)
if (!tabClosed) {
getLogger().error('ChatDiff: Unable to close the diff view tab for %s', tab.label)
}
}
})
)
getLogger().debug(
'listOfTestGenerationJobId length: %d, groupName: %s',
session.listOfTestGenerationJobId.length,
groupName
)
if (session.listOfTestGenerationJobId.length && groupName) {
for (const id of session.listOfTestGenerationJobId) {
if (id === session.acceptedJobId) {
TelemetryHelper.instance.sendTestGenerationEvent(
groupName,
id,
session.fileLanguage,
session.numberOfTestsGenerated,
session.numberOfTestsGenerated, // this is number of accepted test cases, now they can only accept all
session.linesOfCodeGenerated,
session.linesOfCodeAccepted,
session.charsOfCodeGenerated,
session.charsOfCodeAccepted
)
} else {
TelemetryHelper.instance.sendTestGenerationEvent(
groupName,
id,
session.fileLanguage,
session.numberOfTestsGenerated,
0,
session.linesOfCodeGenerated,
0,
session.charsOfCodeGenerated,
0
)
}
}
}
session.listOfTestGenerationJobId = []
session.testGenerationJobGroupName = undefined
// session.testGenerationJob = undefined
session.updatedBuildCommands = undefined
session.shortAnswer = undefined
session.testCoveragePercentage = 0
session.conversationState = ConversationState.IDLE
session.sourceFilePath = ''
session.generatedFilePath = ''
session.projectRootPath = ''
session.stopIteration = false
session.fileLanguage = undefined
ChatSessionManager.Instance.setIsInProgress(false)
session.linesOfCodeGenerated = 0
session.linesOfCodeAccepted = 0
session.charsOfCodeGenerated = 0
session.charsOfCodeAccepted = 0
session.acceptedJobId = ''
session.numberOfTestsGenerated = 0
if (session.tabID) {
getLogger().debug('Setting input state with tabID: %s', session.tabID)
this.messenger.sendChatInputEnabled(session.tabID, true)
this.messenger.sendUpdatePlaceholder(session.tabID, 'Enter "/" for quick actions')
}
getLogger().debug(
'Deleting output.log and temp result directory. testGenerationLogsDir: %s',
testGenerationLogsDir
)
const outputLogPath = path.join(testGenerationLogsDir, 'output.log')
if (await fs.existsFile(outputLogPath)) {
await fs.delete(outputLogPath)
}
if (
await fs
.stat(this.tempResultDirPath)
.then(() => true)
.catch(() => false)
) {
await fs.delete(this.tempResultDirPath, { recursive: true })
}
}