Skip to content

Commit 251d1f6

Browse files
authored
Build Exec ShortAnswer Refactoring (#10)
* refactor build exec shortAnswer * remove shortAnswer from model
1 parent 610dc77 commit 251d1f6

File tree

5 files changed

+8
-33
lines changed

5 files changed

+8
-33
lines changed

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,6 @@ export class TestController {
11151115
}
11161116

11171117
private async checkForInstallationDependencies(data: any) {
1118-
// const session: Session = this.sessionStorage.getSession()
1119-
// const listOfInstallationDependencies = session.testGenerationJob?.shortAnswer?.installationDependencies || []
1120-
// MOCK: As there is no installation dependencies in shortAnswer
11211118
const listOfInstallationDependencies = ['']
11221119
const installationDependencies = listOfInstallationDependencies.join('\n')
11231120

@@ -1481,7 +1478,6 @@ export class TestController {
14811478
session.testGenerationJobGroupName = undefined
14821479
// session.testGenerationJob = undefined
14831480
session.updatedBuildCommands = undefined
1484-
session.shortAnswer = undefined
14851481
session.testCoveragePercentage = 0
14861482
session.conversationState = ConversationState.IDLE
14871483
session.sourceFilePath = ''
@@ -1526,8 +1522,8 @@ export class TestController {
15261522
return [...session.updatedBuildCommands]
15271523
}
15281524

1529-
if (session.shortAnswer && session.shortAnswer?.buildCommand) {
1530-
return [session.shortAnswer.buildCommand]
1525+
if (session.packageInfo && session.packageInfo?.buildCommand) {
1526+
return [session.packageInfo.buildCommand]
15311527
}
15321528
// TODO: Add a generic command here for external launch according to the build system.
15331529
return ['brazil-build release']

packages/core/src/amazonqTest/chat/session/session.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { ShortAnswer, Reference } from '../../../codewhisperer/models/model'
7-
import { TargetFileInfo, TestGenerationJob } from '../../../codewhisperer/client/codewhispereruserclient'
6+
import { Reference } from '../../../codewhisperer/models/model'
7+
import { PackageInfo, TargetFileInfo, TestGenerationJob } from '../../../codewhisperer/client/codewhispereruserclient'
88

99
export enum ConversationState {
1010
IDLE,
@@ -37,13 +37,13 @@ export class Session {
3737
// Start Test generation
3838
public isSupportedLanguage: boolean = false
3939
public conversationState: ConversationState = ConversationState.IDLE
40-
public shortAnswer: ShortAnswer | undefined
4140
public sourceFilePath: string = ''
4241
public generatedFilePath: string = ''
4342
public projectRootPath: string = ''
4443
public fileLanguage: string | undefined = 'plaintext'
4544
public stopIteration: boolean = false
4645
public targetFileInfo: TargetFileInfo | undefined
46+
public packageInfo: PackageInfo | undefined
4747
public jobSummary: string = ''
4848

4949
// Telemetry

packages/core/src/codewhisperer/commands/startTestGeneration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export async function startTestGenerationProcess(
5454
const projectPath = zipUtil.getProjectPath(filePath) ?? ''
5555
const relativeTargetPath = path.relative(projectPath, filePath)
5656
session.listOfTestGenerationJobId = []
57-
session.shortAnswer = undefined
5857
session.sourceFilePath = relativeTargetPath
5958
session.projectRootPath = projectPath
6059
session.listOfTestGenerationJobId = []

packages/core/src/codewhisperer/models/model.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,18 +1174,3 @@ export interface Reference {
11741174
end: number
11751175
}
11761176
}
1177-
1178-
// TODO: remove ShortAnswer because it will be deprecated
1179-
export interface ShortAnswer {
1180-
testFilePath: string
1181-
buildCommand: string
1182-
planSummary: string
1183-
sourceFilePath?: string
1184-
testFramework?: string
1185-
executionCommands?: string[]
1186-
testCoverage?: number
1187-
stopIteration?: string
1188-
errorMessage?: string
1189-
codeReferences?: References
1190-
numberOfTestMethods?: number
1191-
}

packages/core/src/codewhisperer/service/testGenHandler.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
TestGenTimedOutError,
2323
} from '../../amazonqTest/error'
2424
import { getMd5, uploadArtifactToS3 } from './securityScanHandler'
25-
import { ShortAnswer, testGenState, Reference } from '../models/model'
25+
import { testGenState, Reference } from '../models/model'
2626
import { ChatSessionManager } from '../../amazonqTest/chat/storages/chatSession'
2727
import { createCodeWhispererChatStreamingClient } from '../../shared/clients/codewhispererChatClient'
2828
import { downloadExportResultArchive } from '../../shared/utilities/download'
@@ -159,12 +159,6 @@ export async function pollTestJobStatus(
159159
})
160160
}
161161

162-
const shortAnswerString = resp.testGenerationJob?.shortAnswer
163-
if (shortAnswerString) {
164-
const parsedShortAnswer = JSON.parse(shortAnswerString)
165-
const shortAnswer: ShortAnswer = JSON.parse(parsedShortAnswer)
166-
}
167-
168162
const jobSummary = resp.testGenerationJob?.jobSummary ?? ''
169163
const jobSummaryNoBackticks = jobSummary.replace(/^`+|`+$/g, '')
170164
ChatSessionManager.Instance.getSession().jobSummary = jobSummaryNoBackticks
@@ -173,7 +167,8 @@ export async function pollTestJobStatus(
173167
const targetFileInfo = packageInfo?.targetFileInfoList?.[0]
174168

175169
if (packageInfo) {
176-
// TODO: will need some fields from packageInfo such as buildCommand, packagePlan, packageSummary
170+
// TODO: will use some fields from packageInfo in the future
171+
ChatSessionManager.Instance.getSession().packageInfo = packageInfo
177172
}
178173
if (targetFileInfo) {
179174
if (targetFileInfo.numberOfTestMethods) {

0 commit comments

Comments
 (0)