Skip to content

Commit

Permalink
Merge master into feature/amazonqLSP
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-toolkit-automation authored Mar 11, 2025
2 parents b19d52b + 27a698f commit e72fece
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/filterDuplicates.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ async function run() {
console.log('%s duplicates found', filteredDuplicates.length)
if (filteredDuplicates.length > 0) {
console.log(formatDuplicates(filteredDuplicates, commitHash, repoName))
console.log(
'* Hint: if these duplicates appear unrelated to the changes, rebase onto or merge in the latest target branch.'
)
process.exit(1)
}
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/"
},
"devDependencies": {
"@aws-toolkits/telemetry": "^1.0.305",
"@aws-toolkits/telemetry": "^1.0.307",
"@playwright/browser-chromium": "^1.43.1",
"@stylistic/eslint-plugin": "^2.11.0",
"@types/he": "^1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Amazon Q chat: Create a new prompt form does not autofocus or submit with Enter press"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "/review: Zip files are created with the wrong file path for file scans in multifolder workspaces."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "/review: show code diff for fix preview"
}
1 change: 1 addition & 0 deletions packages/amazonq/test/e2e/amazonq/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { loginToIdC } from './utils/setup'
import { webviewConstants, webviewTabConstants } from 'aws-core-vscode/amazonq'

describe('Amazon Q Chat', function () {
this.retries(3)
let framework: qTestingFramework
let tab: Messenger
let store: MynahUIDataModel
Expand Down
4 changes: 3 additions & 1 deletion packages/amazonq/test/e2e/inline/inline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import { Commands, globals, sleep, waitUntil, collectionUtil } from 'aws-core-vs
import { loginToIdC } from '../amazonq/utils/setup'

describe('Amazon Q Inline', async function () {
let tempFolder: string
const retries = 3
this.retries(retries)

let tempFolder: string
const waitOptions = {
interval: 500,
timeout: 10000,
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/amazonq/webview/ui/apps/cwChatConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,29 @@ export class Connector extends BaseConnector {
)
}

onFormTextualItemKeyPress = (
tabId: string,
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
eventId?: string
) => {
if (itemId === 'prompt-name' && event.key === 'Enter') {
event.preventDefault()
this.sendMessageToExtension({
command: 'form-action-click',
action: {
id: 'submit-create-prompt',
formItemValues: formData,
},
tabType: this.getTabType(),
tabID: tabId,
})
return true
}
return false
}

handleMessageReceive = async (messageData: any): Promise<void> => {
if (messageData.type === 'chatMessage') {
await this.processChatMessage(messageData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export class Connector extends BaseConnector {
body: messageData.message,
canBeVoted: false,
informationCard: messageData.informationCard,
buttons: messageData.buttons ?? [],
}
this.onChatAnswerReceived(messageData.tabID, answer, messageData)
}
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/amazonq/webview/ui/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,20 @@ export class Connector {
}
}

onFormTextualItemKeyPress = (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
switch (this.tabsStorage.getTab(tabId)?.type) {
case 'cwc':
return this.cwChatConnector.onFormTextualItemKeyPress(tabId, event, formData, itemId, eventId)
}
return false
}

onCustomFormAction = (
tabId: string,
messageId: string | undefined,
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,15 @@ export const createMynahUI = (
onCustomFormAction: (tabId, action, eventId) => {
connector.onCustomFormAction(tabId, undefined, action, eventId)
},
onFormTextualItemKeyPress: (
event: KeyboardEvent,
formData: Record<string, string>,
itemId: string,
tabId: string,
eventId?: string
) => {
return connector.onFormTextualItemKeyPress(event, formData, itemId, tabId, eventId)
},
onChatPromptProgressActionButtonClicked: (tabID, action) => {
connector.onCustomFormAction(tabID, undefined, action)
},
Expand Down
87 changes: 77 additions & 10 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import MessengerUtils, { ButtonActions } from './messenger/messengerUtils'
import { getTelemetryReasonDesc, isAwsError } from '../../../shared/errors'
import { ChatItemType } from '../../../amazonq/commons/model'
import { ProgressField } from '@aws/mynah-ui'
import { ChatItemButton, MynahIcons, ProgressField } from '@aws/mynah-ui'
import { FollowUpTypes } from '../../../amazonq/commons/types'
import {
cancelBuild,
Expand Down Expand Up @@ -63,6 +63,9 @@ import {
} from '../../../codewhisperer/models/constants'
import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker'
import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider'
import { submitFeedback } from '../../../feedback/vue/submitFeedback'
import { placeholder } from '../../../shared/vscode/commands2'
import { Auth } from '../../../auth/auth'

export interface TestChatControllerEventEmitters {
readonly tabOpened: vscode.EventEmitter<any>
Expand Down Expand Up @@ -286,7 +289,7 @@ export class TestController {
}
TelemetryHelper.instance.sendTestGenerationToolkitEvent(
session,
true,
session.isSupportedLanguage,
true,
isCancel ? 'Cancelled' : 'Failed',
session.startTestGenerationRequestId,
Expand All @@ -295,14 +298,34 @@ export class TestController {
session.isCodeBlockSelected,
session.artifactsUploadDuration,
session.srcPayloadSize,
session.srcZipFileSize
session.srcZipFileSize,
session.charsOfCodeAccepted,
session.numberOfTestsGenerated,
session.linesOfCodeGenerated,
session.charsOfCodeGenerated,
session.numberOfTestsGenerated,
session.linesOfCodeGenerated,
undefined,
isCancel ? 'CANCELLED' : 'FAILED'
)
if (session.stopIteration) {
// Error from Science
this.messenger.sendMessage(data.error.uiMessage.replaceAll('```', ''), data.tabID, 'answer')
this.messenger.sendMessage(
data.error.uiMessage.replaceAll('```', ''),
data.tabID,
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
} else {
isCancel
? this.messenger.sendMessage(data.error.uiMessage, data.tabID, 'answer')
? this.messenger.sendMessage(
data.error.uiMessage,
data.tabID,
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
: this.sendErrorMessage(data)
}
await this.sessionCleanUp()
Expand All @@ -322,7 +345,9 @@ export class TestController {
return this.messenger.sendMessage(
i18n('AWS.amazonq.featureDev.error.monthlyLimitReached'),
tabID,
'answer'
'answer',
'testGenErrorMessage',
this.getFeedbackButtons()
)
}
if (error.message.includes('Too many requests')) {
Expand Down Expand Up @@ -354,6 +379,7 @@ export class TestController {
// This function handles actions if user clicked on any Button one of these cases will be executed
private async handleFormActionClicked(data: any) {
const typedAction = MessengerUtils.stringToEnumValue(ButtonActions, data.action as any)
let getFeedbackCommentData = ''
switch (typedAction) {
case ButtonActions.STOP_TEST_GEN:
testGenState.setToCancelling()
Expand All @@ -366,6 +392,16 @@ export class TestController {
this.messenger.sendChatInputEnabled(data.tabID, true)
await this.sessionCleanUp()
break
case ButtonActions.PROVIDE_FEEDBACK:
getFeedbackCommentData = `Q Test Generation: RequestId: ${this.sessionStorage.getSession().startTestGenerationRequestId}, TestGenerationJobId: ${this.sessionStorage.getSession().testGenerationJob?.testGenerationJobId}`
void submitFeedback(placeholder, 'Amazon Q', getFeedbackCommentData)
telemetry.ui_click.emit({ elementId: 'unitTestGeneration_provideFeedback' })
this.messenger.sendMessage(
'Unit test generation completed. Thanks for providing feedback.',
data.tabID,
'answer'
)
break
}
}
// This function handles actions if user gives any input from the chatInput box
Expand Down Expand Up @@ -395,12 +431,31 @@ export class TestController {
}
}

private getFeedbackButtons(): ChatItemButton[] {
const buttons: ChatItemButton[] = []
if (Auth.instance.isInternalAmazonUser()) {
buttons.push({
keepCardAfterClick: false,
text: 'How can we make /test better?',
id: ButtonActions.PROVIDE_FEEDBACK,
disabled: false, // allow button to be re-clicked
position: 'outside',
icon: 'comment' as MynahIcons,
})
}
return buttons
}

/**
* Start Test Generation and show the code results
*/

private async startTestGen(message: any, regenerateTests: boolean) {
const session: Session = this.sessionStorage.getSession()
// Perform session cleanup before start of unit test generation workflow unless there is an existing job in progress.
if (!ChatSessionManager.Instance.getIsInProgress()) {
await this.sessionCleanUp()
}
const tabID = this.sessionStorage.setActiveTab(message.tabID)
getLogger().debug('startTestGen message: %O', message)
getLogger().debug('startTestGen tabId: %O', message.tabID)
Expand Down Expand Up @@ -502,6 +557,7 @@ export class TestController {
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below.`
}
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
session.isSupportedLanguage = false
await this.onCodeGeneration(
session,
userPrompt,
Expand Down Expand Up @@ -529,6 +585,7 @@ export class TestController {
)
}
session.isCodeBlockSelected = selectionRange !== undefined
session.isSupportedLanguage = true

/**
* Zip the project
Expand Down Expand Up @@ -792,7 +849,9 @@ export class TestController {
session.linesOfCodeAccepted,
session.charsOfCodeGenerated,
session.numberOfTestsGenerated,
session.linesOfCodeGenerated
session.linesOfCodeGenerated,
undefined,
'ACCEPTED'
)

await this.endSession(message, FollowUpTypes.SkipBuildAndFinish)
Expand Down Expand Up @@ -897,7 +956,13 @@ export class TestController {

// TODO: Check if there are more cases to endSession if yes create a enum or type for step
private async endSession(data: any, step: FollowUpTypes) {
this.messenger.sendMessage('Unit test generation completed.', data.tabID, 'answer')
this.messenger.sendMessage(
'Unit test generation completed.',
data.tabID,
'answer',
'testGenEndSessionMessage',
this.getFeedbackButtons()
)

const session = this.sessionStorage.getSession()
if (step === FollowUpTypes.RejectCode) {
Expand All @@ -918,7 +983,9 @@ export class TestController {
0,
session.charsOfCodeGenerated,
session.numberOfTestsGenerated,
session.linesOfCodeGenerated
session.linesOfCodeGenerated,
undefined,
'REJECTED'
)
telemetry.ui_click.emit({ elementId: 'unitTestGeneration_rejectDiff' })
}
Expand Down Expand Up @@ -1328,7 +1395,7 @@ export class TestController {
}
session.listOfTestGenerationJobId = []
session.testGenerationJobGroupName = undefined
session.testGenerationJob = undefined
// session.testGenerationJob = undefined
session.updatedBuildCommands = undefined
session.shortAnswer = undefined
session.testCoveragePercentage = 0
Expand Down
Loading

0 comments on commit e72fece

Please sign in to comment.