Skip to content

Commit 31bd370

Browse files
committed
PR fixes: refactoring, syntax changes
1 parent deadc6d commit 31bd370

File tree

8 files changed

+306
-387
lines changed

8 files changed

+306
-387
lines changed

packages/core/src/amazonqGumby/activation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ export async function activate(context: ExtContext) {
7272
)
7373
}),
7474

75+
Commands.register(
76+
'aws.amazonq.transformationHub.updateContent',
77+
async (button, startTime, historyFileUpdated) => {
78+
await transformationHubViewProvider.updateContent(button, startTime, historyFileUpdated)
79+
}
80+
),
81+
7582
workspaceChangeEvent
7683
)
7784
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,8 @@ export class GumbyController {
191191

192192
private async transformInitiated(message: any) {
193193
// check if any jobs potentially still in progress on backend
194-
const history = readHistoryFile()
195-
let numInProgress = 0
196-
history.forEach((job) => {
197-
if (job.status === 'FAILED') {
198-
numInProgress += 1
199-
}
200-
})
194+
const history = await readHistoryFile()
195+
const numInProgress = history.filter((job) => job.status === 'FAILED').length
201196
this.messenger.sendViewHistoryMessage(message.tabID, numInProgress)
202197
if (transformByQState.isRefreshInProgress()) {
203198
this.messenger.sendMessage(CodeWhispererConstants.refreshInProgressChatMessage, message.tabID, 'ai-prompt')

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,15 +749,14 @@ export async function postTransformationJob() {
749749
})
750750
}
751751

752+
// delete original upload ZIP at very end of transformation
753+
fs.rmSync(transformByQState.getPayloadFilePath(), { force: true })
754+
752755
if (
753756
transformByQState.isSucceeded() ||
754757
transformByQState.isPartiallySucceeded() ||
755758
transformByQState.isCancelled()
756759
) {
757-
if (transformByQState.getPayloadFilePath()) {
758-
// delete original upload ZIP at very end of transformation
759-
fs.rmSync(transformByQState.getPayloadFilePath(), { force: true })
760-
}
761760
// delete the copy of the upload ZIP
762761
fs.rmSync(path.join(transformByQState.getJobHistoryPath(), 'zipped-code.zip'), { force: true })
763762
// delete transformation job metadata file (no longer needed)
@@ -801,7 +800,7 @@ export async function postTransformationJob() {
801800
]
802801

803802
const jobDetails = fields.join('\t') + '\n'
804-
fs.writeFileSync(historyLogFilePath, jobDetails, { flag: 'a' })
803+
fs.writeFileSync(historyLogFilePath, jobDetails, { flag: 'a' }) // 'a' flag used to append to file
805804
await vscode.commands.executeCommand(
806805
'aws.amazonq.transformationHub.updateContent',
807806
'job history',

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ export const viewHistoryMessage = (numInProgress: number) =>
812812
: 'View previous transformations run from the IDE'
813813

814814
export const transformationHistoryTableDescription =
815-
'This table lists the most recent jobs that you have run in the past 30 days. To open the diff patch and summary files, click the provided links. Jobs with a status of FAILED may still be in progress. Resume them within 12 hours of starting the job to get an updated job status and artifacts. Click the refresh icon to do so. The diff patch and summary will appear once they are available.'
815+
'This table lists the most recent jobs that you have run in the past 30 days. To open the diff patch and summary files, click the provided links. To get an updated job status, click the refresh icon. The diff patch and summary will appear once they are available.<br><br>' +
816+
'Jobs with a status of FAILED may still be in progress. Resume these jobs within 12 hours of starting the job to get an updated job status and artifacts.'
816817

817818
export const refreshErrorChatMessage =
818819
"Sorry, I couldn't refresh the job. Please try again or start a new transformation."
@@ -939,3 +940,14 @@ export const codeReviewFindingsSuffix = '_codeReviewFindings'
939940
export const displayFindingsSuffix = '_displayFindings'
940941

941942
export const displayFindingsDetectorName = 'DisplayFindings'
943+
export const findingsSuffix = '_codeReviewFindings'
944+
945+
export interface HistoryObject {
946+
startTime: string
947+
projectName: string
948+
status: string
949+
duration: string
950+
diffPath: string
951+
summaryPath: string
952+
jobId: string
953+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ export class TransformByQState {
11571157
this.buildLog = ''
11581158
this.customBuildCommand = ''
11591159
this.intervalId = undefined
1160+
this.jobHistoryPath = ''
11601161
}
11611162
}
11621163

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

Lines changed: 134 additions & 160 deletions
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,16 @@ export class ProposedTransformationExplorer {
451451
transformByQState.getSummaryFilePath(),
452452
path.join(transformByQState.getJobHistoryPath(), 'summary', 'summary.md')
453453
)
454-
fs.copyFileSync(
455-
path.join(path.dirname(transformByQState.getSummaryFilePath()), 'buildCommandOutput.log'),
456-
path.join(transformByQState.getJobHistoryPath(), 'summary', 'buildCommandOutput.log')
457-
)
454+
if (
455+
fs.existsSync(
456+
path.join(path.dirname(transformByQState.getSummaryFilePath()), 'buildCommandOutput.log')
457+
)
458+
) {
459+
fs.copyFileSync(
460+
path.join(path.dirname(transformByQState.getSummaryFilePath()), 'buildCommandOutput.log'),
461+
path.join(transformByQState.getJobHistoryPath(), 'summary', 'buildCommandOutput.log')
462+
)
463+
}
458464

459465
transformByQState.setResultArchiveFilePath(pathContainingArchive)
460466
await setContext('gumby.isSummaryAvailable', true)

0 commit comments

Comments
 (0)