Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

2 changes: 1 addition & 1 deletion packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,6 @@
},
"engines": {
"npm": "^10.1.0",
"vscode": "^1.83.0"
"vscode": "^1.68.0"
}
}
31 changes: 30 additions & 1 deletion packages/amazonq/src/app/chat/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { telemetry } from 'aws-core-vscode/telemetry'
import { AuthUtil, CodeWhispererSettings } from 'aws-core-vscode/codewhisperer'
import { Commands, placeholder, funcUtil } from 'aws-core-vscode/shared'
import * as amazonq from 'aws-core-vscode/amazonq'
import * as semver from 'semver'

export async function activate(context: ExtensionContext) {
const appInitContext = amazonq.DefaultAmazonQAppInitContext.instance
Expand Down Expand Up @@ -58,14 +59,14 @@ export async function activate(context: ExtensionContext) {
await amazonq.activateBadge()
void setupLsp()
void setupAuthNotification()
void setupVscodeVersionNotification()
}

function registerApps(appInitContext: amazonq.AmazonQAppInitContext) {
amazonq.cwChatAppInit(appInitContext)
amazonq.featureDevChatAppInit(appInitContext)
amazonq.gumbyChatAppInit(appInitContext)
}

/**
* Display a notification to user for Log In.
*
Expand Down Expand Up @@ -105,3 +106,31 @@ async function setupAuthNotification() {
}
}
}
// TODO: remove once version bump to 1.83.0 is complete.
export function setupVscodeVersionNotification() {
let notificationDisplayed = false
tryShowNotification()

function tryShowNotification() {
// Do not show the notification if the IDE version will continue to be supported.
if (!semver.gte(vscode.version, '1.83.0')) {
return
}

if (notificationDisplayed) {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this ever run? Its always set to false on line 111.
Also it seems its only called once on activation anyways. This seems like more code than we need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly wasn't sure, but I was using this as an example:

async function setupAuthNotification() {
let notificationDisplayed = false // Auth Notification should be displayed only once.
await tryShowNotification()
async function tryShowNotification() {
// Do not show the notification if the IDE starts and user is already authenticated.
if (AuthUtil.instance.isConnected()) {
notificationDisplayed = true
}
if (notificationDisplayed) {
return
}
const source = 'authNotification'
const buttonAction = 'Sign In'
notificationDisplayed = true
telemetry.toolkit_showNotification.emit({
component: 'editor',
id: source,
reason: 'notLoggedIn',
result: 'Succeeded',
})
const selection = await vscode.window.showWarningMessage('Start using Amazon Q', buttonAction)
if (selection === buttonAction) {
void amazonq.focusAmazonQPanel.execute(placeholder, source)
}
}
}
and left it in to be safe.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That example sorta makes sense because the state of notificationDisplayed can change after its initialized but before evaluation. But regardless it is a such a confusing and unnecessary way to evaluate the message. IMO we should refactor that.

}

notificationDisplayed = true

telemetry.toolkit_showNotification.emit({
component: 'editor',
id: 'versionNotification',
reason: 'unsupportedVersion',
result: 'Succeeded',
})
void vscode.window.showWarningMessage(
'Update VS Code to version 1.83.0+, support for previous versions will be dropped soon. '
)
}
}
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"engines": {
"npm": "^10.1.0",
"vscode": "^1.83.0"
"vscode": "^1.68.0"
},
"exports": {
".": "./dist/src/extension.js",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import vscode from 'vscode'
import * as nls from 'vscode-nls'

import globals, { initialize, isWeb } from './shared/extensionGlobals'
import { join } from 'path'
import { Commands } from './shared/vscode/commands2'
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"browser": "./dist/src/extensionWeb",
"engines": {
"npm": "^10.1.0",
"vscode": "^1.83.0"
"vscode": "^1.68.0"
},
"scripts": {
"vscode:prepublish": "npm run clean && npm run buildScripts && webpack --mode production",
Expand Down
33 changes: 33 additions & 0 deletions packages/toolkit/src/extensionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,48 @@ import type { ExtensionContext } from 'vscode'
import { activate as activateCore, deactivate as deactivateCore } from 'aws-core-vscode/node'
import { awsToolkitApi } from './api'
import { Commands } from 'aws-core-vscode/shared'
import * as semver from 'semver'
import * as vscode from 'vscode'
import { telemetry } from 'aws-core-vscode/telemetry'

export async function activate(context: ExtensionContext) {
await activateCore(context)

// after toolkit is activated, ask Amazon Q to register toolkit api callbacks
await Commands.tryExecute('aws.amazonq.refreshConnectionCallback', awsToolkitApi)
void setupVscodeVersionNotification()
return awsToolkitApi
}

export async function deactivate() {
await deactivateCore()
}

// TODO: remove once version bump to 1.83.0 is complete.
export function setupVscodeVersionNotification() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need duplicate code?
AFAIK the null extension bug only impacts when running the extension in debug mode and not when its packaged into a vsix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, not aware of that. I can remove the duplicate code in that case.

let notificationDisplayed = false
tryShowNotification()

function tryShowNotification() {
// Do not show the notification if the IDE version will continue to be supported.
if (!semver.gte(vscode.version, '1.83.0')) {
return
}

if (notificationDisplayed) {
return
}

notificationDisplayed = true

telemetry.toolkit_showNotification.emit({
component: 'editor',
id: 'versionNotification',
reason: 'unsupportedVersion',
result: 'Succeeded',
})
void vscode.window.showWarningMessage(
'Update VS Code to version 1.83.0+, support for previous versions will be dropped soon. '
)
}
}
Loading