Skip to content

Commit 14cb291

Browse files
committed
feat(startup): show message if vscode is outdated
1 parent de9d7cf commit 14cb291

12 files changed

+63
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Deprecation",
3+
"description": "The next release of this extension will require VS Code 1.83.0 or newer."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Show a one-time warning if new VS Code is required"
4+
}

packages/amazonq/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
"type": "boolean",
113113
"default": false
114114
},
115+
"minIdeVersion": {
116+
"type": "boolean",
117+
"default": false
118+
},
115119
"ssoCacheError": {
116120
"type": "boolean",
117121
"default": false

packages/amazonq/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
placeholder,
4141
setContext,
4242
setupUninstallHandler,
43+
maybeShowMinVscodeWarning,
4344
} from 'aws-core-vscode/shared'
4445
import { ExtStartUpSources, telemetry } from 'aws-core-vscode/telemetry'
4546
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
@@ -98,6 +99,8 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
9899
}
99100
}
100101

102+
void maybeShowMinVscodeWarning('1.83.0')
103+
101104
globals.machineId = await getMachineId()
102105
globals.awsContext = new DefaultAwsContext()
103106
globals.sdkClientBuilder = new DefaultAWSClientBuilder(globals.awsContext)

packages/core/src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { registerCommands } from './commands'
5555
// In web mode everything must be in a single file, so things like the endpoints file will not be available.
5656
// The following imports the endpoints file, which causes webpack to bundle it in the final output file
5757
import endpoints from '../resources/endpoints.json'
58-
import { getLogger, setupUninstallHandler } from './shared'
58+
import { getLogger, maybeShowMinVscodeWarning, setupUninstallHandler } from './shared'
5959
import { showViewLogsMessage } from './shared/utilities/messages'
6060

6161
disableAwsSdkWarning()
@@ -102,6 +102,8 @@ export async function activateCommon(
102102
getLogger().error('fs.init: invalid home directory given by env vars: %O', homeDirLogs)
103103
}
104104

105+
void maybeShowMinVscodeWarning('1.83.0')
106+
105107
if (isCloud9()) {
106108
vscode.window.withProgress = wrapWithProgressForCloud9(globals.outputChannel)
107109
context.subscriptions.push(

packages/core/src/shared/extensionUtilities.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
import * as _ from 'lodash'
77
import * as os from 'os'
88
import * as vscode from 'vscode'
9+
import * as semver from 'semver'
910
import * as nls from 'vscode-nls'
1011
import { getLogger } from './logger'
1112
import { VSCODE_EXTENSION_ID, extensionAlphaVersion } from './extensions'
1213
import { Ec2MetadataClient } from './clients/ec2MetadataClient'
1314
import { DefaultEc2MetadataClient } from './clients/ec2MetadataClient'
1415
import { extensionVersion, getCodeCatalystDevEnvId } from './vscode/env'
15-
import { DevSettings } from './settings'
16+
import { AmazonQPromptSettings, DevSettings, ToolkitPromptSettings } from './settings'
1617
import globals from './extensionGlobals'
1718
import { once } from './utilities/functionUtils'
19+
import * as localizedText from './localizedText'
1820
import {
1921
apprunnerCreateServiceDocUrl,
2022
debugNewSamAppDocUrl,
@@ -262,6 +264,33 @@ export function showWelcomeMessage(context: vscode.ExtensionContext): void {
262264
}
263265
}
264266

267+
/**
268+
* Shows a (suppressible) warning if the current vscode version is older than `minVscode`.
269+
*/
270+
export async function maybeShowMinVscodeWarning(minVscode: string) {
271+
const settings = isAmazonQ() ? AmazonQPromptSettings.instance : ToolkitPromptSettings.instance
272+
if (!(await settings.isPromptEnabled('minIdeVersion'))) {
273+
return
274+
}
275+
const isVscode = !!vscode.env.appName?.startsWith(vscodeAppname)
276+
const updateButton = `Update ${vscode.env.appName}`
277+
if (isVscode && semver.lt(vscode.version, minVscode)) {
278+
vscode.window
279+
.showWarningMessage(
280+
`The next release of the ${productName()} extension will require VS Code ${minVscode} or newer. Your are currently running ${vscode.version}`,
281+
updateButton,
282+
localizedText.dontShow
283+
)
284+
.then(async (resp) => {
285+
if (resp === updateButton) {
286+
await vscode.commands.executeCommand('update.checkForUpdate')
287+
} else if (resp === localizedText.dontShow) {
288+
settings.disablePrompt('minIdeVersion')
289+
}
290+
})
291+
}
292+
}
293+
265294
function _getDocumentationUrl(urls: { cloud9: vscode.Uri; toolkit: vscode.Uri }): vscode.Uri {
266295
return isCloud9() ? urls.cloud9 : urls.toolkit
267296
}

packages/core/src/shared/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export { activate as activateTelemetry } from './telemetry/activation'
1414
export { DefaultAwsContext } from './awsContext'
1515
export { DefaultAWSClientBuilder, ServiceOptions } from './awsClientBuilder'
1616
export { Settings } from './settings'
17-
export { initializeComputeRegion } from './extensionUtilities'
17+
export * from './extensionUtilities'
1818
export { RegionProvider } from './regions/regionProvider'
1919
export { Commands } from './vscode/commands2'
2020
export { getMachineId } from './vscode/env'

packages/core/src/shared/settings-amazonq.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const amazonqSettings = {
1717
"codeWhispererConnectionExpired": {},
1818
"amazonQWelcomePage": {},
1919
"amazonQSessionConfigurationMessage": {},
20+
"minIdeVersion": {},
2021
"ssoCacheError": {}
2122
},
2223
"amazonQ.showInlineCodeSuggestionsWithCodeReferences": {},

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export const toolkitSettings = {
3737
"samcliConfirmDevStack": {},
3838
"remoteConnected": {},
3939
"codeCatalystConnectionExpired": {},
40+
"minIdeVersion": {},
4041
"ssoCacheError": {}
4142
},
4243
"aws.experiments": {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Deprecation",
3+
"description": "The next release of this extension will require VS Code 1.83.0 or newer."
4+
}

0 commit comments

Comments
 (0)