Skip to content

Commit e90c9c0

Browse files
author
tomzu
committed
global state tracking and optional don't show
1 parent c60e762 commit e90c9c0

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

packages/core/src/dev/activation.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { DevNotificationsState } from '../notifications/types'
2626
import { QuickPickItem } from 'vscode'
2727
import { ChildProcess } from '../shared/utilities/processUtils'
2828
import { WorkspaceLSPResolver } from '../amazonq/lsp/workspaceInstaller'
29+
import * as ManifestResolver from '../shared/lsp/manifestResolver'
2930

3031
interface MenuOption {
3132
readonly label: string
@@ -453,10 +454,16 @@ const resettableFeatures: readonly ResettableFeature[] = [
453454
},
454455
{
455456
name: 'workspace lsp',
456-
label: 'Lsp',
457+
label: 'Lsp Download',
457458
detail: 'Resets workspace LSP',
458459
executor: resetWorkspaceLspDownload,
459460
},
461+
{
462+
name: 'lsp global state',
463+
label: 'Lsp State',
464+
detail: 'Resets LSP manifest global state',
465+
executor: resetLSPGlobalState,
466+
},
460467
] as const
461468

462469
// TODO this is *somewhat* similar to `openStorageFromInput`. If we need another
@@ -549,6 +556,10 @@ async function resetWorkspaceLspDownload() {
549556
await new WorkspaceLSPResolver().resolve()
550557
}
551558

559+
async function resetLSPGlobalState() {
560+
await ManifestResolver.resetManifestState()
561+
}
562+
552563
async function editNotifications() {
553564
const storageKey = 'aws.notifications.dev'
554565
const current = globalState.get(storageKey) ?? {}

packages/core/src/shared/lsp/manifestResolver.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,25 @@ import globals from '../extensionGlobals'
1111
import { Manifest } from './types'
1212
import { StageResolver, tryStageResolvers } from './utils/setupStage'
1313
import { HttpResourceFetcher } from '../resourcefetcher/httpResourceFetcher'
14+
import * as localizedText from '../localizedText'
1415

1516
const logger = getLogger('lsp')
1617

1718
interface StorageManifest {
1819
etag: string
1920
content: string
21+
muteDeprecation: boolean
2022
}
2123

2224
type ManifestStorage = Record<string, StorageManifest>
2325

2426
export const manifestStorageKey = 'aws.toolkit.lsp.manifest'
2527
const manifestTimeoutMs = 15000
2628

29+
export async function resetManifestState() {
30+
await globals.globalState.update(manifestStorageKey, {})
31+
}
32+
2733
export class ManifestResolver {
2834
constructor(
2935
private readonly manifestURL: string,
@@ -98,22 +104,42 @@ export class ManifestResolver {
98104
}
99105
}
100106

107+
/**
108+
* Check if the current manifest is deprecated.
109+
* If yes and user hasn't muted this notification, shows a toast message with two buttons:
110+
* - OK: close and do nothing
111+
* - Don't Show Again: Update global state (muteDecprecation) so the deprecation message is never shown for this manifest.
112+
* @param manifest
113+
*/
101114
private checkDeprecation(manifest: Manifest): void {
102-
if (manifest.isManifestDeprecated) {
115+
if (manifest.isManifestDeprecated && !this.getStorage()[this.lsName].muteDeprecation) {
103116
const deprecationMessage = `${this.lsName} manifest is deprecated. No future updates will be available.`
104117
logger.info(deprecationMessage)
105-
void vscode.window.showInformationMessage(deprecationMessage)
118+
119+
void vscode.window
120+
.showInformationMessage(deprecationMessage, localizedText.ok, localizedText.dontShow)
121+
.then((button) => {
122+
if (button === localizedText.dontShow) {
123+
this.getStorage()[this.lsName].muteDeprecation = true
124+
}
125+
})
106126
}
107127
}
108128

109129
private async saveManifest(etag: string, content: string): Promise<void> {
110130
const storage = this.getStorage()
111131

132+
// Only true when incoming manifest is deprecated & existing muteDeprecation is true (set by user)
133+
const muteDeprecation =
134+
(storage[this.lsName] ? storage[this.lsName].muteDeprecation : false) &&
135+
(JSON.parse(content) as Manifest).isManifestDeprecated
136+
112137
globals.globalState.tryUpdate(manifestStorageKey, {
113138
...storage,
114139
[this.lsName]: {
115140
etag,
116141
content,
142+
muteDeprecation,
117143
},
118144
})
119145
}

0 commit comments

Comments
 (0)