@@ -9,9 +9,12 @@ import {
99 PythonEnvironmentInfo ,
1010} from '../../api' ;
1111import { showErrorMessageWithLogs } from '../../common/errors/utils' ;
12- import { SysManagerStrings } from '../../common/localize' ;
13- import { traceVerbose } from '../../common/logging' ;
14- import { withProgress } from '../../common/window.apis' ;
12+ import { getExtension } from '../../common/extension.apis' ;
13+ import { Common , PixiStrings , SysManagerStrings } from '../../common/localize' ;
14+ import { traceInfo , traceVerbose } from '../../common/logging' ;
15+ import { getGlobalPersistentState } from '../../common/persistentState' ;
16+ import { showInformationMessage , withProgress } from '../../common/window.apis' ;
17+ import { openExtension } from '../../common/workbenchCommands' ;
1518import {
1619 isNativeEnvInfo ,
1720 NativeEnvInfo ,
@@ -22,6 +25,10 @@ import { shortVersion, sortEnvironments } from '../common/utils';
2225import { runPython , runUV , shouldUseUv } from './helpers' ;
2326import { parsePipList , PipPackage } from './pipListUtils' ;
2427
28+ const PIXI_EXTENSION_ID = 'renan-r-santos.pixi-code' ;
29+ const PIXI_RECOMMEND_DONT_ASK_KEY = 'pixi-extension-recommend-dont-ask' ;
30+ let pixiRecommendationShown = false ;
31+
2532function asPackageQuickPickItem ( name : string , version ?: string ) : QuickPickItem {
2633 return {
2734 label : name ,
@@ -99,6 +106,38 @@ function getPythonInfo(env: NativeEnvInfo): PythonEnvironmentInfo {
99106 }
100107}
101108
109+ async function recommendPixiExtension ( ) : Promise < void > {
110+ if ( pixiRecommendationShown ) {
111+ return ;
112+ }
113+ pixiRecommendationShown = true ;
114+
115+ if ( getExtension ( PIXI_EXTENSION_ID ) ) {
116+ return ;
117+ }
118+
119+ const state = await getGlobalPersistentState ( ) ;
120+ const dontAsk = await state . get < boolean > ( PIXI_RECOMMEND_DONT_ASK_KEY ) ;
121+ if ( dontAsk ) {
122+ traceInfo ( 'Skipping Pixi extension recommendation: user selected "Don\'t ask again"' ) ;
123+ return ;
124+ }
125+
126+ const result = await showInformationMessage (
127+ PixiStrings . pixiExtensionRecommendation ,
128+ PixiStrings . install ,
129+ Common . dontAskAgain ,
130+ ) ;
131+
132+ if ( result === PixiStrings . install ) {
133+ traceInfo ( `Opening extension page: ${ PIXI_EXTENSION_ID } ` ) ;
134+ await openExtension ( PIXI_EXTENSION_ID ) ;
135+ } else if ( result === Common . dontAskAgain ) {
136+ await state . set ( PIXI_RECOMMEND_DONT_ASK_KEY , true ) ;
137+ traceInfo ( 'User selected "Don\'t ask again" for Pixi extension recommendation' ) ;
138+ }
139+ }
140+
102141export async function refreshPythons (
103142 hardRefresh : boolean ,
104143 nativeFinder : NativePythonFinder ,
@@ -109,25 +148,29 @@ export async function refreshPythons(
109148) : Promise < PythonEnvironment [ ] > {
110149 const collection : PythonEnvironment [ ] = [ ] ;
111150 const data = await nativeFinder . refresh ( hardRefresh , uris ) ;
112- const envs = data
113- . filter ( ( e ) => isNativeEnvInfo ( e ) )
114- . map ( ( e ) => e as NativeEnvInfo )
115- . filter (
116- ( e ) =>
117- e . kind === undefined ||
118- ( e . kind &&
119- [
120- NativePythonEnvironmentKind . globalPaths ,
121- NativePythonEnvironmentKind . homebrew ,
122- NativePythonEnvironmentKind . linuxGlobal ,
123- NativePythonEnvironmentKind . macCommandLineTools ,
124- NativePythonEnvironmentKind . macPythonOrg ,
125- NativePythonEnvironmentKind . macXCode ,
126- NativePythonEnvironmentKind . windowsRegistry ,
127- NativePythonEnvironmentKind . windowsStore ,
128- NativePythonEnvironmentKind . winpython ,
129- ] . includes ( e . kind ) ) ,
130- ) ;
151+ const allNativeEnvs = data . filter ( ( e ) => isNativeEnvInfo ( e ) ) . map ( ( e ) => e as NativeEnvInfo ) ;
152+
153+ const hasPixiEnvs = allNativeEnvs . some ( ( e ) => e . kind === NativePythonEnvironmentKind . pixi ) ;
154+ if ( hasPixiEnvs ) {
155+ recommendPixiExtension ( ) . catch ( ( e ) => log . error ( 'Error recommending Pixi extension' , e ) ) ;
156+ }
157+
158+ const envs = allNativeEnvs . filter (
159+ ( e ) =>
160+ e . kind === undefined ||
161+ ( e . kind &&
162+ [
163+ NativePythonEnvironmentKind . globalPaths ,
164+ NativePythonEnvironmentKind . homebrew ,
165+ NativePythonEnvironmentKind . linuxGlobal ,
166+ NativePythonEnvironmentKind . macCommandLineTools ,
167+ NativePythonEnvironmentKind . macPythonOrg ,
168+ NativePythonEnvironmentKind . macXCode ,
169+ NativePythonEnvironmentKind . windowsRegistry ,
170+ NativePythonEnvironmentKind . windowsStore ,
171+ NativePythonEnvironmentKind . winpython ,
172+ ] . includes ( e . kind ) ) ,
173+ ) ;
131174 envs . forEach ( ( env ) => {
132175 try {
133176 const envInfo = getPythonInfo ( env ) ;
0 commit comments