Skip to content

Commit

Permalink
Merge branch 'master' into eslint-import-index
Browse files Browse the repository at this point in the history
  • Loading branch information
hayemaxi authored Feb 7, 2025
2 parents 93f68ef + 750770f commit 6c1ff4b
Show file tree
Hide file tree
Showing 42 changed files with 299 additions and 177 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

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

38 changes: 38 additions & 0 deletions packages/amazonq/.changes/1.46.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"date": "2025-02-05",
"version": "1.46.0",
"entries": [
{
"type": "Bug Fix",
"description": "Citation links are not clickable as numbers, but appear as non-clickable texts"
},
{
"type": "Bug Fix",
"description": "Fix language server start failure in AL2023 ARM64"
},
{
"type": "Bug Fix",
"description": "/review: Auto-review issues did not populate code issues list"
},
{
"type": "Bug Fix",
"description": "Amazon Q: Fix code upload error when using /dev or /doc on Remote SSH"
},
{
"type": "Bug Fix",
"description": "/test placeholder text aligned across IDEs"
},
{
"type": "Bug Fix",
"description": "Inline: Typos in the first example suggestion"
},
{
"type": "Feature",
"description": "Inline suggestions: Pre-fetch recommendations to reduce suggestion latency."
},
{
"type": "Feature",
"description": "Added github issue link and description to the chat answer feedback form"
}
]
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "`Send to prompt` and other context menu options not sent if chat was closed"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "/transform: automatically download results when ready"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "/transform: support Java 21 transformations"
}
5 changes: 0 additions & 5 deletions packages/amazonq/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"debugWebviews": true,
"rendererDebugOptions": {
"urlFilter": "*amazonwebservices.amazon-q-vscode*",
"webRoot": "${workspaceFolder}"
},
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"env": {
Expand Down
11 changes: 11 additions & 0 deletions packages/amazonq/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 1.46.0 2025-02-05

- **Bug Fix** Citation links are not clickable as numbers, but appear as non-clickable texts
- **Bug Fix** Fix language server start failure in AL2023 ARM64
- **Bug Fix** /review: Auto-review issues did not populate code issues list
- **Bug Fix** Amazon Q: Fix code upload error when using /dev or /doc on Remote SSH
- **Bug Fix** /test placeholder text aligned across IDEs
- **Bug Fix** Inline: Typos in the first example suggestion
- **Feature** Inline suggestions: Pre-fetch recommendations to reduce suggestion latency.
- **Feature** Added github issue link and description to the chat answer feedback form

## 1.45.0 2025-01-30

- **Bug Fix** Allow AB users with an overridden customization to go back to the default customization
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "amazon-q-vscode",
"displayName": "Amazon Q",
"description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI",
"version": "1.46.0-SNAPSHOT",
"version": "1.47.0-SNAPSHOT",
"extensionKind": [
"workspace"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/amazonq/src/extensionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
try {
// May call connection validate functions that try to refresh the token.
// This could result in network errors.
authState = (await AuthUtil.instance.getChatAuthState(false)).codewhispererChat
authState = (await AuthUtil.instance._getChatAuthState(false)).codewhispererChat
} catch (err) {
if (
isNetworkError(err) &&
Expand Down
36 changes: 36 additions & 0 deletions packages/amazonq/test/e2e/amazonq/transformByQ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,42 @@ describe('Amazon Q Code Transformation', function () {
assert.strictEqual(viewSummaryChatItem?.body?.includes('view a summary'), true)
})

it('CANNOT do a Java 21 to Java 17 transformation', async () => {
sinon.stub(startTransformByQ, 'getValidSQLConversionCandidateProjects').resolves([])
sinon.stub(GumbyController.prototype, 'validateLanguageUpgradeProjects' as keyof GumbyController).resolves([
{
name: 'qct-sample-java-8-app-main',
path: '/Users/alias/Desktop/qct-sample-java-8-app-main',
JDKVersion: JDKVersion.JDK21,
},
])
tab.addChatMessage({ command: '/transform' })
await tab.waitForEvent(() => tab.getChatItems().length > 3, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})
const projectForm = tab.getChatItems().pop()
assert.strictEqual(projectForm?.formItems?.[0]?.id ?? undefined, 'GumbyTransformLanguageUpgradeProjectForm')

const projectFormItemValues = {
GumbyTransformLanguageUpgradeProjectForm: '/Users/alias/Desktop/qct-sample-java-8-app-main',
GumbyTransformJdkFromForm: '21',
GumbyTransformJdkToForm: '17',
}
const projectFormValues: Record<string, string> = { ...projectFormItemValues }
tab.clickCustomFormButton({
id: 'gumbyLanguageUpgradeTransformFormConfirm',
text: 'Confirm',
formItemValues: projectFormValues,
})
await tab.waitForEvent(() => tab.getChatItems().length > 4, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})
const errorMessage = tab.getChatItems().pop()
assert.strictEqual(errorMessage?.body, CodeWhispererConstants.invalidFromToJdkChatMessage)
})

it('Can provide metadata file for a SQL conversion', async () => {
sinon.stub(startTransformByQ, 'getValidSQLConversionCandidateProjects').resolves([
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source code and template.yaml files",
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.",
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/amazonq/apps/initContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
*/

import { EventEmitter } from 'vscode'
import { MessagePublisher } from '../messages/messagePublisher'
import { MessagePublisher, UiMessagePublisher } from '../messages/messagePublisher'
import { MessageListener } from '../messages/messageListener'
import { TabType } from '../webview/ui/storages/tabsStorage'

export interface AmazonQAppInitContext {
registerWebViewToAppMessagePublisher(eventEmitter: MessagePublisher<any>, tabType: TabType): void
getAppsToWebViewMessagePublisher(): MessagePublisher<any>
getAppsToWebViewMessagePublisher(): UiMessagePublisher<any>
onDidChangeAmazonQVisibility: EventEmitter<boolean>
}

export class DefaultAmazonQAppInitContext implements AmazonQAppInitContext {
private readonly appsToWebViewEventEmitter = new EventEmitter<any>()
private readonly appsToWebViewMessageListener = new MessageListener<any>(this.appsToWebViewEventEmitter)
private readonly appsToWebViewMessagePublisher = new MessagePublisher<any>(this.appsToWebViewEventEmitter)
private readonly appsToWebViewMessagePublisher = new UiMessagePublisher<any>(this.appsToWebViewEventEmitter)
private readonly webViewToAppsMessagePublishers: Map<TabType, MessagePublisher<any>> = new Map()
public readonly onDidChangeAmazonQVisibility = new EventEmitter<boolean>()

Expand All @@ -41,7 +41,7 @@ export class DefaultAmazonQAppInitContext implements AmazonQAppInitContext {
return this.appsToWebViewMessageListener
}

getAppsToWebViewMessagePublisher(): MessagePublisher<any> {
getAppsToWebViewMessagePublisher(): UiMessagePublisher<any> {
return this.appsToWebViewMessagePublisher
}
}
45 changes: 45 additions & 0 deletions packages/core/src/amazonq/messages/messagePublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,48 @@ export class MessagePublisher<T> {
this.eventEmitter.fire(event)
}
}

/**
* Same as {@link MessagePublisher}, but will wait until the UI indicates it
* is ready to recieve messages, before the message is published.
*
* This solves a problem when running a right click menu option like
* "Send To Prompt" BUT chat is not opened yet, it would result in the prompt failing to
* be recieved by chat.
*/
export class UiMessagePublisher<T> extends MessagePublisher<T> {
private isUiReady: boolean = false
private buffer: T[] = []

constructor(eventEmitter: EventEmitter<T>) {
super(eventEmitter)
}

public override publish(event: T): void {
// immediately send if Chat UI is ready
if (this.isUiReady) {
super.publish(event)
return
}

this.buffer.push(event)
}

/**
* Indicate the Q Chat UI is ready to recieve messages.
*/
public setUiReady() {
this.isUiReady = true
this.flush()
}

/**
* Publishes all blocked messages
*/
private flush() {
for (const msg of this.buffer) {
super.publish(msg)
}
this.buffer = []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AmazonQChatMessageDuration } from '../../messages/chatMessageDuration'
import { isClickTelemetry, isOpenAgentTelemetry } from '../ui/telemetry/actions'
import globals from '../../../shared/extensionGlobals'
import { openUrl } from '../../../shared/utilities/vsCodeUtils'
import { DefaultAmazonQAppInitContext } from '../../apps/initContext'

export function dispatchWebViewMessagesToApps(
webview: Webview,
Expand All @@ -22,12 +23,12 @@ export function dispatchWebViewMessagesToApps(
webview.onDidReceiveMessage((msg) => {
switch (msg.command) {
case 'ui-is-ready': {
DefaultAmazonQAppInitContext.instance.getAppsToWebViewMessagePublisher().setUiReady()
/**
* ui-is-ready isn't associated to any tab so just record the telemetry event and continue.
* This would be equivalent of the duration between "user clicked open q" and "ui has become available"
* NOTE: Amazon Q UI is only loaded ONCE. The state is saved between each hide/show of the webview.
*/

telemetry.webview_load.emit({
webviewName: 'amazonq',
duration: performance.measure(amazonqMark.uiReady, amazonqMark.open).duration,
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@ export class GumbyController {
message.tabID
)

// do not allow downgrades (only this combination can be selected in the UI)
if (fromJDKVersion === JDKVersion.JDK21 && toJDKVersion === JDKVersion.JDK17) {
this.messenger.sendUnrecoverableErrorResponse('invalid-from-to-jdk', message.tabID)
return
}

await processLanguageUpgradeTransformFormInput(pathToProject, fromJDKVersion, toJDKVersion)
await this.messenger.sendSkipTestsPrompt(message.tabID)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type UnrecoverableErrorType =
| 'unsupported-target-db'
| 'error-parsing-sct-file'
| 'invalid-zip-no-sct-file'
| 'invalid-from-to-jdk'

export enum GumbyNamedMessages {
COMPILATION_PROGRESS_MESSAGE = 'gumbyProjectCompilationMessage',
Expand Down Expand Up @@ -176,7 +177,9 @@ export class Messenger {
this.dispatcher.sendAsyncEventProgress(
new AsyncEventProgressMessage(tabID, {
inProgress: true,
message: CodeWhispererConstants.userPatchDescriptionChatMessage,
message: CodeWhispererConstants.userPatchDescriptionChatMessage(
transformByQState.getTargetJDKVersion() ?? ''
),
})
)

Expand Down Expand Up @@ -233,6 +236,10 @@ export class Messenger {
value: JDKVersion.JDK17,
label: JDKVersion.JDK17,
},
{
value: JDKVersion.JDK21,
label: JDKVersion.JDK21,
},
],
})

Expand All @@ -246,6 +253,10 @@ export class Messenger {
value: JDKVersion.JDK17,
label: JDKVersion.JDK17,
},
{
value: JDKVersion.JDK21,
label: JDKVersion.JDK21,
},
],
})

Expand Down Expand Up @@ -481,6 +492,9 @@ export class Messenger {
case 'invalid-zip-no-sct-file':
message = CodeWhispererConstants.invalidMetadataFileNoSctFile
break
case 'invalid-from-to-jdk':
message = CodeWhispererConstants.invalidFromToJdkChatMessage
break
}

this.sendJobFinishedMessage(tabID, message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class MessengerUtils {
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(11)}`
} else if (jdkVersion === JDKVersion.JDK17) {
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(17)}`
} else if (jdkVersion === JDKVersion.JDK21) {
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(21)}`
}
} else {
javaHomePrompt += ` ${CodeWhispererConstants.linuxJavaHomeHelpChatMessage}`
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/amazonqGumby/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AlternateDependencyVersionsNotFoundError extends Error {
}

export class JobStoppedError extends Error {
constructor(readonly requestId: string) {
constructor() {
super('Job was rejected, stopped, or failed')
}
}
Expand Down
Loading

0 comments on commit 6c1ff4b

Please sign in to comment.