Skip to content

Commit 69cbe54

Browse files
Merge master into feature/inline-rollback
2 parents 95c4178 + c20b211 commit 69cbe54

File tree

11 files changed

+158
-34
lines changed

11 files changed

+158
-34
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Q CodeTransformation: add more job metadata to history table"
4+
}

packages/amazonq/package.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,17 +1470,6 @@
14701470
},
14711471
"completionEvents": []
14721472
},
1473-
{
1474-
"id": "aws.amazonq.walkthrough.securityScan",
1475-
"title": "Check for security vulnerabilities",
1476-
"description": "Amazon Q scans your code to identify security vulnerabilities and suggests fixes.\n\nStart a scan from the status bar menu.\n\n[Scan your current project](command:_aws.amazonq.walkthrough.securityScanExample)\n\nIdentifies vulnerabilities in Python, Typescript, Ruby, AWS CDK, and [more](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/q-language-ide-support.html#security-scans-language-support)",
1477-
"media": {
1478-
"markdown": "./resources/walkthrough/amazonq/scans.md"
1479-
},
1480-
"completionEvents": [
1481-
"onCommand:_aws.amazonq.walkthrough.securityScanExample"
1482-
]
1483-
},
14841473
{
14851474
"id": "aws.amazonq.walkthrough.settings",
14861475
"title": "Access actions and options",

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,11 @@ export class GumbyController {
403403
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
404404
break
405405
case ButtonActions.STOP_TRANSFORMATION_JOB:
406-
await stopTransformByQ(transformByQState.getJobId())
407-
await postTransformationJob()
408-
await cleanupTransformationJob()
406+
if (transformByQState.isRunning() || transformByQState.isRefreshInProgress()) {
407+
await stopTransformByQ(transformByQState.getJobId())
408+
await postTransformationJob()
409+
await cleanupTransformationJob()
410+
}
409411
break
410412
case ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW:
411413
this.resetTransformationChatFlow()

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,22 @@ export class Messenger {
400400
}
401401

402402
public sendJobRefreshInProgressMessage(tabID: string, jobId: string) {
403-
this.dispatcher.sendAsyncEventProgress(
404-
new AsyncEventProgressMessage(tabID, {
405-
inProgress: true,
406-
message: CodeWhispererConstants.refreshingJobChatMessage(jobId),
407-
})
403+
const buttons: ChatItemButton[] = []
404+
buttons.push({
405+
keepCardAfterClick: true,
406+
text: CodeWhispererConstants.stopTransformationButtonText,
407+
id: ButtonActions.STOP_TRANSFORMATION_JOB,
408+
disabled: false,
409+
})
410+
this.dispatcher.sendChatMessage(
411+
new ChatMessage(
412+
{
413+
message: CodeWhispererConstants.refreshingJobChatMessage(jobId),
414+
messageType: 'ai-prompt',
415+
buttons: buttons,
416+
},
417+
tabID
418+
)
408419
)
409420
}
410421

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,12 @@ export async function postTransformationJob() {
769769
latest.status,
770770
latest.duration,
771771
transformByQState.getJobId(),
772-
transformByQState.getJobHistoryPath()
772+
transformByQState.getJobHistoryPath(),
773+
latest.transformationType,
774+
latest.sourceJDKVersion,
775+
latest.targetJDKVersion,
776+
latest.customDependencyVersionsFilePath,
777+
latest.customBuildCommand
773778
)
774779
}
775780
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,17 @@ export const jobPlanProgress: {
688688
}
689689

690690
export let sessionJobHistory: {
691-
[jobId: string]: { startTime: string; projectName: string; status: string; duration: string }
691+
[jobId: string]: {
692+
startTime: string
693+
projectName: string
694+
status: string
695+
duration: string
696+
transformationType: string
697+
sourceJDKVersion: string
698+
targetJDKVersion: string
699+
customDependencyVersionsFilePath: string
700+
customBuildCommand: string
701+
}
692702
} = {}
693703

694704
export class TransformByQState {

packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,29 @@ export function throwIfCancelled() {
6868
}
6969

7070
export function updateJobHistory() {
71-
if (transformByQState.getJobId() !== '') {
71+
if (transformByQState.getJobId() !== '' && transformByQState.getSourceJDKVersion() !== undefined) {
7272
sessionJobHistory[transformByQState.getJobId()] = {
7373
startTime: transformByQState.getStartTime(),
7474
projectName: transformByQState.getProjectName(),
7575
status: transformByQState.getPolledJobStatus(),
7676
duration: convertToTimeString(calculateTotalLatency(CodeTransformTelemetryState.instance.getStartTime())),
77+
transformationType: transformByQState.getTransformationType() ?? 'N/A',
78+
sourceJDKVersion:
79+
transformByQState.getTransformationType() === TransformationType.LANGUAGE_UPGRADE
80+
? (transformByQState.getSourceJDKVersion() ?? 'N/A')
81+
: 'N/A',
82+
targetJDKVersion:
83+
transformByQState.getTransformationType() === TransformationType.LANGUAGE_UPGRADE
84+
? (transformByQState.getTargetJDKVersion() ?? 'N/A')
85+
: 'N/A',
86+
customDependencyVersionsFilePath:
87+
transformByQState.getTransformationType() === TransformationType.LANGUAGE_UPGRADE
88+
? transformByQState.getCustomDependencyVersionFilePath() || 'N/A'
89+
: 'N/A',
90+
customBuildCommand:
91+
transformByQState.getTransformationType() === TransformationType.LANGUAGE_UPGRADE
92+
? transformByQState.getCustomBuildCommand() || 'N/A'
93+
: 'N/A',
7794
}
7895
}
7996
return sessionJobHistory

packages/core/src/codewhisperer/service/transformByQ/transformationHistoryHandler.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export interface HistoryObject {
2626
diffPath: string
2727
summaryPath: string
2828
jobId: string
29+
transformationType: string
30+
sourceJDKVersion: string
31+
targetJDKVersion: string
32+
customDependencyVersionFilePath: string
33+
customBuildCommand: string
2934
}
3035

3136
export interface JobMetadata {
@@ -71,6 +76,11 @@ export async function readHistoryFile(): Promise<HistoryObject[]> {
7176
diffPath: jobInfo[4],
7277
summaryPath: jobInfo[5],
7378
jobId: jobInfo[6],
79+
transformationType: jobInfo[7],
80+
sourceJDKVersion: jobInfo[8],
81+
targetJDKVersion: jobInfo[9],
82+
customDependencyVersionFilePath: jobInfo[10],
83+
customBuildCommand: jobInfo[11],
7484
})
7585
}
7686
}
@@ -125,14 +135,22 @@ export async function writeToHistoryFile(
125135
status: string,
126136
duration: string,
127137
jobId: string,
128-
jobHistoryPath: string
138+
jobHistoryPath: string,
139+
transformationType: string,
140+
sourceJDKVersion: string,
141+
targetJDKVersion: string,
142+
customDependencyVersionFilePath: string,
143+
customBuildCommand: string
129144
) {
130145
const historyLogFilePath = path.join(os.homedir(), '.aws', 'transform', 'transformation_history.tsv')
131146
// create transform folder if necessary
132147
if (!(await fs.existsFile(historyLogFilePath))) {
133148
await fs.mkdir(path.dirname(historyLogFilePath))
134149
// create headers of new transformation history file
135-
await fs.writeFile(historyLogFilePath, 'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\n')
150+
await fs.writeFile(
151+
historyLogFilePath,
152+
'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\ttransformation_type\tsource_jdk_version\ttarget_jdk_version\tcustom_dependency_version_file_path\tcustom_build_command\n'
153+
)
136154
}
137155
const artifactsExist = status === 'COMPLETED' || status === 'PARTIALLY_COMPLETED'
138156
const fields = [
@@ -143,6 +161,11 @@ export async function writeToHistoryFile(
143161
artifactsExist ? path.join(jobHistoryPath, 'diff.patch') : '',
144162
artifactsExist ? path.join(jobHistoryPath, 'summary', 'summary.md') : '',
145163
jobId,
164+
transformationType,
165+
sourceJDKVersion,
166+
targetJDKVersion,
167+
customDependencyVersionFilePath,
168+
customBuildCommand,
146169
]
147170

148171
const jobDetails = fields.join('\t') + '\n'
@@ -318,7 +341,8 @@ async function updateHistoryFile(status: string, duration: string, jobHistoryPat
318341
for (const job of jobs) {
319342
if (job) {
320343
const jobInfo = job.split('\t')
321-
// startTime: jobInfo[0], projectName: jobInfo[1], status: jobInfo[2], duration: jobInfo[3], diffPath: jobInfo[4], summaryPath: jobInfo[5], jobId: jobInfo[6]
344+
// 0: startTime, 1: projectName, 2: status, 3: duration, 4: diffPath, 5: summaryPath, 6: jobId
345+
// 7: transformationType, 8: sourceJDKVersion, 9: targetJDKVersion, 10: customDependencyVersionFilePath, 11: customBuildCommand
322346
if (jobInfo[6] === jobId) {
323347
// update any values if applicable
324348
jobInfo[2] = status
@@ -341,7 +365,10 @@ async function updateHistoryFile(status: string, duration: string, jobHistoryPat
341365
}
342366

343367
// rewrite file
344-
await fs.writeFile(historyLogFilePath, 'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\n')
368+
await fs.writeFile(
369+
historyLogFilePath,
370+
'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\ttransformation_type\tsource_jdk_version\ttarget_jdk_version\tcustom_dependency_version_file_path\tcustom_build_command\n'
371+
)
345372
const tsvContent = history.map((row) => row.join('\t')).join('\n') + '\n'
346373
await fs.appendFile(historyLogFilePath, tsvContent)
347374

packages/core/src/codewhisperer/service/transformByQ/transformationHubViewProvider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
120120
diffPath: '',
121121
summaryPath: '',
122122
jobId: transformByQState.getJobId(),
123+
transformationType: current.transformationType,
124+
sourceJDKVersion: current.sourceJDKVersion,
125+
targetJDKVersion: current.targetJDKVersion,
126+
customDependencyVersionFilePath: current.customDependencyVersionsFilePath,
127+
customBuildCommand: current.customBuildCommand,
123128
})
124129
}
125130
return `<!DOCTYPE html>
@@ -208,6 +213,11 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
208213
<th>Summary File</th>
209214
<th>Job Id</th>
210215
<th>Refresh Job</th>
216+
<th>Transformation Type</th>
217+
<th>Source JDK Version</th>
218+
<th>Target JDK Version</th>
219+
<th>Custom Dependency Version File Path</th>
220+
<th>Custom Build Command</th>
211221
</tr>
212222
</thead>
213223
<tbody>
@@ -242,6 +252,11 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
242252
243253
</button>
244254
</td>
255+
<td>${job.transformationType ?? ''}</td>
256+
<td>${job.sourceJDKVersion ?? ''}</td>
257+
<td>${job.targetJDKVersion ?? ''}</td>
258+
<td>${job.customDependencyVersionFilePath ?? ''}</td>
259+
<td>${job.customBuildCommand ? `mvn ${job.customBuildCommand}` : ''}</td>
245260
</tr>
246261
`
247262
)

packages/core/src/test/amazonqGumby/transformationJobHistory.test.ts

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,51 @@ describe('Transformation History Handler', function () {
9898

9999
it('Creates history file with headers when it does not exist', async function () {
100100
sinon.stub(fs, 'existsFile').resolves(false)
101-
await writeToHistoryFile('01/01/25, 10:00 AM', 'test-project', 'COMPLETED', '5 min', 'job-123', '/job/path')
101+
await writeToHistoryFile(
102+
'01/01/25, 10:00 AM',
103+
'test-project',
104+
'COMPLETED',
105+
'5 min',
106+
'job-123',
107+
'/job/path',
108+
'LANGUAGE_UPGRADE',
109+
'JDK8',
110+
'JDK17',
111+
'/path/here',
112+
'clean test-compile'
113+
)
102114

103115
const expectedPath = path.join(os.homedir(), '.aws', 'transform', 'transformation_history.tsv')
104116
const fileContent = writtenFiles.get(expectedPath)
105117

106118
assert(fileContent)
107-
assert(fileContent.includes('date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\n'))
108119
assert(
109120
fileContent.includes(
110-
`01/01/25, 10:00 AM\ttest-project\tCOMPLETED\t5 min\t${path.join('/job/path', 'diff.patch')}\t${path.join('/job/path', 'summary', 'summary.md')}\tjob-123\n`
121+
'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\ttransformation_type\tsource_jdk_version\ttarget_jdk_version\tcustom_dependency_version_file_path\tcustom_build_command\n'
122+
)
123+
)
124+
assert(
125+
fileContent.includes(
126+
`01/01/25, 10:00 AM\ttest-project\tCOMPLETED\t5 min\t${path.join('/job/path', 'diff.patch')}\t${path.join('/job/path', 'summary', 'summary.md')}\tjob-123\tLANGUAGE_UPGRADE\tJDK8\tJDK17\t/path/here\tclean test-compile\n`
111127
)
112128
)
113129
})
114130

115131
it('Excludes artifact paths for failed jobs', async function () {
116132
sinon.stub(fs, 'existsFile').resolves(false)
117-
await writeToHistoryFile('01/01/25, 10:00 AM', 'test-project', 'FAILED', '5 min', 'job-123', '/job/path')
133+
await writeToHistoryFile(
134+
'01/01/25, 10:00 AM',
135+
'test-project',
136+
'FAILED',
137+
'5 min',
138+
'job-123',
139+
'/job/path',
140+
'LANGUAGE_UPGRADE',
141+
'JDK8',
142+
'JDK17',
143+
'/path/here',
144+
'clean test-compile'
145+
)
118146

119147
const expectedPath = path.join(os.homedir(), '.aws', 'transform', 'transformation_history.tsv')
120148
const fileContent = writtenFiles.get(expectedPath)
@@ -130,7 +158,7 @@ describe('Transformation History Handler', function () {
130158
it('Appends new job to existing history file', async function () {
131159
const existingContent =
132160
'date\tproject_name\tstatus\tduration\tdiff_patch\tsummary\tjob_id\n' +
133-
'12/31/24, 09:00 AM\told-project\tCOMPLETED\t3 min\t/old/diff.patch\t/old/summary.md\told-job-456\n'
161+
'12/31/24, 09:00 AM\told-project\tCOMPLETED\t3 min\t/old/diff.patch\t/old/summary.md\told-job-456\t/old/path\tLANGUAGE_UPGRADE\tJDK8\tJDK17\t/old/path2\tclean test-compile\n'
134162

135163
writtenFiles.set(
136164
path.join(os.homedir(), '.aws', 'transform', 'transformation_history.tsv'),
@@ -139,14 +167,28 @@ describe('Transformation History Handler', function () {
139167

140168
sinon.stub(fs, 'existsFile').resolves(true)
141169

142-
await writeToHistoryFile('01/01/25, 10:00 AM', 'new-project', 'FAILED', '2 min', 'new-job-789', '/new/path')
170+
await writeToHistoryFile(
171+
'01/01/25, 10:00 AM',
172+
'new-project',
173+
'FAILED',
174+
'2 min',
175+
'new-job-789',
176+
'/new/path',
177+
'LANGUAGE_UPGRADE',
178+
'JDK8',
179+
'JDK17',
180+
'/path/here',
181+
'clean test-compile'
182+
)
143183

144184
const expectedPath = path.join(os.homedir(), '.aws', 'transform', 'transformation_history.tsv')
145185
const fileContent = writtenFiles.get(expectedPath)
146186

147187
// Verify old data is preserved
148188
assert(
149-
fileContent?.includes('old-project\tCOMPLETED\t3 min\t/old/diff.patch\t/old/summary.md\told-job-456')
189+
fileContent?.includes(
190+
'old-project\tCOMPLETED\t3 min\t/old/diff.patch\t/old/summary.md\told-job-456\t/old/path\tLANGUAGE_UPGRADE\tJDK8\tJDK17\t/old/path2\tclean test-compile\n'
191+
)
150192
)
151193

152194
// Verify new data is added

0 commit comments

Comments
 (0)