1+ import { createHash } from "node:crypto" ;
12import { createCache } from "async-cache-dedupe" ;
23import vscode , { MarkdownString } from "vscode" ;
34import { version } from "../package.json" ;
45import {
56 MISE_CONFIGURE_ALL_SKD_PATHS ,
7+ MISE_DISMISS_MISSING_TOOLS_WARNING ,
68 MISE_DOCTOR ,
79 MISE_EDIT_SETTING ,
810 MISE_FMT ,
@@ -122,6 +124,33 @@ export class MiseExtension {
122124 ) ;
123125 this . statusBarItem . command = MISE_OPEN_MENU ;
124126
127+ context . subscriptions . push (
128+ vscode . commands . registerCommand (
129+ MISE_DISMISS_MISSING_TOOLS_WARNING ,
130+ async ( ) => {
131+ const tools = await this . miseService . getCurrentTools ( ) ;
132+ const missingTools = tools . filter ( ( tool ) => ! tool . installed ) ;
133+ const hash = this . generateMissingToolsHash ( missingTools ) ;
134+
135+ const dismissedHashes = this . context . workspaceState . get < string [ ] > (
136+ "dismissedMissingToolsHashes" ,
137+ [ ] ,
138+ ) ;
139+
140+ if ( ! dismissedHashes . includes ( hash ) ) {
141+ dismissedHashes . push ( hash ) ;
142+ await context . workspaceState . update (
143+ "dismissedMissingToolsHashes" ,
144+ dismissedHashes ,
145+ ) ;
146+ }
147+
148+ this . missingToolBarItem . hide ( ) ;
149+ logger . info ( "Dismissed missing tools warning" ) ;
150+ } ,
151+ ) ,
152+ ) ;
153+
125154 const tasksProvider = new MiseTasksProvider ( this . miseService ) ;
126155 const toolsProvider = new MiseToolsProvider ( this . miseService ) ;
127156 const envsProvider = new MiseEnvsProvider ( this . miseService ) ;
@@ -680,6 +709,19 @@ export class MiseExtension {
680709 return ;
681710 }
682711
712+ const currentHash = this . generateMissingToolsHash ( missingTools ) ;
713+ const dismissedHashes = this . context . workspaceState . get < string [ ] > (
714+ "dismissedMissingToolsHashes" ,
715+ [ ] ,
716+ ) ;
717+
718+ if ( dismissedHashes . includes ( currentHash ) ) {
719+ if ( this . missingToolBarItem ) {
720+ this . missingToolBarItem . hide ( ) ;
721+ }
722+ return ;
723+ }
724+
683725 if ( ! this . missingToolBarItem ) {
684726 this . missingToolBarItem = vscode . window . createStatusBarItem (
685727 vscode . StatusBarAlignment . Left ,
@@ -698,4 +740,12 @@ export class MiseExtension {
698740 this . missingToolBarItem . command = MISE_MISSING_TOOLS_MENU ;
699741 } ) ;
700742 }
743+
744+ private generateMissingToolsHash ( tools : MiseTool [ ] ) {
745+ const hash = createHash ( "sha256" ) ;
746+ tools . forEach ( ( tool ) => {
747+ hash . update ( tool . name + ( tool . version || "" ) ) ;
748+ } ) ;
749+ return hash . digest ( "hex" ) ;
750+ }
701751}
0 commit comments