File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 805805 {
806806 "command" : " aws.amazonq.walkthrough.show" ,
807807 "title" : " %AWS.amazonq.welcomeWalkthrough%"
808+ },
809+ {
810+ "command" : " aws.amazonq.clearCache" ,
811+ "title" : " %AWS.amazonq.clearCache%" ,
812+ "category" : " %AWS.amazonq.title%"
808813 }
809814 ],
810815 "keybindings" : [
Original file line number Diff line number Diff line change 99import * as vscode from 'vscode'
1010import { Auth } from 'aws-core-vscode/auth'
1111import { Commands } from 'aws-core-vscode/shared'
12+ import { clearCacheDeclaration } from './util/clearCache'
1213
1314export function registerCommands ( context : vscode . ExtensionContext ) {
14- context . subscriptions . push ( Commands . register ( '_aws.amazonq.auth.autoConnect' , Auth . instance . tryAutoConnect ) )
15+ context . subscriptions . push (
16+ Commands . register ( '_aws.amazonq.auth.autoConnect' , Auth . instance . tryAutoConnect ) ,
17+ clearCacheDeclaration . register ( )
18+ )
1519}
Original file line number Diff line number Diff line change 1+ /*!
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ import { AuthUtil } from 'aws-core-vscode/codewhisperer'
7+ import { Commands , globals } from 'aws-core-vscode/shared'
8+ import vscode from 'vscode'
9+
10+ /**
11+ * The purpose of this module is to provide a util to clear all extension cache so that it has a clean state
12+ */
13+
14+ /**
15+ * Clears "all" cache of the extension, effectively putting the user in a "net new" state.
16+ *
17+ * NOTE: This is a best attempt. There may be state like a file in the filesystem which is not deleted.
18+ * We should aim to add all state clearing in to this method.
19+ */
20+ async function clearCache ( ) {
21+ // SSO cache persists on disk, this should indirectly delete it
22+ const conn = AuthUtil . instance . conn
23+ if ( conn ) {
24+ await AuthUtil . instance . auth . deleteConnection ( conn )
25+ }
26+
27+ await globals . globalState . clear ( )
28+
29+ // Make the IDE reload so all new changes take effect
30+ void vscode . commands . executeCommand ( 'workbench.action.reloadWindow' )
31+ }
32+ export const clearCacheDeclaration = Commands . declare ( { id : 'aws.amazonq.clearCache' } , ( ) => clearCache )
Original file line number Diff line number Diff line change 328328 "AWS.amazonq.title" : " Amazon Q" ,
329329 "AWS.amazonq.chat" : " Chat" ,
330330 "AWS.amazonq.openChat" : " Open Chat" ,
331+ "AWS.amazonq.clearCache" : " Clear extension cache" ,
331332 "AWS.amazonq.context.folders.title" : " Folders" ,
332333 "AWS.amazonq.context.folders.description" : " Add all files in a folder to context" ,
333334 "AWS.amazonq.context.files.title" : " Files" ,
You can’t perform that action at this time.
0 commit comments